/* Warm paper + terracotta. Thin borders, soft shadows, serif headings. */
:root {
  --bg: #faf8f4; --surface: #ffffff; --surface-2: #f4f0e9; --line: #eae4da;
  --ink: #26221d; --muted: #81786c;
  --accent: #c4613f; --accent-strong: #a94e30; --accent-soft: #fbece5; --on-accent: #fffaf7;
  --ok: #2f7d53; --ok-soft: #e6f4ec; --warn: #96630f; --warn-soft: #fbf0d9;
  --info: #3b66a8; --info-soft: #e8eff9; --bad: #b3372f; --bad-soft: #fbe9e7; --off-soft: #efebe5;
  --shadow: 0 1px 2px rgba(64, 44, 20, .04), 0 12px 32px -12px rgba(64, 44, 20, .10);
  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171412; --surface: #201c19; --surface-2: #2a2521; --line: #352f2a;
    --ink: #f1ebe3; --muted: #a89e91;
    --accent: #e2825f; --accent-strong: #ee9574; --accent-soft: #3a261e; --on-accent: #241008;
    --ok: #7cc79b; --ok-soft: #1d3327; --warn: #e3b45f; --warn-soft: #362a15;
    --info: #92b4e8; --info-soft: #1f2a3b; --bad: #ee8f86; --bad-soft: #3b201e; --off-soft: #2c2723;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 12px 32px -12px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #171412; --surface: #201c19; --surface-2: #2a2521; --line: #352f2a;
  --ink: #f1ebe3; --muted: #a89e91;
  --accent: #e2825f; --accent-strong: #ee9574; --accent-soft: #3a261e; --on-accent: #241008;
  --ok: #7cc79b; --ok-soft: #1d3327; --warn: #e3b45f; --warn-soft: #362a15;
  --info: #92b4e8; --info-soft: #1f2a3b; --bad: #ee8f86; --bad-soft: #3b201e; --off-soft: #2c2723;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 12px 32px -12px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 28px; line-height: 1.25; overflow-wrap: anywhere; }
h2 { font-size: 18px; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.mono, code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .92em; }
.ico { width: 19px; height: 19px; flex: none; }

/* layout */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 26px; padding: 22px 16px; border-right: 1px solid var(--line); background: var(--surface); }
.logo { display: flex; align-items: center; gap: 11px; padding: 0 8px; color: var(--ink); font-family: var(--serif); font-weight: 600; font-size: 17px; line-height: 1.2; }
.logo:hover { color: var(--ink); }
.logo small, .me small, .person small, .rows small, .feed small { display: block; color: var(--muted); font: 12px/1.45 system-ui, sans-serif; }
.side nav { display: flex; flex-direction: column; gap: 3px; }
.side nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px; color: var(--muted); font-weight: 500; transition: background .2s, color .2s; }
.side nav a:hover { background: var(--surface-2); color: var(--ink); }
.side nav a[aria-current] { background: var(--accent-soft); color: var(--accent); }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 6px; padding-top: 16px; border-top: 1px solid var(--line); }
.me { display: flex; align-items: center; gap: 10px; margin-right: auto; min-width: 0; line-height: 1.3; }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; transition: color .2s, border-color .2s; }
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.main { width: 100%; max-width: 1180px; margin: 0 auto; padding: 32px 32px 56px; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 14px; margin-bottom: 24px; }
.actions { display: flex; gap: 8px; }

