[hidden]{display:none!important}

:root{
  --brand-primary: #07172a;
  --brand-secondary: #40bb90;
  --brand-accent: #50d6a6;
  --brand-glow: #4ade80;
  --bg-body: #050a12;
  --bg-surface: #0b1320;
  --bg-elevated: #101d2e;
  --bg-card: #0e1926;
  --ink: #e8eef5;
  --muted: #8fa3b8;
  --line: #1a2d42;
  --line-bright: #2a4566;
  --green: #40bb90;
  --green2: #50d6a6;
  --gold: #c99427;
  --red: #f87171;
  --navy: #07172a;
  --accent-blue: #38bdf8;
  --accent-violet: #8b5cf6;
  --glow: 0 0 18px rgba(56,189,248,0.25), 0 0 36px rgba(139,92,246,0.15);
  --card-shadow: 0 10px 30px rgba(0,0,0,0.45);
}

*{box-sizing:border-box}

html,body{height:100%}

body{
  margin:0;
  background: radial-gradient(ellipse at 20% 0%, rgba(17,34,56,0.45) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 10%, rgba(56,189,248,0.08) 0%, transparent 40%),
              var(--bg-body);
  color: var(--ink);
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-attachment: fixed;
}

/* Header */
.topbar{
  height: 70px;
  background: rgba(11,19,32,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 max(28px, calc((100vw - 1500px) / 2));
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand{
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark{
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--brand-secondary, #40bb90);
  color: var(--brand-accent, #50d6a6);
  font: 700 21px 'Space Grotesk', sans-serif;
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  flex: none;
}

.brand-logo{
  height: 40px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  flex: none;
}

.brand:has(.brand-logo:not([hidden])) .brand-mark{
  display: none;
}


.brand-mark.has-logo{
  border: none;
  background: transparent;
}

.brand-text{
  display: flex;
  flex-direction: column;
}

.topbar strong{
  font-size: 17px;
  letter-spacing: 0.06em;
  color: #fff;
}

.topbar span{
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.topbar-center{
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 24px;
  color: var(--muted);
  font-size: 12px;
}

.health{
  display: flex;
  align-items: center;
  gap: 8px;
}

.health i{
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d89b3c;
  box-shadow: 0 0 8px #d89b3c;
}

.health.ok i{
  background: #35c78a;
  box-shadow: 0 0 8px #35c78a;
}

.max-upload{
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
}

.logout, #logout-button{
  background: transparent;
  border: 1px solid var(--line-bright);
  color: var(--ink);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: 0.2s;
}

.logout:hover, #logout-button:hover{
  background: rgba(255,255,255,0.08);
  border-color: var(--brand-secondary);
}

/* Login styles are in /static/login.css */

/* App */
.app-main{
  max-width: 1500px;
  margin: auto;
  padding: 28px;
}

/* Hero */
.hero{
  display: grid;
  grid-template-columns: 1fr 480px;
  gap: 48px;
  align-items: center;
  margin-bottom: 32px;
}

.hero-text .eyebrow{
  margin: 0 0 10px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--accent-blue);
  text-transform: uppercase;
}

.hero-text h1{
  font: 500 clamp(32px, 4vw, 52px)/1.08 'Space Grotesk', sans-serif;
  margin: 0 0 18px;
  color: #fff;
}

.brand-gradient{
  background: linear-gradient(90deg, var(--brand-secondary, #40bb90), var(--accent-blue, #38bdf8));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-text p{
  color: var(--muted);
  max-width: 640px;
  font-size: 15px;
  line-height: 1.65;
  margin: 0;
}

/* Upload card */
.upload-card{
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--card-shadow);
}

.drop-zone{
  min-height: 180px;
  border: 1.5px dashed var(--line-bright);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  text-align: center;
  padding: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.drop-zone.dragging{
  border-color: var(--brand-secondary);
  box-shadow: 0 0 18px rgba(64,187,144,0.25);
}

.upload-icon{
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(64,187,144,0.12);
  color: var(--brand-accent);
  font-size: 24px;
  margin-bottom: 12px;
}

.drop-zone strong{
  color: #fff;
  font-weight: 600;
}

.drop-zone small{
  color: var(--muted);
  margin: 6px 0 14px;
}

.source-buttons{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

button, .button-link{
  border: 0;
  border-radius: 8px;
  background: var(--brand-secondary, #40bb90);
  color: #07172a;
  padding: 10px 16px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: filter 0.2s, box-shadow 0.2s;
}

button:hover, .button-link:hover{
  filter: brightness(1.1);
}

button:disabled{
  opacity: 0.5;
  cursor: not-allowed;
}

button.secondary, .button-link.secondary{
  background: transparent;
  border: 1px solid var(--line-bright);
  color: var(--ink);
}

button.secondary:hover{
  background: rgba(255,255,255,0.05);
}

.extract{
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  background: linear-gradient(90deg, var(--brand-secondary, #40bb90), var(--brand-accent, #50d6a6));
  color: #07172a;
  font-size: 14px;
  font-weight: 700;
}

.extract:disabled{
  background: var(--line-bright);
  color: var(--muted);
}

.selected-file{
  display: block;
  margin-top: 12px;
  font-weight: 600;
  color: var(--brand-accent);
}

#upload-message{
  min-height: 20px;
  color: var(--muted);
  font-size: 12px;
  margin: 12px 0 0;
}

#upload-message.error{
  color: var(--red);
}

#upload-message.batch-summary{
  color: var(--brand-accent);
}

/* Dashboard metrics */
.dashboard-metrics{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 32px;
}

.metric-card{
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  display: flex;
  gap: 18px;
  align-items: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s, box-shadow 0.2s, border-color 0.2s;
}

.metric-card:hover{
  transform: translateY(-2px);
  border-color: var(--line-bright);
  box-shadow: 0 16px 40px rgba(0,0,0,0.5), var(--glow);
}

.metric-card.active{
  border-color: var(--brand-secondary);
  box-shadow: 0 0 0 1px var(--brand-secondary), var(--glow);
}

.metric-card.active .metric-glow{
  opacity: 1;
}

.metric-icon{
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(64,187,144,0.12);
  color: var(--brand-accent);
  flex: none;
}

.metric-info{
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.metric-label{
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric-value{
  font-size: 36px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

.metric-glow{
  position: absolute;
  right: -20px;
  top: -20px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(64,187,144,0.22), transparent 70%);
  opacity: 0.4;
  pointer-events: none;
}

/* Workspace */
.workspace{
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
  align-items: start;
}

.run-history, .review-panel{
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 18px;
  min-height: 700px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.run-history-header, .section-heading{
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.run-history-header p, .section-heading p{
  margin: 0;
  color: var(--accent-blue);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.run-history-header h2, .section-heading h2{
  font: 500 20px 'Space Grotesk', sans-serif;
  margin: 6px 0 0;
  color: #fff;
}

.icon-button{
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  color: var(--ink);
  font-size: 18px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
}

.icon-button:hover{
  background: rgba(255,255,255,0.1);
}

.run-list{
  max-height: 740px;
  overflow: auto;
  padding: 12px;
}

.run-item{
  display: block;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--ink);
  text-align: left;
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.run-item:hover{
  background: rgba(255,255,255,0.05);
  border-color: var(--line-bright);
}

.run-item.active{
  border-color: var(--brand-secondary);
  background: rgba(64,187,144,0.1);
  box-shadow: 0 0 14px rgba(64,187,144,0.12);
}

.run-item strong{
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
  font-weight: 600;
  margin-bottom: 8px;
}

.run-item > span{
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 8px;
}

.status-pill{
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: #1a2d42;
  color: var(--muted);
}

.status-pill.validated{
  background: rgba(64,187,144,0.18);
  color: var(--brand-accent);
}

.status-pill.failed{
  background: rgba(248,113,113,0.15);
  color: var(--red);
}

.status-pill.needs_review{
  background: rgba(201,148,39,0.18);
  color: #fbbf24;
}

.empty{
  padding: 40px;
  text-align: center;
  color: var(--muted);
}

/* Review panel */
.review-panel.empty-panel{
  display: grid;
  place-items: center;
}

.empty-state{
  text-align: center;
  color: var(--muted);
  padding: 40px;
  max-width: 420px;
}

.empty-state svg{
  color: #4b6a8a;
  margin-bottom: 20px;
}

.empty-state h2{
  color: #fff;
  font: 500 26px 'Space Grotesk', sans-serif;
  margin: 0 0 10px;
}

.empty-state .secondary-text{
  font-size: 13px;
  color: var(--muted);
}

.review-header{
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
  gap: 16px;
}

.review-title p{
  margin: 0;
}

.review-title h2{
  font: 500 22px 'Space Grotesk', sans-serif;
  margin: 8px 0 6px;
  color: #fff;
}

.review-title .eyebrow{
  color: var(--accent-blue);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

#run-path, #run-meta{
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 4px;
}

.header-actions{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.status-strip{
  padding: 12px 24px;
  background: rgba(201,148,39,0.12);
  color: #fbbf24;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.status-strip.good{
  background: rgba(64,187,144,0.12);
  color: var(--brand-accent);
}

.status-strip.bad{
  background: rgba(248,113,113,0.12);
  color: var(--red);
}

.metrics{
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--line);
}

.metrics article{
  padding: 18px 22px;
  border-right: 1px solid var(--line);
}

.metrics article:last-child{
  border-right: none;
}

.metrics span{
  display: block;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metrics strong{
  font-size: 16px;
  color: #fff;
}

.tabs{
  display: flex;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  gap: 4px;
}

.tabs button{
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 14px 14px;
  border-bottom: 2px solid transparent;
  font-weight: 600;
}

.tabs button.active{
  color: var(--brand-accent);
  border-bottom-color: var(--brand-secondary);
}

.tab-pane{
  display: none;
}

.tab-pane.active{
  display: block;
}

.compare-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 18px;
}

.compare-grid.active{
  display: grid;
}

.panel{
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  min-width: 0;
  background: var(--bg-card);
}

.panel-title{
  height: 48px;
  padding: 0 16px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-title h3{
  margin: 0;
  font-size: 14px;
  color: #fff;
}

.panel-title a{
  color: var(--accent-blue);
  font-size: 12px;
}

iframe{
  display: block;
  width: 100%;
  height: 560px;
  border: 0;
  background: #050a12;
}

.result-summary{
  padding: 16px;
  max-height: 560px;
  overflow: auto;
}

.summary-group{
  border-bottom: 1px solid var(--line);
  padding: 0 0 14px;
  margin-bottom: 14px;
}

.summary-group h4{
  font: 500 18px 'Space Grotesk', sans-serif;
  margin: 0 0 10px;
  color: #fff;
}

.field-row{
  display: grid;
  grid-template-columns: 42% 1fr;
  gap: 12px;
  padding: 6px 0;
}

.field-row span{
  color: var(--muted);
  font-size: 13px;
}

.field-row strong{
  color: var(--ink);
  font-weight: 500;
  overflow-wrap: anywhere;
}

.warning-list{
  padding: 14px;
  background: rgba(251,191,36,0.08);
  border-radius: 8px;
  color: #fbbf24;
  margin: 12px 0;
}

.warning-list p{
  margin: 4px 0;
}

.tab-pane > pre,
#tab-json pre,
#tab-raw pre{
  margin: 18px;
  max-height: 620px;
  overflow: auto;
  background: #050a12;
  color: #a5d2e8;
  border-radius: 10px;
  padding: 18px;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
}

.table-wrap{
  overflow: auto;
  padding: 18px;
}

table{
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th{
  text-align: left;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(255,255,255,0.03);
}

th, td{
  padding: 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

td:last-child{
  max-width: 330px;
}

.review-decision{
  border-top: 1px solid var(--line);
  padding: 22px 24px;
}

.review-decision h3{
  margin: 8px 0 0;
  font: 500 20px 'Space Grotesk', sans-serif;
  color: #fff;
}

.review-decision p{
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 0;
}

.review-decision .eyebrow{
  color: var(--accent-blue);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

textarea{
  width: 100%;
  min-height: 80px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font: inherit;
  resize: vertical;
  background: var(--bg-surface);
  color: var(--ink);
  margin-top: 18px;
}

.decision-buttons{
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.decision-buttons .danger{
  background: rgba(248,113,113,0.15);
  color: var(--red);
  border: 1px solid rgba(248,113,113,0.4);
}

.review-record{
  font-size: 12px;
  background: rgba(255,255,255,0.04);
  padding: 10px;
  margin-top: 8px;
  border-radius: 6px;
}

.review-record strong{
  margin-right: 10px;
  color: #fff;
}

.review-record span{
  color: var(--muted);
}

/* Responsive */
@media (max-width: 980px){
  .hero{ grid-template-columns: 1fr; }
  .workspace{ grid-template-columns: 1fr; }
  .workspace aside{ position: static; min-height: 0; }
  .run-list{ max-height: 300px; }
  .compare-grid.active{ grid-template-columns: 1fr; }
  .metrics{ grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 700px){
  .topbar{ padding: 0 16px; gap: 12px; }
  .topbar-center{ display: none; }
  .app-main{ padding: 16px; }
  .hero{ gap: 24px; }
  .dashboard-metrics{ grid-template-columns: 1fr; }
  .metrics{ grid-template-columns: 1fr 1fr; }
  .metrics article{ border-right: none; border-bottom: 1px solid var(--line); }
  .metrics article:nth-child(3), .metrics article:nth-child(4){ border-bottom: none; }
  .review-header{ flex-direction: column; gap: 12px; }
  .tabs{ overflow: auto; padding: 0 8px; }
  .decision-buttons{ flex-wrap: wrap; }
  .login-card{ padding: 32px 24px; }
}

@media (max-width: 500px){
  .metrics{ grid-template-columns: 1fr; }
  .source-buttons{ flex-direction: column; width: 100%; }
  .source-buttons button{ width: 100%; }
}