:root {
  --bg: #f5f6f8; --card: #ffffff; --text: #1d2330; --muted: #6b7385; --line: #e3e6ec;
  --accent: #2f6fdd; --accent-soft: #e6eefc; --pass: #1f9d55; --fail: #d64545; --warn: #c98a12;
  --side: #1d2330; --side-text: #c9cfdb; --side-active: #ffffff;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --card: #1b2029; --text: #e4e8ef; --muted: #8b93a5; --line: #2a303b;
    --accent: #5b8ff0; --accent-soft: #22304a; --side: #0d1015; --side-text: #9aa3b5;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; font-weight: 600; }
h2 { font-size: 16px; margin: 24px 0 10px; font-weight: 600; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.err { color: var(--fail); min-height: 1em; }

.brand { font-weight: 800; letter-spacing: 2px; font-size: 18px; color: #fff; padding: 18px 20px; }
.side-top { display: flex; align-items: center; justify-content: space-between; }
.burger { display: none; background: transparent; border: 1px solid rgba(255,255,255,.2); color: var(--side-text); border-radius: 8px; font-size: 18px; padding: 4px 11px; margin-right: 14px; cursor: pointer; }
.nav-h { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: rgba(201,207,219,.5); padding: 14px 12px 4px; }
.brand.big { color: var(--text); font-size: 28px; padding: 0 0 6px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side nav { display: flex; flex-direction: column; padding: 4px 10px; gap: 2px; flex: 1; overflow-y: auto; }
.side nav a { color: var(--side-text); padding: 9px 12px; border-radius: 8px; }
.side nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.side nav a.active { background: rgba(255,255,255,.12); color: var(--side-active); }
.who { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
main { padding: 26px 30px 60px; min-width: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.tile .n { font-size: 28px; font-weight: 700; }
.tile .l { color: var(--muted); font-size: 13px; }
.tile.pass .n { color: var(--pass); } .tile.fail .n { color: var(--fail); } .tile.warn .n { color: var(--warn); }
a.tile { color: inherit; display: block; } a.tile:hover { border-color: var(--accent); text-decoration: none; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 12.5px; background: var(--bg); }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--accent-soft); }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--card); -webkit-overflow-scrolling: touch; }
.tablewrap table { min-width: 100%; }
tr:last-child td { border-bottom: 0; }
tr.home td { color: var(--muted); background: var(--bg); }
tr.dim td { opacity: .6; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.wrap { overflow-wrap: anywhere; min-width: 160px; max-width: 360px; }
.small { font-size: 12px; }
.pass-t, .good-t { color: var(--pass); } .fail-t, .bad-t { color: var(--fail); }
code { font-family: var(--mono); font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 0 4px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge.PASS { background: rgba(31,157,85,.14); color: var(--pass); }
.badge.FAIL { background: rgba(214,69,69,.14); color: var(--fail); }
.badge.LOW_BATTERY, .badge.INCOMPLETE, .badge.INTERRUPTED, .badge.off { background: rgba(201,138,18,.16); color: var(--warn); }
.chip { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 12px; background: var(--bg); border: 1px solid var(--line); margin: 1px 3px 1px 0; font-family: var(--mono); }

.btn { border: 1px solid var(--line); background: var(--card); color: var(--text); padding: 7px 13px; border-radius: 8px; cursor: pointer; font: inherit; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--fail); }
.btn.danger-solid { background: var(--fail); border-color: var(--fail); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn.ghost { background: transparent; color: inherit; border-color: rgba(255,255,255,.2); }
input, select, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea { font-family: var(--mono); font-size: 12.5px; min-height: 340px; }
label { display: block; font-size: 12.5px; color: var(--muted); margin: 10px 0 4px; }
.field-inline { display: flex; align-items: center; gap: 8px; }
.field-inline input[type=checkbox] { width: auto; }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 8px; }
.bar { flex: 1; display: flex; flex-direction: column-reverse; min-width: 8px; border-radius: 4px 4px 0 0; overflow: hidden; background: var(--bg); position: relative; }
.bar i { display: block; }
.bar .p { background: var(--pass); } .bar .f { background: var(--fail); } .bar .o { background: var(--warn); }
.barlabels { display: flex; gap: 6px; font-size: 10.5px; color: var(--muted); }
.barlabels span { flex: 1; text-align: center; min-width: 8px; }

.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.fitem { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; gap: 10px; align-items: center; color: inherit; overflow: hidden; }
.fitem:hover { border-color: var(--accent); text-decoration: none; }
.fitem .ico { font-size: 22px; }
.fitem .nm { font-weight: 600; word-break: break-all; }
.fitem .meta { font-size: 12px; color: var(--muted); }
pre.view { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; overflow: auto; font: 12.5px/1.45 var(--mono); max-height: 70vh; white-space: pre; }
.crumbs { margin-bottom: 14px; font-size: 13.5px; }
.crumbs a, .crumbs span { margin-right: 4px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--text); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }

.gcard h3 { margin: 0; font-size: 15px; }
.icard { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-top: 10px; background: var(--bg); }
.icard .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.icard .name { font-weight: 700; font-family: var(--mono); }
.list-plain { list-style: none; margin: 6px 0 0; padding: 0; font-size: 13px; }
.list-plain li { padding: 2px 0; }
.journal { font: 12.5px/1.5 var(--mono); }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; z-index: 10; }
.modal-card { width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; }
.modal-card.wide { max-width: 980px; }
.modal-card h2 { margin-top: 0; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.secret { font: 600 15px var(--mono); padding: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; word-break: break-all; user-select: all; flex: 1; min-width: 0; }
.secret.small-secret { font-size: 12.5px; font-weight: 500; }
.secret-row { display: flex; gap: 8px; align-items: center; }
.warnbox { background: rgba(201,138,18,.12); border: 1px solid rgba(201,138,18,.4); color: var(--text); border-radius: 8px; padding: 10px 12px; margin-bottom: 6px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 20; max-width: 90vw; }
.toast.bad { background: var(--fail); color: #fff; }

/* states */
.badge.st-ok { background: rgba(31,157,85,.14); color: var(--pass); }
.badge.st-bad { background: rgba(214,69,69,.14); color: var(--fail); }
.badge.st-warn { background: rgba(201,138,18,.16); color: var(--warn); }
.badge.st-muted { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.badge.st-info { background: var(--accent-soft); color: var(--accent); }
a.chip { color: var(--text); } a.chip:hover { border-color: var(--accent); text-decoration: none; }

/* made / planned */
.prog { min-width: 140px; }
.prog-bar { display: flex; height: 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; }
.prog-bar i { display: block; height: 100%; }
.prog-bar .p { background: var(--pass); } .prog-bar .f { background: var(--fail); } .prog-bar .o { background: var(--accent); }
.prog-t { font-size: 12.5px; margin-top: 3px; white-space: nowrap; }
.tile .prog { margin-top: 8px; }

.empty { border: 1px dashed var(--line); border-radius: 12px; padding: 26px 18px; text-align: center; background: var(--card); }
.empty-t { font-weight: 600; margin-bottom: 4px; }
td .empty { border: 0; padding: 14px; }

.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px 20px; }
.kv > div { display: flex; flex-direction: column; min-width: 0; }
.kv span { font-size: 12px; color: var(--muted); }
.kv b { font-weight: 500; word-break: break-word; }
.serial-big { font-size: 26px; font-weight: 700; letter-spacing: .5px; word-break: break-all; }
h3.sub { font-size: 13px; color: var(--muted); font-weight: 600; margin: 16px 0 8px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--card); }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 7px 12px; font: inherit; cursor: pointer; }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.check { padding: 14px 16px; max-width: 760px; }
.chk-out { margin-top: 8px; font-size: 13px; min-height: 1.4em; }
.chk-out.good { color: var(--pass); } .chk-out.bad { color: var(--fail); }
.chk-out a { font-weight: 600; }
.nowrap-row { flex-wrap: nowrap; }

.grid-2f { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid-3f { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 12px; max-height: 200px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
label.check-item { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--text); font-size: 13px; cursor: pointer; }
label.check-item input, label.field-inline input { width: auto; }
label.field-inline { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13.5px; margin-top: 14px; }
textarea.ta-notes { min-height: 110px; font-family: inherit; font-size: 14px; }
.invisible { visibility: hidden; }
.notes { margin-top: 6px; font-size: 12.5px; max-width: 320px; white-space: pre-wrap; }

.tree-org { border-top: 1px solid var(--line); padding: 10px 0 4px; margin-top: 10px; }
.tree-grp { margin: 8px 0 0 18px; padding-left: 12px; border-left: 2px solid var(--line); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; height: auto; z-index: 5; }
  .burger { display: block; }
  .brand { padding: 12px 16px; }
  .side nav, .side .who { display: none; }
  .side.open nav, .side.open .who { display: flex; }
  .side.open nav { max-height: calc(100vh - 110px); padding-bottom: 8px; }
  main { padding: 18px 16px 50px; }
  h1 { font-size: 20px; }
  .grid-3f { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .toast { left: 16px; right: 16px; bottom: 16px; }
}
@media (max-width: 480px) {
  .grid-2f { grid-template-columns: 1fr; }
  .serial-big { font-size: 21px; }
  .secret-row { flex-direction: column; align-items: stretch; }
  .modal { padding: 8px; }
  .modal-card { padding: 14px; }
}
h1 .mono { font-size: inherit; }
.chip { white-space: nowrap; }
.row.acts { margin-top: 8px; gap: 6px; }
.dl + .dl { margin-top: 6px; }
.btn { white-space: nowrap; }
.tabs { overflow-x: auto; } .tabs a { white-space: nowrap; }

/* login and small forms: label above the field */
.fld { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.fld input { width: 100%; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.login-card .small { margin: 0; line-height: 1.4; }
