/* ============================================================================
   CBRE Investment Sales Dashboard — styles
   Brand ink: CBRE Green #003F2D · Accent #17E88F · Sage #538184
   Categorical data palette (CVD-safe, Okabe-Ito): assigned per asset type in JS
   ========================================================================== */

:root {
  /* --- CBRE brand --- */
  --cbre-green: #003F2D;
  --cbre-green-700: #06422f;
  --cbre-green-600: #1a5c46;
  --cbre-accent: #17E88F;
  --cbre-sage: #538184;
  --cbre-sage-200: #cdddd8;

  /* --- surfaces & ink --- */
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #fbfcfb;
  --border: #e2e6e4;
  --border-strong: #cbd3d0;
  --ink: #14211c;
  --ink-2: #40514b;
  --ink-muted: #6d7c76;

  /* --- categorical (mirrored from app.js ASSET_COLORS) --- */
  --c-apartment: #009E73;
  --c-office: #0072B2;
  --c-retail: #E69F00;
  --c-industrial: #CC79A7;
  --c-resland: #56B4E9;
  --c-iciland: #D55E00;
  --c-other: #6b7280;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(16, 33, 28, .06), 0 1px 3px rgba(16, 33, 28, .05);
  --shadow-md: 0 4px 16px rgba(16, 33, 28, .08);
  --font: "Calibre", "Helvetica Neue", Helvetica, Arial, "Segoe UI", system-ui, sans-serif;
  --font-num: "Calibre", "Helvetica Neue", Arial, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------ white header --- */
.app-header {
  background: #fff;
  border-bottom: 5px solid var(--cbre-green);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.app-header .titles h1 { margin: 0; font-size: 23px; font-weight: 800; letter-spacing: .2px; color: var(--cbre-green); }
.app-header .titles p { margin: 3px 0 0; font-size: 12.5px; color: var(--ink-muted); }
.app-header .freshness {
  margin-left: auto; text-align: right; font-size: 11.5px; color: var(--ink-2); line-height: 1.5;
}
.app-header .freshness strong { color: var(--cbre-green); font-weight: 700; }

/* ------------------------------------------------------------------ tabs --- */
.tabs {
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20; box-shadow: var(--shadow-sm);
}
.tabs-inner {
  max-width: 1360px; margin: 0 auto; padding: 0 24px;
  display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none;
}
.tabs-inner::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  font-family: inherit; font-size: 13.5px; font-weight: 600; color: var(--ink-muted);
  background: none; border: none; border-bottom: 2.5px solid transparent;
  padding: 14px 16px; cursor: pointer; transition: color .15s, border-color .15s;
}
.tab svg { width: 16px; height: 16px; flex: none; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--cbre-green); border-bottom-color: var(--cbre-accent); }
.tab:focus-visible { outline: 2px solid var(--cbre-sage); outline-offset: -2px; border-radius: 4px; }

/* --------------------------------------------------------------- panels --- */
.tab-panel { animation: panel-in .2s ease-out; }
@keyframes panel-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- layout --- */
.wrap { max-width: 1360px; margin: 0 auto; padding: 20px 24px 60px; }

/* --------------------------------------------------------------- filters --- */
.filters {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow-sm); margin-bottom: 18px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-muted); font-weight: 600; }
.field select {
  font-family: inherit; font-size: 13.5px; color: var(--ink);
  padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); min-width: 150px; cursor: pointer;
}
.field select:focus { outline: 2px solid var(--cbre-sage); outline-offset: 1px; }
.field.range { flex-direction: row; align-items: flex-end; gap: 8px; }
.filters .spacer { margin-left: auto; }
.btn {
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  border-radius: var(--radius-sm); padding: 8px 14px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--ink-2);
}
.btn:hover { background: #eef1f0; }
.btn.primary { background: var(--cbre-green); color: #fff; border-color: var(--cbre-green); }
.btn.primary:hover { background: var(--cbre-green-600); }

/* ------------------------------------------------------------------ KPIs --- */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--cbre-green); }
.kpi .k-label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-muted); font-weight: 600; }
.kpi .k-value { font-family: var(--font-num); font-size: 30px; font-weight: 700; color: var(--cbre-green); margin: 6px 0 2px; line-height: 1; }
.kpi .k-sub { font-size: 12px; color: var(--ink-2); }

