:root {
  --tse-blue: #0a2540;
  --tse-blue-light: #14345c;
  --tse-accent: #2f7fe0;
  --border: #e0e4e9;
  --bg: #f5f6f8;
  --text: #1a1f27;
  --text-muted: #6b7280;
  --busy: #d9534f;
  --free: #4caf82;
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ---------- Login ---------- */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--tse-blue);
}

.login-card {
  background: #fff;
  padding: 2.5rem;
  border-radius: var(--radius);
  width: 100%;
  max-width: 360px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.login-card h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  color: var(--tse-blue);
}

.login-subtitle {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.login-card label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 0.65rem;
}

.login-card input {
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
}

.login-card button {
  margin-top: 1.5rem;
  padding: 0.7rem;
  border: none;
  border-radius: var(--radius);
  background: var(--tse-accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
}

.login-card button:disabled {
  opacity: 0.6;
  cursor: default;
}

.error-message {
  margin-top: 1rem;
  color: var(--busy);
  font-size: 0.85rem;
}

/* ---------- Dashboard shell ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--tse-blue);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
}

.sidebar-title {
  font-size: 1.1rem;
  margin: 0 0 1.5rem;
  padding: 0 0.5rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.nav-item {
  text-align: left;
  background: none;
  border: none;
  color: #cbd5e1;
  padding: 0.7rem 0.6rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.nav-item:hover {
  background: var(--tse-blue-light);
  color: #fff;
}

.nav-item.active {
  background: var(--tse-accent);
  color: #fff;
  font-weight: 600;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  padding-top: 1rem;
}

.user-email {
  font-size: 0.75rem;
  color: #9fb0c3;
  margin: 0 0 0.6rem;
  word-break: break-all;
}

.logout-btn {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  padding: 0.5rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.main-content {
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 100%;
  overflow-x: auto;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

.section h2 {
  margin: 0 0 0.25rem;
  color: var(--tse-blue);
}

.section-hint {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---------- Calendar ---------- */

.calendar-layout {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.calendar-panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  width: 320px;
  flex-shrink: 0;
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.calendar-nav button {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.25rem 0.6rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-weekday {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
  padding-bottom: 4px;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 0.85rem;
  position: relative;
}

.calendar-day.empty {
  background: transparent;
}

.calendar-day.selectable {
  cursor: pointer;
}

.calendar-day.selectable:hover {
  border-color: var(--tse-accent);
}

.calendar-day.selected {
  background: var(--tse-accent);
  color: #fff;
}

.calendar-day.has-busy::after {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--busy);
  position: absolute;
  bottom: 4px;
}

.calendar-day.selected.has-busy::after {
  background: #fff;
}

.slots-panel {
  flex: 1;
  min-width: 280px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}

.slots-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.slots-header h3 {
  margin: 0;
  color: var(--tse-blue);
  font-size: 1rem;
}

.slots-bulk-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-secondary {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
}

.btn-secondary:hover {
  border-color: var(--tse-accent);
}

.slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 0.5rem;
}

.slot-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.4rem;
  font-size: 0.8rem;
  background: #fff;
  color: var(--text);
}

.slot-btn.free:hover {
  border-color: var(--free);
}

.slot-btn.busy {
  background: var(--busy);
  border-color: var(--busy);
  color: #fff;
}

.slot-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ---------- Tables ---------- */

.table-wrap {
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table th {
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.data-table tbody tr:hover {
  background: var(--bg);
}

.empty-row {
  text-align: center;
  color: var(--text-muted);
  padding: 1.5rem;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-iris {
  background: #e4edfc;
  color: var(--tse-accent);
}

.badge-form {
  background: #eef1f5;
  color: var(--text-muted);
}

/* ---------- Agreements ---------- */

.agreement-form {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  max-width: 720px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-field input {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.payment-section {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-bottom: 1.25rem;
}

.payment-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.payment-section-header h3 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--tse-blue);
}

.payment-rows {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.payment-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 0.5rem;
  align-items: center;
}

.payment-row input {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  width: 100%;
}

.payment-row-remove {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--busy);
  padding: 0.5rem 0.6rem;
  font-size: 0.85rem;
}

.payment-row-remove:hover {
  border-color: var(--busy);
}

.main-btn-admin {
  border: none;
  border-radius: var(--radius);
  background: var(--tse-accent);
  color: #fff;
  padding: 0.7rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.main-btn-admin:hover {
  background: var(--tse-blue-light);
}

.main-btn-admin:disabled {
  opacity: 0.6;
  cursor: default;
}

.link-result {
  max-width: 720px;
  background: #eef8f2;
  border: 1px solid var(--free);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-top: 1.25rem;
}

.link-result-label {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.link-result-row {
  display: flex;
  gap: 0.5rem;
}

.link-result-row input {
  flex: 1;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  background: #fff;
}

.agreements-table-title {
  margin: 2rem 0 0.75rem;
  color: var(--tse-blue);
  font-size: 1rem;
}

.link-cell {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.link-cell .btn-secondary {
  white-space: nowrap;
}

.project-status-select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.82rem;
  background: #fff;
  color: var(--text);
}

.project-status-select:disabled {
  opacity: 0.6;
}

.badge-pending {
  background: #fdf1e0;
  color: #a4650f;
}

.badge-accepted {
  background: #e3f6ec;
  color: #1f8f5c;
}

@media (max-width: 720px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .main-content {
    padding: 1.25rem;
  }
}

/* ---------- TSE Platform pipelines ---------- */

.pipeline-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 1.5rem;
}

.pipeline-chip {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border);
}

.pipeline-chip-active {
  background: var(--tse-accent);
  border-color: var(--tse-accent);
  color: #fff;
}

.pipeline-chip-disabled {
  color: var(--text-muted);
  background: var(--bg);
}

.pipeline-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.pipeline-placeholder {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.pipeline-placeholder p {
  margin: 0;
}
