/* KYE Cloud + Admin shared dashboard CSS — tier-1-bank-grade chrome.
   Layered on top of the surface-specific assets/styles.css of each
   subdomain (app.* uses teal accent, admin.* uses purple).

   Adds:
   - sidebar layout
   - data tables, filterbars
   - drill-down side panels
   - SVG graph editor canvas
   - tab nav
   - mobile responsive overrides
*/

:root {
  --side: 240px;
  --pad: 22px;
}

/* ---------- App shell: sidebar + content ---------- */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: calc(100vh - 56px); }
.side {
  background: var(--paper);
  border-right: 1px solid var(--line);
  padding: 18px 0;
  position: sticky; top: 56px; align-self: start;
  height: calc(100vh - 56px); overflow-y: auto;
}
.side-group { padding: 0 14px 8px; }
.side-group-title {
  font-size: var(--type-11); text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-dim); margin: 10px 8px 6px; font-weight: 700;
}
.side a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 8px; color: var(--text-muted);
  font-size: var(--type-13); font-weight: 500; margin: 1px 0;
}
.side a:hover { background: var(--paper-2); color: var(--text); text-decoration: none; }
.side a.active { background: var(--accent-soft); color: var(--accent-2); }
.side a .ic {
  width: 18px; height: 18px; opacity: 0.8;
  display: inline-grid; place-items: center; font-size: var(--type-13);
}
.content { padding: 22px 28px 60px; max-width: 1200px; margin: 0 auto; width: 100%; }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: static; height: auto; padding: 10px 0;
    border-right: 0; border-bottom: 1px solid var(--line);
    display: flex; overflow-x: auto; overflow-y: hidden; gap: 4px;
  }
  .side-group { padding: 0 8px; flex-shrink: 0; }
  .side-group-title { display: none; }
  .side a { white-space: nowrap; padding: 6px 12px; }
  .content { padding: 18px 14px 60px; }
}

/* ---------- Breadcrumb ---------- */
.crumb {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: var(--type-12); color: var(--text-dim); margin-bottom: 14px;
}
.crumb a { color: var(--text-muted); }
.crumb .sep { color: var(--text-dim); opacity: 0.6; }
.crumb .here { color: var(--text); }

/* ---------- Tab nav ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a, .tabs button {
  background: none; border: 0; padding: 9px 14px;
  color: var(--text-muted); font-size: var(--type-13); font-weight: 500;
  border-bottom: 2px solid transparent; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.tabs a:hover, .tabs button:hover { color: var(--text); }
.tabs a.active, .tabs button.active {
  color: var(--accent-2); border-bottom-color: var(--accent);
}

/* ---------- Filterbar ---------- */
.filterbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 12px; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 14px;
}
.filterbar input.kye, .filterbar select.kye { min-width: 160px; }
.filterbar label { font-size: var(--type-11); color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }

