:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #667085;
  --line: #d7dde6;
  --panel: #ffffff;
  --page: #f5f7fb;
  --nav: #0f172a;
  --nav-soft: #1e293b;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --gold: #b7791f;
  --danger: #b42318;
  --shadow: 0 10px 28px rgba(16, 24, 40, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
}

body.auth-locked {
  overflow: hidden;
}

body.auth-locked .app-shell {
  display: none;
}

body.is-authenticated .login-screen {
  display: none;
}

button,
input,
select {
  font: inherit;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(circle at 50% 0%, rgba(37, 99, 235, 0.18), transparent 34%),
    linear-gradient(135deg, #020617 0%, #0f172a 52%, #111827 100%);
  color: #fff;
}

.login-content {
  width: min(100%, 430px);
  display: grid;
  justify-items: center;
  gap: 22px;
}

.login-logo {
  width: min(280px, 72vw);
  border-radius: 8px;
  background: #020617;
  border: 1px solid rgba(148, 163, 184, 0.24);
  box-shadow: 0 24px 70px rgba(2, 6, 23, 0.42);
}

.login-card {
  width: 100%;
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 1px solid rgba(226, 232, 240, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.97);
  color: var(--ink);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.34);
}

.login-card h1 {
  font-size: 2rem;
  line-height: 1;
}

.login-card p:not(.eyebrow):not(.login-error) {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--nav);
  color: #fff;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.brand {
  display: grid;
  grid-template-columns: 92px 1fr;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 92px;
  height: 62px;
  object-fit: contain;
  display: block;
  border-radius: 8px;
  background: #030712;
  padding: 6px;
  border: 1px solid rgba(148, 163, 184, 0.22);
}

.brand p,
.brand strong {
  margin: 0;
}

.brand p {
  color: #93a4bb;
  font-size: 0.84rem;
  font-weight: 800;
}

.brand strong {
  display: block;
  line-height: 1.15;
  font-size: 0.96rem;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-list a {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border-radius: 8px;
  color: #cbd5e1;
  text-decoration: none;
  font-weight: 700;
}

.nav-list a.active,
.nav-list a:hover {
  background: var(--nav-soft);
  color: #fff;
}

.logout-button {
  width: 100%;
  min-height: 44px;
  margin-top: auto;
  border: 1px solid rgba(203, 213, 225, 0.22);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.18);
  color: #e2e8f0;
  cursor: pointer;
  font-weight: 800;
}

.logout-button:hover {
  background: var(--nav-soft);
  color: #fff;
}

.app-shell[aria-hidden="true"] {
  pointer-events: none;
}

.dashboard {
  padding: 32px;
  display: grid;
  gap: 24px;
  align-content: start;
}

.view-section {
  display: none;
}

.view-section.active-view {
  display: grid;
}

.topbar,
.panel-title {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.eyebrow {
  color: var(--accent-strong);
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
  font-size: 0.78rem;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 2.8rem);
  line-height: 1.05;
}

h2 {
  font-size: 1.05rem;
}

.primary-button,
.secondary-button,
.icon-button,
.edit-button,
.register-button {
  border: 0;
  border-radius: 8px;
  font-weight: 800;
  min-height: 44px;
  cursor: pointer;
}

.primary-button {
  background: var(--accent);
  color: #fff;
  padding: 0 18px;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22);
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  background: #eef2f6;
  color: var(--ink);
  padding: 0 16px;
}

.icon-button {
  width: 40px;
  background: #eef2f6;
  color: var(--ink);
  font-size: 1.4rem;
  line-height: 1;
}

.edit-button {
  min-height: 34px;
  padding: 0 12px;
  background: #eff6ff;
  color: var(--accent-strong);
  white-space: nowrap;
}

.edit-button:hover {
  background: #dbeafe;
}

.register-cell {
  display: grid;
  gap: 8px;
  min-width: 150px;
}

.register-button {
  min-height: 30px;
  padding: 0 10px;
  background: #eef2f6;
  color: var(--ink);
  white-space: nowrap;
}

.register-button:hover {
  background: #dbe4ef;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 16px;
}

.metric-card,
.toolbar,
.table-panel {
  background: var(--panel);
  border: 1px solid rgba(215, 221, 230, 0.95);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 18px;
  display: grid;
  gap: 5px;
}

.metric-card span,
.metric-card small,
.panel-title p,
label span {
  color: var(--muted);
}

.metric-card span,
label span {
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-card strong {
  font-size: 1.7rem;
}

.metric-card small {
  font-size: 0.86rem;
}

.toolbar {
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 190px 220px;
  gap: 14px;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 126, 102, 0.15);
}

.table-panel {
  overflow: hidden;
}

.panel-title {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

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

table {
  width: 100%;
  min-width: 1450px;
  border-collapse: collapse;
}

th,
td {
  padding: 15px 12px;
  text-align: left;
  border-bottom: 1px solid #edf1f5;
  vertical-align: middle;
}

th {
  color: #596476;
  background: #f8fafc;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

td {
  font-size: 0.9rem;
}

tr:last-child td {
  border-bottom: 0;
}

.student-cell {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 9px;
  align-items: center;
  font-weight: 800;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #e5f3ef;
  color: var(--accent-strong);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-weight: 800;
  font-size: 0.8rem;
  background: #eff6ff;
  color: var(--accent-strong);
  white-space: nowrap;
}

.pill.gold {
  background: #fff3df;
  color: #8b5c12;
}

.balance {
  font-weight: 800;
}

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

.muted-status {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  background: #eef2f6;
  color: var(--muted);
  font-weight: 800;
}

.muted-status.dmv-needed {
  background: #fee4e2;
  color: var(--danger);
}

.completion-date {
  font-weight: 800;
  border-radius: 8px;
}

.completion-date.safe {
  color: #067647;
  background: #dcfae6;
}

.completion-date.warning {
  color: #8a5a00;
  background: #fff4d6;
}

.completion-date.danger {
  color: #fff;
  background: var(--danger);
}

.progress-cell {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) 42px;
  gap: 8px;
  align-items: center;
}

.progress-track {
  height: 9px;
  border-radius: 999px;
  background: #e4eaf0;
  overflow: hidden;
}

.progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 34px;
}

