:root {
  color-scheme: dark;
  --bg: #06111f;
  --bg-2: #09182a;
  --panel: rgba(13, 28, 48, 0.78);
  --panel-strong: rgba(9, 20, 35, 0.92);
  --panel-soft: rgba(255, 255, 255, 0.045);
  --ink: #f6f9fc;
  --muted: #9aa9bb;
  --subtle: #64748b;
  --line: rgba(177, 199, 226, 0.14);
  --line-strong: rgba(177, 199, 226, 0.22);
  --primary: #3b82f6;
  --primary-strong: #2563eb;
  --accent: #35d0ba;
  --accent-strong: #14b8a6;
  --success: #35d07f;
  --warning: #f4b740;
  --danger: #f87171;
  --shadow: 0 22px 56px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, #071426 0%, #0a1a2c 46%, #06111f 100%);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

.loading-screen {
  min-height: 100vh;
  display: grid;
  place-content: center;
  gap: 10px;
  text-align: center;
  color: var(--ink);
  background: var(--bg);
}

.loading-screen strong { font-size: 26px; }
.loading-screen span { color: var(--muted); }
.loading-screen.error strong { color: var(--danger); }

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

::selection {
  background: rgba(53, 208, 186, 0.28);
  color: #ffffff;
}

* {
  scrollbar-color: rgba(59, 130, 246, 0.34) rgba(6, 17, 31, 0.5);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(6, 17, 31, 0.5);
}

::-webkit-scrollbar-thumb {
  background: rgba(59, 130, 246, 0.34);
  border: 2px solid rgba(6, 17, 31, 0.55);
  border-radius: 999px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 440px) 1fr;
  background: #081625;
}

.login-hero {
  position: relative;
  padding: 56px 48px;
  color: white;
  display: flex;
  justify-content: center;
  border-right: 1px solid var(--line);
  background: #071321;
}

.login-brand-block { max-width: 340px; }

.login-brand-preview { margin-bottom: 24px; }
.login-company-name { color: #d8e2ee; font-size: 14px; font-weight: 700; }

.login-hero h1 {
  margin: 0 0 16px;
  font-size: 30px;
  line-height: 1.25;
  letter-spacing: 0;
}

.login-hero p {
  margin: 0;
  color: #aab9cb;
  line-height: 1.7;
}

.login-main {
  display: grid;
  place-items: center;
  padding: 40px;
  background: #0a192a;
}

.login-box {
  width: min(420px, 100%);
  background: #0d2034;
  border: 1px solid rgba(177, 199, 226, 0.16);
  border-radius: 8px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.26);
  padding: 36px;
}

.login-box h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

.login-subtitle {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 14px;
}

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

.field {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}

.field span {
  color: #c8d3df;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(3, 10, 18, 0.54);
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

select option {
  background: #0b1728;
  color: var(--ink);
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(53, 208, 186, 0.78);
  box-shadow: 0 0 0 4px rgba(53, 208, 186, 0.1);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border-radius: 8px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.075);
  color: #dbe7f3;
  font-size: 14px;
  font-weight: 750;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.btn:hover {
  border-color: rgba(53, 208, 186, 0.34);
  background: rgba(53, 208, 186, 0.09);
  color: white;
}

.btn.primary {
  border-color: transparent;
  background: var(--primary-strong);
  color: white;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.22);
}

.btn.primary:hover {
  transform: translateY(-1px);
  background: #1d4ed8;
}

.btn.danger {
  border-color: rgba(248, 113, 113, 0.22);
  background: rgba(248, 113, 113, 0.1);
  color: #fecaca;
}

.btn.ghost {
  background: transparent;
  color: #93c5fd;
}

.btn.full {
  width: 100%;
  margin-top: 20px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  color: white;
  padding: 20px 14px;
  border-right: 1px solid var(--line);
  background: rgba(4, 14, 26, 0.82);
  box-shadow: 18px 0 44px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(18px);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 4px 6px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 17px;
  font-weight: 850;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.95), rgba(53, 208, 186, 0.95));
  box-shadow: 0 12px 30px rgba(59, 130, 246, 0.24);
}

.brand-logo {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  overflow: hidden;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

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

.nav button {
  width: 100%;
  display: flex;
  align-items: center;
  min-height: 42px;
  background: transparent;
  color: #aebbd0;
  text-align: left;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 700;
}

.nav button.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.95), rgba(53, 208, 186, 0.92));
  color: white;
  box-shadow: 0 14px 34px rgba(59, 130, 246, 0.18);
}

