@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;600;700&family=Figtree:wght@400;500;600;700&display=swap");

:root {
  --page: #f4f0e8;
  --ink: #1c1917;
  --muted: #6b6560;
  --border: #ddd5c8;
  --surface: #fffdf9;
  --rail: #1a2e28;
  --rail-muted: #a8b5b0;
  --rail-hover: #243d35;
  --brass: #c4a35a;
  --brass-soft: rgba(196, 163, 90, 0.18);
  --moss: #3d6b4f;
  --moss-soft: #e8f0eb;
  --clay: #b45309;
  --clay-soft: #fef3e2;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --success-soft: #dcfce7;
  --shadow: 0 1px 2px rgba(28, 25, 23, 0.06), 0 8px 24px rgba(28, 25, 23, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Figtree", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  background: var(--page);
  color: var(--ink);
}

h1,
h2,
h3,
.stat-value,
.display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
}

a {
  color: var(--moss);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: #2d5540;
}

body.layout-desk {
  display: block;
}

.layout-desk {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

.rail {
  width: 240px;
  flex-shrink: 0;
  background: var(--rail);
  color: #f5f5f4;
  padding: 1.25rem 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.rail-brand {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 0.25rem;
}

.rail-sub {
  font-size: 0.8rem;
  color: var(--rail-muted);
  margin-bottom: 1rem;
}

.role-chip {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--brass-soft);
  color: var(--brass);
  margin-bottom: 0.75rem;
}

.rail nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nav-link {
  display: block;
  color: var(--rail-muted);
  text-decoration: none;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  background: var(--rail-hover);
  color: #fff;
}

.nav-link.active {
  background: var(--brass-soft);
  color: #f5e6c8;
}

.rail-foot {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.82rem;
}

.rail-foot .muted {
  color: var(--rail-muted);
  word-break: break-all;
}

.rail-foot a {
  color: #d4b87a;
  text-decoration: none;
  font-weight: 500;
}

.rail-foot a:hover {
  color: #fff;
}

.rail-menu {
  display: none;
}

.main {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  padding: 1.5rem 2rem 2.5rem;
}

.layout-portal .portal-top {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-top: 4px solid var(--rail);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.portal-brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
}

.portal-nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.portal-nav .nav-link {
  color: var(--muted);
}

.portal-nav .nav-link.active,
.portal-nav .nav-link:hover {
  background: var(--moss-soft);
  color: var(--moss);
}

.portal-shell .main,
.layout-portal .main {
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
}

.layout-auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: radial-gradient(ellipse at 30% 20%, #ebe4d6 0%, var(--page) 55%);
}

.auth-card {
  width: 100%;
  max-width: 26rem;
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.75rem;
}

.page-header .lede {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 42rem;
}

.page-header-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem 1.5rem;
}

.back-link {
  display: inline-block;
  margin-bottom: 0.45rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}

.account-title {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
}

.account-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.55rem 0 0;
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
}

.account-actions form {
  display: inline-flex;
  margin: 0;
}

.muted {
  color: var(--muted);
}

.flash {
  background: var(--success-soft);
  border: 1px solid #86efac;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.error {
  background: var(--danger-soft);
  border: 1px solid #fca5a5;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.92rem;
  color: #7f1d1d;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.35rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 0.85rem;
  font-size: 1.05rem;
}

.card h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
  width: 100%;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.stat-tile .label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.stat-tile .stat-value {
  font-size: 1.5rem;
  line-height: 1.2;
  margin: 0;
}

.stat-tile.clay .stat-value {
  color: var(--clay);
}

.stat-tile.moss .stat-value {
  color: var(--moss);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  width: 100%;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.85rem;
}

.room-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

.room-list-head h2 {
  margin: 0;
}

.room-lines {
  list-style: none;
  margin: 0;
  padding: 0;
}

.room-lines li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}

.room-lines li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.room-line-name {
  flex: 0 0 6.5rem;
  font-weight: 600;
  padding-top: 0.15rem;
}

.room-line-beds {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem;
}

.room-line-edit {
  flex: 0 0 auto;
  padding-top: 0.15rem;
  font-size: 0.88rem;
  font-weight: 600;
}

.pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  text-transform: capitalize;
  white-space: nowrap;
}

.pill-active,
.pill-moss {
  background: var(--moss-soft);
  color: var(--moss);
}

