/* App0 accounting dashboard (styles shared with the NextGenPoker analytics dashboard). Dark only, matching nextgenerationpoker.com
   (page #181a1b, cards #232627). Chart colors validated with the dataviz
   validator on the card surface: brand green alone, and green + violet. */
:root {
  color-scheme: dark;
  --page: #181a1b;
  --surface-1: #232627;
  --text-primary: #e8e6e3;
  --text-secondary: #b9b6b0;
  --text-muted: #8f8b85;
  --grid: #33373a;
  --axis: #464b4e;
  --border: rgba(255, 255, 255, 0.08);
  --series-1: #28a745;          /* brand green */
  --series-2: #9085e9;          /* violet (validated pair with green) */
  --accent: #28a745;
  --meter-track: #1d3a24;       /* darker step of the green ramp */
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--text-primary); font-family: var(--font); }
body { line-height: 1.45; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; }
.brand strong { font-weight: 600; }
.logo { height: 28px; width: auto; }
.session { display: flex; align-items: center; gap: 14px; }

main { max-width: 1180px; margin: 0 auto; padding: 20px 24px 48px; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 0 0 4px; }
.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }

button { font: inherit; color: inherit; cursor: pointer; }
.btn-ghost {
  background: transparent; border: 1px solid var(--axis); border-radius: 6px; padding: 5px 12px;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.05); }

.tabs {
  display: flex; gap: 4px; margin: 0 0 14px; border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
.tabs a {
  padding: 8px 14px; color: var(--text-secondary); text-decoration: none; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--text-primary); }
.tabs a.selected { color: var(--text-primary); border-bottom-color: var(--accent); font-weight: 600; }
.revenue-tiles { margin-top: 12px; }
.years table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: 0.88rem; margin-top: 8px; }
.years th, .years td { text-align: right; padding: 4px 8px; border-bottom: 1px solid var(--grid); }
.years th:first-child, .years td:first-child { text-align: left; }
.years tfoot td { font-weight: 600; border-bottom: 0; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 18px; }
.filter-label { color: var(--text-muted); font-size: 0.85rem; margin-right: 4px; }
.filters button {
  background: transparent; border: 1px solid var(--border); border-radius: 6px;
  padding: 5px 12px; color: var(--text-secondary); font-size: 0.9rem;
}
.filters button:hover { background: rgba(255, 255, 255, 0.05); }
.filters button.selected { border-color: var(--accent); color: var(--text-primary); font-weight: 600; }