.nav button:hover:not(.active) {
  background: rgba(255, 255, 255, 0.07);
  color: white;
}

.main {
  position: relative;
  min-width: 0;
  padding: 24px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: -24px -24px 22px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(6, 17, 31, 0.82);
  backdrop-filter: blur(18px);
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

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

.grid > * {
  min-width: 0;
}

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

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

.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
  backdrop-filter: blur(16px);
}

.panel h2,
.panel h3 {
  margin: 0 0 14px;
}

.stat {
  min-height: 112px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.035)),
    var(--panel);
}

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

.stat strong {
  display: block;
  margin-top: 10px;
  font-size: 34px;
  line-height: 1;
}

.toolbar {
  min-width: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.actions {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.compact-field {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.compact-field input {
  width: 82px;
  min-height: 34px;
  padding: 6px 8px;
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.status-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

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

.section-subtitle {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.3;
}

.insight-list {
  display: grid;
  gap: 10px;
}

.mini-stat {
  min-height: 104px;
  display: grid;
  align-content: space-between;
  gap: 8px;
}

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

.mini-stat strong {
  font-size: 30px;
  line-height: 1;
}

.mini-stat i {
  justify-self: start;
  font-style: normal;
}

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

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.035);
}

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

th {
  color: #cbd7e4;
  background: rgba(255, 255, 255, 0.055);
  font-weight: 800;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.075);
  color: #d6e1ed;
  font-size: 12px;
  font-weight: 800;
}

.badge.green {
  background: rgba(53, 208, 127, 0.12);
  color: #b7f7d3;
  border-color: rgba(53, 208, 127, 0.22);
}

.badge.red {
  background: rgba(248, 113, 113, 0.12);
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.22);
}

.badge.orange {
  background: rgba(244, 183, 64, 0.12);
  color: #fde68a;
  border-color: rgba(244, 183, 64, 0.22);
}

.badge.blue {
  background: rgba(59, 130, 246, 0.13);
  color: #bfdbfe;
  border-color: rgba(59, 130, 246, 0.22);
}

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

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

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

.help-list {
  margin: 0;
  padding-left: 22px;
  color: #d6e1ed;
  line-height: 1.8;
}

.code-block,
.help-pre {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(3, 10, 18, 0.54);
  color: #dbeafe;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.code-block {
  padding: 12px;
  margin-bottom: 12px;
}

.help-pre {
  display: block;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 14px;
  line-height: 1.7;
  white-space: pre;
}

.example-stack {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.example-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.045);
}

.example-card strong {
  display: block;
  margin-bottom: 8px;
  color: #f6f9fc;
}

.example-card p {
  margin: 6px 0 0;
  color: #c8d3df;
  line-height: 1.55;
}

.example-card code {
  color: #bfdbfe;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.check-grid span {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  color: #dbeafe;
  font-size: 13px;
}

.option-row {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.question-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.045);
}

.question-card + .question-card {
  margin-top: 14px;
}

.question-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  font-weight: 800;
}

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

.answer-option {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(3, 10, 18, 0.38);
}

.answer-option input {
  width: auto;
  margin: 4px 0 0;
}

.category-list,
.question-picker {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.category-list {
  display: flex;
  flex-wrap: wrap;
}

.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-weight: 700;
}

.category-chip button {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  cursor: pointer;
}

.question-picker-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 10px;
  margin-top: 8px;
}

.question-picker {
  max-height: 440px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(3, 10, 18, 0.26);
}

.question-pick-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.question-pick-row:hover {
  border-color: rgba(177, 199, 226, 0.24);
  background: rgba(255, 255, 255, 0.04);
}

.question-pick-row input {
  width: auto;
  margin-top: 3px;
}

.question-pick-row strong,
.question-pick-row small {
  display: block;
}

.question-pick-row small {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}

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

.sticky {
  position: sticky;
  top: 92px;
}

.timer {
  font-size: 30px;
  font-weight: 900;
  color: #7dd3fc;
}

.progress-dots {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.dot {
  display: grid;
  place-items: center;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.075);
  color: #cbd7e4;
  font-weight: 800;
}

