/* ECOVATION — ui_kits/smart_bi/styles.css
 * Layout only. Every colour, size and radius comes from ../../colors_and_type.css.
 *
 * Charts use at most TWO categorical hues — --chart-1 and --chart-3.
 * That pair was validated: normal-vision ΔE 50.6, protan 38.9, tritan 36.2.
 * The full six-slot ramp fails adjacent separation (--chart-5 ↔ --chart-6 ΔE 7.1),
 * so never put more than two series in one chart here. Single-series charts carry
 * no legend; the title names them.
 */

body {
  background: var(--surface-1);
  font-family: var(--font-ui);
  color: var(--text-1);
  min-height: 100vh;
}

.app { display: flex; min-height: 100vh; }

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.side {
  width: var(--sidebar-w-expanded);
  flex: none;
  background: var(--surface-0);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.side__brand {
  height: var(--header-h); flex: none;
  padding: 0 var(--sp-4);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--sp-3);
}
.side__brand img { width: 28px; height: 28px; object-fit: contain; flex: none; }
.side__name { font-size: var(--fs-13); line-height: 1.2; font-weight: 700; color: var(--text-1); }
.side__kit {
  font-size: 10px; line-height: 1; font-weight: 600;
  letter-spacing: .10em; text-transform: uppercase;
  color: var(--text-3); margin-top: 3px;
}
.side__nav { flex: 1; overflow-y: auto; padding: var(--sp-2) 0 var(--sp-4); }
.side__group {
  padding: var(--sp-3) var(--sp-4) var(--sp-1);
  font-size: 10px; line-height: 1; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; color: var(--text-3);
}
.side__link {
  display: flex; align-items: center; gap: var(--sp-3);
  height: var(--h-md); padding: 0 var(--sp-4);
  font-size: var(--fs-13); font-weight: 500;
  color: var(--text-2); text-decoration: none;
  border-left: 3px solid transparent;
}
.side__link:hover { background: var(--surface-3); color: var(--text-1); }
.side__link svg { width: 17px; height: 17px; flex: none; }
.side__link[aria-current] {
  background: var(--primary-pale);
  border-left-color: var(--primary);
  color: var(--primary-text);
  font-weight: 600;
}
.side__foot {
  flex: none; padding: var(--sp-4);
  border-top: 1px solid var(--border);
  font-size: var(--fs-12); color: var(--text-3);
}
.side__foot a { color: var(--primary-text); }

/* ── Main column ────────────────────────────────────────────────────────── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.top {
  height: var(--header-h); flex: none;
  background: var(--surface-0);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-6);
  position: sticky; top: 0; z-index: var(--z-overlay);
}
.top__title {
  flex: 1; min-width: 0;
  font-family: var(--font-display);
  font-size: var(--fs-16); font-weight: 600; color: var(--text-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.top__search {
  display: flex; align-items: center; gap: var(--sp-2);
  width: 260px; height: var(--h-sm); padding: 0 var(--sp-3);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--fs-13); color: var(--text-3);
}
.top__search svg { width: 15px; height: 15px; flex: none; }
.top__icon {
  position: relative;
  width: 34px; height: 34px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-md);
  background: none; border: 0; cursor: pointer; color: var(--text-2);
}
.top__icon:hover { background: var(--surface-3); color: var(--text-1); }
.top__icon svg { width: 17px; height: 17px; }
.top__icon .dot {
  position: absolute; top: 7px; right: 7px;
  width: 6px; height: 6px; border-radius: var(--r-pill);
  background: var(--err);
}
.top__me {
  width: 30px; height: 30px; flex: none; border-radius: var(--r-pill);
  background: var(--primary-pale); border: 1px solid var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-12); font-weight: 700; color: var(--primary-text);
}

.content { flex: 1; padding: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-4); }
.page-note { font-size: var(--fs-12); color: var(--text-3); }

/* ── KPI row ────────────────────────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--sp-3); }
.kpi {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--sp-4);
  box-shadow: var(--shadow-card);
}
.kpi__head { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.kpi__icon {
  width: 30px; height: 30px; flex: none; border-radius: var(--r-sm);
  background: var(--surface-3); color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
}
.kpi__icon svg { width: 16px; height: 16px; }
.kpi__label { font-size: var(--fs-12); font-weight: 600; color: var(--text-2); }
.kpi__value {
  font-size: var(--fs-28); line-height: 1.1; font-weight: 700;
  letter-spacing: -.02em; color: var(--text-1);
}
.kpi__foot { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-2); }
.kpi__sub { font-size: var(--fs-12); color: var(--text-3); }
.delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: var(--fs-12); font-weight: 600;
}
.delta svg { width: 12px; height: 12px; }
.delta--up { color: var(--ok); }
.delta--down { color: var(--err); }

/* ── Card ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--sp-5);
  box-shadow: var(--shadow-card);
}
.card__head {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.card__title { font-size: var(--fs-14); font-weight: 700; color: var(--text-1); }
.card__sub { font-size: var(--fs-12); color: var(--text-3); margin-top: 2px; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.cols-3 { display: grid; grid-template-columns: 2fr 1fr; gap: var(--sp-4); }

/* ── Legend — always present for two series, never for one ──────────────── */
.legend { display: flex; align-items: center; gap: var(--sp-4); margin-left: auto; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-12); color: var(--text-2); }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .s1 { background: var(--chart-1); }
.legend .s2 { background: var(--chart-3); }

