:root {
  --ink: #12192B;
  --ink-soft: #4A5468;
  --paper: #F6F5F1;
  --panel: #FFFFFF;
  --line: #DFDCD3;
  --brand: #1F3A5F;
  --brand-soft: #EFF3F8;

  --risk-critical: #8C1D2B;
  --risk-veryhigh: #C24A2C;
  --risk-high: #D98A2B;
  --risk-medium: #C9A227;
  --risk-low: #3D7A5C;
  --risk-unmapped: #9C97A8;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, 'Helvetica Neue', Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
}
button { font-family: inherit; }
table { border-collapse: collapse; width: 100%; }

/* ---------- Header ---------- */
.app-header {
  background: var(--ink);
  color: #fff;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.app-header-brand { display: flex; align-items: center; gap: 12px; }
.app-header-logo {
  width: 34px; height: 34px; border-radius: 8px; background: #2A4670;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.app-header-title { font-weight: 700; font-size: 15.5px; font-family: Georgia, serif; }
.app-header-sub { font-size: 11.5px; color: #B7C0D4; margin-top: 2px; }
.btn-primary {
  background: #2A4670; color: #fff; border: none; border-radius: 8px;
  padding: 9px 16px; font-size: 13px; font-weight: 700; display: inline-flex;
  align-items: center; gap: 7px; cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.08); }

/* ---------- Upload screen ---------- */
.upload-screen { max-width: 760px; margin: 0 auto; padding: 60px 20px; }
.section-heading { margin-bottom: 18px; }
.section-eyebrow { font-size: 12px; font-weight: 700; color: var(--brand); margin-bottom: 4px; }
.section-title { font-size: 20px; font-weight: 700; color: var(--ink); margin: 0; font-family: Georgia, 'Iowan Old Style', serif; }
.section-desc { font-size: 13.5px; color: var(--ink-soft); margin-top: 6px; max-width: 640px; }

.upload-slot {
  border: 1.5px dashed var(--line);
  border-radius: 12px; padding: 26px 22px; cursor: pointer; background: var(--panel);
  display: flex; gap: 16px; align-items: flex-start; transition: border-color .15s;
}
.upload-slot.ok { border-color: #3D7A5C88; background: #F3F8F5; }
.upload-slot.error { border-color: #8C1D2B66; }
.upload-slot-icon {
  width: 40px; height: 40px; border-radius: 9px; background: var(--brand-soft);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 18px;
}
.upload-slot.ok .upload-slot-icon { background: #DDEEE3; }
.upload-slot-label { font-weight: 700; font-size: 14.5px; color: var(--ink); }
.upload-slot-desc { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; }
.upload-slot-status { font-size: 12.5px; margin-top: 8px; font-weight: 600; }
.upload-slot-status.ok { color: #2C6B4A; }
.upload-slot-status.error { color: #8C1D2B; }
.upload-slot-hint { font-size: 12px; margin-top: 8px; color: var(--brand); font-weight: 600; }
.link-btn { background: none; border: none; color: var(--brand); font-weight: 700; cursor: pointer; padding: 0; font-size: 12.5px; }
.link-btn.soft { color: var(--ink-soft); }

.notice-banner {
  margin-top: 22px; background: #FBEFD9; border: 1px solid #E8CE94; border-radius: 10px;
  padding: 14px 16px; display: flex; gap: 10px; font-size: 13px; color: #5C3D0A;
}
.notice-banner.inline { margin: 0 0 20px; align-items: center; }

/* ---------- Layout ---------- */
.app-body { display: flex; }
.sidebar {
  width: 232px; flex-shrink: 0; border-right: 1px solid var(--line);
  min-height: calc(100vh - 70px); padding: 18px 10px; background: var(--panel);
}
.nav-item {
  width: 100%; text-align: left; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; border: none; background: transparent;
  color: var(--ink-soft); font-weight: 500; font-size: 13.5px; cursor: pointer; margin-bottom: 2px;
}
.nav-item .icon { font-size: 15px; width: 18px; text-align: center; }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.sidebar-footer {
  margin-top: 18px; padding: 10px 12px; font-size: 11.5px; color: var(--ink-soft);
  border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px;
}
.main-content { flex: 1; padding: 26px 32px; min-width: 0; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Cards / stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.stat-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 18px 20px; min-width: 0;
}
.stat-label { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; letter-spacing: .2px; margin-bottom: 8px; }
.stat-value { font-size: 30px; font-weight: 700; color: var(--ink); line-height: 1; }
.stat-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 6px; }

.tri-stat-line {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 20px; display: flex; align-items: center;
}
.tri-stat-item { display: flex; align-items: baseline; gap: 8px; flex: 1; min-width: 0; }
.tri-stat-value { font-size: 24px; font-weight: 700; line-height: 1; }
.tri-stat-label { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; white-space: nowrap; }
.tri-stat-divider { width: 1px; align-self: stretch; background: var(--line); margin: 0 22px; }

.pill { background: #EEECE4; color: var(--ink-soft); font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 5px; white-space: nowrap; display: inline-block; }
.pill-good { background: #E4EFE8; color: #2C6B4A; }
.pill-bad { background: #F6E4E1; color: #8C1D2B; }
.pill-warn { background: #FBEFD9; color: #8A5A0A; }
.risk-pill { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 5px; white-space: nowrap; border: 1px solid; display: inline-block; }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 24px; color: var(--ink-soft); text-align: center; gap: 8px; }
.empty-state-icon { font-size: 28px; }
.empty-state-title { font-weight: 600; color: var(--ink); font-size: 14.5px; }
.empty-state-body { font-size: 13px; max-width: 380px; }

.chart-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 18px 8px; }
.chart-card-title { font-weight: 700; font-size: 14px; color: var(--ink); margin-bottom: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2b { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; }

/* ---------- Bars / donut (pure CSS charts) ---------- */
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.bar-row-label { width: 130px; font-size: 11.5px; color: var(--ink-soft); text-align: right; flex-shrink: 0; }
.bar-row-track { flex: 1; background: #EEF1F4; border-radius: 3px; height: 16px; overflow: hidden; }
.bar-row-fill { height: 100%; }
.bar-row-value { width: 46px; font-size: 11.5px; font-weight: 700; text-align: right; }

.donut { border-radius: 50%; flex-shrink: 0; }
.legend-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; flex-shrink: 0; }
.legend-label { width: 80px; font-size: 12.5px; }
.legend-track { flex: 1; background: #EEF1F4; border-radius: 2px; height: 10px; overflow: hidden; }
.legend-fill { height: 100%; }
.legend-count { width: 28px; font-size: 12.5px; text-align: right; }

/* ---------- Tables ---------- */
.panel-table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.table-toolbar { display: flex; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.search-box { display: flex; align-items: center; gap: 8px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; flex: 1 1 220px; }
.search-box input { border: none; outline: none; background: transparent; font-size: 13px; width: 100%; color: var(--ink); }
.select-box { font-size: 13px; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: var(--paper); color: var(--ink); }
.data-table { width: 100%; border-collapse: collapse; min-width: 900px; }
.data-table thead { background: var(--paper); }
.data-table th { text-align: left; padding: 10px 14px; font-size: 11.5px; color: var(--ink-soft); font-weight: 700; letter-spacing: .3px; white-space: nowrap; }
.data-table th.sortable { cursor: pointer; }
.data-table td { padding: 10px 14px; font-size: 13px; border-top: 1px solid var(--line); }
.table-scroll { overflow-x: auto; }
.process-link { border: none; background: none; color: var(--brand); font-size: 12.5px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 2px; }

/* ---------- Drawer ---------- */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(18,25,43,.4); z-index: 50;
  display: none; justify-content: flex-end;
}
.drawer-overlay.open { display: flex; }
.drawer-panel {
  width: min(560px, 94vw); height: 100%; background: var(--panel); overflow-y: auto;
  box-shadow: -12px 0 30px rgba(0,0,0,.15);
}
.drawer-header {
  padding: 20px 24px; border-bottom: 1px solid var(--line); display: flex;
  justify-content: space-between; align-items: flex-start; position: sticky; top: 0; background: var(--panel);
}
.drawer-close { border: none; background: var(--paper); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 14px; }
.drawer-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 22px; }
.drawer-section-title { font-weight: 700; font-size: 13.5px; margin-bottom: 8px; }

/* ---------- Findings / recommendations ---------- */
.finding-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin-bottom: 8px; }
.finding-head { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.finding-cat { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.finding-text { font-size: 13px; color: var(--ink); }

/* ---------- Report tab ---------- */
.report-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; max-width: 520px; }

@media (max-width: 900px) {
  .app-body { flex-direction: column; }
  .sidebar { width: 100%; min-height: auto; display: flex; flex-wrap: wrap; }
  .nav-item { width: auto; }
  .grid-2, .grid-2b { grid-template-columns: 1fr; }
  .data-table { min-width: 700px; }
}

/* ---------- Output Validation Tester tab (added, scoped with .vt- prefix) ---------- */
.vt-panel { }
.vt-review-btn {
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--brand);
  cursor: pointer;
  white-space: nowrap;
}
.vt-review-btn:hover { background: var(--brand-soft); }
.vt-issue-row.vt-reviewed { opacity: 0.7; }
.vt-process-row-head:hover { background: var(--brand-soft) !important; }
