/* Ported from app/templates/base.html (DocClass MVP) — same tokens, components and spacing.
   Demo-only additions are grouped at the bottom. */
:root {
  --navy: #1B3A5C;
  --blue: #2E75B6;
  --blue-light: #E8F0FE;
  --green: #2D8B4E;
  --green-light: #D4EDDA;
  --red: #CC0000;
  --red-light: #FFCDD2;
  --orange: #FF6B35;
  --orange-light: #FFE0B2;
  --yellow-light: #FFF3CD;
  --gray-50: #F8F9FA;
  --gray-100: #F1F3F5;
  --gray-200: #DEE2E6;
  --gray-400: #ADB5BD;
  --gray-600: #6C757D;
  --gray-800: #343A40;
  --gray-900: #212529;
  --font: 'IBM Plex Sans', -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', monospace;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
  --demo-bar: 32px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); background: var(--gray-50); color: var(--gray-900); font-size: 14px; line-height: 1.5; padding-top: var(--demo-bar); overflow-x: hidden; }
code { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ── Nav ── */
nav.app-nav { background: var(--navy); padding: 0 24px; display: flex; align-items: center; height: 56px; gap: 32px; overflow-x: auto; scrollbar-width: none; }
nav.app-nav::-webkit-scrollbar { display: none; }
nav.app-nav .brand { color: white; font-weight: 700; font-size: 16px; letter-spacing: 0.5px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
nav.app-nav .brand span { background: var(--blue); padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; letter-spacing: 1px; }
nav.app-nav a { color: rgba(255,255,255,0.75); text-decoration: none; font-size: 13px; font-weight: 500; padding: 16px 0; border-bottom: 2px solid transparent; transition: all 0.2s; white-space: nowrap; }
nav.app-nav a:hover, nav.app-nav a.active { color: white; border-bottom-color: var(--blue); }
nav.app-nav .nav-count { background: var(--orange); color: white; border-radius: 9px; font-size: 10px; font-weight: 700; padding: 1px 6px; margin-left: 4px; font-family: var(--mono); }

/* ── Layout ── */
.container { max-width: 1280px; margin: 0 auto; padding: 24px; }
.page-title { font-size: 24px; font-weight: 700; color: var(--navy); margin-bottom: 24px; }

/* ── Cards ── */
.card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; min-width: 0; }
.card-title { font-size: 13px; font-weight: 600; color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; }

/* ── Metric Cards ── */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 24px; }
.metric-card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; text-align: center; border-top: 3px solid var(--blue); }
.metric-card.green { border-top-color: var(--green); }
.metric-card.red { border-top-color: var(--red); }
.metric-card.orange { border-top-color: var(--orange); }
.metric-value { font-size: 32px; font-weight: 700; color: var(--navy); font-family: var(--mono); }
.metric-label { font-size: 12px; color: var(--gray-600); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }
a.metric-card { text-decoration: none; display: block; transition: box-shadow 0.2s; }
a.metric-card:hover { box-shadow: var(--shadow-lg); }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { background: var(--gray-100); font-size: 11px; font-weight: 600; color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.5px; padding: 10px 12px; text-align: left; border-bottom: 2px solid var(--gray-200); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--gray-200); font-size: 13px; }
tr:hover td { background: var(--gray-50); }