.pill-clay,
.pill-owed {
  background: var(--clay-soft);
  color: var(--clay);
}

.pill-muted,
.pill-vacant {
  background: #f5f0e8;
  color: var(--muted);
  border: 1px dashed var(--border);
}

.pill-warn {
  background: #fef9c3;
  color: #854d0e;
}

.pill-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

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

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.55rem 0.65rem;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: #faf7f2;
}

.data-table th .sort-link {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.data-table th .sort-link:hover {
  color: var(--moss);
}

.data-table th .sort-link.is-active {
  color: var(--ink);
}

.data-table th .sort-indicator {
  font-size: 0.85em;
  line-height: 1;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table .amount-owed {
  font-weight: 600;
  color: var(--clay);
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background: var(--moss);
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.3;
  transition: filter 0.15s, transform 0.1s;
}

.btn:hover {
  filter: brightness(1.06);
  color: #fff;
}

.btn:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: #57534e;
}

.btn-ghost {
  background: transparent;
  color: var(--moss);
  border: 1px solid var(--border);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.82rem;
}

.btn.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.ledger-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.85rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.ledger-pager-meta {
  font-size: 0.85rem;
}

.maint-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.maint-stack {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.maint-stack .card {
  margin-bottom: 0;
}

.maint-deadline {
  display: block;
  font-size: 0.78rem;
  margin-top: 0.2rem;
}

.maint-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 1rem 1.25rem;
}

.maint-summary-wide {
  grid-column: 1 / -1;
}

.maint-summary-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.maint-follow-note {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
}

.maint-work-form {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.maint-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.maint-timeline-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 0.55rem;
  background: var(--surface);
}

.maint-timeline-item time {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.maint-timeline-head {
  margin: 0;
  font-weight: 600;
}

.maint-timeline-detail {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
}

.back-link {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
}

.back-link a {
  color: var(--moss);
  font-weight: 600;
  text-decoration: none;
}

.back-link a:hover {
  text-decoration: underline;
}

.card-kicker {
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--moss);
}

.card-intro {
  margin: -0.35rem 0 1rem;
  max-width: 42rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.btn-danger {
  background: var(--danger);
}

form label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  margin-top: 0.85rem;
  color: var(--ink);
}

form label:first-child {
  margin-top: 0;
}

form input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
form select,
form textarea {
  display: block;
  width: 100%;
  max-width: 28rem;
  padding: 0.55rem 0.75rem;
  margin-top: 0.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.92rem;
  background: #fff;
}

form textarea {
  min-height: 4rem;
  resize: vertical;
}

form input[type="checkbox"],
form input[type="radio"] {
  display: inline-block;
  width: auto;
  max-width: none;
  margin-top: 0;
  padding: 0;
}

.form-stacked {
  max-width: 28rem;
}

.form-stacked .form-field {
  margin-top: 1rem;
}

.form-stacked > .form-field:first-child {
  margin-top: 0;
}

.form-stacked > .form-grid {
  margin-top: 1rem;
}

.form-stacked .form-grid .form-field {
  margin-top: 0;
}

.form-stacked .form-field > label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin: 0;
  color: var(--ink);
}

.form-stacked .form-field input,
.form-stacked .form-field textarea,
.form-stacked .form-field select {
  display: block;
  width: 100%;
  max-width: none;
  margin-top: 0.45rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.92rem;
  background: #fff;
}

.form-stacked .form-field input[type="number"] {
  min-height: 2.5rem;
}

.form-stacked .field-hint {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

.label-block {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.theme-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 1.25rem;
  margin-top: 0.5rem;
}

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  width: 4.25rem;
  min-height: 3.75rem;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--muted);
  position: relative;
}

.theme-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0, 0, 0, 0);
  overflow: hidden;
}

.theme-swatch {
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  box-sizing: border-box;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: linear-gradient(135deg, var(--swatch-rail) 55%, var(--swatch-moss) 55%);
  box-shadow: var(--shadow);
}

.theme-option input:checked + .theme-swatch {
  border-color: var(--moss);
  box-shadow: 0 0 0 1px var(--moss), var(--shadow);
}

.theme-label {
  display: block;
  width: 100%;
  text-align: center;
  line-height: 1.25;
  min-height: 1.25em;
}

.form-stacked .form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.15rem 0 0;
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}

.form-inline label {
  margin-top: 0;
  flex: 1;
  min-width: 8rem;
}

