:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface-1: #fcfcfb;
  --border: #e3e2de;
  --text-primary: #161616;
  --text-secondary: #52514e;
  --text-muted: #6f6e69;
  --accent: #1f63b5;
  --accent-ink: #ffffff;
  --series-1: #2a78d6;
  --grid: #ecebe7;
  --hover: rgba(42, 120, 214, .08);
  --danger: #b42318;
  --ok-bg: #e7f4ec; --ok-ink: #14532d;
  --err-bg: #fdecea; --err-ink: #8a1c12;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110;
    --surface-1: #1a1a19;
    --border: #2e2e2c;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #9a998f;
    --accent: #3987e5;
    --series-1: #3987e5;
    --grid: #2a2a28;
    --hover: rgba(57, 135, 229, .14);
    --danger: #f0716a;
    --ok-bg: #12301f; --ok-ink: #b7e4c7;
    --err-bg: #3a1512; --err-ink: #f8c4bf;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110; --surface-1: #1a1a19; --border: #2e2e2c;
  --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #9a998f;
  --accent: #3987e5; --series-1: #3987e5; --grid: #2a2a28; --hover: rgba(57,135,229,.14);
  --danger: #f0716a; --ok-bg: #12301f; --ok-ink: #b7e4c7; --err-bg: #3a1512; --err-ink: #f8c4bf;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text-primary);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 24px; margin: 4px 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--text-secondary); }
.small { font-size: 13px; }
main { max-width: 1120px; margin: 0 auto; padding: 20px 16px 60px; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 12px 20px; background: var(--surface-1); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text-primary); text-decoration: none; }
.top nav { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.top nav a { color: var(--text-secondary); text-decoration: none; }
.top nav a:hover { color: var(--text-primary); }
.top form { margin: 0; }

.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px; min-width: 0;
}
.narrow { max-width: 460px; margin: 24px auto; }
.empty { text-align: center; padding: 40px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 0; }
.back { font-size: 13px; text-decoration: none; }
.back::before { content: "‹ "; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 { margin-bottom: 16px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tile-n { display: block; font-size: 28px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile-l { color: var(--text-secondary); font-size: 13px; }

.period { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; margin-bottom: 14px; background: var(--surface-1); }
.period a { padding: 6px 14px; text-decoration: none; color: var(--text-secondary); font-size: 14px; }
.period a.on { background: var(--accent); color: var(--accent-ink); }

.btn {
  display: inline-block; border: 0; border-radius: 8px; padding: 9px 16px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; text-decoration: none;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1px var(--border); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1px var(--border); margin-top: 12px; }
button.link { background: none; border: 0; color: var(--text-secondary); font: inherit; cursor: pointer; padding: 0; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--grid); color: var(--text-secondary); vertical-align: middle; }

.stack { display: grid; gap: 14px; }
label { display: grid; gap: 5px; font-weight: 600; font-size: 14px; }
label small { font-weight: 400; color: var(--text-muted); }
label.check { display: block; font-weight: 500; }
label.check small { display: block; margin-left: 24px; }
input[type=text], input[type=email], input[type=password], input:not([type]), textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text-primary); font: inherit; font-weight: 400;
}
textarea { font: 13px/1.4 ui-monospace, Menlo, Consolas, monospace; resize: vertical; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.copy-row { display: flex; gap: 8px; }
.error { background: var(--err-bg); color: var(--err-ink); padding: 10px 12px; border-radius: 8px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; background: var(--ok-bg); color: var(--ok-ink); }
.flash.error { background: var(--err-bg); color: var(--err-ink); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--text-secondary); font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions details { font-size: 13px; }
td.actions form { margin-top: 6px; }
form.inline { display: flex; gap: 6px; }
details summary { cursor: pointer; color: var(--accent); }
.table-view, .howto { margin-top: 10px; }
.howto ul { padding-left: 20px; }
.howto label { margin-top: 10px; }

.chart-scroll { overflow-x: auto; }
.chart { width: 100%; height: auto; display: block; }
@media (max-width: 640px) { .chart { min-width: 600px; } }
.chart .bar { fill: var(--series-1); }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--text-muted); stroke-width: 1; }
.chart .tick { fill: var(--text-secondary); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; }
.chart .hit:hover, .chart .hit.on:hover { fill: var(--hover); }
#tip {
  position: fixed; z-index: 1000; pointer-events: none; padding: 5px 9px; border-radius: 6px; font-size: 13px;
  background: var(--text-primary); color: var(--surface-1); white-space: nowrap;
}
#tip[hidden] { display: none; }

.map { height: 340px; border-radius: 8px; border: 1px solid var(--border); z-index: 0; }
.qr-preview { display: block; width: 200px; height: 200px; margin: 0 0 14px; border-radius: 8px; background: #fff; }

.settings form { max-width: 560px; }
.design { display: grid; grid-template-columns: 260px 1fr; gap: 28px; align-items: start; }
@media (max-width: 760px) { .design { grid-template-columns: 1fr; } }
.design-preview .qr-preview { width: 240px; height: 240px; }
.swatches { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 480px) { .swatches { grid-template-columns: 1fr; } }
.swatch { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.swatch input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-1); cursor: pointer; }
.swatch code { font-size: 13px; color: var(--text-secondary); }
fieldset.dots { border: 0; padding: 0; margin: 0; display: flex; gap: 20px; flex-wrap: wrap; }
fieldset.dots legend { font-weight: 600; font-size: 14px; padding: 0; margin-bottom: 6px; width: 100%; }
input[type=file] { font: inherit; font-weight: 400; color: var(--text-secondary); }