/* ----------------------------------------------------------------- cards --- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 18px 20px 20px; margin-bottom: 20px;
}
.card-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.card-head h2 { margin: 0; font-size: 16px; font-weight: 700; color: var(--ink); }
.card-head .sub { font-size: 12.5px; color: var(--ink-muted); }
.card-head .toggle-table {
  margin-left: auto; font-size: 12px; color: var(--cbre-sage); background: none; border: none;
  cursor: pointer; font-weight: 600; text-decoration: underline; text-underline-offset: 2px;
}
.grid-2 { display: grid; grid-template-columns: 1.55fr 1fr; gap: 20px; }

/* ---------------------------------------------------------------- legend --- */
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 6px 0 12px; }
.legend .item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.legend .swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }

/* --------------------------------------------------------------- svg bits --- */
.chart svg { width: 100%; height: auto; display: block; }
.axis-label { fill: var(--ink-muted); font-size: 11px; }
.axis-tick { fill: var(--ink-2); font-size: 11px; }
.grid-line { stroke: #eceeed; stroke-width: 1; }
.axis-line { stroke: var(--border-strong); stroke-width: 1; }
.bar-seg { stroke: var(--surface); stroke-width: 2; }        /* 2px surface gap */
.bar-label { fill: var(--ink-2); font-size: 10.5px; font-weight: 600; text-anchor: middle; }
.line-path { fill: none; stroke: var(--cbre-green); stroke-width: 2; }
.line-dot { fill: var(--cbre-green); stroke: var(--surface); stroke-width: 2; }
.panel-title { fill: var(--ink-muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

/* --------------------------------------------------------- horizontal bars --- */
.hbar-track { fill: #eef1f0; }
.hbar-bar { transition: opacity .12s; }
.hbar-bar:hover { opacity: .85; }
.hbar-label { fill: var(--ink-2); font-size: 12.5px; }
.hbar-value { fill: var(--ink); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------- tooltip --- */
.tooltip {
  position: fixed; pointer-events: none; z-index: 50; background: #0c1a15; color: #fff;
  border-radius: 6px; padding: 9px 11px; font-size: 12px; line-height: 1.5; box-shadow: var(--shadow-md);
  opacity: 0; transition: opacity .08s; max-width: 260px;
}
.tooltip .tt-title { font-weight: 700; margin-bottom: 4px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; }
.tooltip .tt-row .sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
.tooltip .tt-total { border-top: 1px solid #2b3d36; margin-top: 5px; padding-top: 4px; font-weight: 700; }

/* --------------------------------------------------------------- tables --- */
.data-table { display: none; margin-top: 12px; overflow-x: auto; }
.data-table.show { display: block; }
.data-table table { border-collapse: collapse; width: 100%; font-size: 12px; }
.data-table th, .data-table td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table thead th { color: var(--ink-muted); text-transform: uppercase; font-size: 10.5px; letter-spacing: .5px; background: var(--surface-2); position: sticky; top: 0; }
.data-table tfoot td { font-weight: 700; border-top: 2px solid var(--border-strong); }

/* -------------------------------------------------------------- donut kpi --- */
.donut-wrap { display: flex; align-items: center; gap: 20px; }
.donut-legend { display: flex; flex-direction: column; gap: 10px; }
.donut-legend .item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.donut-legend .swatch { width: 12px; height: 12px; border-radius: 3px; }
.donut-legend .lab { color: var(--ink-2); }
.donut-legend .val { font-weight: 700; color: var(--ink); margin-left: auto; padding-left: 18px; }
.donut-legend .pct { color: var(--ink-muted); font-size: 12px; width: 42px; text-align: right; }

/* --------------------------------------------------------------- footer --- */
.foot { color: var(--ink-muted); font-size: 11.5px; text-align: center; margin-top: 30px; line-height: 1.6; }
.notice { background: #fff8e8; border: 1px solid #f0dfae; color: #6b551d; border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 12px; margin-bottom: 16px; }

.empty { text-align: center; color: var(--ink-muted); padding: 40px 0; font-size: 13px; }

@media (max-width: 940px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .app-header .freshness { display: none; }
  .tabs-inner, .wrap { padding-left: 16px; padding-right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
