:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --panel: #ffffff;
  --text: #162033;
  --muted: #667085;
  --line: #d9dee8;
  --brand: #0f766e;
  --brand-2: #b42318;
  --focus: #2563eb;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}
a { color: var(--brand); text-decoration: none; }
button, input, textarea, select {
  font: inherit;
}
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}
.sidebar {
  background: #17202f;
  color: #fff;
  padding: 18px;
}
.brand {
  font-weight: 700;
  font-size: 18px;
  margin: 4px 0 18px;
}
.nav a, .nav button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin: 4px 0;
  border: 0;
  border-radius: 6px;
  color: #e8edf7;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.nav a.active, .nav a:hover, .nav button:hover {
  background: rgba(255,255,255,.12);
}
.main {
  padding: 24px;
  max-width: 1280px;
  width: 100%;
}
.topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
h1 { font-size: 28px; margin: 0; }
h2 { font-size: 20px; margin: 0 0 12px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
}
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.stat strong { display: block; font-size: 30px; }
label { display: block; font-weight: 700; margin: 10px 0 6px; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
}
textarea { min-height: 180px; resize: vertical; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }
.row.compact > * { flex: 0 1 auto; }
.checkline { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.checkline input { width: auto; }
.btn {
  width: auto;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  border-radius: 6px;
  padding: 10px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn.secondary { background: #fff; color: var(--brand); }
.btn.danger { background: var(--brand-2); border-color: var(--brand-2); }
.btn.small { padding: 6px 9px; font-size: 14px; }
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}
th, td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  vertical-align: top;
  text-align: left;
}
th { color: var(--muted); font-size: 13px; }
.message {
  min-height: 24px;
  color: var(--brand-2);
  white-space: pre-wrap;
}
.ok { color: var(--brand); }
.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 36px));
}
.toast {
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff7f7;
  color: var(--brand-2);
  padding: 12px 14px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .18);
}
.toast.ok {
  border-color: #99f6e4;
  background: #f0fdfa;
  color: var(--brand);
}
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-box {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}
.preview {
  max-height: 520px;
  overflow: auto;
  background: #fff;
}
.question-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin: 10px 0;
}
.asset-thumb {
  max-width: 120px;
  max-height: 80px;
  object-fit: contain;
}
.passage {
  border: 1px solid var(--line);
  background: #f7fafc;
  border-radius: 8px;
  padding: 12px;
  margin: 10px 0;
}
.low-confidence {
  border-color: #d97706;
  background: #fffaf0;
}
.template-card, .import-summary {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}
.template-card strong, .import-summary strong {
  display: block;
  font-size: 18px;
}
.template-card span, .import-summary span {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}
.import-summary {
  background: #f8fbff;
  margin-bottom: 12px;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(15, 23, 42, .45);
  display: grid;
  place-items: center;
  padding: 18px;
}
.modal {
  width: min(920px, 100%);
  max-height: min(86vh, 860px);
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .22);
}
.modal textarea {
  min-height: 110px;
}
.modal-actions {
  margin-top: 14px;
}
.hidden { display: none !important; }
@media (max-width: 850px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .main { padding: 16px; }
  .grid, .grid.two { grid-template-columns: 1fr; }
  .topline { align-items: flex-start; flex-direction: column; }
  .template-card, .import-summary { align-items: stretch; flex-direction: column; }
}
