/* ============================================================
   NOVA TECH — ADMIN DASHBOARD
   Builds on the tokens/fonts declared in style.css (the
   ledger/parchment/stamp visual language from the sign-in page).
   ============================================================ */

body { background: var(--parchment); }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

/* ---------------- SIDEBAR ---------------- */

.sidebar {
  background: linear-gradient(180deg, var(--ink) 0%, var(--ink-2) 100%);
  color: var(--parchment);
  padding: 1.6rem 1.1rem;
  display: flex;
  flex-direction: column;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.4rem 0.6rem 1.6rem;
  border-bottom: 1px solid rgba(243, 236, 220, 0.14);
  margin-bottom: 1.2rem;
}

.seal--sm {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.seal--sm .seal__initials {
  font-size: 0.9rem;
}

.sidebar__school {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  margin: 0;
  color: var(--paper);
}

.sidebar__portal {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 0.15rem 0 0;
}

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

.nav__item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  border: none;
  background: transparent;
  color: rgba(243, 236, 220, 0.72);
  font-family: var(--font-body);
  font-size: 0.87rem;
  font-weight: 500;
  padding: 0.65rem 0.7rem;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}

.nav__item:hover {
  background: rgba(243, 236, 220, 0.07);
  color: var(--paper);
}

.nav__item.is-active {
  background: rgba(169, 128, 63, 0.18);
  color: var(--brass);
  font-weight: 600;
}

.nav__item:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

.nav__icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.sidebar__footer {
  border-top: 1px solid rgba(243, 236, 220, 0.14);
  padding-top: 0.8rem;
}

.nav__item--muted {
  color: rgba(243, 236, 220, 0.5);
}

/* ---------------- MAIN / TOPBAR ---------------- */

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.4rem clamp(1.2rem, 3vw, 2.4rem);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.topbar__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.5rem;
  margin: 0;
  color: var(--text);
}

.topbar__subtitle {
  font-size: 0.85rem;
  color: var(--text-soft);
  margin: 0.2rem 0 0;
}

.topbar__account {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.topbar__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--maroon);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
}

.topbar__name {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.topbar__role {
  margin: 0;
  font-size: 0.72rem;
  color: var(--text-soft);
}

.content {
  padding: clamp(1.2rem, 3vw, 2.4rem);
  flex: 1;
}

/* ---------------- PAGE SECTIONS ---------------- */

.page-section {
  display: none;
}

.page-section.is-active {
  display: block;
  animation: fade-in 0.25s ease;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------- STAT CARDS ---------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.4rem;
}

.stat-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
}

.stat-card--warn {
  border-color: rgba(161, 54, 54, 0.35);
}

.stat-card__label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin: 0 0 0.4rem;
}

.stat-card__value {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.stat-card--warn .stat-card__value {
  color: var(--error);
}

.stat-card__hint {
  font-size: 0.75rem;
  color: var(--text-soft);
  margin: 0.3rem 0 0;
}

/* ---------------- PANEL ---------------- */

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem clamp(1rem, 3vw, 1.8rem);
  margin-bottom: 1.4rem;
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.panel__head h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  margin: 0;
  color: var(--text);
}

.panel__note {
  font-size: 0.82rem;
  color: var(--text-soft);
  margin: 0.5rem 0 1.2rem;
  max-width: 60rem;
}

.panel__note code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--parchment-dark);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
}

/* ---------------- BUTTONS ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0.6rem 1rem;
  cursor: pointer;
}

.btn__icon {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.btn--primary {
  background: var(--maroon);
  color: var(--paper);
}

.btn--primary:hover {
  background: var(--maroon-dark);
}

.btn--ghost {
  background: transparent;
  color: var(--text-soft);
  border: 1.5px solid var(--line);
}

.btn--ghost:hover {
  color: var(--text);
  border-color: var(--text-soft);
}

.btn--small {
  padding: 0.4rem 0.7rem;
  font-size: 0.76rem;
}

/* ---------------- SELECT ---------------- */

.select-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.select-wrap__label {
  font-size: 0.78rem;
  color: var(--text-soft);
}

.select-wrap select {
  font-family: var(--font-body);
  font-size: 0.82rem;
  /* extra right padding leaves room for the chevron in style.css */
  padding: 0.45rem 1.9rem 0.45rem 0.6rem;
  border-radius: var(--radius);
  border: 1.5px solid var(--line);
  background-color: var(--parchment);
  color: var(--text);
}

/* ---------------- TABLE ---------------- */

.table-wrap {
  overflow-x: auto;
}

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

.table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-soft);
  padding: 0.6rem 0.7rem;
  border-bottom: 1.5px solid var(--line);
  white-space: nowrap;
}

.table td {
  padding: 0.75rem 0.7rem;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  vertical-align: middle;
}

.table tbody tr:hover {
  background: rgba(38, 32, 25, 0.03);
}

.cell-id {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-soft);
}

.cell-sub {
  display: block;
  font-size: 0.74rem;
  color: var(--text-soft);
  margin-top: 0.1rem;
}

/* Status stamp badges — echoes the ink-stamp motif from the sign-in card */

.stamp-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.25rem 0.55rem;
  border-radius: 3px;
  border: 1.3px dashed currentColor;
}

.stamp-badge--active { color: var(--forest-dark); background: rgba(63, 93, 79, 0.08); }
.stamp-badge--locked { color: var(--error); background: rgba(161, 54, 54, 0.08); }
.stamp-badge--expired { color: var(--brass-dark); background: rgba(169, 128, 63, 0.1); }