/* ── Badges ── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; letter-spacing: 0.3px; white-space: nowrap; }
.badge-public { background: var(--green-light); color: var(--green); }
.badge-internal { background: var(--blue-light); color: var(--blue); }
.badge-confidential { background: var(--orange-light); color: #C24A1B; }
.badge-strictly { background: var(--red-light); color: var(--red); }
.badge-pending { background: var(--yellow-light); color: #856404; }
.badge-review { background: var(--orange-light); color: #C24A1B; }
.badge-classified { background: var(--green-light); color: var(--green); }
.badge-reviewed { background: var(--blue-light); color: var(--blue); }
.badge-lg { font-size: 14px; padding: 4px 14px; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-800); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea, .input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--gray-200); border-radius: 6px;
  font-family: var(--font); font-size: 14px; transition: border-color 0.2s; background: white; color: var(--gray-900);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus, .input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(46,117,182,0.1); }
textarea { resize: vertical; min-height: 80px; }
.form-group input[type=checkbox] { width: auto; margin-right: 6px; }
.hint { font-size: 12px; color: var(--gray-600); margin-top: 4px; }

/* ── Buttons ── */
.btn { display: inline-block; padding: 8px 20px; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; border: none; transition: all 0.2s; text-decoration: none; font-family: var(--font); line-height: 1.4; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--navy); }
.btn-success { background: var(--green); color: white; }
.btn-success:hover { background: #236B3D; }
.btn-outline { background: white; color: var(--gray-800); border: 1px solid var(--gray-200); }
.btn-outline:hover { background: var(--gray-100); }
.btn-danger-outline { background: white; color: var(--red); border: 1px solid var(--red); }
.btn-sm { padding: 4px 12px; font-size: 12px; }

/* ── Upload area ── */
.upload-area { border: 2px dashed var(--gray-200); border-radius: 12px; padding: 48px; text-align: center; background: white; transition: all 0.2s; cursor: pointer; width: 100%; font-family: var(--font); }
.upload-area:hover, .upload-area.dragover { border-color: var(--blue); background: var(--blue-light); }
.upload-area .icon { font-size: 48px; margin-bottom: 12px; }
.upload-area p { color: var(--gray-600); }

/* ── Flash messages ── */
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; font-weight: 500; }
.flash-success { background: var(--green-light); color: #155724; border: 1px solid #C3E6CB; }
.flash-error { background: var(--red-light); color: #721C24; border: 1px solid #F5C6CB; }
.flash-info { background: var(--blue-light); color: var(--navy); border: 1px solid #C9DAF5; }

/* ── Detail sections ── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-item { margin-bottom: 8px; }
.detail-item .label { font-size: 11px; font-weight: 600; color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.5px; }
.detail-item .value { font-size: 14px; color: var(--gray-900); margin-top: 2px; }
.confidence-bar { height: 8px; background: var(--gray-200); border-radius: 4px; overflow: hidden; margin-top: 4px; position: relative; }
.confidence-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }
.findings-list { list-style: none; }
.findings-list li { padding: 8px 12px; margin-bottom: 4px; background: var(--gray-50); border-radius: 6px; border-left: 3px solid var(--red); font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.findings-list li.low { border-left-color: var(--gray-400); }
.findings-list li.medium { border-left-color: var(--orange); }
.findings-list li.high { border-left-color: var(--red); }
.findings-list li.critical { border-left-color: #8B0000; }
.findings-list li.rejected { opacity: 0.6; border-left-style: dashed; border-left-color: var(--gray-400); }
.sep { color: var(--gray-600); margin: 0 6px; }

/* ── Charts area ── */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.chart-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.chart-bar-label { min-width: 140px; font-size: 12px; text-align: right; color: var(--gray-600); }
.chart-bar-track { flex: 1; height: 24px; background: var(--gray-100); border-radius: 4px; overflow: hidden; }
.chart-bar-fill { height: 100%; border-radius: 4px; display: flex; align-items: center; padding-left: 8px; font-size: 11px; font-weight: 600; color: white; min-width: 28px; transition: width 0.4s ease; }
.chart-bar-count { min-width: 30px; font-size: 12px; font-weight: 600; color: var(--gray-800); font-family: var(--mono); }

.filter-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar a, .filter-bar button { padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 500; text-decoration: none; font-family: var(--font); cursor: pointer;
  background: white; color: var(--gray-600); border: 1px solid var(--gray-200); transition: all 0.2s; }
.filter-bar a:hover, .filter-bar button:hover { background: var(--gray-100); }
.filter-bar a.active, .filter-bar button.active { background: var(--navy); color: white; border-color: var(--navy); }

.empty { color: var(--gray-400); text-align: center; padding: 24px; }
.mono { font-family: var(--mono); }
.muted { color: var(--gray-600); }
.page-head { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head .page-title { margin-bottom: 0; overflow-wrap: anywhere; }

/* ════ Demo additions ════ */

/* Demo bar */
.demo-bar { position: fixed; top: 0; left: 0; right: 0; height: var(--demo-bar); z-index: 1000; display: flex; align-items: center; gap: 14px;
  padding: 0 16px; background: #111418; color: #C9CED6; font-size: 12px; font-family: var(--font); }
.demo-bar a { color: #E9ECEF; text-decoration: none; font-weight: 600; white-space: nowrap; }
.demo-bar a:hover { text-decoration: underline; }
.demo-bar .demo-title { font-weight: 600; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.demo-bar .demo-note { color: #8A939F; white-space: nowrap; }
.demo-bar .spacer { flex: 1; }
.demo-bar button { background: transparent; color: #E9ECEF; border: 1px solid #3A414B; border-radius: 4px; font-size: 11px; padding: 3px 10px; cursor: pointer; font-family: var(--font); white-space: nowrap; }
.demo-bar button:hover { background: #262C34; }

/* Tour */
.tour { position: fixed; top: calc(var(--demo-bar) + 10px); right: 16px; z-index: 1001; width: min(340px, calc(100vw - 32px)); background: white; border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0,0,0,0.18); padding: 18px; border-top: 3px solid var(--blue); }
.tour h3 { font-size: 14px; color: var(--navy); margin-bottom: 6px; }
.tour p { font-size: 13px; color: var(--gray-800); margin-bottom: 12px; }
.tour .tour-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tour .tour-step { font-size: 11px; color: var(--gray-600); font-family: var(--mono); }

/* Upload page */
.upload-layout { display: grid; grid-template-columns: minmax(0, 640px) minmax(0, 1fr); gap: 16px; align-items: start; }
.samples-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.sample-card { text-align: left; background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 8px; padding: 12px; cursor: pointer; font-family: var(--font); transition: all 0.2s; color: var(--gray-900); }
.sample-card:hover { border-color: var(--blue); background: var(--blue-light); }
.sample-card .s-title { font-weight: 600; font-size: 13px; color: var(--navy); }
.sample-card .s-file { font-family: var(--mono); font-size: 11px; color: var(--gray-600); margin-top: 2px; overflow-wrap: anywhere; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--gray-200); margin-bottom: 16px; }
.tabs button { background: none; border: none; border-bottom: 2px solid transparent; padding: 8px 14px; font-family: var(--font); font-size: 13px; font-weight: 600; color: var(--gray-600); cursor: pointer; }
.tabs button.active { color: var(--navy); border-bottom-color: var(--blue); }

/* Pipeline */
.pipeline { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; margin: 8px 0 20px; }
.pipe-step { position: relative; text-align: center; padding: 0 6px; }
.pipe-step::before { content: ''; position: absolute; top: 19px; left: -50%; width: 100%; height: 3px; background: var(--gray-200); z-index: 0; }
.pipe-step:first-child::before { display: none; }
.pipe-step.done::before, .pipe-step.active::before { background: var(--blue); }
.pipe-dot { position: relative; z-index: 1; width: 40px; height: 40px; border-radius: 50%; margin: 0 auto 8px; display: flex; align-items: center; justify-content: center;
  background: white; border: 3px solid var(--gray-200); font-family: var(--mono); font-weight: 700; color: var(--gray-400); font-size: 14px; transition: all 0.25s; }
.pipe-step.active .pipe-dot { border-color: var(--blue); color: var(--blue); box-shadow: 0 0 0 6px rgba(46,117,182,0.15); }
.pipe-step.done .pipe-dot { border-color: var(--blue); background: var(--blue); color: white; }
.pipe-step.done.warn .pipe-dot { border-color: var(--orange); background: var(--orange); }
.pipe-name { font-size: 11px; font-weight: 700; letter-spacing: 0.6px; color: var(--gray-600); }
.pipe-step.active .pipe-name, .pipe-step.done .pipe-name { color: var(--navy); }
.pipe-sub { font-size: 11px; color: var(--gray-600); margin-top: 2px; min-height: 16px; font-family: var(--mono); overflow-wrap: anywhere; }
.worker-log { background: #0F1A26; color: #C9D6E3; font-family: var(--mono); font-size: 12px; border-radius: 6px; padding: 12px 14px; height: 260px; overflow: auto; line-height: 1.6; }
.worker-log .ts { color: #6C7C8E; }
.worker-log .lv-warn { color: #FFB38A; }
.worker-log .lv-crit { color: #FF8A8A; }
.worker-log .lv-ok { color: #8FD6A6; }
.worker-log div { white-space: pre-wrap; overflow-wrap: anywhere; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.pipe-step.active .pipe-dot { animation: pulse 1s ease-in-out infinite; }

/* Inline document viewer */
.doc-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.doc-text { font-family: var(--mono); font-size: 12.5px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--gray-50); border: 1px solid var(--gray-200);
  border-radius: 6px; padding: 16px; max-height: 520px; overflow: auto; }
.dlp-mark { font: inherit; border: none; cursor: pointer; padding: 0 3px; border-radius: 3px; border-bottom: 2px solid; line-height: inherit; }
.dlp-mark.sev-critical { background: #FFD6D6; border-color: #8B0000; color: #6B0000; }
.dlp-mark.sev-high { background: var(--red-light); border-color: var(--red); color: #8B0000; }
.dlp-mark.sev-medium { background: var(--orange-light); border-color: var(--orange); color: #8A3A12; }
.dlp-mark.sev-low { background: var(--gray-200); border-color: var(--gray-600); color: var(--gray-800); }
.dlp-mark.revealed { outline: 1px dashed currentColor; }
.dlp-mark.flash { box-shadow: 0 0 0 3px rgba(46,117,182,0.5); }
.kw-mark { background: var(--yellow-light); border-bottom: 1px dotted #856404; }
.cls-mark { background: var(--blue-light); border-bottom: 1px dotted var(--blue); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 11px; color: var(--gray-600); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; vertical-align: -2px; margin-right: 4px; }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--gray-800); cursor: pointer; }

/* Decision trace */
.trace-step { display: grid; grid-template-columns: 28px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--gray-100); }
.trace-step:last-child { border-bottom: none; }
.trace-num { width: 28px; height: 28px; border-radius: 50%; background: var(--navy); color: white; font-family: var(--mono); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.trace-step h4 { font-size: 13px; color: var(--navy); margin-bottom: 4px; }
.trace-step p { font-size: 13px; color: var(--gray-800); }
.formula { font-family: var(--mono); font-size: 12px; background: var(--gray-50); border-radius: 6px; padding: 8px 10px; margin-top: 6px; overflow-wrap: anywhere; }
.score-row { display: grid; grid-template-columns: 190px 1fr 70px 56px; gap: 8px; align-items: center; margin-bottom: 6px; font-size: 12px; }
.score-row .lbl { color: var(--gray-800); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-row .lbl.best { color: var(--navy); font-weight: 700; }
.score-row .num { font-family: var(--mono); text-align: right; }
.kw-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0 10px; }
.kw-chip { font-family: var(--mono); font-size: 11px; background: var(--blue-light); color: var(--navy); border-radius: 10px; padding: 1px 8px; }
.reasons { list-style: none; }
.reasons li { padding: 6px 0 6px 22px; position: relative; font-size: 13px; }
.reasons li::before { content: '→'; position: absolute; left: 0; color: var(--blue); font-weight: 700; }
.threshold-marker { position: absolute; top: -3px; width: 2px; height: 14px; background: var(--gray-900); }

/* Admin */
.thr-row { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; padding: 12px; background: var(--gray-50); border-radius: 8px; border-left: 4px solid var(--gray-400); flex-wrap: wrap; }
.thr-row .thr-name { min-width: 200px; }
.thr-row input[type=range] { flex: 1; min-width: 140px; }
.thr-val { min-width: 50px; text-align: right; font-family: var(--mono); font-weight: 700; font-size: 16px; }
.wl-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.wl-chip { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 12px; background: var(--gray-100); border: 1px solid var(--gray-200); border-radius: 14px; padding: 2px 4px 2px 10px; }
.wl-chip button { border: none; background: none; cursor: pointer; color: var(--gray-600); font-size: 14px; line-height: 1; padding: 0 4px; border-radius: 50%; }
.wl-chip button:hover { color: var(--red); }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form .input { flex: 1; min-width: 160px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 1002; background: var(--navy); color: white; padding: 10px 18px; border-radius: 6px; font-size: 13px; box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px); }

@media (max-width: 1000px) {
  .upload-layout { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .detail-grid, .charts-grid { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .container { padding: 16px; }
  nav.app-nav { padding: 0 16px; gap: 20px; }
  .chart-bar-label { min-width: 96px; }
  .upload-area { padding: 28px 16px; }
  .demo-bar { gap: 10px; padding: 0 10px; }
  .demo-bar .demo-note { display: none; }
  .pipeline { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .pipe-name { font-size: 9px; letter-spacing: 0; }
  .pipe-sub { display: none; }
  .pipe-dot { width: 32px; height: 32px; font-size: 12px; }
  .pipe-step::before { top: 15px; }
  .score-row { grid-template-columns: 110px 1fr 52px 44px; }
  .metric-value { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