.kpis { display: grid; grid-template-columns: minmax(220px, 1fr) 3fr; gap: 14px; margin-bottom: 14px; }
.hero, .tile, .card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px;
}
.hero { padding: 18px 20px; }
.hero .label, .tile .label { color: var(--text-secondary); font-size: 0.9rem; }
.hero .value { font-size: 3.4rem; font-weight: 600; line-height: 1.1; margin: 6px 0 2px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.tile { padding: 14px 16px; }
.tile .value { font-size: 1.7rem; font-weight: 600; margin-top: 4px; }

.card { padding: 18px 20px; margin-bottom: 14px; }
.grid { display: grid; gap: 18px; margin-top: 12px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.funnel { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; }
.funnel li { display: grid; grid-template-columns: 190px 90px 1fr 70px; align-items: center; gap: 12px; }
.funnel .step { color: var(--text-secondary); }
.funnel .count { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.funnel .meter { height: 8px; background: var(--meter-track); border-radius: 4px; overflow: hidden; }
.funnel .meter > span { display: block; height: 100%; background: var(--series-1); border-radius: 4px; }
.funnel .rate { font-variant-numeric: tabular-nums; color: var(--text-secondary); text-align: right; }
.funnel .source { grid-column: 1 / -1; color: var(--text-muted); font-size: 0.78rem; margin: 4px 0 -2px; }

.chart { margin: 0; }
.chart figcaption { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chart .title { font-size: 0.92rem; color: var(--text-secondary); }
.chart .total { font-size: 0.92rem; font-weight: 600; }
.chart svg { display: block; width: 100%; height: auto; margin-top: 6px; overflow: visible; }
.chart .legend { display: flex; gap: 14px; font-size: 0.82rem; color: var(--text-secondary); margin-top: 4px; }
.chart .key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.chart .key.s1 { background: var(--series-1); }
.chart .key.s2 { background: var(--series-2); }
.chart details { margin-top: 6px; font-size: 0.82rem; }
.chart summary { color: var(--text-muted); cursor: pointer; }
.chart table { border-collapse: collapse; margin-top: 6px; width: 100%; font-variant-numeric: tabular-nums; }
.chart th, .chart td { text-align: right; padding: 2px 6px; border-bottom: 1px solid var(--grid); }
.chart th:first-child, .chart td:first-child { text-align: left; }
.empty { color: var(--text-muted); font-size: 0.85rem; padding: 30px 0; text-align: center; }

svg .grid-line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
svg .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
svg .tick { fill: var(--text-muted); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
svg .bar { fill: var(--series-1); }
svg .bar.s2 { fill: var(--series-2); }
svg .bar:hover, svg .hit:hover + .bar, svg .bar.active { filter: brightness(1.25); }
svg .hit { fill: transparent; }
svg .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg .area { fill: var(--series-1); fill-opacity: 0.1; }
svg .dot { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; }
svg .line.s2 { stroke: var(--series-2); }
svg .dot.s2 { fill: var(--series-2); }
svg .crosshair { stroke: var(--axis); stroke-width: 1; }

.tooltip {
  position: fixed; z-index: 10; pointer-events: none; background: #2d3133; border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 9px; font-size: 0.82rem; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.tooltip .tt-period { color: var(--text-muted); }
.tooltip .tt-row { display: flex; align-items: center; gap: 6px; }
.tooltip .tt-key { width: 12px; height: 2px; border-radius: 1px; }
.tooltip .tt-key.s1 { background: var(--series-1); }
.tooltip .tt-key.s2 { background: var(--series-2); }
.tooltip strong { font-weight: 600; }

.kpi-row { margin-bottom: 14px; }
.tile.negative .value { color: var(--text-primary); }
.badge { font-size: 0.85rem; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-secondary); }
.badge.ok { border-color: var(--accent); color: var(--text-primary); }
.badge.amber { border-color: #b8860b; color: var(--text-primary); }
.badge.red { border-color: #d61d28; color: var(--text-primary); font-weight: 600; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.toolbar .actions { display: flex; flex-wrap: wrap; gap: 8px; }
select { font: inherit; color: var(--text-primary); background: var(--page); border: 1px solid var(--axis); border-radius: 6px; padding: 4px 8px; margin-left: 6px; }
.statement { align-self: start; border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; margin-top: 10px; }
.statement td { padding: 5px 8px; border-bottom: 1px solid var(--grid); white-space: pre; }
.statement td:last-child { text-align: right; }
.statement tr.head td { color: var(--text-muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 0; padding-top: 14px; }
.statement tr.sub td { color: var(--text-secondary); }
.statement tr.total td { font-weight: 600; border-top: 1px solid var(--axis); border-bottom: 0; }
.bars li { grid-template-columns: 190px 110px 1fr 50px; }
.table-wrap { overflow-x: auto; margin-top: 10px; }
.txns { border-collapse: collapse; width: 100%; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.txns th { text-align: left; color: var(--text-muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--axis); }
.txns td { padding: 6px 8px; border-bottom: 1px solid var(--grid); }
.txns td:nth-child(2) { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txns th:last-child, .txns td:last-child { text-align: right; white-space: nowrap; }
.txns td.in { color: var(--text-primary); font-weight: 600; }
.txns tr.flag td { background: rgba(214, 29, 40, 0.12); }
.pill { margin-left: 8px; font-size: 0.72rem; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--axis); color: var(--text-secondary); }
.txns select { margin: 0; max-width: 220px; }
.txns td.label-cell { white-space: nowrap; }
.txns .revert { margin-left: 6px; padding: 1px 6px; font-size: 0.78rem; }
.pill.user { border-color: var(--accent); color: var(--text-primary); }
input[type="checkbox"] { accent-color: var(--accent); vertical-align: -2px; }
dialog { background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--axis); border-radius: 10px;
         padding: 18px 20px; width: min(420px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog .field { display: block; margin: 12px 0; color: var(--text-secondary); font-size: 0.9rem; }
dialog .field input, dialog .field select { display: block; width: 100%; margin: 4px 0 0; font: inherit; color: var(--text-primary);
         background: var(--page); border: 1px solid var(--axis); border-radius: 6px; padding: 6px 8px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.btn-primary { background: #095412; border: 1px solid #095412; color: #e8e6e3; border-radius: 6px; padding: 5px 12px; }
.btn-primary:hover { background: #0b6b17; }
#new-label-error { color: var(--text-primary); border-left: 3px solid #d61d28; padding-left: 8px; }
.txns tr.sep-q td { padding: 10px 8px 4px; font-size: 0.82rem; color: var(--text-muted); text-transform: uppercase;
                    letter-spacing: 0.04em; border-bottom: 1px solid var(--grid); }
.txns tr.sep-q td:last-child { text-align: right; }
#labels-list { max-height: 55vh; overflow-y: auto; margin-top: 8px; }
#labels-list:focus { outline: none; }
#labels-list h3 { font-size: 0.82rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 14px 0 4px; }
.label-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--grid); }
.label-row .name { flex: 1; }
.label-row button { padding: 2px 8px; font-size: 0.82rem; }
#labels-error { color: var(--text-primary); border-left: 3px solid #d61d28; padding-left: 8px; }
dialog#labels-dialog { width: min(520px, calc(100vw - 32px)); }
.notes { margin-top: 20px; }
.notes li { margin-bottom: 4px; }

@media (max-width: 760px) {
  .kpis { grid-template-columns: 1fr; }
  .funnel li { grid-template-columns: 1fr 70px 60px; }
  .funnel .meter { grid-column: 1 / -1; grid-row: 2; }
  main { padding: 16px; }
  .top { padding: 12px 16px; }
}
