/* =============================================================================
 * PIE INVESTMENTS — ROIP PORTAL
 * Premium investor-style finance dashboard. Cool slate neutrals + restrained
 * Papa John's red used only as a focal accent for negative / brand callouts.
 * ============================================================================= */

:root {
  /* Surfaces — cool blue-greys with a faint cream warmth on the page */
  --bg:           #f4f3ef;        /* page background, faint warm parchment */
  --surface-1:    #ffffff;        /* primary card */
  --surface-2:    #fafaf7;        /* nested panels, table heads */
  --surface-3:    #f0eee8;        /* faint zones */
  --surface-ink:  #0f1a2c;        /* navy / ink — primary text */

  /* Ink ramp */
  --ink-1:        #0f1a2c;        /* headlines */
  --ink-2:        #2c3447;        /* body */
  --ink-3:        #5b6478;        /* secondary */
  --ink-4:        #8a92a3;        /* meta / captions */
  --ink-5:        #c9cdd5;        /* hairlines */

  /* Borders */
  --border:       #e4e2db;
  --border-strong:#cfccc1;

  /* Brand */
  --pie-red:      #c8281d;        /* deep, restrained — for negative states & focal accents */
  --pie-red-hi:   #e23a2d;        /* hover */
  --pie-red-soft: #fbe9e7;
  --pie-cream:    #f5e7b7;        /* warm dot, subtle highlight */

  /* Status (data viz) */
  --pos:          #1f7a4d;        /* deep green — pass / positive */
  --pos-soft:     #e3f1e8;
  --pos-mid:      #2f9c66;
  --warn:         #b86a14;        /* burnt amber */
  --warn-soft:    #fbeed8;
  --neg:          #c8281d;
  --neg-soft:     #fbe9e7;
  --info:         #29476b;        /* deep navy accent */

  /* Type */
  --font-sans: "Satoshi", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Radii / shadows / motion */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --shadow-1: 0 1px 0 rgba(15, 26, 44, 0.04), 0 1px 2px rgba(15, 26, 44, 0.04);
  --shadow-2: 0 1px 0 rgba(15, 26, 44, 0.04), 0 8px 24px -8px rgba(15, 26, 44, 0.10);
  --shadow-3: 0 1px 0 rgba(15, 26, 44, 0.04), 0 20px 40px -20px rgba(15, 26, 44, 0.18);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ---------------------------- base reset ---------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-feature-settings: "ss01", "ss02", "cv11";
  font-variant-numeric: tabular-nums lining-nums;
  background: var(--bg);
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { color: var(--ink-1); margin: 0; letter-spacing: -0.01em; }
h1 { font-weight: 600; font-size: 32px; line-height: 1.15; letter-spacing: -0.025em; }
h2 { font-weight: 600; font-size: 18px; }
h3 { font-weight: 600; font-size: 15px; }

a { color: inherit; text-decoration: none; }

button { font-family: inherit; }

.skip-link {
  position: absolute; top: -40px; left: 16px; background: var(--ink-1);
  color: #fff; padding: 8px 12px; border-radius: var(--r-sm); z-index: 100;
}
.skip-link:focus { top: 12px; }

/* =============================== TOPBAR =============================== */
.topbar {
  background: var(--surface-ink);
  color: #fff;
  border-bottom: 1px solid #1c2740;
}
.topbar__inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex; align-items: center;
  color: inherit;
}
.brand__wordmark { display: flex; flex-direction: column; line-height: 1.1; }
.brand__name {
  font-weight: 700; font-size: 13px; letter-spacing: 0.18em;
  text-transform: uppercase;
}
.brand__sub {
  font-size: 12px; color: #a8b1c4; margin-top: 2px;
  letter-spacing: 0.02em;
}

.topbar__meta {
  display: flex; align-items: center; gap: 24px;
  font-size: 12px; color: #a8b1c4;
}
.topbar__client {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 14px 6px 10px;
  background: #fff;
  border-radius: 999px;
  color: var(--ink-1);
}
.topbar__client img { height: 18px; width: auto; display: block; }
.topbar__client-name { font-size: 12px; font-weight: 700; color: var(--pie-red); letter-spacing: 0.02em; }

.topbar__meta-stack { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.topbar__meta-stack b { color: #fff; font-weight: 500; }

/* =============================== PAGE =============================== */
.page {
  max-width: 1320px;
  margin: 0 auto;
  padding: 32px 32px 80px;
}

/* =============================== HERO =============================== */
.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 32px 48px;
  align-items: end;
  padding: 4px 0 26px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}
.hero__eyebrow {
  grid-column: 1 / -1;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-4);
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 4px;
}
.hero__eyebrow::before {
  content: "";
  display: inline-block;
  width: 18px; height: 1px;
  background: var(--pie-red);
}
.hero__title {
  grid-column: 1;
  font-size: 44px;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.03em;
}
.hero__lede {
  grid-column: 1;
  font-size: 16px;
  color: var(--ink-3);
  max-width: 56ch;
  margin: 12px 0 0;
}
.hero__chips {
  grid-column: 2;
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end;
  align-self: end;
}
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
}
.chip__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-4); }
.chip--positive .chip__dot { background: var(--pos-mid); }
.chip--warning  .chip__dot { background: var(--warn); }
.chip--negative .chip__dot { background: var(--neg); }