/* ── Column chart ───────────────────────────────────────────────────────── */
.plot { display: flex; gap: var(--sp-3); }
.plot__y {
  flex: none; width: 46px;
  display: flex; flex-direction: column; justify-content: space-between;
  font-size: var(--fs-12); color: var(--text-3); text-align: right;
  font-family: var(--font-mono);
  padding-bottom: 22px;      /* clears the x labels */
}
.plot__area { flex: 1; min-width: 0; position: relative; }
.plot__grid {
  position: absolute; left: 0; right: 0; top: 0; bottom: 22px;
  display: flex; flex-direction: column; justify-content: space-between;
  pointer-events: none;
}
.plot__grid i { height: 1px; background: var(--border-soft); }
.plot__grid i:last-child { background: var(--border); }
.cols {
  position: relative;
  height: var(--plot-h, 180px);
  display: flex; align-items: flex-end; gap: var(--sp-2);
}
.col { flex: 1; min-width: 0; height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.bar {
  position: relative;
  width: 14px; max-width: 46%;
  border-radius: 4px 4px 0 0;
  background: var(--chart-1);
  min-height: 2px;
}
.bar--s2 { background: var(--chart-3); }
.bar--wide { width: 30px; }
.col:hover .bar { outline: 2px solid var(--surface-2); outline-offset: 0; }

.tip {
  position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  padding: var(--sp-2) var(--sp-3);
  background: var(--navy); color: var(--text-on-primary);
  border-radius: var(--r-sm);
  font-size: var(--fs-12); line-height: 1.45; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease-out);
  z-index: var(--z-toast);
  box-shadow: var(--shadow-lg);
}
.col:hover .tip, .hbar:hover .tip { opacity: 1; }
.tip b { font-weight: 600; }

.plot__x {
  display: flex; gap: var(--sp-2);
  margin-top: 6px; height: 16px;
}
.plot__x span {
  flex: 1; min-width: 0; text-align: center;
  font-size: var(--fs-12); color: var(--text-3);
  font-family: var(--font-mono);
}

/* ── Horizontal bars — single hue, direct labels ────────────────────────── */
.hbars { display: flex; flex-direction: column; gap: var(--sp-3); }
.hbar { position: relative; }
.hbar__top {
  display: flex; align-items: baseline; gap: var(--sp-2);
  margin-bottom: 5px;
}
.hbar__name { font-size: var(--fs-13); color: var(--text-1); }
.hbar__val {
  margin-left: auto; font-family: var(--font-mono);
  font-size: var(--fs-12); color: var(--text-2);
}
.hbar__track { height: 10px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.hbar__fill { display: block; height: 100%; border-radius: var(--r-pill); background: var(--chart-1); min-width: 3px; }

/* ── Table view — the relief for the sub-3:1 contrast warning ───────────── */
details.table { margin-top: var(--sp-4); }
details.table > summary {
  font-size: var(--fs-12); font-weight: 600; color: var(--primary-text);
  cursor: pointer; list-style: none;
}
details.table > summary::-webkit-details-marker { display: none; }
details.table > summary::before { content: '▸ '; }
details.table[open] > summary::before { content: '▾ '; }

table { width: 100%; border-collapse: collapse; margin-top: var(--sp-3); }
th, td {
  text-align: left; padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-12); border-bottom: 1px solid var(--border-soft);
}
th { color: var(--text-3); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
td { color: var(--text-1); }
td.num, th.num { text-align: right; font-family: var(--font-mono); }
td.mid, th.mid { text-align: left; }
td.st,  th.st  { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }

/* ── Status pills & alert rows ──────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  height: 22px; padding: 0 var(--sp-2);
  border-radius: var(--r-pill);
  font-size: var(--fs-12); font-weight: 600; letter-spacing: .03em;
  white-space: nowrap;
}
.pill svg { width: 12px; height: 12px; }
.pill--ok   { background: var(--ok-soft);   color: var(--ok); }
.pill--info { background: var(--info-soft); color: var(--info); }
.pill--warn { background: var(--warn-soft); color: var(--warn); }
.pill--err  { background: var(--err-soft);  color: var(--err); }
.pill--idle { background: var(--surface-3); color: var(--text-2); }

.alerts { display: flex; flex-direction: column; }
.alert {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border-soft);
}
.alert:first-child { padding-top: 0; }
.alert:last-child { border-bottom: 0; padding-bottom: 0; }
.alert__icon {
  width: 30px; height: 30px; flex: none; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-3); color: var(--text-2);
}
.alert__icon svg { width: 16px; height: 16px; }
.alert__icon--warn { background: var(--warn-soft); color: var(--warn); }
.alert__icon--err  { background: var(--err-soft);  color: var(--err); }
.alert__icon--info { background: var(--info-soft); color: var(--info); }
.alert__body { flex: 1; min-width: 0; }
.alert__t { font-size: var(--fs-13); line-height: var(--lh-13); font-weight: 600; color: var(--text-1); }
.alert__s { font-size: var(--fs-12); line-height: 17px; color: var(--text-2); margin-top: 2px; }
.alert__when { font-size: var(--fs-12); color: var(--text-3); font-family: var(--font-mono); margin-top: 3px; }

/* ── Zero Trust gate — always L1 → L4 ───────────────────────────────────── */
.gate { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-3); }
.gate__layer {
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2); border: 1px solid var(--border);
  border-top: 3px solid var(--edge, var(--ok));
  border-radius: var(--r-sm);
}
.gate__layer--ok  { --edge: var(--ok); }
.gate__layer--warn { --edge: var(--warn); }
.gate__layer--err  { --edge: var(--err); }
.gate__id { font-family: var(--font-mono); font-size: var(--fs-12); color: var(--text-3); }
.gate__name { font-size: var(--fs-13); font-weight: 600; color: var(--text-1); margin: 4px 0 6px; }
.gate__src { font-size: var(--fs-12); line-height: 16px; color: var(--text-3); margin-top: 6px; }

@media (max-width: 1100px) {
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .gate { grid-template-columns: repeat(2, 1fr); }
}