.bulk-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
  margin-bottom: 0.75rem;
}

.bulk-toolbar .form-field {
  flex: 1;
  min-width: 12rem;
  margin: 0;
}

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

.bulk-student-list {
  max-height: 10rem;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.35rem;
  background: var(--surface);
}

.bulk-student-scroll-hint {
  margin: 0 0 1rem;
  font-size: 0.85rem;
}

.bulk-student-row {
  display: flex;
  margin-top: 0.25rem;
}

.bulk-student-row span {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  align-items: baseline;
}

.bulk-subhead {
  font-size: 1rem;
  margin: 0 0 0.35rem;
}

.bulk-service-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem 0.65rem;
}

.bulk-services-field {
  margin-bottom: 1rem;
  max-width: 28rem;
}

.bulk-services-field .field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.bulk-services-dropdown {
  position: relative;
}

.bulk-services-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.bulk-services-toggle:hover {
  border-color: var(--moss);
}

.bulk-services-toggle[aria-expanded="true"] {
  border-color: var(--moss);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.bulk-services-chevron {
  font-size: 0.75rem;
  opacity: 0.7;
}

.bulk-services-panel {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  max-height: 14rem;
  overflow: auto;
  border: 1px solid var(--moss);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 20px rgb(0 0 0 / 8%);
}

.bulk-service-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 6.5rem;
  align-items: center;
  gap: 0.65rem;
  padding: 0.25rem 0;
}

form .bulk-service-pick {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  min-width: 0;
  font-size: 0.9rem;
  color: var(--ink);
  cursor: pointer;
}

.bulk-service-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bulk-service-amount-input {
  width: 100%;
  flex-shrink: 0;
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.bulk-service-amount-input:disabled {
  opacity: 0.45;
}

.bulk-summary {
  margin: 0.5rem 0 0;
}

.checkbox-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.35rem;
  font-size: 0.9rem;
}

.checkbox-row input {
  width: auto;
  margin: 0;
}

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

.house-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.house-card h3 {
  margin: 0;
  font-size: 1.15rem;
}

.house-card .slug {
  font-size: 0.85rem;
  color: var(--muted);
  font-family: ui-monospace, monospace;
}

.house-card .actions {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.65rem;
}

.house-card .action-row,
.house-card .resend-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
}

.house-card .resend-form label {
  margin: 0;
  flex: 1 1 12rem;
}

.house-card .resend-form input {
  max-width: none;
}

.balance-hero {
  background: linear-gradient(135deg, var(--rail) 0%, #243d35 100%);
  color: #f5f5f4;
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.balance-hero h1 {
  margin: 0 0 0.25rem;
  font-size: 1.65rem;
  color: #fff;
}

.balance-hero .room-line {
  color: var(--rail-muted);
  margin: 0 0 1rem;
  font-size: 0.95rem;
}

.balance-hero .big-balance {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.balance-hero .balance-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  font-size: 0.88rem;
  color: #d6d3d1;
}

.balance-hero .balance-meta strong {
  color: #fff;
  display: block;
  font-size: 1rem;
  font-weight: 600;
}

.ticket-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin-bottom: 0.65rem;
  background: #fff;
}

.ticket-card .ticket-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.35rem;
}

.queue-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.queue-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.queue-list li:last-child {
  border-bottom: none;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
}

.dash-toolbar {
  display: flex;
  justify-content: flex-end;
  margin: -0.5rem 0 1rem;
}

.period-bar {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
  margin: -0.35rem 0 1rem;
}

.period-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.75rem;
}

.period-modes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  min-height: 2.375rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem;
  box-sizing: border-box;
}

.period-modes a {
  text-decoration: none;
  color: var(--muted);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
}

.period-modes a.active,
.period-modes a:hover {
  background: var(--rail);
  color: #fff;
}

form.period-pick,
form.period-room-pick {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

form.period-pick input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
form.period-pick select,
form.period-room-pick select {
  display: inline-block;
  width: auto;
  max-width: 12rem;
  height: 2.375rem;
  margin: 0;
  padding: 0 0.9rem;
  box-sizing: border-box;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--ink);
  box-shadow: none;
}

form.period-pick input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):focus,
form.period-pick select:focus,
form.period-room-pick select:focus {
  outline: none;
}

