:root {
  color-scheme: light;
  --ink: #14231f;
  --muted: #68766f;
  --line: #dfe7e3;
  --line-strong: #cbd8d2;
  --surface: #ffffff;
  --surface-soft: #f7faf8;
  --bg: #eef4f0;
  --brand: #173f35;
  --brand-2: #285d4c;
  --brand-soft: #e6f0eb;
  --blue: #244c78;
  --blue-soft: #e8f0f8;
  --gold: #b98b25;
  --gold-soft: #f7efd9;
  --danger: #b42318;
  --danger-soft: #fcebe9;
  --ok: #1f7a45;
  --ok-soft: #e7f4ec;
  --shadow: 0 18px 45px rgba(20, 35, 31, .08);
  --radius: 8px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, system-ui, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(23, 63, 53, .05), transparent 260px),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 14px;
  min-height: 42px;
  font-weight: 700;
  cursor: pointer;
  background: var(--brand);
  color: white;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

button:hover:not(:disabled) {
  background: var(--brand-2);
  box-shadow: 0 8px 18px rgba(23, 63, 53, .16);
  transform: translateY(-1px);
}

button:disabled {
  cursor: default;
  opacity: .55;
}

button.secondary {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: #c7dad0;
}

button.secondary:hover:not(:disabled),
button.ghost:hover:not(:disabled) {
  background: #dcebe4;
}

button.ghost {
  background: white;
  color: var(--brand);
  border-color: var(--line);
}

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

input,
select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  background: white;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(40, 93, 76, .14);
}

label {
  display: block;
  margin: 14px 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 4vw, 42px);
  letter-spacing: 0;
  line-height: 1.16;
}

h2 {
  font-size: 18px;
  letter-spacing: 0;
}

p {
  color: var(--muted);
  line-height: 1.65;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  background: #f9fbfa;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand-block {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.brand-block img {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.brand-block strong {
  display: block;
  font-size: 17px;
  line-height: 1.2;
}

.brand-block span,
.side-foot span,
.topbar-title span,
.eyebrow,
.panel-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.nav button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  background: transparent;
  color: var(--ink);
  border-color: transparent;
  box-shadow: none;
}

.nav button.active,
.nav button:hover {
  background: var(--brand-soft);
  color: var(--brand);
  transform: none;
  box-shadow: none;
}

.side-foot {
  margin-top: auto;
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

.main {
  min-width: 0;
}

.topbar {
  min-height: 72px;
  padding: 14px 28px;
  background: rgba(255, 255, 255, .88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-title {
  display: grid;
  gap: 2px;
}

.topbar-title strong {
  font-size: 16px;
}

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

.actions {
  margin-top: 16px;
}

.actions.compact {
  margin-top: 10px;
}

.layout {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.page-title {
  margin-bottom: 22px;
}

.page-title h1 {
  margin: 4px 0 8px;
}

.eyebrow {
  color: var(--brand-2);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  min-height: 96px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  display: grid;
  align-content: space-between;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stat strong {
  font-size: 30px;
  color: var(--brand);
}

.stat.blue strong { color: var(--blue); }
.stat.gold strong { color: var(--gold); }
.stat.green strong { color: var(--ok); }

.portal-grid,
.workspace-grid,
.scanner-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.portal-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.portal-card {
  min-height: 260px;
  padding: 24px;
  display: grid;
  align-content: space-between;
  gap: 16px;
}

.portal-card h2 {
  font-size: 24px;
}

.card-icon {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 900;
  color: var(--brand);
  background: var(--brand-soft);
}

.portal-card.student .card-icon {
  color: var(--blue);
  background: var(--blue-soft);
}

.panel {
  padding: 18px;
  margin-bottom: 18px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-meta {
  white-space: nowrap;
}

.narrow {
  max-width: 560px;
}

.form,
.inline-form {
  display: block;
}

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

.form-row.four {
  grid-template-columns: 1fr 1.5fr .8fr 1fr;
}

.notice {
  padding: 12px 14px;
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--blue);
  border: 1px solid #cfe0ef;
  margin: 12px 0;
  line-height: 1.55;
}

.notice.error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #f4c8c3;
}

.notice.ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: #c2e4ce;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #edf1ef;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.badge.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.session-summary,
.student-profile {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.session-summary.vertical {
  grid-template-columns: 1fr;
}

.session-summary div,
.student-profile div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  display: grid;
  gap: 4px;
}

.session-summary span,
.student-profile span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  background: var(--surface-soft);
}

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

.qr {
  display: grid;
  place-items: center;
  gap: 12px;
  padding: 22px;
  margin-top: 12px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.qr img {
  width: min(280px, 100%);
  height: auto;
}

.scanner {
  width: min(560px, 100%);
  aspect-ratio: 1;
  background: #0a0f0d;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow);
}

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-frame {
  position: absolute;
  inset: 16%;
  border: 3px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: 0 0 0 999px rgba(0, 0, 0, .28);
  pointer-events: none;
}

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

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

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }

  .brand-block {
    border-bottom: 0;
    padding-bottom: 0;
  }

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

  .side-foot {
    display: none;
  }

  .portal-grid,
  .workspace-grid,
  .scanner-layout,
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .layout {
    padding: 18px 14px;
  }

  .topbar {
    position: static;
    padding: 12px 14px;
    align-items: flex-start;
    flex-direction: column;
  }

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

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

  .form-row,
  .form-row.four,
  .session-summary,
  .student-profile {
    grid-template-columns: 1fr;
  }

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