:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #1d2330; --muted: #6b7380; --line: #e3e6eb;
  --accent: #2457d6; --accent-ink: #ffffff;
  --ok: #167a46; --ok-bg: #e5f5ec; --bad: #b3261e; --bad-bg: #fce9e7; --warn: #8a5a00; --warn-bg: #fff3d6;
  --bar: #2457d6; --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --panel: #1b1f27; --text: #e6e9ef; --muted: #9aa3b2; --line: #2b313c;
    --accent: #6c93ff; --accent-ink: #0d1220;
    --ok: #5fd08f; --ok-bg: #16301f; --bad: #ff8f86; --bad-bg: #3a1c1a; --warn: #f1c45c; --warn-bg: #352a10;
    --bar: #6c93ff;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h1 small { font-weight: 400; color: var(--muted); font-size: 1rem; margin-left: .4rem; }
h2 { font-size: 1rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.r { text-align: right; }
.warntext { color: var(--warn); font-weight: 600; }

.top { display: flex; align-items: center; gap: 1.5rem; padding: .7rem 1.25rem; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; }
.top nav { display: flex; gap: .25rem; flex: 1; }
.top nav a { padding: .35rem .75rem; border-radius: 8px; color: var(--muted); }
.top nav a.on, .top nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.logout { display: flex; align-items: center; gap: .6rem; margin: 0; }
.who { color: var(--muted); }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 1.25rem; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.grid3 .panel { margin: 0; }
.grid3 { margin-bottom: 1rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.card .num { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.card .lbl { color: var(--muted); font-size: .85rem; margin-top: .2rem; }
.card.bad .num { color: var(--bad); }
.card.warn .num { color: var(--warn); }

.chart { width: 100%; height: auto; }
.chart .bar { fill: var(--bar); }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .grid { stroke: var(--line); }

table { width: 100%; border-collapse: collapse; }
th, td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; white-space: nowrap; }
th.r, td.r { text-align: right; }
tfoot th { border-top: 2px solid var(--line); border-bottom: 0; color: var(--text); font-size: .9rem; }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.scroll { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 .4rem; }
.thumbcell { width: 64px; padding-right: 0; }
.thumbcell img { display: block; border-radius: 6px; object-fit: cover; background: var(--line); }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.alert { padding: .6rem .9rem; border-radius: 8px; margin-bottom: .8rem; }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.status-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.status-row .alert { margin-bottom: 1rem; }
.meta { color: var(--muted); margin-top: -.5rem; }

.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: 1rem; }
.filters label, .stack label { display: flex; flex-direction: column; gap: .25rem; font-size: .8rem; color: var(--muted); }
.filters .grow { flex: 1; min-width: 220px; }
input, select { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .45rem .6rem; min-width: 0; }
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.btn { display: inline-block; font: inherit; font-weight: 600; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); padding: .45rem .9rem; border-radius: 8px; cursor: pointer; text-decoration: none; }
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
form.inline { display: flex; gap: .4rem; margin: 0; }
form.inline input { width: 150px; padding: .25rem .5rem; }

.pager { display: flex; gap: .4rem; align-items: center; justify-content: center; margin: 1rem 0; flex-wrap: wrap; }
.pg { padding: .3rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.pg.off { color: var(--muted); opacity: .6; }
.pg.cur { border-color: transparent; background: transparent; color: var(--muted); }

dl { display: grid; grid-template-columns: 9.5rem 1fr; gap: .35rem .75rem; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; word-break: break-word; }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .75rem; overflow-x: auto; margin: 0; white-space: pre-wrap; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem; }
.shot { margin: 0; }
.shot img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: var(--line); display: block; }
.shot figcaption { font-size: .8rem; color: var(--muted); margin-top: .25rem; }
.shot .ph { aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--line); border-radius: 8px; color: var(--warn); font-size: .85rem; }

.login { max-width: 360px; margin: 8vh auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.stack .btn { width: 100%; }

.lb { position: fixed; inset: 0; background: rgba(0,0,0,.88); display: none; align-items: center; justify-content: center; z-index: 50; flex-direction: column; padding: 1rem; }
.lb.open { display: flex; }
.lb img { max-width: 100%; max-height: 82vh; border-radius: 6px; }
.lb .cap { color: #ddd; margin-top: .6rem; }
.lb button { position: absolute; background: rgba(255,255,255,.12); color: #fff; border: 0; font-size: 1.6rem; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; }
.lb .x { top: 14px; right: 14px; } .lb .p { left: 14px; top: 50%; } .lb .n { right: 14px; top: 50%; }

@media (max-width: 640px) {
  .wrap { padding: .8rem; }
  dl { grid-template-columns: 8rem 1fr; }
  .top { gap: .6rem; }
}

.titlebar { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.titlebar h1 { margin-bottom: .5rem; }
.badge.edited { background: var(--warn-bg); color: var(--warn); font-size: .7rem; }
button.link.small { font-size: .78rem; }
button.link.small:disabled { color: var(--muted); cursor: wait; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .8rem 1rem; }
label.field { display: flex; flex-direction: column; gap: .25rem; font-size: .8rem; color: var(--muted); }
label.field.bad input, label.field.bad select { border-color: var(--bad); }
.err { color: var(--bad); font-size: .78rem; }
td.old { color: var(--muted); text-decoration: line-through; }
.actions { margin: 1rem 0 2rem; }

.stoform { margin: 0; }
.stoform label { display: flex; align-items: center; gap: .4rem; color: var(--muted); font-size: .85rem; }
.stoform select { padding: .25rem .5rem; }
.stobadge { padding: .2rem .65rem; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); font-size: .85rem; font-weight: 600; }
.picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .6rem; }
label.pick { display: flex; flex-direction: column; gap: .25rem; font-size: .78rem; cursor: pointer; position: relative; }
label.pick input { position: absolute; top: 6px; left: 6px; width: 18px; height: 18px; z-index: 1; }
label.pick img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: var(--line); }
label.pick em { color: var(--warn); font-style: normal; font-weight: 600; }
label.check { display: block; padding: .2rem 0; }
pre.preview { max-height: 22rem; overflow: auto; font-size: .82rem; }
h3 { font-size: .9rem; margin: 1rem 0 .4rem; }
