:root {
  color-scheme: dark;
  --bg: #08111f;
  --surface: #0f1b2d;
  --surface-2: #13223a;
  --border: rgba(203, 222, 255, 0.15);
  --border-strong: rgba(203, 222, 255, 0.28);
  --text: #edf4ff;
  --muted: #9dadc5;
  --blue: #3ab3ff;
  --blue-strong: #0d8de4;
  --green: #35d084;
  --amber: #f4b84a;
  --red: #ff6b6b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(900px 520px at 12% -10%, rgba(58, 179, 255, 0.16), transparent 58%),
    radial-gradient(720px 440px at 90% 4%, rgba(53, 208, 132, 0.09), transparent 55%),
    var(--bg);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.page-shell { min-height: 100vh; }
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(100%, 440px);
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: linear-gradient(155deg, rgba(19, 34, 58, 0.98), rgba(11, 23, 41, 0.98));
  box-shadow: var(--shadow);
}
.brand-lockup, .brand, .topbar-actions, .panel-head, .section-heading, .workspace-heading, .sidebar-head, .button-row {
  display: flex;
  align-items: center;
}
.brand-lockup { gap: 14px; margin-bottom: 18px; }
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: white;
  background: linear-gradient(145deg, #23b4ff, #1166c2);
  border: 1px solid rgba(255,255,255,.32);
  border-radius: 11px;
  font-size: .79rem;
  font-weight: 900;
  letter-spacing: .08em;
}
h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: 1.55rem; }
h2 { margin-bottom: 6px; font-size: 1.35rem; }
h3 { margin-bottom: 6px; font-size: 1.04rem; }
h4 { margin: 0; font-size: .99rem; }
.eyebrow { margin-bottom: 5px; color: var(--blue); font-size: .75rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.muted { color: var(--muted); line-height: 1.5; }
.small { font-size: .84rem; }
.optional { color: var(--muted); font-size: .8rem; font-weight: 500; }
.stack { display: grid; gap: 14px; margin-top: 24px; }
label { display: grid; gap: 7px; color: #dbe8fb; font-size: .92rem; font-weight: 650; }
input, select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  background: rgba(3, 10, 20, 0.52);
  outline: none;
}
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(58,179,255,.18); }
input[type="file"] { padding: 8px; font-size: .82rem; }
input[type="file"]::file-selector-button { margin-right: 10px; border: 0; border-radius: 7px; padding: 6px 9px; color: #dcecff; background: #24446d; cursor: pointer; }
.form-message { min-height: 22px; margin: 14px 0 0; color: var(--red); font-size: .9rem; }
.form-message.success { color: var(--green); }

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  color: var(--text);
  font-size: .9rem;
  font-weight: 750;
  text-decoration: none;
  transition: transform .12s ease, border-color .12s ease, background .12s ease, opacity .12s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .5; }