.dot:hover,
.dot:focus-visible {
  border-color: rgba(125, 211, 252, 0.48);
  outline: 0;
}

.dot.done {
  background: rgba(53, 208, 127, 0.14);
  color: #b7f7d3;
}

.empty {
  border: 1px dashed rgba(177, 199, 226, 0.28);
  border-radius: 8px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.035);
}

.notice {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(53, 208, 186, 0.18);
  border-radius: 8px;
  background: rgba(53, 208, 186, 0.08);
  color: #b8fff3;
  line-height: 1.6;
}

.tenant-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.tenant-hero h2 {
  margin: 14px 0 8px;
}

.tenant-hero p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.milestone-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.tenant-brand-line,
.login-brand-preview {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tenant-brand-line strong {
  display: block;
  color: var(--ink);
}

.tenant-brand-line span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.preview-shell {
  display: grid;
  grid-template-columns: 190px 1fr;
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(3, 10, 18, 0.4);
}

.preview-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--preview-brand) 20%, rgba(4, 14, 26, 0.92));
}

.preview-main {
  padding: 22px;
}

.preview-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.preview-main h3 {
  margin: 20px 0 10px;
  font-size: 24px;
}

.preview-main p {
  color: var(--muted);
  line-height: 1.7;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid rgba(53, 208, 186, 0.28);
  border-radius: 8px;
  background: rgba(6, 17, 31, 0.94);
  color: #dffdf8;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.48);
}

.modal {
  width: min(520px, 100%);
  max-height: min(720px, calc(100vh - 36px));
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
}

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

.modal-header h2 {
  margin: 0;
}

.modal-description {
  margin: 10px 0 0;
}

.modal-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 4px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.icon-btn:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
}

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

.print-only {
  display: none;
}

@media (max-width: 960px) {
  .login-shell,
  .app-shell,
  .exam-layout,
  .grid.cols-2,
  .grid.cols-3,
  .form-grid,
  .filter-bar,
  .status-board {
    grid-template-columns: 1fr;
  }

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

  .main {
    padding: 16px;
  }

  .topbar {
    margin: -16px -16px 18px;
    padding: 16px;
    align-items: flex-start;
    flex-direction: column;
  }

  .user-pill,
  .toolbar,
  .tenant-hero,
  .preview-top,
  .question-title {
    align-items: stretch;
    flex-direction: column;
  }

  .user-pill {
    width: 100%;
    flex-wrap: wrap;
  }

  .toolbar > *,
  .tenant-hero > *,
  .actions,
  .actions .btn,
  .actions input,
  .actions select {
    min-width: 0;
    max-width: 100%;
  }

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

  .nav button {
    justify-content: flex-start;
  }

  .question-picker-toolbar,
  .preview-shell,
  .check-grid {
    grid-template-columns: 1fr;
  }

  .sticky {
    position: static;
  }

  .exam-submit-bar {
    position: sticky;
    bottom: 0;
    z-index: 10;
    margin: 16px -14px -14px;
    padding: 12px 14px;
    background: rgba(9, 20, 35, 0.96);
    border-top: 1px solid var(--line);
  }

  .preview-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .login-hero {
    padding: 32px;
  }
}

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

  .login-box {
    padding: 22px;
  }

  .login-hero {
    padding: 24px 18px;
  }

  .login-hero h1 {
    font-size: 24px;
  }

  .brand {
    align-items: flex-start;
  }

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

  .nav button {
    min-height: 40px;
    padding: 9px 10px;
    font-size: 13px;
  }

  .main {
    padding: 12px;
  }

  .topbar {
    margin: -12px -12px 16px;
    padding: 14px 12px;
  }

  .topbar h1 {
    font-size: 20px;
  }

  .panel,
  .question-card {
    padding: 14px;
  }

  .stat strong,
  .mini-stat strong {
    font-size: 28px;
  }

  .toast {
    right: 12px;
    bottom: 12px;
    max-width: calc(100vw - 24px);
  }
}

@media print {
  .sidebar,
  .topbar,
  .toolbar,
  .btn,
  .no-print {
    display: none !important;
  }

  body {
    background: white;
    color: #111827;
  }

  .app-shell {
    display: block;
  }

  .main {
    padding: 0;
  }

  .panel {
    box-shadow: none;
    border: 0;
    background: white;
    color: #111827;
  }

  .print-only {
    display: block;
  }
}
