:root {
  --bg: #f6f7f8; --panel: #ffffff; --ink: #14181f; --muted: #5d6673; --line: #e3e6ea; --soft: #f0f2f4;
  --brand: #0f766e; --brand-ink: #ffffff; --brand-soft: #e3f3f1;
  --ok: #15803d; --ok-soft: #e7f6ec; --warn: #b45309; --warn-soft: #fdf3e2; --bad: #b91c1c; --bad-soft: #fdecec; --info: #1d4ed8; --info-soft: #e8eefc;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216; --panel: #161a20; --ink: #e7eaee; --muted: #9aa3ae; --line: #262c34; --soft: #1c2129;
    --brand: #2dd4bf; --brand-ink: #062a27; --brand-soft: #123532;
    --ok: #4ade80; --ok-soft: #12301f; --warn: #fbbf24; --warn-soft: #33270e; --bad: #f87171; --bad-soft: #3a1717; --info: #93b4ff; --info-soft: #18223d;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 17px; margin: 0 0 10px; } h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: var(--mono); font-size: 12px; }
.boot { padding: 40px; color: var(--muted); }

.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.brandmark { display: flex; align-items: center; gap: 8px; font-weight: 700; padding: 4px 8px 12px; }
.brandmark i { width: 22px; height: 22px; border-radius: 6px; background: var(--brand); display: inline-block; }
.side select { width: 100%; margin-bottom: 10px; }
.side .sec { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 10px 4px; }
.side a.nav { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; border-radius: 8px; color: var(--ink); }
.side a.nav:hover { background: var(--soft); text-decoration: none; }
.side a.nav.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.side .grow { flex: 1; }
main { padding: 22px 28px 60px; max-width: 1280px; width: 100%; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0,1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.split { display: grid; grid-template-columns: minmax(0,1fr) 340px; gap: 16px; align-items: start; }
.stat .v { font-size: 26px; font-weight: 700; } .stat .l { color: var(--muted); font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sp { flex: 1; }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

button, .btn { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 7px 12px; border-radius: 8px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
button:hover, .btn:hover { background: var(--soft); text-decoration: none; }
button.pri, .btn.pri { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
button.pri:hover { filter: brightness(1.05); }
button.danger { color: var(--bad); }
button.sm { padding: 3px 8px; font-size: 12px; }
button:disabled { opacity: .55; cursor: progress; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%; }
textarea { min-height: 90px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: auto; }
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
label.f > small { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
label.chk { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 10px; }
label.chk small { display: block; color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
tr:hover td { background: var(--soft); }
.tablewrap { overflow-x: auto; }

.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--soft); color: var(--muted); }
.chip.ok { background: var(--ok-soft); color: var(--ok); } .chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); } .chip.info { background: var(--info-soft); color: var(--info); }
.chip.brand { background: var(--brand-soft); color: var(--brand); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 12px; color: var(--muted); }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 8px; }
.cal .dow { font-size: 11px; color: var(--muted); text-transform: uppercase; text-align: center; }
.day { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; min-height: 128px; padding: 6px; display: flex; flex-direction: column; gap: 6px; }
.day.other { opacity: .45; } .day.today { outline: 2px solid var(--brand); }
.day.drop { background: var(--brand-soft); }
.day .dn { font-size: 12px; color: var(--muted); font-weight: 600; }
.kcard { border: 1px solid var(--line); border-radius: 8px; padding: 6px; font-size: 12px; background: var(--soft); cursor: grab; }
.kcard img { width: 100%; height: 54px; object-fit: cover; border-radius: 6px; display: block; margin-bottom: 4px; }
.kcard .kw { font-weight: 600; line-height: 1.25; margin: 2px 0; word-break: break-word; }
.kcard .meta { color: var(--muted); font-size: 11px; display: flex; gap: 8px; }
.kcard .acts { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }

/* article */
.article-body { line-height: 1.7; font-size: 15px; }
.article-body img { max-width: 100%; border-radius: 8px; }
.article-body h2 { font-size: 20px; margin: 26px 0 8px; } .article-body h3 { font-size: 16px; margin: 18px 0 6px; }
.article-body table { margin: 12px 0; } .article-body blockquote { border-left: 3px solid var(--line); margin: 0; padding-left: 12px; color: var(--muted); }
.cover { width: 100%; max-height: 320px; object-fit: cover; border-radius: 10px; margin-bottom: 14px; }
.gauge { font-size: 40px; font-weight: 800; }
.bar { height: 6px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); }
.factor { margin-bottom: 8px; }
.factor .row { justify-content: space-between; font-size: 12px; }
.editor { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 12px; }
.editor textarea { min-height: 70vh; font-family: var(--mono); font-size: 13px; }
.editor .preview { max-height: 70vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: var(--panel); }
.events li { margin-bottom: 6px; }
.copybox { white-space: pre-wrap; background: var(--soft); border-radius: 8px; padding: 10px; font-size: 13px; }

.listedit .item { display: flex; gap: 6px; margin-bottom: 6px; }
.listedit .item input { flex: 1; }

dialog { border: 1px solid var(--line); border-radius: 12px; padding: 0; background: var(--panel); color: var(--ink); width: min(560px, 94vw); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(10,14,20,.45); }
dialog .dh { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
dialog .db { padding: 16px; max-height: 70vh; overflow: auto; }
dialog .df { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

.toast { position: fixed; right: 18px; bottom: 18px; background: var(--ink); color: var(--panel); padding: 10px 14px; border-radius: 10px; max-width: 420px; z-index: 50; box-shadow: var(--shadow); white-space: pre-wrap; }
.toast.err { background: var(--bad); color: #fff; }
.login { max-width: 360px; margin: 12vh auto; }
.empty { text-align: center; padding: 30px; color: var(--muted); }
.check li { margin-bottom: 6px; }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: s 0.8s linear infinite; vertical-align: -2px; }
@keyframes s { to { transform: rotate(360deg); } }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .side .sec, .side .grow { display: none; }
  main { padding: 16px; }
  .split, .g2, .g3, .g4, .editor { grid-template-columns: 1fr; }
  .cal { grid-template-columns: repeat(2, minmax(0,1fr)); } .cal .dow { display: none; }
}
