/* apphermesa2 — Hermesa orange & graphite, light/dark */
:root {
  --brand: #f39a0b;
  --brand-strong: #d9820a;
  --brand-soft: #fff3df;
  --ink: #23262b;
  --ink-2: #4b5059;
  --muted: #7b818b;
  --line: #e7e4df;
  --bg: #f6f4f1;
  --surface: #ffffff;
  --surface-2: #faf9f7;
  --side: #26282c;
  --side-ink: #c9cbd0;
  --side-hover: #33363b;
  --ok: #1f8a4c;   --ok-bg: #e4f5ea;
  --info: #2364c4; --info-bg: #e5eefb;
  --warn: #b26a00; --warn-bg: #fff1d9;
  --dim: #6b7079;  --dim-bg: #eeeeec;
  --danger: #b4232c; --danger-bg: #fde8ea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 20, 20, .04), 0 4px 16px rgba(20, 20, 20, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand-soft: #3a2a10; --ink: #eceef1; --ink-2: #c2c6cd; --muted: #8d939c; --line: #33363c;
    --bg: #17181b; --surface: #1f2125; --surface-2: #24262b; --side: #121315; --side-ink: #b9bcc2; --side-hover: #24262a;
    --ok: #5fd08e; --ok-bg: #173324; --info: #7fb0ff; --info-bg: #182a46; --warn: #ffbf5a; --warn-bg: #3a2a10;
    --dim: #a2a7af; --dim-bg: #2b2d32; --danger: #ff8a92; --danger-bg: #3d1a1d;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand-soft: #3a2a10; --ink: #eceef1; --ink-2: #c2c6cd; --muted: #8d939c; --line: #33363c;
  --bg: #17181b; --surface: #1f2125; --surface-2: #24262b; --side: #121315; --side-ink: #b9bcc2; --side-hover: #24262a;
  --ok: #5fd08e; --ok-bg: #173324; --info: #7fb0ff; --info-bg: #182a46; --warn: #ffbf5a; --warn-bg: #3a2a10;
  --dim: #a2a7af; --dim-bg: #2b2d32; --danger: #ff8a92; --danger-bg: #3d1a1d;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--side); color: var(--side-ink); padding: 18px 12px; overflow-y: auto;
}
.brand { display: block; padding: 6px 10px 18px; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.07); margin-bottom: 12px; }
.brand-logo { display: block; width: 100%; max-width: 180px; height: auto; background: #fff; border-radius: 8px; padding: 6px 10px; }
.brand-sub { display: block; margin-top: 10px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--brand); font-weight: 600; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px;
  text-decoration: none; font-weight: 500; font-size: 14px; color: var(--side-ink);
}
.nav-item:hover { background: var(--side-hover); color: #fff; }
.nav-item.is-active { background: var(--brand); color: #1d1405; }
.nav-item.is-soon { opacity: .45; cursor: default; }
.nav-item.is-soon:hover { background: none; color: var(--side-ink); }
.nav-item em { margin-left: auto; font-style: normal; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; border: 1px solid currentColor; border-radius: 99px; padding: 0 6px; }
.side-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.07); display: flex; flex-direction: column; gap: 8px; }
.me { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.me form { margin-left: auto; }
.me-name { font-size: 14px; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: #1d1405; font-weight: 700; flex: none; }
.side .icon-btn { color: var(--side-ink); }
.side .icon-btn:hover { background: var(--side-hover); color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: 14px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.top-title { font-size: 20px; font-weight: 650; flex: 1; }
.content { padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 20px; max-width: 1400px; width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; border: 0; background: none; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.only-mobile { display: none; }
.scrim { display: none; }

/* ---------- cards & grid ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { font-size: 16px; font-weight: 650; }
.head-actions { display: flex; align-items: center; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-detail { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 20px; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.count { display: inline-block; margin-left: 6px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; padding: 0 8px; vertical-align: middle; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
.kpi {
  display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  border-top: 3px solid var(--brand);
}
a.kpi:hover { border-color: var(--brand); }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi-value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-foot { font-size: 12px; color: var(--muted); min-height: 20px; }

/* ---------- chart ---------- */
.chart-scroll { overflow-x: auto; }
.chart { width: 100%; min-width: 360px; height: 240px; display: block; }
.bar { fill: var(--brand); transition: fill .15s; }
.chart a:hover .bar { fill: var(--brand-strong); }
.bar-val { font-size: 11px; font-weight: 600; text-anchor: middle; fill: var(--ink-2); }
.bar-lbl { font-size: 12px; text-anchor: middle; fill: var(--muted); }

/* ---------- lists ---------- */
.list, .rank, .files { list-style: none; margin: 0; padding: 0; }
.list li + li { border-top: 1px solid var(--line); }
.list-row { display: flex; align-items: center; gap: 14px; padding: 10px 6px; text-decoration: none; border-radius: 8px; }
.list-row:hover { background: var(--surface-2); }
.list-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.list-main small { color: var(--muted); }
.list-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.list-side small { color: var(--muted); font-size: 12px; }
.rank li { display: grid; grid-template-columns: minmax(0, 1.4fr) 1fr auto; align-items: center; gap: 12px; padding: 8px 0; }
.rank li + li { border-top: 1px solid var(--line); }
.rank a { text-decoration: none; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank a:hover { color: var(--brand-strong); }
.rank-bar { width: 100%; height: 8px; border: 0; border-radius: 99px; background: var(--surface-2); appearance: none; overflow: hidden; }
.rank-bar::-webkit-progress-bar { background: var(--surface-2); border-radius: 99px; }
.rank-bar::-webkit-progress-value { background: var(--brand); border-radius: 99px; }
.rank-bar::-moz-progress-bar { background: var(--brand); border-radius: 99px; }
.rank-n { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 3ch; text-align: right; }
.files li a { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 8px; text-decoration: none; overflow-wrap: anywhere; }
.files li a:hover { background: var(--surface-2); color: var(--brand-strong); }
.files li + li { border-top: 1px solid var(--line); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 99px; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { color: var(--ok); background: var(--ok-bg); }
.badge-info { color: var(--info); background: var(--info-bg); }
.badge-warn { color: var(--warn); background: var(--warn-bg); }
.badge-muted { color: var(--dim); background: var(--dim-bg); }

/* ---------- filters & forms ---------- */
.filters { display: flex; flex-direction: column; gap: 14px; }
.search { display: flex; align-items: center; gap: 10px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--muted); }
.search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.search input { flex: 1; border: 0; background: none; padding: 12px 0; font: inherit; color: var(--ink); outline: none; min-width: 0; }
.filter-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.field-inline { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
select, input[type=date], .field input {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; min-height: 38px;
}
select:focus, input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.filter-actions { display: flex; gap: 8px; margin-left: auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 8px 14px;
  font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
}
.btn:hover { border-color: var(--brand); color: var(--brand-strong); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #1d1405; }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: #1d1405; }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.link { color: var(--brand-strong); font-weight: 600; font-size: 14px; text-decoration: none; }
.link:hover { text-decoration: underline; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr[data-href] { cursor: pointer; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tr.sub td { padding-top: 0; font-size: 13px; border-top: 0; }
.th-sort { text-decoration: none; }
.th-sort:hover, .th-sort.is-cur { color: var(--ink); }
.code, .code a { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; text-decoration: none; color: var(--brand-strong); }
.code-lg { font-size: 26px; font-weight: 750; letter-spacing: -.01em; }
.w-code { width: 1%; }
.w-date { width: 1%; }
.strong { font-weight: 600; }
.big { font-size: 17px; margin: 0 0 10px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.clamp-1, .clamp-2 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-1 { -webkit-line-clamp: 1; }
.clamp-2 { -webkit-line-clamp: 2; }

/* ---------- pager ---------- */
.pager { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 18px; }
.pg { min-width: 38px; height: 38px; padding: 0 12px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }
.pg:hover { border-color: var(--brand); color: var(--brand-strong); }
.pg.is-cur { background: var(--brand); border-color: var(--brand); color: #1d1405; }
.pg.is-off { pointer-events: none; opacity: .4; }
.pg-gap { align-self: center; color: var(--muted); padding: 0 4px; }

/* ---------- detail ---------- */
.page-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.page-head-main { display: flex; align-items: center; gap: 12px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.prose { margin: 0 0 18px; white-space: normal; overflow-wrap: anywhere; font-size: 15px; }
.kvs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; margin: 0; }
.kvs-1 { grid-template-columns: 1fr; gap: 8px; margin-bottom: 12px; }
.kv dt { font-size: 12px; color: var(--muted); font-weight: 500; }
.kv dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.kvs-1 .kv { display: flex; justify-content: space-between; gap: 12px; }
.kvs-1 .kv dd { margin: 0; text-align: right; }

.empty { text-align: center; padding: 40px 16px; }
.empty h2, .empty h3 { margin-bottom: 8px; }
.alert { background: var(--danger-bg); color: var(--danger); border-radius: 8px; padding: 10px 12px; font-size: 14px; margin-bottom: 14px; }

/* ---------- login ---------- */
.bare { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 10% -10%, var(--brand-soft), transparent), var(--bg); }
.login-wrap { width: 100%; padding: 24px 16px; display: grid; place-items: center; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 28px; }
.login-logo { display: block; width: 200px; max-width: 100%; height: auto; margin: 0 auto 18px; background: #fff; border-radius: 8px; padding: 6px 10px; }
.login-card h1 { font-size: 20px; text-align: center; }
.login-card > .muted { text-align: center; margin: 4px 0 20px; font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input { min-height: 42px; }
.login-alt { display: block; margin-top: 16px; text-align: center; font-size: 13px; color: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 1200px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 980px) {
  .grid-2, .grid-detail { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 30; left: 0; top: 0; width: 264px; transform: translateX(-100%); transition: transform .2s ease; }
  .side-open .side { transform: none; }
  .side-open .scrim { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.4); }
  .only-mobile { display: inline-grid; }
  .top { padding: 12px 16px; }
  .content { padding: 16px 16px 40px; gap: 16px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpi-value { font-size: 24px; }
  .hide-sm { display: none; }
  .filter-actions { margin-left: 0; }
  .page-actions { margin-left: 0; }
  .kvs { grid-template-columns: 1fr; }
  .table-wrap { margin: 0 -20px; }
}
