:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-strong: #e5ebf7;
  --panel-soft: #f1f5fb;
  --ink: #29497a;
  --muted: #5c6690;
  --line: #d6deef;
  --accent: #35c8cf;
  --accent-soft: #dcf6f7;
  --accent-deep: #284c82;
  --warn: #d75f4a;
  --warn-soft: #fae4de;
  --gold: #f0c53f;
  --gold-soft: #fff4c9;
  --plum: #8a4a7a;
  --plum-soft: #f2e3ee;
  --booked: #52508f;
  --booked-soft: #e5e4f6;
  --shadow: 0 18px 42px rgba(41, 73, 122, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(40, 76, 130, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(53, 200, 207, 0.12), transparent 22%),
    radial-gradient(circle at bottom left, rgba(138, 74, 122, 0.10), transparent 20%),
    radial-gradient(circle at bottom right, rgba(240, 197, 63, 0.10), transparent 18%),
    var(--bg);
  color: var(--ink);
  font-family: "Aptos", "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  min-height: 100vh;
}

.content {
  padding: 24px;
  max-width: 1680px;
  margin: 0 auto;
}

.brand h1,
.hero h2,
.panel-head h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: -0.02em;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 20px;
  margin-bottom: 10px;
}

.header-actions {
  display: flex;
  flex-direction: column;
  align-items: end;
  gap: 12px;
}

.utility-panel {
  width: min(420px, 100%);
  margin-bottom: 0;
}

.session-actions {
  display: flex;
  justify-content: flex-start;
  width: auto;
}

.hero {
  display: flex;
  justify-content: flex-end;
  gap: 20px;
  align-items: start;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--plum);
  font-weight: 700;
}

.muted {
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
  position: relative;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  border-radius: 18px 18px 0 0;
  background: linear-gradient(90deg, var(--accent-deep), var(--booked), var(--accent), var(--warn), var(--gold));
  opacity: 0.85;
}

.compact {
  padding-bottom: 16px;
}

