:root {
  --bg: #f6f7f8; --surface: #fff; --text: #1f2430; --muted: #6b7280; --line: #e3e6ea;
  --primary: #2b3a55; --primary-h: #1f2b40; --accent: #3b6ea8;
  --ok: #1f7a4d; --ok-bg: #e4f4ec; --bad: #b3261e; --bad-bg: #fbe9e7; --warn: #8a5a00; --warn-bg: #fdf1d6; --info: #1d5a96; --info-bg: #e5f0fb; --mute-bg: #eceef1;
  --r: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c; --surface: #1d2128; --text: #e7e9ee; --muted: #9aa3b2; --line: #2e343e;
    --primary: #6f93c8; --primary-h: #8aa9d6; --accent: #8fb3e3;
    --ok: #66d19e; --ok-bg: #153024; --bad: #ff8a80; --bad-bg: #3a1c1a; --warn: #f2c261; --warn-bg: #3a2e12; --info: #8fc2f5; --info-bg: #16293d; --mute-bg: #272c35;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; } .grow { flex: 1; } .gap-s { gap: 6px; }
.stack > * + * { margin-top: 16px; }

.btn { font: inherit; padding: 8px 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; min-height: 38px; }
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #10151d; } }
.btn.primary:hover { background: var(--primary-h); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: .85rem; }
.icon-btn { border: 0; background: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 4px 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--text); min-height: 38px; }
textarea { min-height: 80px; resize: vertical; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.fields .full { grid-column: 1 / -1; }
.err-msg { color: var(--bad); font-size: .9rem; min-height: 1.2em; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--bg); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr.click { cursor: pointer; } tbody tr.click:hover { background: var(--bg); }
.thumb { width: 52px; height: 40px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); background: var(--bg); display: block; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; 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); } .badge.info { background: var(--info-bg); color: var(--info); } .badge.mute { background: var(--mute-bg); color: var(--muted); }

.overlay { position: fixed; inset: 0; background: rgba(15, 20, 30, .5); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 12px; overflow-y: auto; z-index: 50; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 520px; border: 1px solid var(--line); }
.modal.wide { max-width: 860px; }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); } .modal-h h3 { margin: 0; }
.modal-b { padding: 18px; } .modal-f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--primary); color: #fff; padding: 10px 18px; border-radius: var(--r); z-index: 100; max-width: 90vw; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast { color: #10151d; } }
.toast.err { background: var(--bad); color: #fff; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; } .kv dt { color: var(--muted); } .kv dd { margin: 0; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { font: inherit; background: none; border: 0; padding: 10px 14px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--primary); font-weight: 600; }