form.period-room-pick select {
  max-width: 9rem;
  padding-right: 1.75rem;
  cursor: pointer;
}

form.period-room-pick.room-history-select select {
  min-width: 10rem;
  max-width: 16rem;
}

form.period-pick .btn {
  flex-shrink: 0;
  height: 2.375rem;
  border-radius: 999px;
  margin: 0;
}

.period-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font-size: 1.2rem;
  line-height: 1;
}

.period-step:hover {
  border-color: var(--moss);
  color: var(--moss);
}

.period-step.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

.drill-window-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.65rem 0.85rem;
  margin: 0.65rem 0.95rem 0.15rem;
  padding: 0.55rem 0.75rem;
  border: 1px dashed var(--border);
  border-radius: 999px;
  background: #faf7f2;
}

.drill-window-meta {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  min-width: 6.5rem;
  text-align: center;
}

.period-label {
  color: var(--muted);
  font-size: 0.88rem;
}

.record-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(8, auto);
  gap: 1rem;
  width: 100%;
  align-items: start;
}

.record-grid-col {
  display: grid;
  grid-template-rows: subgrid;
  grid-row: 1 / span 8;
  min-width: 0;
}

.record-grid-col .settings-subhead {
  margin: 0;
}

.record-grid-hint {
  margin: 0.35rem 0 0;
}

.record-grid-hint:empty {
  min-height: 0;
}

.record-form-grid {
  display: contents;
}

.record-form-grid .form-field {
  margin-top: 0;
}

.record-grid-actions {
  margin: 0;
  padding-top: 0.25rem;
}

.record-grid-spacer {
  min-height: 0;
}

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

.section-head h2,
.section-head .section-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.section-close {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}

.section-close:hover {
  color: var(--danger);
  border-color: #fca5a5;
  background: var(--danger-soft);
}

.dash-section {
  margin-bottom: 1rem;
}