.tools-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.tools-tabs,
.tool-panel {
  background: var(--panel);
  border: 1px solid rgba(216, 222, 232, 0.85);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.tools-tabs {
  padding: 10px;
  display: grid;
  gap: 8px;
}

.tool-tab {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
  text-align: left;
  padding: 0 12px;
  cursor: pointer;
}

.tool-tab.active,
.tool-tab:hover {
  background: #eff6ff;
  color: var(--accent-strong);
}

.tool-panel {
  overflow: hidden;
}

.upload-zone {
  margin: 18px;
  min-height: 150px;
  border: 2px dashed #bfd2dc;
  border-radius: 8px;
  display: grid;
  place-items: center;
  gap: 6px;
  text-align: center;
  background: #f8fbfc;
  cursor: pointer;
}

.upload-zone:hover {
  border-color: var(--accent);
  background: #f8fbff;
}

.upload-zone strong {
  color: var(--accent-strong);
  font-size: 1.15rem;
}

.upload-zone small {
  color: var(--muted);
}

.upload-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.resource-grid {
  padding: 0 18px 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.resource-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.resource-preview {
  width: 100%;
  height: 180px;
  display: block;
  border: 0;
  background: #eef2f6;
  object-fit: cover;
}

.resource-body {
  padding: 14px;
  display: grid;
  gap: 8px;
}

.resource-body h3 {
  margin: 0;
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.resource-body p {
  color: var(--muted);
  font-size: 0.88rem;
}

.resource-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.resource-link {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.payments-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.payment-form {
  display: grid;
  gap: 14px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid rgba(215, 221, 230, 0.95);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.payment-form h2 {
  font-size: 1.12rem;
}

.payment-history {
  min-width: 0;
}

.payments-table {
  min-width: 720px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.settings-card {
  display: grid;
  gap: 8px;
  background: var(--panel);
  border: 1px solid rgba(215, 221, 230, 0.95);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

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

.settings-card span {
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.settings-card p {
  color: var(--muted);
  line-height: 1.5;
}

.workflow-settings {
  display: grid;
  gap: 16px;
  margin-top: 8px;
}

.workflow-section {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fafc;
}

.workflow-section h3 {
  margin: 0;
  font-size: 1rem;
}

.settings-placeholder {
  min-height: 48px;
  display: flex;
  align-items: center;
  border-radius: 8px;
  padding: 0 12px;
  background: #eef2f6;
  color: var(--muted);
  font-weight: 700;
}

.settings-form {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.settings-form label {
  grid-template-columns: minmax(0, 1fr) 92px;
  align-items: center;
  gap: 12px;
}

.settings-form input {
  text-align: right;
}

.settings-form small {
  color: var(--muted);
  font-weight: 800;
}

.settings-form-scroll {
  max-height: 520px;
  overflow: auto;
  padding-right: 6px;
}

.settings-form-scroll #preTripWeightsList {
  display: grid;
  gap: 10px;
}

.student-dialog {
  width: min(720px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 26px 80px rgba(18, 35, 50, 0.28);
}

.student-dialog::backdrop {
  background: rgba(18, 35, 50, 0.52);
}

.student-dialog form {
  display: grid;
  gap: 20px;
  padding: 24px;
}

.dialog-header,
.dialog-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.dialog-actions {
  justify-content: flex-end;
}

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

.checklist-dialog {
  width: min(760px, calc(100vw - 32px));
}

.checklist-summary {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfc;
}

.checklist-summary strong {
  color: var(--accent-strong);
}

.checklist-items {
  display: grid;
  gap: 10px;
  max-height: 48vh;
  overflow: auto;
  padding-right: 2px;
}

.checklist-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 40px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.checklist-done {
  width: 20px;
  min-height: 20px;
  accent-color: var(--accent);
}

.checklist-text {
  min-height: 38px;
}

@media (max-width: 980px) {
  .login-screen {
    padding: 28px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    padding: 18px;
  }

  .nav-list {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .nav-list a {
    justify-content: center;
  }

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

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

  .search-field {
    grid-column: 1 / -1;
  }

  .tools-layout {
    grid-template-columns: 1fr;
  }

  .payments-layout {
    grid-template-columns: 1fr;
  }

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

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

  .tool-tab {
    text-align: center;
  }
}

@media (max-width: 640px) {
  .login-screen {
    padding: 24px 18px;
    overflow: auto;
  }

  .login-card {
    padding: 22px;
  }

  .dashboard {
    padding: 20px;
  }

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

  .primary-button {
    width: 100%;
  }

  .metrics,
  .toolbar,
  .nav-list {
    grid-template-columns: 1fr;
  }

  .nav-list a {
    justify-content: flex-start;
  }

  .brand {
    grid-template-columns: 86px 1fr;
  }

  .brand-logo {
    width: 86px;
    height: 58px;
  }

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

  .tools-tabs,
  .resource-grid {
    grid-template-columns: 1fr;
  }
}
