/* IRIS — Investor Reporting and Integrity System
   Design tokens mirror ECHO / SORA / ATLAS so the suite is visually
   coherent. If a token here is changed, change it across the suite. */

:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --accent: #4f46e5;
  --accent-2: #6366f1;
  --accent-soft: #eef2ff;
  --ok: #10b981;
  --ok-soft: #ecfdf5;
  --warn: #f59e0b;
  --warn-soft: #fffbeb;
  --bad: #ef4444;
  --bad-soft: #fef2f2;
  --neutral: #94a3b8;
  --chip: #f1f5f9;
  /* Dark sidebar (matches ECHO/ATLAS/SORA pattern) */
  --sidebar-bg: #0b1220;
  --sidebar-text: #9ca3af;
  --sidebar-text-strong: #e5e7eb;
  --sidebar-section: #475569;
  --sidebar-hover-bg: rgba(255,255,255,0.05);
  --sidebar-active-bg: rgba(79,70,229,0.22);
  --sidebar-active-text: #c7d2fe;
  --sidebar-border: rgba(255,255,255,0.06);
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.04);
  --shadow-md: 0 1px 3px rgba(15,23,42,0.08), 0 1px 2px rgba(15,23,42,0.04);

  /* Severity tokens (kept distinct so the workbench colors don't drift) */
  --sev-critical: #b91c1c;
  --sev-error:    #d97706;
  --sev-warning:  #ca8a04;
  --sev-info:     #2563eb;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  background: var(--bg); color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; color: var(--text-2); }

/* ---------------- Shell layout ---------------- */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-right: 1px solid var(--sidebar-border);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
}
.brand {
  padding: 18px 18px 14px;
  display: flex; align-items: center; gap: 10px;
}
.brand-stacked {
  flex-direction: column; align-items: stretch; gap: 6px;
  padding: 12px 12px 6px;
}
.brand-logo-card {
  background: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.04);
}
.brand-logo-full {
  width: 100%; max-width: 168px; height: auto;
  display: block;
  /* Logo sits on a white card inside the dark sidebar so the dark-navy
     wordmark stays brand-correct without filters. */
}
.brand-stacked .brand-sub {
  font-size: 9px; color: #94a3b8;
  letter-spacing: 0.7px; line-height: 1.3;
  text-transform: uppercase; font-weight: 600;
  margin: 0;
  text-align: center;
}
.sidebar-divider {
  height: 1px; background: var(--sidebar-border); margin: 2px 10px;
}
.nav-section {
  padding: 8px 22px 2px;
  font-size: 9.5px; font-weight: 700;
  color: var(--sidebar-section);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}