/* =============================== SECTIONS =============================== */
.section { margin-bottom: 44px; }
.section__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}
.section__title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-1);
  position: relative;
  padding-bottom: 2px;
}
.section__title::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -10px;
  width: 32px; height: 2px;
  background: var(--pie-red);
}
.section__sub {
  font-size: 13px;
  color: var(--ink-4);
  margin: 0;
}

/* =============================== KPI GRID =============================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.kpi {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px 22px 18px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.kpi:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); }
.kpi::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--ink-5);
}
.kpi--positive::before { background: var(--pos-mid); }
.kpi--warning::before  { background: var(--warn); }
.kpi--negative::before { background: var(--pie-red); }

.kpi__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.kpi__value {
  font-size: 38px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--ink-1);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.kpi--positive .kpi__value { color: var(--pos); }
.kpi--warning  .kpi__value { color: var(--warn); }
.kpi--negative .kpi__value { color: var(--pie-red); }

.kpi__sub {
  font-size: 12px;
  color: var(--ink-4);
  margin-top: 8px;
}
.kpi__delta {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--pos);
  font-family: var(--font-mono);
}

/* =============================== MARKETS =============================== */
.market-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 16px;
}
.market {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 24px;
  position: relative;
}
.market__head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.market__name { font-size: 16px; font-weight: 600; }
.market__badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--ink-3);
}
.market--positive .market__badge { background: var(--pos-soft); color: var(--pos); }
.market--warning  .market__badge { background: var(--warn-soft); color: var(--warn); }
.market--negative .market__badge { background: var(--neg-soft);  color: var(--neg); }

.market__stats {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 20px 24px;
}
.stat__label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin-bottom: 6px;
}
.stat__value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink-1);
  font-variant-numeric: tabular-nums;
}
.stat--pos .stat__value { color: var(--pos); }
.stat--neg .stat__value { color: var(--pie-red); }

/* =============================== PORTFOLIO MAP =============================== */
.portfolio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 0.8fr);
  gap: 16px;
}
.panel--map { min-height: 520px; }
.map-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.portfolio-map {
  height: 390px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-3);
}
.portfolio-map .leaflet-control-attribution { font-size: 9px; }
.map-fallback {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--ink-4);
  font-size: 13px;
}
.portfolio-detail { min-height: 520px; }
.portfolio-detail__eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin-bottom: 8px;
}
.portfolio-detail__title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 18px;
}
.portfolio-detail__count {
  font-family: var(--font-mono);
  font-size: 64px;
  line-height: 0.95;
  font-weight: 600;
  color: var(--pie-red);
}
.portfolio-detail__sub {
  color: var(--ink-4);
  font-size: 13px;
  margin: 8px 0 24px;
}
.roip-mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
.roip-mini {
  border: 1px solid var(--border);
  border-left: 3px solid var(--ink-5);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
}
.roip-mini span {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin-bottom: 5px;
}
.roip-mini b {
  font-family: var(--font-mono);
  font-size: 20px;
  color: var(--ink-1);
}
.roip-mini--positive { border-left-color: var(--pos-mid); }
.roip-mini--positive b { color: var(--pos); }
.roip-mini--warning { border-left-color: var(--warn); }
.roip-mini--warning b { color: var(--warn); }
.roip-mini--negative { border-left-color: var(--pie-red); }
.roip-mini--negative b { color: var(--pie-red); }
.portfolio-facts {
  display: grid;
  grid-template-columns: 124px 1fr;
  gap: 10px 14px;
  padding: 18px 0;
  margin: 0 0 18px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.portfolio-facts dt {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-4);
}
.portfolio-facts dd {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
}
.portfolio-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.portfolio-tags span {
  display: inline-flex;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 12px;
  color: var(--ink-2);
}

/* =============================== PANELS =============================== */
.analysis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.duo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 22px;
}
.panel--flush { padding: 0; overflow: hidden; }
.panel--flush .panel__head { padding: 18px 22px; border-bottom: 1px solid var(--border); margin: 0; }

.panel__head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 18px;
}
.panel__title { font-size: 15px; font-weight: 600; }
.panel__hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-4);
  letter-spacing: 0.04em;
}
.panel__hint.positive { color: var(--pos); }
.panel__hint.negative { color: var(--pie-red); }