/* ---------- KPI strip ---------- */
.kpi-strip { display: grid; gap: 14px; grid-template-columns: repeat(4, 1fr); margin-bottom: 22px; }
@media (max-width: 900px) { .kpi-strip { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .kpi-strip { grid-template-columns: 1fr; } }
.kpi { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.kpi .lbl { font-size: var(--type-11); text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: 6px; }
.kpi .val { font-size: var(--type-28); font-weight: 700; letter-spacing: -0.02em; }
/* F12 — token-driven semantic colour for KPI values (was inline-hex). */
.kpi .val.val-ok   { color: var(--success); }
.kpi .val.val-warn { color: var(--warning); }
.kpi .val.val-bad  { color: var(--danger); }
.kpi .sub { font-size: var(--type-12); color: var(--text-muted); margin-top: 4px; }

/* ---------- Side drawer / drill-down ---------- */
.drawer-mask {
  position: fixed; inset: 0; background: var(--scrim, color-mix(in srgb, #000 55%, transparent));
  z-index: 50; display: none;
}
.drawer-mask.open { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(640px, 100%);
  background: var(--paper); border-left: 1px solid var(--line);
  z-index: 51; transform: translateX(100%); transition: transform 0.18s ease;
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.drawer-head h3 { margin: 0; font-size: var(--type-16); font-weight: 700; }
.drawer-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.x-btn { background: transparent; border: 0; color: var(--text-muted); font-size: var(--type-18); cursor: pointer; padding: 0 6px; }
.x-btn:hover { color: var(--text); }

.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; font-size: var(--type-13); }
.kv dt { color: var(--text-dim); font-weight: 500; }
.kv dd { margin: 0; color: var(--text); font-family: var(--mono); font-size: var(--type-12); word-break: break-all; }

/* ---------- SVG Graph editor (Operating Model authoring) ---------- */
.graph-wrap {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  display: grid; grid-template-columns: 1fr 280px;
}
@media (max-width: 980px) { .graph-wrap { grid-template-columns: 1fr; } }
.graph-canvas {
  width: 100%; height: 560px; background:
    radial-gradient(circle at 1px 1px, var(--line-soft) 1px, transparent 0);
  background-size: 18px 18px;
  cursor: crosshair;
}
.graph-canvas .node-rect {
  fill: var(--paper-2); stroke: var(--accent); stroke-width: 1.5;
  cursor: grab;
}
.graph-canvas .node-rect.selected { stroke: var(--accent-2); stroke-width: 2.5; filter: drop-shadow(0 0 6px var(--accent)); }
.graph-canvas .node-label { fill: var(--text); font-family: var(--sans); font-size: var(--type-12); font-weight: 600; pointer-events: none; }
.graph-canvas .node-sub { fill: var(--text-muted); font-family: var(--mono); font-size: var(--type-11); pointer-events: none; }
.graph-canvas .edge { fill: none; stroke: var(--accent-2); stroke-width: 1.5; opacity: 0.7; marker-end: url(#arrow); }
.graph-canvas .edge-drag { stroke: var(--warning); stroke-dasharray: 4 3; }
.graph-side {
  padding: 16px; border-left: 1px solid var(--line);
  background: var(--paper-2); overflow-y: auto; max-height: 560px;
}
.graph-toolbar { display: flex; gap: 6px; padding: 10px; border-bottom: 1px solid var(--line); background: var(--paper-2); flex-wrap: wrap; }
.graph-toolbar button { font-size: var(--type-12); padding: 5px 10px; }

/* ---------- Status banner / auth wall ---------- */
.auth-wall {
  max-width: 460px; margin: 80px auto; padding: 40px 36px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px;
  text-align: center;
}
.auth-wall .seal {
  width: 64px; height: 64px; border-radius: 16px;
  margin: 0 auto 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: var(--surface-solid); font-weight: 800; font-size: var(--type-28);
}
.auth-wall h1 { font-size: var(--type-22); margin: 0 0 6px; }
.auth-wall p { color: var(--text-muted); font-size: var(--type-13); margin: 0 0 16px; }
.auth-wall .auth-list { text-align: left; margin: 16px 0 20px; padding: 14px 16px; background: var(--paper-2); border-radius: 10px; font-size: var(--type-12); color: var(--text-muted); }
.auth-wall .auth-list li { margin: 4px 0; }
.auth-wall button.kye { width: 100%; padding: 11px 14px; font-size: var(--type-14); }
.auth-wall .clerk-mount { margin-top: 18px; }
.auth-wall .clerk-mount:empty { margin-top: 0; }
.auth-wall .mfa-row { font-size: var(--type-11); color: var(--text-dim); margin-top: 12px; display: flex; gap: 6px; justify-content: center; align-items: center; }

/* ---------- Misc ---------- */
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions button { font-size: var(--type-11); padding: 4px 9px; }
.hint { font-size: var(--type-11); color: var(--text-dim); margin-top: 6px; }
.tag { display: inline-block; padding: 2px 8px; background: var(--paper-3); color: var(--text-muted); border-radius: 6px; font-family: var(--mono); font-size: var(--type-11); }
.empty {
  padding: 40px; text-align: center; background: var(--paper);
  border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--text-muted);
}
.spark { display: inline-block; height: 28px; width: 100px; vertical-align: middle; }

/* F7 — inline status banner above the SSO submit button. Replaces
   the browser's native validation popup when required consent ticks
   are missing. Live region (aria-live=polite) is set on the element. */
.signin-consent-status[hidden] { display: none; }
.signin-consent-status {
  display: block;
  margin: 0 0 10px;
  padding: 8px 12px;
  font-size: var(--type-12);
  font-weight: 600;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.30);
  border-radius: 8px;
  line-height: 1.4;
}

/* Decision Map mini-viewer */
.dmap { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.dmap-step {
  display: grid; grid-template-columns: 28px 1fr; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.dmap-step:last-child { border-bottom: 0; }
.dmap-step .dot { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-2); display: grid; place-items: center; font-size: var(--type-11); font-weight: 700; }
.dmap-step .label { font-weight: 600; }
.dmap-step .body { color: var(--text-muted); font-size: var(--type-12); margin-top: 2px; }

/* Behaviour table editor */
.beh-edit input.kye, .beh-edit select.kye, .beh-edit textarea.kye { width: 100%; }
.beh-edit textarea.kye { min-height: 60px; }
.beh-edit td { vertical-align: top; }

/* Bars (cheap chart) */
.bar { height: 6px; background: var(--paper-3); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }

/* Code-block JSON */
.json-block {
  background: var(--surface-3); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; font-size: var(--type-12);
  white-space: pre-wrap; word-break: break-all; max-height: 360px; overflow: auto;
  font-family: var(--font-mono);
}

/* ---------- Compliance heatmap matrix ---------- */
.heat { width: 100%; border-collapse: collapse; font-size: var(--type-12); }
.heat th, .heat td { padding: 8px 10px; border: 1px solid var(--line); text-align: left; }
.heat th { background: var(--paper-2); color: var(--text-dim); text-transform: uppercase; font-size: var(--type-11); letter-spacing: 0.06em; }
.heat td.cover { text-align: center; font-weight: 700; }
.heat td.cv-full { background: var(--success-soft); color: var(--success); }
.heat td.cv-part { background: var(--warning-soft); color: var(--warning); }
.heat td.cv-none { background: var(--danger-soft);  color: var(--danger); }
.heat td.cv-na   { background: var(--surface-2);    color: var(--text-dim); }
