/* Colours from the Hive Manager prototype (lib/theme/tokens.dart). Dark by default. */
:root, :root[data-theme="dark"] {
  --bg: #12110F; --surface: #1C1B17; --surface2: #26241F;
  --ink: #EEE7D7; --ink2: #B2A893; --ink3: #847B69; --line: #35322B;
  --gold: #D9AA45; --gold2: #E7BD5E; --goldSoft: #3A2F1A;
  --char: #0C0B0A; --charInk: #EDE5D3; --charInk2: #9A907C;
  --ok: #7FB685; --okBg: #1F2E21; --warn: #E0A54A; --warnBg: #35281A;
  --bad: #E07A66; --badBg: #3A201B; --info: #8DB4CF; --infoBg: #1B2830;
  --onGold: #1A1405;
}
:root[data-theme="light"] {
  --bg: #F2EDE2; --surface: #FBF8F2; --surface2: #EEE7D8;
  --ink: #1F1D19; --ink2: #5E574A; --ink3: #8A8270; --line: #DED4C0;
  --gold: #8C6516; --gold2: #C79A3A; --goldSoft: #F1E3BE;
  --char: #1A1916; --charInk: #EDE5D3; --charInk2: #A69C86;
  --ok: #3B7346; --okBg: #E2EEDF; --warn: #9A600F; --warnBg: #F6E6C6;
  --bad: #A83A27; --badBg: #F5DDD5; --info: #335F7C; --infoBg: #DDE8EF;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 Figtree, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 600; margin: 0 0 8px; line-height: 1.15; }
h1 { font-size: 32px; }
h2 { font-size: 24px; margin-top: 8px; }
h3 { font-size: 19px; }
.muted { color: var(--ink2); }
.small { font-size: 13px; }
.mono, td.num, .kpi .v { font-family: "IBM Plex Mono", ui-monospace, monospace; }
[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--char); color: var(--charInk); padding: 10px 24px; border-bottom: 1px solid #2a2722;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { height: 30px; width: auto; }
.product { font-family: "Cormorant Garamond", serif; font-size: 21px; font-weight: 600; }
.product .sub { color: var(--charInk2); font-family: Figtree, sans-serif; font-size: 13px; font-weight: 500; margin-left: 6px; }
.actions { display: flex; align-items: center; gap: 8px; }
.updated { color: var(--charInk2); font-size: 13px; margin-right: 4px; }

.btn {
  min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface2); color: var(--ink); font: 600 14px Figtree, sans-serif; cursor: pointer;
}
.top .btn { background: #24221E; color: var(--charInk); border-color: #3a362f; }
.btn:hover { border-color: var(--gold); }
.btn.gold { background: var(--gold); color: var(--onGold, #1A1405); border-color: var(--gold); }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; min-height: 48px; }
.btn:disabled { opacity: .55; cursor: wait; }

.center { min-height: calc(100vh - 60px); display: grid; place-items: center; padding: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.card.narrow { max-width: 420px; width: 100%; }
.error { color: var(--bad); background: var(--badBg); padding: 10px 12px; border-radius: 10px; }
.notice { background: var(--goldSoft); border: 1px solid var(--gold2); border-radius: 12px; padding: 14px 16px; }
.notice b { color: var(--gold); }

#app { max-width: 1320px; margin: 0 auto; padding: 0 24px 48px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin: 16px 0 20px; scrollbar-width: none; }
.tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent; color: var(--ink2);
  font: 600 14px Figtree, sans-serif; padding: 12px 14px; white-space: nowrap; cursor: pointer; min-height: 44px;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--gold); }
.loading { color: var(--ink2); padding: 24px 0; }

.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-bottom: 18px; }
.cols2 { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); margin-bottom: 18px; }
.cols3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.kpi .l { color: var(--ink2); font-size: 13px; font-weight: 500; }
.kpi .v { font-size: 26px; font-weight: 600; margin-top: 2px; color: var(--ink); }
.kpi .d { color: var(--ink3); font-size: 12px; margin-top: 2px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 6px 0 10px; }

/* Charts */
.chart { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--ink3); font: 11px "IBM Plex Mono", monospace; }
.chart .bar { fill: var(--gold); }
.chart .bar.hl, .chart .hit:hover + .bar { fill: var(--gold2); }
.chart .hit { fill: transparent; cursor: default; }
.hbars { display: grid; gap: 8px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 160px) 1fr 52px; gap: 10px; align-items: center; font-size: 14px; }
.hbar .track { height: 10px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--gold); border-radius: 0 4px 4px 0; }
.hbar .n { text-align: right; font-family: "IBM Plex Mono", monospace; color: var(--ink2); }
.tip {
  position: fixed; z-index: 20; pointer-events: none; background: var(--char); color: var(--charInk);
  border: 1px solid #3a362f; border-radius: 8px; padding: 6px 10px; font-size: 13px; box-shadow: 0 6px 18px rgba(0,0,0,.35);
}
.tip b { font-family: "IBM Plex Mono", monospace; }

/* Tables */
.tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.tools input, .tools select {
  min-height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 0 12px; font: 14px Figtree, sans-serif;
}
.tools input { flex: 1 1 240px; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--ink2); font-weight: 600; font-size: 12.5px; background: var(--surface2); position: sticky; top: 0; cursor: pointer; user-select: none; }
th.num, td.num { text-align: right; }
tr:last-child td { border-bottom: 0; }
td.wrap { white-space: normal; min-width: 260px; max-width: 520px; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.premium { background: var(--goldSoft); color: var(--gold); }
.pill.trial { background: var(--infoBg); color: var(--info); }
.pill.free { background: var(--surface2); color: var(--ink2); }
.pill.ok { background: var(--okBg); color: var(--ok); }
.pill.bad { background: var(--badBg); color: var(--bad); }
.pill.warn { background: var(--warnBg); color: var(--warn); }
.stars { color: var(--gold); letter-spacing: 1px; }

.small-btn { min-height: 32px; padding: 0 10px; font-size: 12.5px; }
.dialog { max-width: 440px; width: calc(100% - 32px); color: var(--ink); padding: 20px 22px; }
.dialog::backdrop { background: rgba(0, 0, 0, .55); }
.field { display: grid; gap: 6px; font-weight: 600; font-size: 14px; margin: 12px 0; }
.field select { min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface2); color: var(--ink); padding: 0 12px; font: 15px Figtree, sans-serif; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; }

@media (max-width: 700px) {
  .top { padding: 10px 16px; }
  .product .sub { display: none; }
  .updated { display: none; }
  #app { padding: 0 16px 40px; }
  .cols2, .cols3 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi .v { font-size: 22px; }
}
