:root {
  color-scheme: light;
  font-family: "Instrument Sans", "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --ink: #16332b;
  --muted: #58685e;
  --line: #dce3db;
  --canvas: #f4f6f0;
  --surface: #fff;
  --forest: #103b31;
  --accent: #1d5945;
  --accent-hover: #174735;
  --mint: #e4efe3;
  --mint-light: #f1f7ee;
  --orange: #8f460f;
  --amber: #fff4e4;
  --danger: #983b37;
  --radius: 18px;
  --shadow: 0 12px 35px #1d3b2720;
}
* { box-sizing: border-box; }
html { min-width: 280px; }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); text-decoration-thickness: .08em; text-underline-offset: .15em; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 3px solid #ba752c; outline-offset: 3px; }
[hidden] { display: none !important; }
.app-shell { display: grid; grid-template-columns: 225px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--forest); color: #ecf4ea; display: flex; flex-direction: column; gap: 38px;
  padding: 30px 19px; min-height: 100vh; position: sticky; top: 0; align-self: start;
}
.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 10px; padding: 0 2px; }
.brand img { border-radius: 12px; background: #1b5042; border: 1px solid #367661; }
.brand strong { font-size: 19px; display: block; letter-spacing: -.035em; white-space: nowrap; }
.brand small { color: #b6cfc1; font-size: 11px; }
.nav { display: grid; gap: 8px; }
.nav-link { display: flex; gap: 12px; align-items: center; border-radius: 11px; min-height: 44px; padding: 10px 12px; text-decoration: none; color: #d9e7de; font-weight: 650; }
.nav-link:hover, .nav-link[aria-current] { background: #285448; color: white; }
.nav-icon { width: 15px; height: 15px; position: relative; display: inline-block; flex: 0 0 auto; color: #bcddc6; }
.icon-grid { border: 1px solid currentColor; border-radius: 3px; background: linear-gradient(90deg,transparent 45%, currentColor 45% 54%, transparent 54%), linear-gradient(transparent 45%, currentColor 45% 54%, transparent 54%); }
.icon-history { border: 1px solid currentColor; border-radius: 50%; }
.icon-history::before { content: ""; position: absolute; width: 4px; height: 5px; top: 2px; left: 6px; border-left: 1px solid currentColor; border-bottom: 1px solid currentColor; }
.icon-lock { border: 1px solid currentColor; border-radius: 3px; height: 11px; margin-top: 4px; }
.icon-lock::before { content: ""; position: absolute; width: 7px; height: 7px; border: 1px solid currentColor; border-bottom: 0; border-radius: 5px 5px 0 0; left: 3px; bottom: 9px; }
.sidebar-foot { margin-top: auto; padding: 16px 3px 0; border-top: 1px solid #467164; display: grid; gap: 6px; }
.sidebar-foot strong { font-size: 13px; }
.sidebar-foot span { font-size: 11px; color: #bdcfc2; }
.workspace { min-width: 0; }
.topbar { min-height: 65px; padding: 10px clamp(18px, 3vw, 42px); display: flex; gap: 14px; align-items: center; justify-content: space-between; background: #ffffffa6; border-bottom: 1px solid var(--line); }
.breadcrumbs { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; }
.breadcrumbs > a, .breadcrumbs > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breadcrumbs > a { color: var(--muted); text-decoration: none; }
.breadcrumbs > a:hover { text-decoration: underline; }
.status-chip { display: inline-flex; align-items: center; gap: 7px; flex-shrink: 0; background: var(--mint-light); color: var(--accent); border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; font-size: 11px; font-weight: 700; }
.status-chip i { width: 7px; height: 7px; border-radius: 50%; background: #54885b; }
.status-chip[data-offline="true"] i { background: #ae7325; }
main { max-width: 1390px; margin: 0 auto; padding: 37px clamp(18px, 3vw, 42px) 55px; min-width: 0; }
.initial { padding: 50px 5px; color: var(--muted); }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin: 0 0 23px; }
h1, h2, h3, p { margin: 0; }
h1 { font-weight: 740; letter-spacing: -.055em; line-height: 1.04; font-size: clamp(36px, 5vw, 56px); overflow-wrap: anywhere; }
h2 { font-size: 21px; letter-spacing: -.028em; line-height: 1.2; }
h3 { font-size: 16px; line-height: 1.3; }
.page-head p { margin-top: 10px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.section-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 21px 0 13px; }
.section-top:first-child { margin-top: 0; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn { border: 1px solid transparent; min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 10px; padding: 8px 14px; font-weight: 690; font-size: 13px; text-align: center; text-decoration: none; line-height: 1.3; white-space: normal; }
.btn.primary { background: var(--accent); color: white; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.secondary { background: white; border-color: #cfdacf; color: var(--ink); }
.btn.secondary:hover:not(:disabled) { background: var(--mint-light); }
.btn.danger { background: #fff; border-color: #eccac5; color: var(--danger); }
.btn.danger:hover { background: #fff3f0; }
.btn.subtle { background: transparent; color: var(--accent); border-color: transparent; }
.btn.subtle:hover { background: var(--mint); }
.plus { font-size: 20px; font-weight: 450; line-height: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(15px, 2vw, 24px); min-width: 0; }
.panel + .panel { margin-top: 14px; }
.empty { min-height: 230px; display: grid; place-items: center; text-align: center; border-style: dashed; background: #fbfcf8; }
.empty-inner { display: grid; justify-items: center; gap: 11px; max-width: 420px; padding: 16px; }
.empty-icon { width: 44px; height: 44px; background: var(--mint); border-radius: 13px; color: var(--accent); font-size: 27px; display: grid; place-items: center; }
.empty p, .muted { color: var(--muted); line-height: 1.55; }
.empty p { font-size: 13px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 12px; }
.tile { display: grid; gap: 8px; min-width: 0; padding: 18px; background: white; border: 1px solid var(--line); border-radius: 15px; color: inherit; text-decoration: none; transition: background .15s; }
.tile:hover { background: #fafff8; border-color: #8fb19a; }
.tile strong { font-size: 16px; letter-spacing: -.015em; overflow-wrap: anywhere; }
.tile span:not(.pill) { color: var(--muted); font-size: 13px; line-height: 1.4; }
.pill { display: inline-flex; width: fit-content; max-width: 100%; gap: 4px; background: var(--mint); color: var(--accent); border-radius: 20px; padding: 4px 8px; font-size: 11px; font-weight: 750; white-space: nowrap; }
.pill.warn { background: var(--amber); color: var(--orange); }
.pill.neutral { background: #eff2ed; color: #4b6155; }
.tabs { display: flex; flex-wrap: wrap; gap: 5px; border-bottom: 1px solid var(--line); margin-bottom: 17px; }
.tab { padding: 11px 14px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 13px; font-weight: 710; }
.tab[aria-current="page"] { border-bottom-color: var(--accent); color: var(--accent); }
.tab:hover { color: var(--accent); }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(145px, 100%), 1fr)); gap: 10px; margin-bottom: 17px; }
.metric { padding: 14px; background: var(--mint-light); border: 1px solid var(--line); border-radius: 13px; }
.metric strong { font-size: 25px; font-weight: 720; letter-spacing: -.045em; display: block; }
.metric small { font-size: 12px; color: var(--muted); }
.list { display: grid; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: white; }
.list-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; color: inherit; text-decoration: none; padding: 13px 15px; min-height: 55px; }
.list-row + .list-row { border-top: 1px solid var(--line); }
a.list-row:hover { background: var(--mint-light); }
.list-row strong { display: block; font-size: 14px; overflow-wrap: anywhere; }
.list-row small { color: var(--muted); font-size: 12px; }
.list-row .actions { justify-content: flex-end; }
.form { display: grid; gap: 14px; }
.fields { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0,1fr)); }
.field { display: grid; gap: 6px; min-width: 0; align-content: start; color: var(--ink); font-size: 13px; font-weight: 690; }
.field small { color: var(--muted); font-size: 12px; line-height: 1.5; font-weight: 450; }
.field.wide { grid-column: 1 / -1; }
.field input:not([type=checkbox]), .field select, .field textarea, .select, .search { width: 100%; min-height: 42px; padding: 9px 10px; border: 1px solid #cbd7cc; border-radius: 9px; color: var(--ink); background: #fff; font-size: 16px; }
.field textarea { min-height: 100px; resize: vertical; }
.field input[type=file] { font-size: 13px; }
.check { display: flex; align-items: start; gap: 8px; font-size: 14px; line-height: 1.4; }
.check input { width: 17px; height: 17px; margin: 2px 0 0; flex-shrink: 0; accent-color: var(--accent); }
.notice { font-size: 13px; line-height: 1.5; padding: 11px 13px; background: var(--mint-light); border: 1px solid var(--line); border-radius: 10px; color: var(--muted); }
.notice.warn { background: var(--amber); border-color: #f0dabc; color: #79461c; }
.notice.error { background: #fdf0ed; border-color: #efcfca; color: var(--danger); }
.notice ul { margin: 0; padding-left: 18px; }
.search { max-width: 325px; }
.details { margin-top: 8px; }
.details summary { cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 700; }
.subject-history-exam > summary { cursor: pointer; color: var(--accent); }
.subject-history-summary { display: inline-grid; gap: 3px; width: calc(100% - 22px); vertical-align: top; overflow-wrap: anywhere; }
.subject-history-summary strong { font-size: 15px; }
.subject-history-summary small { font-size: 12px; color: var(--muted); }
.subject-history-model > summary { padding: 8px 0; }
.raw-text { max-height: 190px; overflow: auto; white-space: pre-wrap; font-size: 12px; line-height: 1.45; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; background: white; text-align: left; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: top; }
th { background: var(--mint-light); font-weight: 750; }
td { min-width: 80px; }
tr:last-child td { border-bottom: 0; }
.key-table td, .key-table th { padding: 6px 8px; vertical-align: middle; }
.key-table select, .key-table input { min-height: 36px; font-size: 14px; padding: 4px 6px; }
.key-table td:first-child { min-width: 42px; }
.key-table .weight { width: 86px; }
.two-column { display: grid; grid-template-columns: minmax(0, 3fr) minmax(230px, 2fr); gap: 14px; align-items: start; }
.two-column .panel + .panel { margin-top: 0; }
.photo-frame { background: #e9ede6; border-radius: 12px; display: grid; place-items: center; overflow: hidden; min-height: 76px; }
.photo-frame img { display: block; max-width: 100%; max-height: 315px; object-fit: contain; }
.photo-button { border: 0; width: 100%; padding: 0; }
.photo-frame.large img { max-height: none; }
.questions { display: grid; grid-template-columns: repeat(auto-fill, minmax(125px,1fr)); gap: 8px; }
.q-button { text-align: left; border: 1px solid var(--line); border-radius: 10px; background: white; padding: 10px 11px; color: var(--ink); min-height: 58px; }
.q-button span { display: block; font-size: 11px; color: var(--muted); }
.q-button strong { display: block; margin-top: 4px; font-size: 14px; }
.q-button.warn { background: var(--amber); border-color: #efdbc2; }
.q-button:hover { border-color: #8ba897; }
.choice-set { display: flex; flex-wrap: wrap; gap: 6px; }
.choice-set button[aria-pressed="true"] { background: var(--accent); color: white; }
.report-frame { border: 1px solid var(--line); border-radius: 10px; width: 100%; min-height: 380px; }
dialog { border: 1px solid var(--line); color: var(--ink); background: white; border-radius: 18px; width: min(640px, calc(100% - 24px)); padding: 0; max-height: min(90dvh, 900px); box-shadow: var(--shadow); }
dialog::backdrop { background: #15312885; }
.dialog-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 18px 20px 13px; border-bottom: 1px solid var(--line); }
.dialog-head button { width: 38px; padding: 0; font-size: 19px; }
.dialog-body { padding: 16px 20px 20px; }
.dialog-body .actions { margin-top: 7px; }
.dialog-body > * + * { margin-top: 12px; }
.toast { position: fixed; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); z-index: 10; border-radius: 12px; background: var(--forest); color: white; padding: 13px 17px; max-width: min(380px, calc(100% - 28px)); box-shadow: var(--shadow); font-size: 14px; }
@media (max-width: 820px) {
  .app-shell { grid-template-columns: 173px minmax(0,1fr); }
  .sidebar { padding: 24px 12px; }
  .brand strong { font-size: 16px; }
  .brand img { width: 35px; height: 35px; }
  .two-column { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .app-shell { display: block; }
  .sidebar { padding: max(10px,env(safe-area-inset-top)) 13px 10px; min-height: auto; z-index: 2; flex-direction: row; justify-content: space-between; align-items: center; gap: 8px; }
  .sidebar-foot, .brand small { display: none; }
  .brand { gap: 6px; }
  .brand strong { font-size: 15px; }
  .nav { display: flex; gap: 3px; }
  .nav-link { gap: 5px; min-height: 39px; padding: 7px 8px; font-size: 12px; }
  .nav-icon { display: none; }
  .topbar { padding: 8px 13px; min-height: 47px; }
  .status-chip { padding: 4px 7px; font-size: 10px; }
  main { padding: 24px 13px max(32px,env(safe-area-inset-bottom)); }
  .page-head { align-items: start; flex-direction: column; gap: 11px; margin-bottom: 17px; }
  .section-top { flex-wrap: wrap; }
  h1 { font-size: clamp(33px, 9vw, 48px); }
  .tabs { flex-wrap: nowrap; overflow-x: auto; }
  .tab { white-space: nowrap; padding: 10px; }
  .metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .dialog-head, .dialog-body { padding-left: 13px; padding-right: 13px; }
  .list-row { padding: 11px; }
}
@media (max-width: 360px) {
  .brand img { width: 30px; height: 30px; }
  .brand strong { font-size: 13px; }
  .nav-link { padding-inline: 6px; }
}
@media (max-width: 375px) {
  .fields { grid-template-columns: 1fr; }
  .topbar .status-chip span { display: none; }
  .topbar .status-chip { padding: 6px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