.legacy-workflow {
  display: none;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.spread {
  align-items: center;
}

.stacked-form,
.field,
.check {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stacked-form {
  gap: 12px;
}

.field span,
.check span {
  font-size: 0.86rem;
  color: var(--muted);
}

.check.inline-check {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.check.inline-check input[type="checkbox"] {
  width: auto;
  margin: 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  padding: 10px 12px;
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

textarea {
  resize: vertical;
}

button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 14px;
  background: linear-gradient(135deg, var(--accent-deep), var(--booked));
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform 140ms ease, opacity 140ms ease, box-shadow 140ms ease, background 140ms ease;
  box-shadow: 0 10px 20px rgba(41, 73, 122, 0.16);
}

button:hover {
  transform: translateY(-1px);
}

button.ghost {
  background: var(--panel-strong);
  color: var(--ink);
  border-color: rgba(82, 80, 143, 0.18);
  box-shadow: none;
}

button.secondary {
  background: var(--plum-soft);
  color: var(--plum);
  border-color: rgba(138, 74, 122, 0.20);
  box-shadow: none;
}

button.danger {
  background: var(--warn-soft);
  color: #8d3f29;
  border-color: rgba(215, 95, 74, 0.28);
  box-shadow: none;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.stacked-list {
  display: grid;
  gap: 12px;
}

.manual-counsellor-subhead {
  margin-top: 18px;
}

.templates button {
  background: var(--accent-soft);
  color: var(--accent-deep);
  border-color: rgba(53, 200, 207, 0.22);
  padding: 8px 12px;
  box-shadow: none;
}

.toolbar {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}

.week-nav {
  background: var(--panel-strong);
  color: var(--ink);
  border: 1px solid rgba(82, 80, 143, 0.20);
  font-weight: 600;
}

.week-nav.current-week {
  background: linear-gradient(135deg, var(--accent-soft), var(--plum-soft));
  color: var(--accent-deep);
  border-color: rgba(53, 200, 207, 0.22);
}

.field.small {
  min-width: 210px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.financial-dashboard {
  display: grid;
  gap: 16px;
}

.financial-filters {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}

.financial-overview,
.financial-counsellors {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.financial-health {
  display: grid;
}

.metric-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.metric-card.paid {
  background: linear-gradient(180deg, var(--accent-soft), #ffffff);
}

.metric-card.warn {
  background: linear-gradient(180deg, var(--warn-soft), #ffffff);
}

.metric-label {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

.metric-value {
  font-size: 2rem;
  font-weight: 700;
  margin: 8px 0 4px;
}

.financial-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
  margin: 12px 0;
}

.financial-split div {
  display: grid;
  gap: 4px;
}

.financial-split strong {
  font-size: 0.82rem;
  color: var(--muted);
}

.financial-split span {
  font-size: 1.1rem;
  font-weight: 700;
}

.calendar-grid {
  display: grid;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.mobile-calendar {
  display: none;
}

.calendar-header,
.calendar-row {
  display: grid;
  grid-template-columns: 180px repeat(7, minmax(170px, 1fr));
  gap: 10px;
}

.calendar-header .cell,
.calendar-row .cell {
  min-height: 100%;
}

.calendar-room {
  background: linear-gradient(180deg, #eef3fa, #f8fbff);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.calendar-room h3 {
  margin: 0;
  font-size: 1rem;
}

.slot-stack {
  display: grid;
  gap: 10px;
}

.day-cell {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: #fffefb;
  display: grid;
  gap: 8px;
}

.day-head {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 700;
}

.slot-card {
  border-radius: 12px;
  padding: 10px;
  display: grid;
  gap: 5px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.slot-card.available {
  background: #fbf7ef;
  border-color: var(--line);
}

.slot-card.occupied {
  background: linear-gradient(180deg, var(--booked-soft), #f7f7fb);
  border-color: rgba(82, 80, 143, 0.26);
}

.slot-card.unavailable {
  background:
    linear-gradient(135deg, rgba(41, 73, 122, 0.12), rgba(234, 226, 210, 0.85)),
    repeating-linear-gradient(135deg, rgba(82, 80, 143, 0.16) 0 8px, rgba(255, 255, 255, 0.28) 8px 16px);
  border-color: rgba(41, 73, 122, 0.34);
}

.slot-card.paid-slot {
  background: linear-gradient(180deg, #dcf6f7, #eefcff);
  border-color: rgba(53, 200, 207, 0.28);
}

.slot-card.unpaid-slot {
  background:
    linear-gradient(180deg, rgba(243, 221, 210, 0.92), rgba(255, 248, 244, 0.96)),
    var(--warn-soft);
  border-color: rgba(159, 77, 47, 0.4);
  box-shadow: inset 0 0 0 2px rgba(159, 77, 47, 0.14);
}

.slot-card.booked-you {
  background: linear-gradient(180deg, #dcf6f7, #f6feff);
  border-color: rgba(53, 200, 207, 0.42);
  box-shadow: inset 0 0 0 2px rgba(53, 200, 207, 0.12);
}

.slot-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(54, 38, 14, 0.08);
}

.slot-card.selected {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px rgba(24, 33, 38, 0.15);
}

.slot-title {
  font-weight: 700;
}

.payment-badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.payment-badge.paid,
.payment-badge.paid-slot,
.payment-badge.booked-you {
  background: rgba(53, 200, 207, 0.16);
  color: var(--accent-deep);
}

.payment-badge.occupied {
  background: rgba(82, 80, 143, 0.12);
  color: var(--booked);
}

.payment-badge.unavailable {
  background: rgba(41, 73, 122, 0.14);
  color: var(--accent-deep);
}

.payment-badge.unpaid,
.payment-badge.unpaid-slot {
  background: rgba(159, 77, 47, 0.14);
  color: var(--warn);
}

.slot-meta,
.subtle {
  color: var(--muted);
  font-size: 0.85rem;
}

.legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.legend-chip {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.legend-chip.available {
  background: #f3ebdd;
}

.legend-chip.occupied {
  background: var(--booked-soft);
  color: var(--booked);
}

.legend-chip.unavailable {
  background: var(--panel-strong);
  color: var(--accent-deep);
}

.legend-chip.paid-slot {
  background: var(--accent-soft);
  color: var(--accent);
}

.legend-chip.unpaid-slot {
  background: var(--warn-soft);
  color: var(--warn);
}

.list-grid {
  display: grid;
  gap: 10px;
}

.list-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fffefb;
}

.list-card.financial-alert {
  border-color: rgba(159, 77, 47, 0.35);
  background: linear-gradient(180deg, rgba(243, 221, 210, 0.35), #fff 35%);
}

.list-card.financial-good {
  border-color: rgba(53, 200, 207, 0.24);
  background: linear-gradient(180deg, rgba(220, 246, 247, 0.35), #fff 38%);
}

.list-card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.list-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.messages {
  display: grid;
  gap: 10px;
}

.message {
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.92rem;
}

.message.info {
  background: #eaf4fb;
}

.message.error {
  background: #f6e3d9;
  color: #7f4022;
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.grid-three {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.selection-panel {
  display: grid;
  gap: 14px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 16px;
  background: #fffefb;
}

.selection-panel.empty {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(244, 240, 232, 0.7));
}

.selection-panel.conflict {
  border-color: rgba(173, 69, 32, 0.35);
  background: linear-gradient(180deg, rgba(255, 242, 236, 0.98), rgba(250, 236, 228, 0.92));
}

input[readonly] {
  background: rgba(234, 226, 210, 0.45);
  color: var(--muted);
}

.selection-summary {
  font-weight: 700;
}

.selection-meta {
  display: grid;
  gap: 6px;
}

.selection-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.selection-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--plum-soft);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-shell[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(41, 73, 122, 0.42);
  backdrop-filter: blur(5px);
}

.modal-card {
  position: relative;
  width: min(720px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 28px 60px rgba(24, 33, 38, 0.2);
  padding: 22px;
  display: grid;
  gap: 18px;
}

.modal-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.login-page {
  min-height: 100vh;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 28px;
  display: grid;
  gap: 16px;
  position: relative;
}

.login-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  border-radius: 24px 24px 0 0;
  background: linear-gradient(90deg, var(--accent-deep), var(--booked), var(--accent), var(--warn), var(--gold));
}

.login-card h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: -0.02em;
}

.grid-two.single-field {
  grid-template-columns: 1fr;
}

@media (max-width: 1180px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .grid-three {
    grid-template-columns: 1fr;
  }

  .calendar-grid:not(.mobile-calendar) .calendar-header,
  .calendar-grid:not(.mobile-calendar) .calendar-row {
    min-width: 1430px;
  }
}

@media (max-width: 860px) {
  .page-header,
  .hero {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    align-items: stretch;
  }

  .utility-panel,
  .session-actions {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .content {
    padding: 14px;
  }

  .panel {
    border-radius: 14px;
    padding: 16px;
  }

  .panel-head.spread {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 10px;
  }

  .toolbar .field.small {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .toolbar button {
    min-height: 44px;
  }

  .calendar-grid.mobile-calendar {
    display: grid;
    gap: 14px;
  }

  .calendar-grid.mobile-calendar .mobile-calendar-note {
    padding: 0 2px;
  }

  .calendar-day-section {
    display: grid;
    gap: 10px;
  }

  .mobile-day-head {
    position: sticky;
    top: 0;
    z-index: 2;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: linear-gradient(180deg, #eef3fa, #ffffff);
    color: var(--accent-deep);
    font-weight: 800;
    padding: 10px 12px;
  }

  .mobile-room-section {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #ffffff;
    padding: 10px;
    display: grid;
    gap: 10px;
  }

  .mobile-room-section h3 {
    margin: 0;
    border-radius: 10px;
    background: var(--panel-soft);
    color: var(--accent-deep);
    font-size: 0.95rem;
    padding: 8px 10px;
  }

  .mobile-room-section .slot-stack {
    gap: 8px;
  }

  .mobile-room-section .slot-card {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 10px;
    min-height: 74px;
  }

  .mobile-room-section .slot-card.paid-slot,
  .mobile-room-section .slot-card.unpaid-slot,
  .mobile-room-section .slot-card.unavailable,
  .mobile-room-section .slot-card.occupied {
    align-items: start;
  }

  .mobile-room-section .slot-title,
  .mobile-room-section .slot-meta {
    min-width: 0;
  }

  .mobile-room-section .payment-badge {
    grid-row: 1 / span 2;
    grid-column: 2;
    justify-self: end;
    white-space: nowrap;
  }
}

@media (max-width: 420px) {
  .toolbar {
    grid-template-columns: 1fr;
  }

  .mobile-room-section .slot-card {
    grid-template-columns: 1fr;
  }

  .mobile-room-section .payment-badge {
    grid-row: auto;
    grid-column: auto;
    justify-self: start;
  }
}