.limit-track {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 90px;
}

.limit-track__bar {
  height: 5px;
  border-radius: 3px;
  background: var(--parchment-dark);
  overflow: hidden;
}

.limit-track__fill {
  height: 100%;
  background: var(--accent);
}

.limit-track__label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-soft);
}

.row-actions {
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
}

/* ---------------- ACTIVITY LIST ---------------- */

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

.activity-list li {
  display: flex;
  gap: 0.7rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--text);
}

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

.activity-list time {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-soft);
  min-width: 6.5rem;
}

/* ---------------- STUDENT BAR LIST ---------------- */

.bar-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.bar-item__head {
  display: flex;
  justify-content: space-between;
  font-size: 0.83rem;
  margin-bottom: 0.3rem;
}

.bar-item__name {
  color: var(--text);
  font-weight: 500;
}

.bar-item__count {
  font-family: var(--font-mono);
  color: var(--text-soft);
}

.bar-item__track {
  height: 8px;
  border-radius: 4px;
  background: var(--parchment-dark);
  overflow: hidden;
}

.bar-item__fill {
  height: 100%;
  background: var(--forest);
  border-radius: 4px;
}

/* ---------------- LIMITS FORM ---------------- */

.limits-form {
  display: flex;
  align-items: flex-end;
  gap: 1.2rem;
  flex-wrap: wrap;
}

.limits-form .field {
  margin-bottom: 0;
  min-width: 14rem;
}

.field__control--plain {
  background: var(--parchment);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 0 0.75rem;
}

.field__control--plain input {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0.62rem 0;
  font-size: 0.9rem;
  color: var(--text);
  outline: none;
}

.field__control--plain:focus-within {
  border-color: var(--accent);
}

.field__optional {
  font-weight: 400;
  color: var(--text-soft);
  font-size: 0.76rem;
}

.field__hint {
  font-size: 0.75rem;
  color: var(--text-soft);
  margin: 0.35rem 0 0;
}

/* ---------------- PERMISSIONS GRID ---------------- */

.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.2rem;
}

.perm-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.perm-card h3 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  margin: 0 0 0.7rem;
  color: var(--text);
}

.perm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--text);
}

.perm-row:last-child {
  border-bottom: none;
}

.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch__track {
  position: absolute;
  inset: 0;
  background: var(--parchment-dark);
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.switch__track::before {
  content: "";
  position: absolute;
  width: 15px;
  height: 15px;
  left: 3px;
  top: 2.5px;
  background: var(--paper);
  border-radius: 50%;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
}

.switch input:checked + .switch__track {
  background: var(--forest);
}

.switch input:checked + .switch__track::before {
  transform: translateX(16px);
}

.switch input:focus-visible + .switch__track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------- MODALS ---------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 33, 48, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}

.modal-overlay.is-open {
  display: flex;
}

.modal {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 1.6rem 1.6rem 1.4rem;
  width: 100%;
  max-width: 26rem;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-card);
}

.modal[hidden] {
  display: none;
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.modal__head h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0;
  color: var(--text);
}

.modal__close {
  border: none;
  background: transparent;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--text-soft);
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}

.modal__note {
  font-size: 0.82rem;
  color: var(--text-soft);
  margin: 0 0 1rem;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.2rem;
}

.credential-box {
  background: var(--parchment);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}

.credential-box__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  font-size: 0.85rem;
}

.credential-box__row code {
  font-family: var(--font-mono);
  background: var(--parchment-dark);
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
}

.toggle-pair {
  display: flex;
  gap: 0.5rem;
}

.toggle-pair__btn {
  flex: 1;
  border: 1.5px solid var(--line);
  background: var(--parchment);
  color: var(--text-soft);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.55rem;
  border-radius: var(--radius);
  cursor: pointer;
}

.toggle-pair__btn.is-selected[data-status="active"] {
  border-color: var(--forest);
  color: var(--forest-dark);
  background: rgba(63, 93, 79, 0.1);
}

.toggle-pair__btn.is-selected[data-status="locked"] {
  border-color: var(--error);
  color: var(--error);
  background: rgba(161, 54, 54, 0.08);
}

/* ---------------- RESPONSIVE ---------------- */

@media (max-width: 1000px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 0.8rem 1rem;
  }

  .sidebar__brand {
    border-bottom: none;
    padding: 0;
    margin: 0 1rem 0 0;
  }

  .sidebar__school, .sidebar__portal { display: none; }

  .nav {
    flex-direction: row;
  }

  .nav__item span { display: none; }

  .sidebar__footer {
    border-top: none;
    padding: 0;
    margin-left: 0.5rem;
  }
}

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

  .topbar__account .topbar__name,
  .topbar__account .topbar__role {
    display: none;
  }

  .panel__head {
    flex-direction: column;
    align-items: flex-start;
  }

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

  /* Every extra bit of width matters once a modal's own padding is
     subtracted from a ~360-390px phone screen. */
  .modal-overlay {
    padding: 0.5rem;
  }

  .modal {
    padding: 1.1rem 1.1rem 1rem;
  }
}

/* Wide data tables (the report table especially, with a column per
   subject) scroll horizontally rather than break the page layout —
   this just makes that scroll feel native on iOS instead of janky. */
.table-wrap {
  -webkit-overflow-scrolling: touch;
}
