:root {
  --ink: #14213d;
  --ink-2: #26344f;
  --muted: #64748b;
  --line: #dce4ee;
  --surface: #ffffff;
  --canvas: #f5f7fb;
  --blue: #2563eb;
  --blue-dark: #1747b8;
  --cyan: #22d3ee;
  --teal: #0f766e;
  --red: #b91c1c;
  --amber: #b45309;
  --shadow: 0 24px 70px rgba(20, 33, 61, 0.10);
  --radius: 20px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { min-height: 100vh; margin: 0; background: var(--canvas); color: var(--ink); }
button, input, select { font: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(32px, 4vw, 50px); line-height: 1.05; letter-spacing: -0.045em; }
h2 { margin-bottom: 7px; font-size: 22px; letter-spacing: -0.025em; }
h3 { margin-bottom: 5px; }
.muted, .lead, small { color: var(--muted); }
.lead { max-width: 740px; font-size: 17px; line-height: 1.65; }
.eyebrow { margin-bottom: 9px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.eyebrow.light { color: #a5e9f6; }
.hidden { display: none !important; }

.brand { display: inline-flex; align-items: center; gap: 11px; font-size: 17px; font-weight: 800; letter-spacing: -.02em; }
.brand-light { color: white; }
.brand-mark { display: inline-flex; width: 32px; height: 32px; align-items: end; justify-content: center; gap: 3px; padding: 7px 6px; border-radius: 10px; background: linear-gradient(145deg, var(--blue), #1d4ed8); box-shadow: 0 8px 22px rgba(37, 99, 235, .28); }
.brand-mark i { display: block; width: 4px; border-radius: 5px; background: white; transform: rotate(18deg); }
.brand-mark i:nth-child(1) { height: 10px; opacity: .7; }
.brand-mark i:nth-child(2) { height: 18px; }
.brand-mark i:nth-child(3) { height: 13px; opacity: .82; }

.auth-body { overflow-x: hidden; background: #071326; }
.auth-shell { display: grid; min-height: 100vh; grid-template-columns: minmax(0, 1.08fr) minmax(420px, .92fr); }
.auth-story { position: relative; display: flex; min-height: 100vh; flex-direction: column; justify-content: space-between; overflow: hidden; padding: 48px 7vw 56px; color: white; background: radial-gradient(circle at 18% 82%, rgba(34, 211, 238, .24), transparent 35%), radial-gradient(circle at 85% 15%, rgba(37, 99, 235, .45), transparent 38%), linear-gradient(145deg, #08162c 0%, #122a52 58%, #0b1c37 100%); }
.auth-story::after { content: ""; position: absolute; width: 520px; height: 520px; right: -240px; bottom: -130px; border: 1px solid rgba(255,255,255,.14); border-radius: 50%; box-shadow: 0 0 0 70px rgba(255,255,255,.025), 0 0 0 140px rgba(255,255,255,.018); }
.auth-story-copy { position: relative; z-index: 1; max-width: 650px; }
.auth-story-copy h1 { max-width: 630px; font-size: clamp(43px, 5.2vw, 74px); }
.auth-story-copy p:last-child { max-width: 560px; color: #c7d7ee; font-size: 18px; line-height: 1.7; }
.auth-proof { position: relative; z-index: 1; display: flex; gap: 40px; }
.auth-proof div { display: flex; flex-direction: column; gap: 5px; }
.auth-proof strong { font-size: 25px; }
.auth-proof span { color: #aebed5; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.auth-panel { display: grid; min-height: 100vh; place-items: center; padding: 36px; background: #f7f9fc; }
.auth-card { width: min(430px, 100%); padding: 45px; border: 1px solid #e5eaf1; border-radius: 24px; background: white; box-shadow: var(--shadow); }
.auth-card h2 { font-size: 32px; }
.stack-form { display: grid; gap: 18px; margin-top: 30px; }
label { display: grid; gap: 8px; color: var(--ink-2); font-size: 13px; font-weight: 700; }
input, select { width: 100%; min-height: 47px; padding: 11px 13px; border: 1px solid #cfd8e5; border-radius: 10px; outline: none; background: white; color: var(--ink); transition: border .2s, box-shadow .2s; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(37, 99, 235, .1); }
.security-note { display: flex; align-items: center; gap: 8px; margin: 22px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.security-note span { color: var(--teal); }
.auth-switch { margin: 22px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.auth-switch a { color: var(--blue); font-weight: 800; }
.auth-switch a:hover { text-decoration: underline; }

.button { display: inline-flex; min-height: 43px; align-items: center; justify-content: center; gap: 10px; padding: 10px 17px; border: 0; border-radius: 10px; cursor: pointer; font-weight: 750; transition: transform .15s, background .15s, box-shadow .15s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .65; transform: none; }
.button-primary { color: white; background: linear-gradient(135deg, var(--blue), #1d4ed8); box-shadow: 0 10px 24px rgba(37, 99, 235, .22); }
.button-primary:hover { background: linear-gradient(135deg, #1d4ed8, var(--blue-dark)); }
.button-secondary { color: var(--blue); border: 1px solid #bcd0fb; background: #eff5ff; }
.button-ghost { color: var(--ink-2); border: 1px solid var(--line); background: white; }
.button-wide { width: 100%; }
.button-small { min-height: 34px; padding: 7px 12px; font-size: 11px; }
.is-loading { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .72; } }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; min-height: 70px; align-items: center; justify-content: space-between; padding: 0 max(28px, calc((100vw - 1220px) / 2)); border-bottom: 1px solid rgba(213, 222, 234, .9); background: rgba(255,255,255,.92); backdrop-filter: blur(18px); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.user-pill { display: inline-flex; align-items: center; gap: 8px; padding: 9px 12px; color: var(--ink-2); border-radius: 999px; background: #f1f5f9; font-size: 12px; font-weight: 700; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #10b981; box-shadow: 0 0 0 4px rgba(16,185,129,.12); }
.workspace { width: min(1220px, calc(100% - 44px)); margin: 0 auto; padding: 52px 0 80px; }
.hero-row { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 30px; }
.model-badge { display: flex; min-width: 250px; align-items: center; gap: 12px; padding: 15px 17px; border: 1px solid #dce7e5; border-radius: 14px; background: #f6fffc; }
.model-badge div { display: flex; flex-direction: column; gap: 3px; }
.model-badge small { font-size: 11px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(310px, .75fr); gap: 22px; align-items: start; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 12px 35px rgba(20,33,61,.055); }
.upload-card, .process-card { padding: 27px; }
.card-heading { margin-bottom: 25px; }
.card-heading > div { display: flex; align-items: flex-start; gap: 13px; }
.card-heading h2, .card-heading p { margin-bottom: 3px; }
.card-heading p { color: var(--muted); font-size: 13px; }
.step-number { display: grid; width: 36px; height: 36px; flex: none; place-items: center; border-radius: 10px; color: var(--blue); background: #edf4ff; font-size: 11px; font-weight: 850; }
.upload-form { display: grid; gap: 20px; }
.upload-choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.drop-zone { min-height: 154px; place-items: center; align-content: center; gap: 7px; padding: 22px; border: 1.5px dashed #b9c7dc; border-radius: 14px; cursor: pointer; background: #fbfcfe; text-align: center; transition: border .18s, background .18s, transform .18s; }
.drop-zone:hover { border-color: var(--blue); background: #f5f8ff; transform: translateY(-1px); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop-zone span:last-child { color: var(--muted); font-size: 11px; font-weight: 500; }
.upload-icon { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 50%; color: var(--blue); background: #eaf1ff; font-size: 20px; }
.folder-icon { color: var(--teal); background: #e8f8f5; }
.selection-summary { margin-top: -9px; padding: 9px 12px; border-radius: 9px; color: var(--muted); background: #f5f7fa; font-size: 12px; }
.selection-summary.has-files { color: var(--teal); background: #edf9f6; font-weight: 700; }
.field-grid { display: grid; grid-template-columns: 1.15fr 1fr .8fr; gap: 13px; }
.field-grid small { min-height: 24px; font-size: 10px; font-weight: 500; line-height: 1.35; }
.optional { color: var(--muted); font-size: 10px; font-weight: 500; }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 58px; }
.input-suffix span { position: absolute; right: 12px; top: 16px; color: var(--muted); font-size: 11px; }
.toggle-row { display: flex; align-items: center; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: #fafcff; cursor: pointer; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle { position: relative; width: 42px; height: 23px; flex: none; border-radius: 999px; background: #bdc8d8; transition: background .2s; }
.toggle::after { content: ""; position: absolute; width: 17px; height: 17px; left: 3px; top: 3px; border-radius: 50%; background: white; transition: transform .2s; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.toggle-row input:checked + .toggle { background: var(--blue); }
.toggle-row input:checked + .toggle::after { transform: translateX(19px); }
.toggle-row > span:last-child { display: flex; flex-direction: column; gap: 3px; }
.toggle-row small { font-weight: 500; }
.form-footnote { margin: -8px 0 0; color: var(--muted); font-size: 10px; text-align: center; }
.process-list { display: grid; gap: 3px; padding: 0; margin: 0; list-style: none; }
.process-list li { display: flex; gap: 13px; padding: 13px 3px; border-bottom: 1px solid #edf1f6; }
.process-list li > span { display: grid; width: 27px; height: 27px; flex: none; place-items: center; border-radius: 50%; color: var(--blue); background: #eff5ff; font-size: 11px; font-weight: 800; }
.process-list strong { font-size: 13px; }
.process-list p { margin: 3px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.privacy-card { display: flex; gap: 12px; margin-top: 20px; padding: 15px; border-radius: 13px; color: #d8e8ff; background: linear-gradient(145deg, #132747, #1c3d6c); }
.privacy-card > span { color: var(--cyan); font-size: 23px; }
.privacy-card strong { color: white; font-size: 12px; }
.privacy-card p { margin: 4px 0 0; font-size: 10px; line-height: 1.5; }
.recent-section { margin-top: 45px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 15px; }
.section-heading h2, .section-heading p { margin-bottom: 2px; }
.section-heading > span { color: var(--muted); font-size: 12px; }
.job-list { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: white; }
.job-row { display: grid; grid-template-columns: 40px 1fr auto 26px; align-items: center; gap: 13px; padding: 16px 18px; border-bottom: 1px solid #edf1f5; transition: background .15s; }
.job-row:last-child { border-bottom: 0; }
.job-row:hover { background: #f8faff; }
.job-row > div { display: flex; flex-direction: column; gap: 4px; }
.job-row small { font-size: 10px; }
.job-icon { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 10px; color: var(--blue); background: #edf4ff; font-weight: 800; }
.row-arrow { color: #95a3b7; }
.status, .decision { display: inline-flex; width: max-content; align-items: center; justify-content: center; padding: 6px 10px; border-radius: 999px; font-size: 10px; font-weight: 850; text-transform: uppercase; letter-spacing: .06em; }
.status-completed, .decision-pass { color: #0b6b55; background: #dff7ef; }
.status-running, .status-queued { color: #1d4ed8; background: #e5edff; }
.status-failed, .decision-fail { color: #a61b1b; background: #fee7e7; }
.decision-uncalibrated { color: #92500a; background: #fff1d6; }
.empty-state { padding: 45px; border: 1px dashed #c9d3df; border-radius: 16px; color: var(--muted); text-align: center; }
.empty-state > span { display: block; color: var(--blue); font-size: 28px; }
.empty-state h3 { margin: 10px 0 5px; color: var(--ink); }

.alert { padding: 12px 14px; border-radius: 10px; font-size: 12px; line-height: 1.5; }
.alert-error { color: #901f1f; border: 1px solid #fecaca; background: #fff1f2; }
.alert-success { color: #0b6b55; border: 1px solid #a7ead5; background: #ecfbf5; }
.welcome-alert { margin-bottom: 24px; }
.history-workspace { max-width: 1080px; }
.history-hero { margin-bottom: 22px; }
.history-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.history-metrics article { display: flex; min-height: 105px; flex-direction: column; justify-content: space-between; padding: 19px; border: 1px solid var(--line); border-radius: 15px; background: white; }
.history-metrics span { color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.history-metrics strong { font-size: 31px; letter-spacing: -.04em; }
.history-list { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: white; }
.history-row { display: grid; grid-template-columns: minmax(280px, 1fr) auto minmax(150px, auto); align-items: center; gap: 18px; padding: 16px 18px; border-bottom: 1px solid #edf1f5; }
.history-row:last-child { border-bottom: 0; }
.history-row:hover { background: #fbfcff; }
.history-main { display: flex; min-width: 0; align-items: center; gap: 13px; }
.history-copy { display: flex; min-width: 0; flex-direction: column; gap: 4px; }
.history-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-copy small { font-size: 10px; }
.history-actions { display: flex; justify-content: flex-end; gap: 8px; }
.history-empty-button { margin-top: 18px; }
.job-workspace { padding-top: 42px; }
.job-header { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.job-header h1 { font-size: 42px; }
.job-actions { display: flex; gap: 10px; }
.progress-card { padding: 20px 22px; }
.progress-meta { display: flex; justify-content: space-between; margin-bottom: 10px; color: var(--ink-2); font-size: 12px; text-transform: capitalize; }
.progress-track { height: 8px; overflow: hidden; border-radius: 999px; background: #e8edf4; }
.progress-track > div { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--cyan)); transition: width .4s ease; }
.progress-card.complete .progress-track > div { background: linear-gradient(90deg, var(--teal), #34d399); }
.summary-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; margin: 24px 0; }
.metric-card { display: flex; min-height: 115px; flex-direction: column; justify-content: space-between; padding: 19px; border: 1px solid var(--line); border-radius: 15px; background: white; }
.metric-label { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.metric-value { font-size: 34px; letter-spacing: -.04em; }
.narrative-card { padding: 27px; }
.narrative-card #narrative { max-width: 920px; white-space: pre-line; color: var(--ink-2); font-size: 14px; line-height: 1.75; }
.narrative-card small { display: block; margin-top: 14px; }
.results-heading { margin-top: 42px; }
.results-grid { display: grid; gap: 20px; }
.result-card { padding: 22px; border: 1px solid var(--line); border-radius: 18px; background: white; box-shadow: 0 12px 32px rgba(20,33,61,.045); }
.result-card-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 17px; }
.result-card-header h3 { overflow-wrap: anywhere; }
.result-card-header small { font-size: 10px; }
.result-visuals { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.result-visuals figure { margin: 0; overflow: hidden; border: 1px solid #e2e8f0; border-radius: 12px; background: #eef2f7; }
.result-visuals img { display: block; width: 100%; max-height: 410px; object-fit: contain; background: #dce3ec; }
.result-visuals figcaption { padding: 9px 12px; color: var(--muted); background: white; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.result-metrics { display: grid; grid-template-columns: repeat(3, minmax(88px, .8fr) minmax(100px, 1fr)); gap: 0; margin: 17px 0; border: 1px solid var(--line); border-radius: 12px; }
.result-metrics div { display: contents; }
.result-metrics dt, .result-metrics dd { margin: 0; padding: 11px 13px; border-bottom: 1px solid #edf1f5; }
.result-metrics dt { color: var(--muted); background: #f8fafc; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.result-metrics dd { font-size: 12px; font-weight: 750; }
.recommendation { padding: 14px; border-radius: 11px; background: #f6f8fb; }
.recommendation strong { font-size: 13px; }
.recommendation p, .recommendation ul { margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.recommendation ul { padding-left: 18px; }
.result-links { display: flex; gap: 16px; margin-top: 15px; }
.text-link { color: var(--blue); font-size: 11px; font-weight: 750; }
.text-link:hover { text-decoration: underline; }

@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-story { min-height: 52vh; padding: 35px 28px; }
  .auth-panel { min-height: 48vh; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .hero-row, .job-header { align-items: start; flex-direction: column; }
  .field-grid { grid-template-columns: 1fr; }
  .summary-metrics { grid-template-columns: 1fr 1fr; }
  .history-row { grid-template-columns: 1fr auto; }
  .history-actions { grid-column: 1 / -1; justify-content: flex-start; padding-left: 47px; }
}

@media (max-width: 600px) {
  .auth-proof { flex-wrap: wrap; gap: 20px; }
  .auth-card { padding: 29px; }
  .topbar { padding: 0 16px; }
  .user-pill { display: none; }
  .workspace { width: min(100% - 28px, 1220px); padding-top: 34px; }
  .upload-choice-grid, .result-visuals, .summary-metrics { grid-template-columns: 1fr; }
  .model-badge { width: 100%; }
  .job-actions { width: 100%; flex-direction: column; }
  .result-metrics { grid-template-columns: 1fr 1fr; }
  .history-metrics { grid-template-columns: 1fr; }
  .history-row { grid-template-columns: 1fr; }
  .history-actions { grid-column: auto; padding-left: 0; }
}