.nav { padding: 0 0 2px; display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  margin: 0 10px;
  padding: 5px 14px;
  border-radius: 7px;
  color: #9ca3af;
  font-size: 12.5px; font-weight: 500;
  line-height: 1.35;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.nav a svg {
  width: 16px; height: 16px; flex-shrink: 0;
  stroke: currentColor; fill: none; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
  opacity: 0.85;
}
.nav a:hover {
  background: rgba(255,255,255,0.05);
  color: #e5e7eb;
  text-decoration: none;
}
.nav a:hover svg { opacity: 1; }
.nav a.active {
  background: linear-gradient(135deg, rgba(79,70,229,0.22), rgba(99,102,241,0.14));
  color: #c7d2fe;
  border-color: rgba(99,102,241,0.28);
}
.nav a.active svg { opacity: 1; color: #c7d2fe; }
.nav-badge {
  margin-left: auto; background: var(--bad); color: #fff;
  font-size: 10px; padding: 2px 7px; border-radius: 999px; font-weight: 700;
}
.sidebar-footer {
  margin-top: auto; padding: 10px 20px 12px;
  border-top: 1px solid var(--sidebar-border);
  font-size: 11.5px; color: #6b7280;
}
.tenant-name { color: #e5e7eb; font-weight: 600; font-size: 12px; }
.mode-pill {
  display: inline-block; margin-top: 6px; padding: 2px 9px; border-radius: 999px;
  font-size: 10px; background: rgba(79,70,229,0.18); color: #c7d2fe;
  letter-spacing: 0.6px; text-transform: uppercase; font-weight: 700;
}

/* Main column */
.main { display: flex; flex-direction: column; min-height: 100vh; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.topbar-title { font-size: 16px; font-weight: 700; color: var(--text); }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.who { font-size: 12px; color: var(--muted); }
.inline-form { margin: 0; display: inline; }
.content { padding: 22px 24px; flex: 1; }

/* ── Bell + notifications panel ─────────────────────────────────── */
.notif-wrap { position: relative; display: inline-flex; }
.notif-btn {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--panel-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); cursor: pointer;
  transition: all 0.12s; position: relative;
}
.notif-btn:hover { background: #fff; border-color: var(--accent); color: var(--accent); }
.notif-dot {
  position: absolute; top: -3px; right: -3px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--bad); color: #fff;
  border-radius: 999px; border: 2px solid #fff;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.notif-panel {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 380px; max-height: 480px;
  display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 18px 48px rgba(15,23,42,0.16), 0 4px 12px rgba(15,23,42,0.06);
  z-index: 1000; overflow: hidden;
}
.notif-panel[hidden] { display: none; }
.notif-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.notif-panel-title { font-size: 13px; font-weight: 700; color: var(--text); }
.notif-panel-link { font-size: 12px; color: var(--accent); font-weight: 600; }
.notif-panel-body { overflow-y: auto; flex: 1; padding: 4px 0; }
.notif-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 16px; border-bottom: 1px solid #f1f5f9;
  text-decoration: none; color: inherit;
  transition: background 0.1s;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--accent-soft); text-decoration: none; }
.notif-item-body { flex: 1; min-width: 0; }
.notif-item-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.notif-item-sub {
  font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.notif-empty {
  text-align: center; padding: 32px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.notif-empty-h { font-size: 13px; color: var(--text-2); font-weight: 600; }
.notif-empty-s { font-size: 12px; color: var(--muted); }
.notif-loading { color: var(--muted); font-size: 13px; padding: 24px; }

/* ---------------- Buttons / forms ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; font-size: 13px;
  border: 1px solid transparent; cursor: pointer; font-weight: 600;
  font-family: inherit;
  transition: all 0.12s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #4338ca);
  color: #fff; box-shadow: var(--shadow-sm);
}
.btn-primary:hover { box-shadow: 0 4px 14px rgba(79,70,229,0.35); transform: translateY(-1px); }
.btn-ghost {
  background: var(--panel); border-color: var(--border); color: var(--text-2);
}
.btn-ghost:hover {
  background: var(--accent-soft); border-color: #c7d2fe; color: var(--accent);
  text-decoration: none;
}

input, select, textarea {
  font: inherit; font-family: inherit;
  padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel); color: var(--text);
  transition: all 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}

.filter-bar {
  display: flex; gap: 8px; padding: 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  margin-bottom: 16px; flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}
.filter-bar input[type="search"] { min-width: 280px; }

/* ---------------- Cards / grids ---------------- */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.card-h {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 700; color: var(--text);
  border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 12px;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

/* KPIs (clickable when rendered as <a>) */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  display: block;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--accent);
  text-decoration: none; color: inherit;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
a.kpi:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(15,23,42,0.08), 0 2px 4px rgba(15,23,42,0.04);
}
a.kpi:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.kpi-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 22px; font-weight: 800; margin-top: 4px; color: var(--text); letter-spacing: -0.01em; }
.kpi.sev-critical { border-left-color: var(--sev-critical); }
.kpi.sev-error    { border-left-color: var(--sev-error); }
.kpi.sev-warning  { border-left-color: var(--sev-warning); }
.kpi.sev-info     { border-left-color: var(--sev-info); }

/* ---------------- Tables ---------------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl th {
  background: var(--panel-2); color: var(--text-2);
  font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  position: sticky; top: 0;
}
.tbl tr:hover td { background: var(--accent-soft); }
.tbl tr.row-clickable { cursor: pointer; }
.tbl tr.row-clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tbl tr.row-clickable:focus { outline: none; }
.tbl tr.row-clickable:focus-within td { background: var(--accent-soft); }
.tbl-dense th, .tbl-dense td { padding: 6px 8px; font-size: 12.5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.msg { max-width: 480px; }
.muted { color: var(--neutral); font-style: italic; }
.row-flag td { background: var(--warn-soft) !important; }

/* ---------------- Pills / severity ---------------- */
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px;
  background: var(--chip); color: var(--text-2); font-weight: 600; letter-spacing: 0.02em;
}
.sev-critical { background: var(--bad-soft); color: var(--sev-critical); }
.sev-error    { background: #ffedd5; color: var(--sev-error); }
.sev-warning  { background: #fef9c3; color: var(--sev-warning); }
.sev-info     { background: #dbeafe; color: var(--sev-info); }

.pill-open         { background: var(--bad-soft); color: var(--sev-critical); }
.pill-in_progress  { background: #fef9c3; color: var(--sev-warning); }
.pill-resolved     { background: var(--ok-soft); color: var(--ok); }
.pill-suppressed   { background: #e5e7eb; color: var(--muted); }
.pill-deferred     { background: #ede9fe; color: #6b21a8; }
.pill-running      { background: #dbeafe; color: var(--sev-info); }
.pill-complete     { background: var(--ok-soft); color: var(--ok); }
.pill-failed       { background: var(--bad-soft); color: var(--sev-critical); }
.pill-cancelled    { background: #e5e7eb; color: var(--muted); }
.pill-active       { background: var(--ok-soft); color: var(--ok); }
.pill-terminated   { background: #e5e7eb; color: var(--muted); }
.pill-in_liquidation { background: #fef9c3; color: var(--sev-warning); }
.pill-investor     { background: var(--accent-soft); color: var(--accent); }

/* ---------------- Detail KV lists ---------------- */
.kvlist { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; margin: 0; font-size: 13px; }
.kvlist dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.kvlist dd { margin: 0; font-weight: 500; color: var(--text); }
.kvlist-2 { grid-template-columns: 160px 1fr 160px 1fr; }
@media (max-width: 900px) { .kvlist-2 { grid-template-columns: 160px 1fr; } }

/* Variance form */
.vf { display: flex; flex-direction: column; gap: 10px; }
.vf label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.vf label > select, .vf label > input, .vf label > textarea { font-size: 13px; text-transform: none; letter-spacing: normal; color: var(--text); font-weight: 400; }

/* Aging dashboard (clickable when rendered as <a>) */
.aging-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.aging-grid > .aging-cell {
  display: block;
  padding: 14px 12px; background: var(--accent-soft); border-radius: 8px;
  text-align: center; text-decoration: none; color: inherit;
  border: 1px solid transparent;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.aging-grid > .aging-cell:hover {
  text-decoration: none;
  transform: translateY(-2px);
  border-color: rgba(79,70,229,0.25);
  box-shadow: 0 4px 12px rgba(15,23,42,0.06);
}
.aging-grid > .aging-cell:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.aging-grid .aging-stale { background: var(--bad-soft); }
.aging-grid > .aging-cell.aging-stale:hover { border-color: rgba(185,28,28,0.25); }
.aging-n { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -0.01em; }
.aging-l { font-size: 10.5px; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }

/* JSON code blocks */
pre.json {
  background: #0f172a; color: #e2e8f0;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 14px; font-size: 12.5px; line-height: 1.6; overflow: auto; max-height: 480px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Comments */
.comments { list-style: none; padding: 0; margin: 0; }
.comments li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.comment-h { margin-bottom: 4px; font-size: 12px; color: var(--muted); }

/* Bulk bar */
.bulk-bar {
  margin-top: 12px; padding: 14px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
  display: flex; flex-direction: column; gap: 12px;
}
.bulk-bar-row {
  display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap;
}
.bulk-count {
  display: inline-flex; align-items: center;
  padding: 6px 12px; border-radius: 999px;
  background: var(--chip); color: var(--muted);
  font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
  white-space: nowrap;
  height: 36px; box-sizing: border-box;
}
.bulk-count.bulk-count-active {
  background: var(--accent-soft); color: var(--accent);
}
.bulk-field {
  display: flex; flex-direction: column; gap: 4px;
  min-width: 180px;
}
.bulk-field[hidden] { display: none; }
.bulk-field.bulk-comment { flex: 1; min-width: 100%; }
.bulk-label {
  font-size: 10.5px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.bulk-field select, .bulk-field input {
  font-size: 13px; padding: 8px 12px; min-width: 0;
}
.bulk-bar .btn:disabled {
  opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none;
}
.bulk-bar .btn:disabled:hover { transform: none; box-shadow: none; }

/* Alerts */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.alert-error { background: var(--bad-soft); color: var(--sev-critical); border: 1px solid #fecaca; }

/* ── Inbound feed freshness tiles (sources page) ────────────────────── */
.freshness-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.freshness-tile {
  display: block; padding: 12px 14px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  border-left: 4px solid var(--neutral);
  text-decoration: none; color: inherit;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.freshness-tile:hover {
  transform: translateY(-1px); text-decoration: none;
  box-shadow: 0 4px 12px rgba(15,23,42,0.06);
}
.freshness-source {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px; color: var(--text); font-weight: 600;
}
.freshness-when {
  font-size: 18px; font-weight: 800; color: var(--text);
  margin-top: 4px; letter-spacing: -0.01em;
}
.freshness-meta {
  font-size: 11px; color: var(--muted); margin-top: 2px;
}
.freshness-failed { color: var(--bad); font-weight: 600; }
.freshness-fresh { border-left-color: var(--ok); }
.freshness-warn  { border-left-color: var(--warn); }
.freshness-stale { border-left-color: var(--bad); }
.freshness-stale .freshness-when { color: var(--bad); }
.freshness-never { opacity: 0.55; border-left-color: var(--neutral); }
.freshness-never .freshness-when { color: var(--muted); }

/* ── Pagination bar (shared partial) ────────────────────────────────── */
.pagination-bar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  padding: 10px 0;
  margin: 4px 0 12px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}
.pagination-info { color: var(--muted); }
.pagination-info strong { color: var(--text); font-weight: 700; }
.pagination-controls { display: flex; align-items: center; gap: 6px; }
.page-btn {
  display: inline-flex; align-items: center;
  padding: 5px 10px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--panel);
  color: var(--text-2); font-size: 12px; font-weight: 600;
  text-decoration: none;
  transition: all 0.12s;
  cursor: pointer;
}
.page-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}
.page-btn.disabled {
  opacity: 0.4; pointer-events: none; cursor: default;
}
.page-indicator {
  padding: 0 10px;
  font-size: 12.5px; color: var(--text-2);
}
.page-indicator strong { color: var(--text); font-weight: 700; }

/* ---------------- Module Hero (matches SORA's pattern in IRIS palette) ---------------- */
.module-hero {
  background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 100%);
  border: 1px solid #c7d2fe;
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 22px;
  display: flex; gap: 14px; align-items: flex-start;
}
.module-hero-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: rgba(79,70,229,0.15); color: var(--accent);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.module-hero-body { flex: 1; min-width: 0; }
.module-hero-eyebrow {
  font-size: 10.5px; font-weight: 700;
  color: var(--accent); text-transform: uppercase;
  letter-spacing: 0.6px; margin-bottom: 4px;
}
.module-hero-purpose { font-size: 13px; color: var(--text); line-height: 1.5; }
.module-hero-watch { font-size: 12px; color: var(--text-2); margin-top: 8px; line-height: 1.5; }
.module-hero-watch strong { color: var(--accent); font-weight: 700; margin-right: 4px; }
.module-hero-watch .hero-chip {
  display: inline-block;
  background: rgba(255,255,255,0.75); border: 1px solid rgba(79,70,229,0.22);
  border-radius: 5px; padding: 1px 7px;
  margin-right: 6px; margin-top: 3px; font-size: 11px; color: var(--text-2);
  font-weight: 500;
}
.module-hero-dismiss {
  background: transparent; border: none; color: var(--neutral);
  cursor: pointer; font-size: 18px; line-height: 1;
  padding: 2px 8px; border-radius: 4px; flex-shrink: 0;
}
.module-hero-dismiss:hover { background: rgba(0,0,0,0.05); color: var(--text-2); }
