:root {
  --ink: #211d13;
  --muted: #665f45;
  --line: #c9bd95;
  --line-strong: #777737;
  --surface: #eee5d2;
  --surface-soft: #e6d8be;
  --surface-strong: #f7efdc;
  --field: #f4ead6;
  --accent: #6f7533;
  --accent-strong: #51591f;
  --accent-soft: #d9d5ad;
  --warm: #9a6a2e;
  --danger: #9c302b;
  --shadow-low: 0 4px 8px rgba(74, 66, 38, 0.16);
  --shadow-mid: 0 8px 18px rgba(74, 66, 38, 0.22);
  --shadow-high: 0 14px 30px rgba(74, 66, 38, 0.28);
  --inset: inset 0 2px 5px rgba(50, 43, 22, 0.26), inset 0 -1px 0 rgba(255, 255, 255, 0.7);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  height: 100svh;
  margin: 0;
  background:
    repeating-linear-gradient(45deg, rgba(92, 83, 48, 0.035) 0 1px, transparent 1px 9px),
    linear-gradient(180deg, #f3ead8 0%, var(--surface) 100%);
  color: var(--ink);
  letter-spacing: 0;
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 36px;
  border: 2px solid rgba(112, 107, 60, 0.56);
  border-radius: 999px;
  background: linear-gradient(180deg, #f4ead4 0%, #ded0b2 100%);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  padding: 0 16px;
  box-shadow:
    0 2px 0 rgba(77, 71, 39, 0.28),
    0 5px 10px rgba(74, 66, 38, 0.16);
  transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: linear-gradient(180deg, #fff5df 0%, #e8d9b9 100%);
  box-shadow:
    0 3px 0 rgba(77, 71, 39, 0.32),
    0 7px 14px rgba(74, 66, 38, 0.2);
}

button:active {
  transform: translateY(1px);
  background: #d7c9a7;
  box-shadow: inset 0 3px 5px rgba(51, 45, 24, 0.3), inset 0 -1px 0 rgba(255, 255, 255, 0.55);
}

button:disabled {
  cursor: not-allowed;
  color: rgba(33, 29, 19, 0.42);
  background: #d8cdb8;
  border-color: rgba(112, 107, 60, 0.2);
  box-shadow: none;
  transform: none;
}

input,
select,
textarea {
  width: 100%;
  border: 2px solid rgba(112, 107, 60, 0.48);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  box-shadow: var(--inset);
}

input::placeholder,
textarea::placeholder {
  color: rgba(84, 77, 49, 0.58);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow:
    var(--inset),
    0 0 0 4px rgba(111, 117, 51, 0.2),
    0 0 0 7px rgba(111, 117, 51, 0.12);
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1180px;
}

th,
td {
  border-bottom: 2px solid rgba(112, 107, 60, 0.18);
  padding: 13px 14px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #e0d2b7;
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 950;
  text-transform: uppercase;
}

td {
  background: rgba(247, 239, 220, 0.82);
  font-size: 0.92rem;
}

tbody tr:hover td {
  background: #f2e6cc;
}

h1,
h2,
p {
  margin: 0;
}

.login-view {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    repeating-linear-gradient(135deg, rgba(91, 83, 51, 0.055) 0 1px, transparent 1px 10px),
    linear-gradient(135deg, #f5ecd8, #e5d6ba);
}

.login-panel {
  width: min(100%, 420px);
  padding: 34px;
  border: 2px solid rgba(112, 107, 60, 0.35);
  border-radius: 12px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-high);
}

.login-panel h1 {
  margin: 8px 0 26px;
  font-size: 2rem;
  line-height: 1.05;
}

.brand-mark {
  width: 58px;
  height: 58px;
  display: block;
  border-radius: 12px;
  box-shadow: var(--shadow-low);
}

.brand-mark.small {
  width: 42px;
  height: 42px;
}

.stack {
  display: grid;
  gap: 16px;
}

.app-shell {
  height: 100svh;
  min-height: 0;
  display: grid;
  grid-template-columns: 254px minmax(0, 1fr);
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: 100svh;
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
  border-right: 2px solid rgba(112, 107, 60, 0.32);
  background:
    repeating-linear-gradient(45deg, rgba(82, 75, 45, 0.035) 0 1px, transparent 1px 8px),
    #e4d7bd;
  box-shadow: inset -5px 0 12px rgba(74, 66, 38, 0.12);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 2px solid rgba(112, 107, 60, 0.24);
  border-radius: 10px;
  background: var(--surface-soft);
  box-shadow: var(--shadow-low);
}

.brand-row strong,
.brand-row span {
  display: block;
}

.brand-row strong {
  font-size: 1rem;
}

.brand-row span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.nav-tabs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 5px;
  border: 2px solid rgba(112, 107, 60, 0.22);
  border-radius: 18px;
  background: #d8c7a8;
  box-shadow: var(--inset);
}

.nav-tabs button,
.ghost {
  border-radius: 999px;
  border-color: transparent;
  background: transparent;
  color: var(--ink);
  text-align: left;
  min-height: 38px;
  padding: 0 16px;
  box-shadow: none;
}

.nav-tabs button.active,
.nav-tabs button:hover,
.ghost:hover {
  background: var(--surface-strong);
  border-color: rgba(112, 107, 60, 0.38);
  box-shadow: 0 2px 5px rgba(74, 66, 38, 0.18);
}

.nav-tabs button.active {
  color: white;
  background: linear-gradient(180deg, #828741 0%, var(--accent) 100%);
  border-color: var(--accent-strong);
  box-shadow:
    0 2px 0 rgba(58, 63, 22, 0.52),
    0 5px 10px rgba(74, 66, 38, 0.2);
}

.sidebar-action {
  margin-top: auto;
}

.workspace {
  min-width: 0;
  min-height: 0;
  height: 100svh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  padding: 26px;
}

.topbar,
.toolbar,
.modal header,
.modal footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 2px solid rgba(112, 107, 60, 0.28);
}

.topbar h1 {
  margin-top: 4px;
  font-size: 2.08rem;
  line-height: 1.05;
}

.topbar-actions,
.filters {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.filters {
  flex: 1;
}

.search-field {
  min-width: min(320px, 100%);
  flex: 1;
}

.primary {
  background: linear-gradient(180deg, #848945 0%, var(--accent) 100%);
  color: #fff7df;
  border-color: var(--accent-strong);
  box-shadow:
    0 2px 0 rgba(58, 63, 22, 0.55),
    0 6px 12px rgba(74, 66, 38, 0.2);
}

.primary:hover {
  background: linear-gradient(180deg, #777d38 0%, var(--accent-strong) 100%);
}

.secondary {
  background: linear-gradient(180deg, #f4ead4 0%, #ded0b2 100%);
  color: var(--ink);
}

.secondary:active,
.primary:active,
.nav-tabs button.active:active {
  box-shadow: inset 0 3px 5px rgba(51, 45, 24, 0.32), inset 0 -1px 0 rgba(255, 255, 255, 0.42);
}

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

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.summary-grid div {
  display: grid;
  gap: 8px;
  min-height: 104px;
  padding: 18px;
  border: 2px solid rgba(112, 107, 60, 0.3);
  border-radius: 12px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-mid);
}

.summary-grid span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 950;
  text-transform: uppercase;
}

.summary-grid strong {
  align-self: end;
  color: var(--accent-strong);
  font-size: 1.58rem;
}

.view-panel {
  display: grid;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
}

.toolbar {
  align-items: end;
  padding: 14px;
  border: 2px solid rgba(112, 107, 60, 0.28);
  border-radius: 12px;
  background: rgba(230, 216, 190, 0.78);
  box-shadow: var(--inset);
}

.table-frame {
  position: relative;
  min-height: 0;
  overflow: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
  border: 2px solid rgba(112, 107, 60, 0.34);
  border-radius: 12px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-mid);
}

.table-frame::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.table-frame th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.table-frame table th:first-child {
  border-top-left-radius: 10px;
}

.table-frame table th:last-child {
  border-top-right-radius: 10px;
}

.student-name,
.payment-name {
  display: grid;
  gap: 2px;
}

.student-name span,
.payment-name span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  min-height: 28px;
  border: 2px solid rgba(81, 89, 31, 0.24);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 900;
  box-shadow: var(--inset);
}

.status-pill.inactive {
  background: #e9d4bd;
  color: var(--warm);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.row-actions button {
  min-height: 32px;
  padding: 0 13px;
  background: linear-gradient(180deg, #f2e8d1 0%, #dacbab 100%);
  font-size: 0.84rem;
}

.row-actions button.danger,
.row-actions .danger {
  border-color: rgba(156, 48, 43, 0.34);
  background: linear-gradient(180deg, #f0ddc9 0%, #dec6ad 100%);
}

.empty-state {
  padding: 28px;
  color: var(--muted);
  font-weight: 850;
}

.modal {
  width: min(900px, calc(100vw - 28px));
  border: 2px solid rgba(112, 107, 60, 0.34);
  border-radius: 12px;
  padding: 0;
  background: var(--surface-strong);
  box-shadow: var(--shadow-high);
}

.modal::backdrop {
  background: rgba(33, 29, 19, 0.38);
}

.modal form {
  display: grid;
  gap: 20px;
  padding: 24px;
}

.modal h2 {
  margin-top: 4px;
  font-size: 1.5rem;
}

.icon-button {
  width: 40px;
  min-width: 40px;
  padding: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #f4ead4 0%, #ded0b2 100%);
  color: var(--ink);
  font-size: 1.4rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.register-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.register-no {
  color: var(--accent-strong);
  font-size: 1rem;
  font-weight: 950;
  text-align: center;
}

.parents-list {
  display: grid;
  gap: 3px;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 760;
}

.note-cell {
  min-width: 220px;
  max-width: 360px;
  white-space: normal;
}

.error-text {
  min-height: 20px;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 850;
}

.eyebrow {
  color: var(--warm);
  font-size: 0.74rem;
  font-weight: 950;
  text-transform: uppercase;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  transform: translateY(120%);
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 2px solid var(--accent-strong);
  border-radius: 10px;
  background: var(--accent);
  color: #fff7df;
  box-shadow: var(--shadow-high);
  transition: transform 180ms ease;
  z-index: 20;
}

.toast.show {
  transform: translateY(0);
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .sidebar {
    height: auto;
    min-height: 0;
    overflow: visible;
    position: sticky;
    top: 0;
    z-index: 10;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
  }

  .nav-tabs {
    min-width: 170px;
  }

  .sidebar-action {
    margin: 0 0 0 auto;
  }

  .workspace {
    height: auto;
    padding: 18px 14px;
  }

  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .filters {
    width: 100%;
  }

  .topbar-actions button,
  .toolbar > button {
    flex: 1;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 14px;
  }

  .summary-grid div {
    min-height: 78px;
    padding: 12px;
  }

  .summary-grid strong {
    font-size: 1.3rem;
  }

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

@media (max-width: 620px) {
  .brand-row span {
    display: none;
  }

  .sidebar {
    flex-wrap: wrap;
  }

  .sidebar-action {
    width: 100%;
    text-align: center;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .register-grid {
    grid-template-columns: 1fr;
  }

  .login-panel {
    padding: 26px;
  }
}