.button.primary { background: linear-gradient(135deg, #219eea, #0566bb); box-shadow: 0 8px 20px rgba(17, 126, 212, 0.26); }
.button.secondary { border-color: var(--border-strong); background: rgba(22, 42, 70, 0.7); }
.button.quiet { min-height: 34px; padding: 6px 9px; border-color: transparent; background: transparent; color: var(--muted); }
.button.quiet:hover { color: var(--text); background: rgba(255,255,255,.06); }
.icon-button { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 9px; color: var(--muted); background: transparent; }
.icon-button:hover { color: var(--text); border-color: var(--border-strong); }

.app-shell { min-height: 100vh; }
.topbar {
  min-height: 66px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 17, 31, 0.78);
  backdrop-filter: blur(18px);
}
.brand { gap: 10px; color: var(--text); text-decoration: none; font-size: 1.05rem; font-weight: 850; }
.brand .brand-mark { width: 31px; height: 31px; border-radius: 9px; font-size: .67rem; }
.environment-badge { padding: 3px 7px; border: 1px solid rgba(244, 184, 74, .45); border-radius: 999px; color: #ffd68c; background: rgba(244,184,74,.08); font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.topbar-actions { gap: 12px; }
.organization-select-label select { width: auto; min-width: 184px; min-height: 35px; padding: 6px 30px 6px 9px; font-size: .85rem; }
.user-email { max-width: 240px; overflow: hidden; color: var(--muted); font-size: .86rem; text-overflow: ellipsis; white-space: nowrap; }

.app-layout { min-height: calc(100vh - 66px); display: grid; grid-template-columns: minmax(290px, 340px) 1fr; }
.sidebar { padding: 24px; border-right: 1px solid var(--border); background: rgba(5, 15, 28, .38); }
.sidebar-head, .workspace-heading, .section-heading { justify-content: space-between; gap: 16px; }
.sidebar-head { margin-bottom: 20px; }
.new-batch-form { display: grid; gap: 14px; padding: 16px; margin-bottom: 20px; border: 1px solid var(--border); border-radius: 15px; background: rgba(19, 34, 58, .65); }
.batch-list { display: grid; gap: 8px; }
.batch-item { width: 100%; display: grid; gap: 5px; text-align: left; border: 1px solid var(--border); border-radius: 12px; padding: 12px; color: var(--text); background: rgba(12, 27, 46, .44); }
.batch-item:hover { border-color: var(--border-strong); background: rgba(20, 46, 77, .65); }
.batch-item.active { border-color: rgba(58,179,255,.75); background: rgba(17, 93, 152, .2); box-shadow: inset 3px 0 0 var(--blue); }
.batch-item-title { overflow: hidden; font-size: .92rem; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.batch-item-meta { color: var(--muted); font-size: .78rem; }
.empty-list { padding: 18px 6px; color: var(--muted); font-size: .88rem; line-height: 1.5; }

.workspace { width: min(100%, 1180px); padding: 32px; margin: 0 auto; }
.workspace-heading { margin-bottom: 26px; }
.workspace-heading h2 { margin-bottom: 6px; }
.status-badge, .count-chip { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 999px; padding: 5px 9px; font-size: .72rem; font-weight: 800; white-space: nowrap; }
.status-badge.neutral { color: #c9d8ec; background: rgba(166, 188, 216, .09); }
.status-badge.success { color: #90efba; border-color: rgba(53,208,132,.35); background: rgba(53,208,132,.11); }
.status-badge.warning { color: #ffd78c; border-color: rgba(244,184,74,.42); background: rgba(244,184,74,.1); }
.status-badge.error { color: #ff9b9b; border-color: rgba(255,107,107,.42); background: rgba(255,107,107,.1); }
.count-chip { color: #b8c9df; background: rgba(255,255,255,.05); }
.empty-state { padding: 52px 28px; border: 1px dashed var(--border-strong); border-radius: 18px; text-align: center; background: rgba(14, 31, 52, .35); }
.empty-state h3 { font-size: 1.12rem; }
.empty-state p { max-width: 520px; margin: 0 auto; color: var(--muted); line-height: 1.55; }
.upload-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.panel { border: 1px solid var(--border); border-radius: 17px; padding: 20px; background: linear-gradient(145deg, rgba(21, 40, 67, .88), rgba(12, 26, 45, .88)); box-shadow: 0 12px 30px rgba(0,0,0,.15); }
.panel-head { justify-content: space-between; gap: 12px; }
.upload-panel { display: grid; gap: 13px; }
.file-list { display: grid; gap: 7px; padding: 0; margin: 0; list-style: none; }
.file-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid rgba(203,222,255,.09); color: #cddbed; font-size: .82rem; }
.file-list li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .file-status { flex: 0 0 auto; color: var(--muted); font-size: .72rem; }

.reconciliation-panel { margin-top: 18px; }
.workflow-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.workflow-heading > div { max-width: 720px; }
.workflow-heading .muted { margin-bottom: 0; }
.workflow-options { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.25fr); gap: 14px; }
.workflow-option { display: flex; flex-direction: column; gap: 12px; min-width: 0; padding: 16px; border: 1px solid var(--border); border-radius: 14px; background: rgba(7, 19, 35, .42); }
.workflow-option-ledger { border-color: rgba(58, 179, 255, .28); background: linear-gradient(145deg, rgba(20, 52, 82, .52), rgba(10, 25, 43, .52)); }
.workflow-option-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.workflow-option-label { display: inline-flex; align-items: center; border: 1px solid rgba(58, 179, 255, .36); border-radius: 999px; padding: 3px 7px; color: #bce6ff; background: rgba(58, 179, 255, .1); font-size: .68rem; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
.workflow-option p { margin-bottom: 0; color: var(--muted); line-height: 1.5; }
.workflow-note { padding: 9px 10px; border-left: 3px solid rgba(53, 208, 132, .65); border-radius: 7px; color: #c7d9eb !important; background: rgba(53, 208, 132, .06); font-size: .84rem; }
.workflow-option > .button { width: 100%; margin-top: auto; }
.workflow-checklist { display: grid; gap: 8px; padding: 0; margin: 0; list-style: none; }
.workflow-checklist li { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 8px; align-items: start; color: #dbe8f8; font-size: .84rem; line-height: 1.35; }
.workflow-checklist-index { width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid rgba(58, 179, 255, .38); border-radius: 50%; color: #bce6ff; background: rgba(58, 179, 255, .09); font-size: .72rem; font-weight: 850; }
.workflow-checklist strong { display: block; }
.workflow-checklist small { display: block; margin-top: 2px; color: var(--muted); font-size: .79rem; }
.workflow-actions { display: grid; gap: 8px; margin-top: auto; }
.workflow-actions .button { width: 100%; }
.workflow-reassurance { margin: 14px 0 0; padding: 11px 13px; border: 1px solid rgba(203, 222, 255, .12); border-radius: 10px; color: #bed0e5; background: rgba(3, 13, 26, .25); font-size: .86rem; line-height: 1.5; }

.button-row { gap: 10px; flex-wrap: wrap; }
.summary-section { margin-top: 24px; }
.section-heading { margin-bottom: 15px; }
.summary-cards { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.summary-card { min-height: 92px; padding: 13px; border: 1px solid var(--border); border-radius: 13px; background: rgba(15, 34, 57, .72); }
.summary-card .metric { margin-top: 7px; font-size: 1.65rem; font-weight: 850; }
.summary-card .label { color: var(--muted); font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.results-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 14px; background: rgba(8, 19, 35, .54); }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th, td { padding: 11px 12px; border-bottom: 1px solid rgba(203,222,255,.08); text-align: left; vertical-align: top; }
th { position: sticky; top: 0; color: #b7c7dd; background: #10213a; font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; }
td { color: #d9e6f7; }
tbody tr:last-child td { border-bottom: 0; }
.result-pill { display: inline-block; border-radius: 999px; padding: 3px 7px; font-size: .7rem; font-weight: 800; white-space: nowrap; }
.result-pill.matched { color: #91efbd; background: rgba(53,208,132,.12); }
.result-pill.unmatched { color: #ffb0b0; background: rgba(255,107,107,.12); }
.result-pill.partial { color: #ffe09d; background: rgba(244,184,74,.12); }
.result-pill.ignored { color: #b7c7dd; background: rgba(183,199,221,.12); }

@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
  .workspace { padding: 24px; }
  .summary-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .upload-grid, .workflow-options { grid-template-columns: 1fr; }
  .workflow-heading { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 640px) {
  .topbar { align-items: flex-start; flex-direction: column; padding: 14px 18px; }
  .topbar-actions { width: 100%; flex-wrap: wrap; }
  .organization-select-label { flex: 1 1 170px; }
  .organization-select-label select { width: 100%; }
  .user-email { max-width: 100%; }
  .sidebar { padding: 18px; }
  .workspace { padding: 20px 18px; }
  .workspace-heading { align-items: flex-start; flex-direction: column; }
  .summary-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
