/* Layout idea: fixed school-blue sidebar of modules, wide working area of tables and forms; summary before detail. */
:root {
  --brand: #2f4ea2;
  --brand-ink: #ffffff;
  --bg: #f3f5fa;
  --surface: #ffffff;
  --ink: #1b2233;
  --muted: #5d6680;
  --line: #dde2ee;
  --tint: #e9eef9;
  --good: #1e7a4c;
  --good-bg: #e3f4ea;
  --warn: #9a5b00;
  --warn-bg: #fdf0d9;
  --bad: #b3261e;
  --bad-bg: #fbe5e3;
  --font-display: "Bitter", "Rockwell", Georgia, "Times New Roman", serif;
  --font-body: "Segoe UI", "IBM Plex Sans", system-ui, -apple-system, Roboto, sans-serif;
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #7f9cf0; --brand-ink: #0e1426; --bg: #0f131c; --surface: #171c28; --ink: #e6e9f2; --muted: #9aa3ba;
    --line: #2a3142; --tint: #1e2638; --good: #6fd19c; --good-bg: #173226; --warn: #f0b65a; --warn-bg: #3a2b12;
    --bad: #ff8b80; --bad-bg: #3d1a18; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: #7f9cf0; --brand-ink: #0e1426; --bg: #0f131c; --surface: #171c28; --ink: #e6e9f2; --muted: #9aa3ba;
  --line: #2a3142; --tint: #1e2638; --good: #6fd19c; --good-bg: #173226; --warn: #f0b65a; --warn-bg: #3a2b12;
  --bad: #ff8b80; --bad-bg: #3d1a18; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font-body); }
button, input, select, textarea { font: inherit; color: inherit; }
.app { display: grid; grid-template-columns: 228px 1fr; min-height: 100%; }
.side { background: #23397a; color: #fff; padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
:root[data-theme="dark"] .side { background: #141b2e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .side { background: #141b2e; } }
.crest { display: flex; gap: 10px; align-items: center; padding: 4px 8px 16px; border-bottom: 1px solid rgba(255,255,255,.15); margin-bottom: 8px; }
.crest .badge { width: 40px; height: 40px; border-radius: 50%; background: #fff; color: #2f4ea2; display: grid; place-items: center; font: 700 13px var(--font-display); flex: none; overflow: hidden; }
.crest .badge img { width: 100%; height: 100%; object-fit: contain; }
.crest b { font: 600 15px/1.2 var(--font-display); display: block; }
.crest small { opacity: .75; font-size: 12px; }
.nav a { display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.86); text-decoration: none; padding: 9px 10px; border-radius: 6px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.on { background: rgba(255,255,255,.16); color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.side .term { margin-top: auto; font-size: 12px; padding: 10px; background: rgba(255,255,255,.08); border-radius: 6px; }
.main { padding: 22px 28px 60px; min-width: 0; }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
h1 { font: 600 26px/1.15 var(--font-display); margin: 0; text-wrap: balance; }
h2 { font: 600 17px/1.2 var(--font-display); margin: 0 0 10px; }
.sub { color: var(--muted); margin-top: 4px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 14px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.tile .v { font: 600 26px/1.2 var(--font-display); margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .s { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.bar { height: 6px; background: var(--tint); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.two { display: grid; grid-template-columns: 3fr 2fr; gap: 14px; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; background: var(--tint); position: sticky; top: 0; }
td.num, th.num { text-align: right; }
td.c, th.c { text-align: center; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--tint); }
tfoot td { font-weight: 700; background: var(--tint); }
.btn { text-decoration: none; border: 1px solid var(--line); background: var(--surface); padding: 7px 12px; border-radius: 6px; cursor: pointer; font-weight: 500; display: inline-flex; gap: 6px; align-items: center; }
.btn:hover { border-color: var(--brand); }
.btn.pri { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.pri:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
input[type=text], input[type=number], input[type=date], input[type=search], input[type=tel], input[type=email], select, textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 7px 9px; min-width: 0;
}
input[type=number] { width: 80px; }
textarea { width: 100%; min-height: 64px; resize: vertical; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
label.f > input, label.f > select, label.f > textarea { color: var(--ink); font-size: 14px; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.form .wide { grid-column: 1 / -1; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.mute { background: var(--tint); color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 9px 14px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 4px 10px; cursor: pointer; font-weight: 600; font-size: 12.5px; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on.P { background: var(--good-bg); color: var(--good); }
.seg button.on.A { background: var(--bad-bg); color: var(--bad); }
.seg button.on.L { background: var(--warn-bg); color: var(--warn); }
.seg button.on.E { background: var(--tint); color: var(--brand); }
.notice { padding: 10px 14px; border-radius: var(--radius); background: var(--warn-bg); color: var(--warn); margin-bottom: 14px; }
.notice.info { background: var(--tint); color: var(--ink); }
.muted { color: var(--muted); }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; background: var(--surface); cursor: pointer; }
.chip.done { border-color: var(--good); color: var(--good); background: var(--good-bg); }
.chip.part { border-color: var(--warn); color: var(--warn); background: var(--warn-bg); }
.chip.on { outline: 2px solid var(--brand); }
.modal-bg { position: fixed; inset: 0; background: rgba(10, 14, 25, .5); display: grid; place-items: start center; padding: 40px 16px; overflow-y: auto; z-index: 20; }
.modal { background: var(--surface); border-radius: 10px; width: min(760px, 100%); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal header h2 { margin: 0; }
.modal .body { padding: 18px; }
.modal footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.x { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.toast { position: fixed; right: 18px; bottom: 18px; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; z-index: 40; max-width: 380px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.err { background: var(--bad); color: #fff; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.demo { font-size: 11px; color: var(--warn); font-weight: 600; margin-left: 6px; }
.menu-btn { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .crest { border: 0; margin: 0; padding: 4px; width: 100%; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav a { padding: 6px 8px; font-size: 13px; }
  .side .term { display: none; }
  .main { padding: 16px; }
  .two { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* standalone additions */
.crest .badge { background: #fff; }
.crest .badge img { padding: 2px; }
.me { margin-top: 10px; padding: 10px; border-top: 1px solid rgba(255,255,255,.15); font-size: 13px; }
.me small { opacity: .75; }
.btn.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }
.btn.ghost:hover { border-color: #fff; }
.notice-item { padding: 10px 0; border-bottom: 1px solid var(--line); display: grid; gap: 4px; }
.notice-item:last-child { border-bottom: 0; }
details summary { cursor: pointer; }
input:disabled, select:disabled, textarea:disabled { opacity: .65; }
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(180deg, #23397a 0, #23397a 38%, var(--bg) 38%); }
.lcard { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px; width: min(420px, 100%); text-align: center; box-shadow: 0 18px 40px rgba(15,25,60,.18); }
.lcard h1 { font-size: 24px; margin-top: 6px; }
.lbadge { width: 116px; height: 116px; object-fit: contain; }
.lmsg { color: var(--bad); min-height: 1.2em; font-size: 13.5px; }
@media (max-width: 860px) { .me { width: 100%; } }

/* grouped menu (version 2.2) */
.nav .grp-h { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; color: rgba(255,255,255,.86); padding: 9px 10px; border-radius: 6px; font: inherit; font-weight: 500; cursor: pointer; text-align: left; }
.nav .grp-h:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav .grp-h span { flex: 1; }
.nav .grp-h i { font-style: normal; font-size: 11px; opacity: .7; transition: transform .15s; transform: rotate(-90deg); }
.nav .grp.open .grp-h i { transform: none; }
.nav .grp-h svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav .grp-items { display: none; margin: 0 0 4px 20px; border-left: 1px solid rgba(255,255,255,.15); padding-left: 8px; }
.nav .grp.open .grp-items { display: block; }
.nav .grp-items a { padding: 6px 10px; font-size: 13.5px; font-weight: 400; }
.crumb { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
@media (max-width: 860px) { .nav .grp-items { margin-left: 0; border: 0; } }