/* cards & stats */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: var(--shadow); margin-bottom: 18px; min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.stats { display: grid; grid-template-columns: 1.6fr repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stats.three { grid-template-columns: 1.4fr 1fr 1.2fr; }
.stats:not(.three):has(> :nth-child(4):last-child) { grid-template-columns: 1.6fr repeat(3, 1fr); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat span { color: var(--muted); font-size: 13px; }
.stat b { font-family: var(--serif); font-size: 28px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat b.small { font-size: 21px; padding: 4px 0; }
.stat small { color: var(--muted); font-size: 12.5px; }
.stat.hero { background: linear-gradient(145deg, var(--accent-soft), var(--surface) 75%); }
.stat.hero b { color: var(--accent); font-size: 32px; }
.split { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 18px; }
.split.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* bot status */
.status-card h2 { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.status-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin: 0; }
.status-grid div { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); }
.status-grid dt { color: var(--muted); font-size: 12.5px; }
.status-grid dd { margin: 2px 0 0; font: 600 20px/1.3 var(--serif); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.status-card > p:not(:empty) { margin-top: 12px; font-size: 13.5px; }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--line); }
.btn.danger:hover { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }

.adjust { margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.adjust label[for="note"] { margin-top: 14px; }
.adjust .btn { margin-top: 14px; }
a.mini { display: inline-flex; }

.btn.take { margin-top: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.history { margin-top: 20px; }
.note { margin-top: 12px; font-size: 13px; }

/* chart: single series, value shown on hover and focus */
.chart { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 6px; height: 240px; padding-top: 56px; }
.col { position: relative; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 8px; border-radius: 6px; }
.col i { display: block; width: 100%; max-width: 30px; min-height: 3px; border-radius: 4px 4px 0 0; background: var(--accent); opacity: .85; transition: opacity .2s; }
.col:hover i, .col:focus i { opacity: 1; }
.col small { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.tip { position: absolute; top: -54px; left: 50%; transform: translateX(-50%); z-index: 3; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); font-size: 12px; line-height: 1.4; text-align: center; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .15s; }
.col:hover .tip, .col:focus .tip { opacity: 1; }
.col:nth-child(-n+2) .tip { left: 0; transform: none; }
.col:nth-last-child(-n+2) .tip { left: auto; right: 0; transform: none; }

/* lists & tables */
.feed { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; }
.feed li { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed b { font-weight: 500; font-size: 14px; }
.dot { width: 8px; height: 8px; margin-top: 7px; border-radius: 50%; flex: none; background: var(--muted); }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.info { background: var(--info); } .dot.bad { background: var(--bad); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { padding: 0 12px 10px; color: var(--muted); font-weight: 500; font-size: 12.5px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
.table td { padding: 12px; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .r { text-align: right; }
.person { display: flex; align-items: center; gap: 10px; color: var(--ink); line-height: 1.3; }
.person b { font-weight: 500; display: block; max-width: 210px; overflow: hidden; text-overflow: ellipsis; }
.person.boxed { margin-top: 18px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 50%; font-weight: 600; font-size: 13px; }
.avatar.t0 { background: var(--accent-soft); color: var(--accent); } .avatar.t1 { background: var(--ok-soft); color: var(--ok); }
.avatar.t2 { background: var(--info-soft); color: var(--info); } .avatar.t3 { background: var(--warn-soft); color: var(--warn); }
.avatar.t4 { background: var(--off-soft); color: var(--ink); }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--off-soft); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); } .badge.bad { background: var(--bad-soft); color: var(--bad); }
.count { display: inline-block; margin-left: 6px; padding: 1px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font: 600 12px/1.7 system-ui, sans-serif; vertical-align: middle; }
.rows { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; }
.rows.scroll { max-height: 520px; overflow-y: auto; }
.rows li { display: grid; grid-template-columns: 34px minmax(0, 1fr) minmax(90px, 170px) auto; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.rows li:last-child { border-bottom: 0; }
.rows li:hover { background: var(--surface-2); }
.num { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.grow { min-width: 0; overflow-wrap: anywhere; }
.pw { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 0; }
.facts dt { color: var(--muted); font-size: 12.5px; }
.facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.facts .big { font-family: var(--serif); font-size: 24px; color: var(--accent); }
.empty { padding: 26px 0; color: var(--muted); text-align: center; }

/* forms */
label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
input, textarea, select { width: 100%; padding: 10px 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--bg); color: var(--ink); font: inherit; transition: border-color .2s, box-shadow .2s; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 110px; resize: vertical; }
form > input + label, form > input + .btn, form > textarea + .btn { margin-top: 14px; }
form > .btn + p { margin-top: 12px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.card > p + .fields { margin-top: 16px; }
.btn, .mini { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 11px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .2s, color .2s, border-color .2s; }
.btn { padding: 10px 18px; background: var(--accent); color: var(--on-accent); }
.btn:hover { background: var(--accent-strong); color: var(--on-accent); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); font-weight: 500; }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn.wide { width: 100%; margin-top: 20px; }
.mini { padding: 6px 12px; border-color: var(--line); border-radius: 9px; background: transparent; color: var(--ink); font-size: 13px; font-weight: 500; }
.mini:hover { border-color: var(--accent); color: var(--accent); }
.switch { display: inline-flex; align-items: center; gap: 12px; margin: 18px 0 0; color: var(--ink); font-size: 14px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { position: relative; width: 42px; height: 24px; border-radius: 999px; background: var(--line); transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.filters { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.tabs a { padding: 6px 13px; border-radius: 9px; color: var(--muted); font-size: 13.5px; font-weight: 500; white-space: nowrap; }
.tabs a[aria-current] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.search, .tools { display: flex; flex-wrap: wrap; gap: 8px; }
.search input[type="search"], .tools input { width: 260px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 18px; font-size: 14px; }
.flash { margin-bottom: 18px; padding: 12px 16px; border-radius: 12px; background: var(--ok-soft); color: var(--ok); }
.flash.bad { background: var(--bad-soft); color: var(--bad); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(900px 500px at 50% -10%, var(--accent-soft), transparent 70%); }
.login-card { width: 100%; max-width: 400px; padding: 34px 30px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.login-card h1 { margin: 16px 0 6px; }
.login-card form { margin-top: 22px; }
.login-card .flash { margin: 18px 0 0; }
.theme-float { position: fixed; top: 18px; right: 18px; background: var(--surface); }

/* responsive */
@media (max-width: 1100px) {
  .stats, .stats.three, .stats:not(.three):has(> :nth-child(4):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat.hero { grid-column: 1 / -1; }
  .split, .split.even { grid-template-columns: minmax(0, 1fr); gap: 0; }
}
@media (max-width: 820px) {
  .shell { display: block; }
  .side { position: sticky; z-index: 5; height: auto; gap: 10px; padding: 12px 14px 8px; border-right: 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .logo { padding: 0; }
  .side-foot { grid-column: 2; grid-row: 1; margin: 0; padding: 0; border: 0; }
  .me { display: none; }
  .side nav { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; }
  .side nav a { flex-direction: column; justify-content: flex-start; gap: 3px; padding: 7px 2px; font-size: 11.5px; line-height: 1.25; text-align: center; }
  .main { padding: 22px 14px 44px; }
  .card { padding: 16px; }
  .fields, .facts { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1100px) { .status-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  h1 { font-size: 23px; }
  .stat { padding: 14px; }
  .stat b { font-size: 22px; }
  .stat.hero b { font-size: 28px; }
  .chart { gap: 3px; height: 200px; }
  .col:nth-child(odd) small { visibility: hidden; }
  .search, .tools, .search input[type="search"], .tools input { width: 100%; }
  .search { flex-wrap: nowrap; }
  /* tables turn into stacked cards */
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { display: none; }
  .table tr { margin-bottom: 10px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 12px; }
  .table td, .table tbody tr:last-child td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); text-align: right; white-space: normal; }
  .table tr td:last-child { border-bottom: 0; }
  .table td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; text-align: left; }
  .table .person { text-align: left; }
  .rows li { grid-template-columns: 24px minmax(0, 1fr) auto; row-gap: 4px; padding: 10px 12px; }
  .rows .num { grid-row: 1 / 3; } .rows .grow { grid-column: 2; } .rows .pw { grid-column: 2; grid-row: 2; } .rows .mini { grid-column: 3; grid-row: 1 / 3; }
}
@media (max-width: 380px) {
  .side nav a { font-size: 10.5px; }
  .rows li { grid-template-columns: minmax(0, 1fr); }
  .rows .num { display: none; } .rows .grow, .rows .pw { grid-column: 1; } .rows .mini { grid-column: 1; grid-row: 3; justify-self: start; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
