:root {
  --bg: #f4f5f7; --panel: #fff; --text: #1d2129; --dim: #6b7280; --line: #e3e5ea;
  --accent: #b5532a; --accent-text: #fff; --ok: #1f7a4d; --bad: #b42318; --chip: #eef0f3;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171b; --panel: #1e2126; --text: #e7e9ee; --dim: #9aa1ad; --line: #2d3138;
    --accent: #e0814f; --accent-text: #1a1a1a; --ok: #4cc38a; --bad: #f97066; --chip: #2a2e35;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
h1 { font-size: 22px; margin: 0 0 8px; }
h2 { font-size: 18px; margin: 24px 0 10px; }
input, select, button { font: inherit; color: inherit; }
input, select { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; min-width: 0; }
input[type=number] { width: 90px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
button { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 12px; cursor: pointer; white-space: nowrap; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--bad); }
button.ghost { background: transparent; }
button.link { background: none; border: 0; color: var(--accent); padding: 0; text-align: left; }
button:disabled { opacity: .5; cursor: default; }
.dim { color: var(--dim); }
.msg { min-height: 1.4em; margin: 0; color: var(--dim); }
.msg.error { color: var(--bad); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; width: min(380px, 100%); display: grid; gap: 12px; }
.card label { display: grid; gap: 4px; color: var(--dim); font-size: 14px; }
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tabs button { border-color: transparent; background: transparent; }
.tabs button.on { background: var(--chip); border-color: var(--line); font-weight: 600; }
.spacer { flex: 1; }
.view { padding: 16px; max-width: 1280px; margin: 0 auto; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat b { display: block; font-size: 24px; }
.stat span { color: var(--dim); font-size: 13px; }
.table { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--dim); font-weight: 500; font-size: 13px; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td .row, .row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.bar input[type=search] { flex: 1; min-width: 180px; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 99px; background: var(--chip); font-size: 13px; }
.chip.ok { color: var(--ok); } .chip.bad { color: var(--bad); } .chip.gold { color: var(--accent); }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; align-items: end; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.form label { display: grid; gap: 4px; color: var(--dim); font-size: 13px; }
.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; max-width: calc(100% - 32px); z-index: 5; }
@media (max-width: 640px) {
  .view { padding: 12px; }
  th, td { padding: 6px 8px; }
}