/* =============================== HISTOGRAM =============================== */
.histogram {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  align-items: end;
  height: 220px;
  padding-top: 8px;
}
.hist {
  display: flex; flex-direction: column; align-items: stretch;
  gap: 8px;
  height: 100%;
}
.hist__bar-wrap {
  flex: 1;
  display: flex; align-items: flex-end;
  background: var(--surface-3);
  border-radius: 4px;
  overflow: hidden;
}
.hist__bar {
  width: 100%;
  background: var(--ink-5);
  border-radius: 3px 3px 0 0;
  transition: height 0.7s var(--ease);
  position: relative;
  min-height: 4px;
}
.hist__count {
  position: absolute; top: -22px; left: 0; right: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}
.hist--positive  .hist__bar { background: var(--pos-mid); }
.hist--excellent .hist__bar { background: var(--pos); }
.hist--neutral   .hist__bar { background: var(--info); }
.hist--warning   .hist__bar { background: var(--warn); }
.hist--negative  .hist__bar { background: var(--pie-red); }

.hist__meta {
  text-align: center;
}
.hist__range {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-2);
  letter-spacing: 0.03em;
}
.hist__label {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin-top: 2px;
}

/* =============================== CHART WRAP =============================== */
.chart-wrap {
  position: relative;
  height: 220px;
  width: 100%;
}

/* =============================== LEGEND =============================== */
.legend {
  display: flex; gap: 16px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.legend__item {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px;
  color: var(--ink-3);
}
.legend__swatch {
  width: 10px; height: 10px; border-radius: 2px;
}

/* =============================== TABLES =============================== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-4);
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.panel:not(.panel--flush) .data-table thead th:first-child { padding-left: 0; }
.panel:not(.panel--flush) .data-table thead th:last-child { padding-right: 0; }
.panel:not(.panel--flush) .data-table thead th { background: transparent; }

.data-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--ink-2);
  vertical-align: middle;
}
.panel:not(.panel--flush) .data-table tbody td:first-child { padding-left: 0; }
.panel:not(.panel--flush) .data-table tbody td:last-child  { padding-right: 0; }

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.15s var(--ease); }
.data-table tbody tr:hover { background: var(--surface-2); }

.data-table th.num,
.data-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table--compact tbody td { padding: 10px 16px; }
.data-table--log { min-width: 920px; }

.store-id {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12px;
  color: var(--ink-1);
  letter-spacing: 0.02em;
}
.score-cell {
  font-family: var(--font-mono);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.score-cell--pos { color: var(--pos); }
.score-cell--mid { color: var(--warn); }
.score-cell--neg { color: var(--pie-red); }

.market-pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--ink-3);
  letter-spacing: 0.02em;
}

.result-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}
.result-pill--pass { background: var(--pos-soft); color: var(--pos); }
.result-pill--fail { background: var(--neg-soft); color: var(--neg); }
.result-pill::before {
  content: "";
  width: 5px; height: 5px; border-radius: 50%; background: currentColor;
}

.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.status-pill--overdue  { background: var(--neg-soft); color: var(--pie-red); }
.status-pill--urgent   { background: var(--warn-soft); color: var(--warn); }
.status-pill--ontrack  { background: var(--pos-soft); color: var(--pos); }

.issues-list {
  padding: 16px 0 0;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.issues-list__head {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin-bottom: 8px;
}
.issues-list__items {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.5;
}
.issues-list__items li::before {
  content: "—";
  color: var(--pie-red);
  margin-right: 8px;
  font-weight: 600;
}

/* =============================== TOOLBAR =============================== */
.table-toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.search {
  flex: 1;
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-1);
  padding: 9px 14px;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 13px;
  color: var(--ink-2);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.search:focus {
  outline: none;
  border-color: var(--ink-1);
  box-shadow: 0 0 0 3px rgba(15, 26, 44, 0.08);
}
.filters {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.filter-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-1);
  padding: 7px 12px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.filter-btn:hover { color: var(--ink-1); border-color: var(--border-strong); }
.filter-btn.is-active {
  background: var(--ink-1);
  color: #fff;
  border-color: var(--ink-1);
}

.table-scroll { overflow-x: auto; }

.table-footer {
  padding: 12px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--ink-4);
}

/* =============================== FOOTER =============================== */
.footer {
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  gap: 24px;
  font-size: 12px;
  color: var(--ink-4);
}
.footer .dot { margin: 0 8px; color: var(--ink-5); }

/* =============================== RESPONSIVE =============================== */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .analysis-grid, .duo-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar__inner { padding: 14px 20px; flex-wrap: wrap; }
  .page { padding: 24px 20px 56px; }
  .hero { grid-template-columns: 1fr; }
  .hero__title { font-size: 32px; }
  .hero__chips { justify-content: flex-start; grid-column: 1; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 18px; }
  .kpi__value { font-size: 30px; }
  .market { padding: 18px; }
  .topbar__meta { font-size: 11px; gap: 12px; }
  .topbar__client { padding: 4px 10px 4px 8px; }
  .table-toolbar { flex-direction: column; align-items: stretch; }
  .footer { flex-direction: column; align-items: flex-start; }
  .section__head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .section__sub { font-size: 12px; }
}
@media (max-width: 460px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .market__stats { grid-template-columns: 1fr 1fr; gap: 14px; }
}