.customize {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.customize summary {
  cursor: pointer;
  list-style: none;
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.customize summary::-webkit-details-marker {
  display: none;
}

.settings-block {
  padding: 0;
  overflow: hidden;
}

.settings-block > .settings-summary {
  cursor: pointer;
  list-style: none;
  padding: 1rem 1.35rem;
  font-weight: 600;
  font-size: 1.05rem;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.settings-block > .settings-summary::-webkit-details-marker {
  display: none;
}

.settings-block > .settings-summary::after {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  flex-shrink: 0;
  transition: transform 0.15s ease;
  margin-top: -0.15rem;
}

.settings-block[open] > .settings-summary::after {
  transform: rotate(-135deg);
  margin-top: 0.2rem;
}

.settings-body {
  padding: 0.9rem 1.35rem 1.15rem;
  border-top: 1px solid var(--border);
}

.settings-body > .period-bar {
  margin-top: 0.15rem;
}

.settings-body .section-hint {
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.settings-body .section-hint + .period-bar {
  margin-top: 0;
}

.settings-subhead {
  margin: 1.25rem 0 0.65rem;
  font-size: 0.95rem;
}

.settings-subhead:first-child {
  margin-top: 0.85rem;
}

.statement-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.statement-toolbar .section-hint {
  margin: 0;
  flex: 1 1 16rem;
  max-width: 42rem;
}

.statement-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 0 1rem;
  overflow: hidden;
  background: var(--surface);
}

.statement-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.75rem 0.95rem;
  background: var(--moss-soft);
  border-bottom: 1px solid var(--border);
}

.statement-block-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.08rem;
}

.statement-block-head .card-kicker {
  margin: 0 0 0.15rem;
}

.statement-kicker {
  margin: 0.9rem 0.95rem 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.statement-block .data-table th:first-child,
.statement-block .data-table td:first-child {
  padding-left: 0.95rem;
}

.statement-block .data-table th:last-child,
.statement-block .data-table td:last-child {
  padding-right: 0.95rem;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.data-table tr.statement-total td {
  font-weight: 700;
  background: #faf7f2;
  border-top: 1px solid var(--border);
}

.statement-grand-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.75rem 0.95rem;
  background: #faf7f2;
  border-top: 2px solid var(--border);
  font-weight: 700;
}

.statement-profit {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.95rem 1.05rem;
  border-radius: var(--radius);
  background: var(--moss);
  color: #fff;
}

.statement-profit span {
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.statement-profit strong {
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
}

.statement-profit.is-loss {
  background: var(--clay);
}

.extra-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 0.25rem;
}

.reversal-stack {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 0.75rem;
}

.reversal-stack .data-table {
  table-layout: auto;
}

.reversal-stack .data-table th:nth-child(1),
.reversal-stack .data-table td:nth-child(1),
.reversal-stack .data-table th:nth-last-child(2),
.reversal-stack .data-table td:nth-last-child(2),
.reversal-stack .data-table th:last-child,
.reversal-stack .data-table td:last-child {
  white-space: nowrap;
}

.reversal-stack .data-table th:last-child,
.reversal-stack .data-table td:last-child:not([colspan]) {
  width: 1%;
  text-align: right;
}

.extra-grid h3 {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
}

.data-table tr.is-selected td {
  background: var(--moss-soft);
}

.staff-user-list .staff-user-row {
  flex-direction: column;
  align-items: stretch;
  gap: 0.65rem;
}

.staff-user-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.staff-user-actions {
  padding: 0.75rem 0 0;
  border-top: 1px dashed var(--border);
}

.staff-perms-form {
  margin-bottom: 0.75rem;
}

.staff-user-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.btn.danger-text,
.danger-text {
  color: var(--danger);
}

.customize-body {
  padding: 0 1rem 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.65rem 1rem;
}

.widget-option {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  font-size: 0.88rem;
  margin: 0;
}

.widget-option input {
  width: auto;
  margin-top: 0.2rem;
}

.widget-option small {
  display: block;
  color: var(--muted);
  font-weight: 400;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
  width: 100%;
}

.chart-box {
  position: relative;
  height: 240px;
  width: 100%;
}

.chart-card:has(#chart-occupancy) .chart-box,
.chart-card:has(#chart-balance) .chart-box {
  width: min(100%, 240px);
  margin-inline: auto;
}

.chart-card canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-card .chart-note {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.mb-1 {
  margin-bottom: 1rem;
}

.mt-1 {
  margin-top: 1rem;
}

.inline-form {
  display: inline;
}

.directory-head,
.student-row {
  display: grid;
  grid-template-columns: 2.75rem minmax(0, 1.6fr) minmax(5rem, 0.6fr) minmax(9rem, 1fr);
  gap: 0.75rem 1rem;
  align-items: center;
}

.directory-head {
  padding: 0 0.35rem 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.directory-head .sort-link {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  text-transform: uppercase;
  letter-spacing: inherit;
}

.directory-head .sort-link:hover {
  color: var(--moss);
}

.directory-head .sort-link.is-active {
  color: var(--ink);
}

.directory-head .sort-indicator {
  font-size: 0.85em;
  line-height: 1;
}

.student-row {
  padding: 0.8rem 0.35rem;
  border-top: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  border-radius: 8px;
}

.student-row:hover {
  background: #faf7f2;
  color: inherit;
}

.student-name {
  display: block;
  font-weight: 600;
}

.student-row:hover .student-name {
  color: var(--moss);
}

.student-meta,
.student-contact span {
  display: block;
  font-size: 0.84rem;
  color: var(--muted);
}

.student-contact span:first-child {
  color: var(--ink);
}

.avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  background: var(--moss-soft);
  color: var(--moss);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
}

.avatar-lg {
  width: 3.4rem;
  height: 3.4rem;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.profile-grid .card {
  margin-bottom: 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem 1.25rem;
  margin: 0;
}

.detail-grid div {
  min-width: 0;
}

.detail-grid dt {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.detail-grid dd {
  margin: 0.2rem 0 0;
}

.modal {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0;
  width: min(46rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(28, 25, 23, 0.18);
  overflow: hidden;
}

.modal > form {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 2rem);
  margin: 0;
  overflow: hidden;
}

.modal::backdrop {
  background: rgba(28, 25, 23, 0.48);
}

.modal-head,
.modal-foot {
  flex: 0 0 auto;
  background: var(--surface);
  padding: 1rem 1.35rem;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  margin: 0;
  font-size: 1.35rem;
}

.modal-head p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 0.35rem 1.35rem 1.15rem;
}

.modal-foot {
  border-top: 1px solid var(--border);
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.35rem;
  font-family: inherit;
}

.icon-btn:hover {
  color: var(--ink);
}

.form-section {
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.form-section:first-child {
  margin-top: 0.35rem;
  padding-top: 0;
  border-top: none;
}

.form-section h3 {
  margin: 0 0 0.8rem;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-hint {
  margin: -0.35rem 0 0.8rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.95rem 1rem;
}

.span-2 {
  grid-column: 1 / -1;
}

.form-profile {
  max-width: none;
}

.form-profile label {
  margin-top: 0;
}

.form-profile .form-field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0;
}

form.form-profile .form-field input:not([type="hidden"]),
form.form-profile .form-field select,
form.form-profile .form-field textarea {
  margin-top: 0;
  max-width: none;
}

.form-profile .form-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
}

.student-search {
  max-width: 36rem;
}

.student-search label {
  display: block;
  margin: 0 0 0.45rem;
  font-size: 0.82rem;
  font-weight: 600;
}

.student-search input {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  background: #fff;
}

.student-search + .section-hint {
  margin-top: 0.85rem;
}

.match-list {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0.3rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  max-height: 16rem;
  overflow: auto;
}

.match-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
}

.match-list a:hover {
  background: #faf7f2;
  color: inherit;
}

.match-list a span {
  display: block;
}

.picked-student {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  background: var(--moss-soft);
}

.picked-student .muted {
  display: block;
  margin-top: 0.15rem;
}

.billing-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1rem;
}

.billing-tabs button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}

.billing-tabs button.active {
  background: var(--rail);
  border-color: var(--rail);
  color: #fff;
}

.billing-form {
  max-width: 40rem;
}

.plan-block + .plan-block {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.plan-block h3 {
  margin: 0;
  font-size: 1rem;
}

.plan-block .muted {
  margin: 0.2rem 0 0.6rem;
}

form.inline-pay {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  justify-content: flex-end;
}

form.inline-pay input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]) {
  width: 8rem;
  max-width: 8rem;
  margin-top: 0;
}

@media (max-width: 900px) {
  .layout-desk {
    flex-direction: column;
  }

  .rail {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 0.75rem;
    row-gap: 0.2rem;
    padding: 0.85rem 1rem;
  }

  .rail-brand {
    grid-column: 1;
    grid-row: 1;
    margin-bottom: 0;
  }

  .role-chip {
    grid-column: 1;
    grid-row: 2;
    margin-bottom: 0;
    justify-self: start;
  }

  .rail-sub {
    display: none;
  }

  .rail-menu {
    grid-column: 2;
    grid-row: 1 / span 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: transparent;
    color: #f5f5f4;
    border-radius: 999px;
    padding: 0.4rem 0.9rem;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
  }

  .rail-menu:hover {
    background: var(--rail-hover);
  }

  .rail nav {
    display: none;
    grid-column: 1 / -1;
    flex-direction: column;
    width: 100%;
    margin-top: 0.55rem;
    padding-top: 0.55rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }

  .rail.is-open nav {
    display: flex;
  }

  .rail-foot {
    display: none;
    grid-column: 1 / -1;
    margin: 0.35rem 0 0;
    padding-top: 0.75rem;
  }

  .rail.is-open .rail-foot {
    display: block;
  }

  .grid-2,
  .chart-grid,
  .profile-grid {
    grid-template-columns: 1fr;
  }

  .record-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .record-grid-col {
    display: block;
    grid-row: auto;
  }

  .record-form-grid {
    display: block;
  }

  .record-form-grid .form-field {
    margin-top: 1rem;
  }

  .record-form-grid .form-field:first-child {
    margin-top: 0;
  }

  .record-grid-spacer {
    display: none;
  }

  .page-header-row {
    flex-direction: column;
    align-items: stretch;
  }

  .account-actions {
    justify-content: flex-start;
  }

  .stat-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main {
    padding: 1.25rem 1rem 2rem;
  }

  .card {
    overflow-x: auto;
  }

  form input,
  form select,
  form textarea {
    max-width: 100%;
  }
}

@media (max-width: 640px) {
  .form-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .directory-head {
    display: none;
  }

  .student-row {
    grid-template-columns: 2.75rem minmax(0, 1fr);
  }

  .student-row .avatar {
    grid-row: 1 / span 3;
  }

  .student-room,
  .student-contact {
    grid-column: 2;
  }
}

@media (max-width: 560px) {
  .stat-row {
    grid-template-columns: 1fr;
  }

  .chart-box {
    height: 200px;
  }

  .portal-top {
    align-items: flex-start;
  }
}
