/* Plain, light layout. Colour is reserved for the chart series
   (dataviz reference palette, validated for colour-blind separation). */
:root {
  color-scheme: light;
  --page: #ffffff;
  --panel: #ffffff;
  --text: #000000;
  --text-secondary: #333333;
  --text-muted: #555555;
  --line: #d4d4d4;
  --grid: #e6e6e6;
  --axis: #b5b5b5;
  --header: #f4f4f4;
  --link: #1f5fa8;
  --error: #b42318;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
  --unalloc-1: #8c8c8c; --unalloc-2: #bdbdbd; --other: #a6a6a6;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--page); }
body {
  color: var(--text);
  font: 13px/1.4 Arial, Helvetica, sans-serif;
}
.page { max-width: 1200px; margin: 0 auto; padding: 16px 24px 40px; }
h1 { font-size: 18px; font-weight: bold; margin: 0; }
h2 { font-size: 14px; font-weight: bold; margin: 0; }
p { margin: 0; }
.muted { color: var(--text-secondary); }
a { color: var(--link); }

.page-header {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 12px; margin-bottom: 16px; border-bottom: 1px solid var(--line);
}
.header-right { display: flex; gap: 12px; align-items: center; }

/* Buttons keep the browser's own look; only the font is matched to the page. */
button { font: inherit; }
button:disabled { cursor: progress; }
button.link { background: none; border: 0; padding: 0; color: var(--link); text-decoration: underline; cursor: pointer; }
.actions { display: flex; gap: 12px; align-items: center; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 1px; }

select, input[type="date"] {
  font: inherit; color: var(--text); background: #fff;
  border: 1px solid var(--line); border-radius: 2px; padding: 3px 6px;
}

.panel { border: 1px solid var(--line); background: var(--panel); padding: 14px 16px; margin: 0 0 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }

/* Filters */
.filters { display: grid; gap: 12px; }
fieldset { border: 0; margin: 0; padding: 0; }
legend { font-weight: bold; padding: 0; margin-bottom: 6px; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.checks .swatch { width: 10px; height: 10px; flex: none; }
.checks .note { color: var(--text-muted); }
.checks.column { flex-direction: column; flex-wrap: nowrap; align-items: flex-start; gap: 4px; max-height: 260px; overflow-y: auto; }
.client-group + .client-group { margin-top: 6px; }
.client-group-title { color: var(--text-muted); font-size: 12px; margin-bottom: 2px; }
.filters fieldset .actions { margin-top: 6px; }
.options { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; padding-top: 10px; border-top: 1px solid var(--grid); }
.options label { display: inline-flex; gap: 6px; align-items: center; }

/* Content */
#content { transition: opacity .15s; }
#content.loading { opacity: .5; }
.notice { border: 1px solid var(--error); color: var(--error); padding: 8px 12px; margin-bottom: 16px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
thead th { background: var(--header); border-bottom: 1px solid var(--line); font-weight: bold; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: bold; border-top: 1px solid var(--line); border-bottom: 0; }

.totals { border: 1px solid var(--line); margin-bottom: 16px; }
.totals th { background: var(--header); font-weight: 400; color: var(--text-secondary); width: 1%; white-space: nowrap; border-bottom: 0; }
.totals td { font-size: 18px; font-weight: bold; border-bottom: 0; text-align: left; }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 0; margin: 0 0 6px; }
.legend li { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: 13px; }
.legend .swatch, .report .swatch { width: 10px; height: 10px; flex: none; display: inline-block; }

.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart text { fill: var(--text-muted); font-size: 11px; font-family: Arial, Helvetica, sans-serif; font-variant-numeric: tabular-nums; }
.chart text.cap { fill: var(--text-secondary); }
.chart .hit { fill: transparent; }
.chart .col:hover .seg { opacity: .85; }
.chart .seg.active { opacity: 1 !important; filter: brightness(1.08); }
.empty { color: var(--text-secondary); padding: 40px 0; text-align: center; }

.tooltip {
  position: fixed; z-index: 10; pointer-events: none;
  background: #fff; color: var(--text); border: 1px solid var(--line);
  padding: 6px 8px; font-size: 13px; min-width: 160px; box-shadow: 0 2px 6px rgba(0, 0, 0, .12);
}
.tooltip .tt-period { color: var(--text-secondary); margin-bottom: 4px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; }
.tooltip .tt-key { width: 12px; height: 2px; flex: none; }
.tooltip .tt-value { font-weight: bold; }
.tooltip .tt-name { color: var(--text-secondary); }
.tooltip .tt-total { color: var(--text-secondary); margin-top: 4px; border-top: 1px solid var(--grid); padding-top: 4px; }

.report .client-cell { display: flex; align-items: center; gap: 8px; }
.report .tenancy { color: var(--text-muted); font-size: 12px; }
.report .comps { color: var(--text-secondary); font-size: 13px; }
.report details summary { cursor: pointer; color: var(--link); }
.report details ul { margin: 4px 0 0; padding-left: 18px; }
.report details li { font-variant-numeric: tabular-nums; }

.data-table { max-height: 360px; overflow: auto; margin-top: 10px; border: 1px solid var(--grid); }
.data-table thead th { position: sticky; top: 0; }

.login { max-width: 420px; display: grid; gap: 8px; }
.login input[type="password"] {
  font: inherit; border: 1px solid var(--line); border-radius: 2px; padding: 5px 6px; width: 100%;
}
.login button { justify-self: start; }
.login .notice { margin: 0; }

@media (max-width: 800px) {
  .page { padding: 12px; }
  .totals tr { display: grid; grid-template-columns: auto 1fr; }
}

/* Header navigation */
.header-left { display: flex; align-items: baseline; gap: 20px; }
nav a + a, .tabs button + button { border-left: 1px solid var(--axis); margin-left: 8px; padding-left: 8px; }
nav a[aria-current="page"] { color: var(--text); text-decoration: none; }

/* Setup page */
.tabs { margin-bottom: 12px; }
.tabs button { background: none; border: 0; padding: 0; color: var(--link); text-decoration: underline; cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--text); text-decoration: none; cursor: default; }
.toolbar, .inline-form { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; margin-bottom: 10px; }
.toolbar label, .inline-form label { display: inline-flex; gap: 6px; align-items: center; }
input[type="text"], input[type="search"] {
  font: inherit; color: var(--text); background: #fff; border: 1px solid var(--line); border-radius: 2px; padding: 3px 6px;
}
#add-client-bar { padding: 10px 16px; }
#add-client-bar .inline-form { margin: 0; }
.tab-panel > p.muted { margin-bottom: 10px; }
.report tr.unassigned td { background: #fff7e0; }
.report tr.muted td { color: var(--text-secondary); }
.actions-cell { white-space: nowrap; text-align: right; }
button.link:disabled { color: var(--text-muted); text-decoration: none; cursor: default; }
.subpanel { border: 1px solid var(--grid); padding: 10px 12px; margin-bottom: 14px; }
.subpanel h2 { margin-bottom: 4px; }
.tag-key { border-top: 1px solid var(--grid); padding: 6px 0; }
.tag-key summary { cursor: pointer; padding: 2px 0; }
.tag-key table { margin: 6px 0; }
.keybox { border: 1px solid #2e7d32; background: #f1f8f1; padding: 10px 12px; margin-bottom: 14px; display: grid; gap: 6px; }
.keybox code { font: 14px Consolas, "Courier New", monospace; background: #fff; border: 1px solid var(--line); padding: 3px 6px; user-select: all; word-break: break-all; }
.keybox .link { justify-self: start; }
.rename-box input[type="text"] { width: 260px; }
.merge-prompt { margin-top: 8px; padding: 8px 10px; border: 1px solid var(--line); background: var(--header); max-width: 420px; display: grid; gap: 6px; }
