:root {
  color-scheme: light;
  --brand: #00bb9b;
  --brand-hover: #009c82;
  --brand-deep: #007d69;
  --navy: #071f35;
  --navy-strong: #02015a;
  --surface: #ffffff;
  --surface-soft: #f5f7f9;
  --surface-muted: #ecf1f7;
  --text: #071f35;
  --text-muted: #566678;
  --border: #d9e0e6;
  --focus: #00bb9b;
  --success: #007d69;
  --warning: #d98f00;
  --danger: #c9363e;
  --control-radius: 0.25rem;
  --surface-radius: 0.5rem;
  --section-radius: 1rem;
  --header-height: 4.75rem;

  font-family: "Be Vietnam Pro", "Avenir Next", Avenir, "Segoe UI", sans-serif;
  background: var(--surface);
  color: var(--text);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface: #071725;
  --surface-soft: #0d2b45;
  --surface-muted: #132f46;
  --text: #f5f7f9;
  --text-muted: #a8b4c0;
  --border: #294257;
  --brand-deep: #4ed8c1;
}

* { box-sizing: border-box; }
html { width: 100%; min-height: 100%; }
body { width: 100%; min-width: 0; min-height: 100vh; margin: 0; background: var(--surface); color: var(--text); }
button, select, input, label[for], summary { font: inherit; }
button, select, label[for], summary, [role="button"] { cursor: pointer; }
button:disabled { cursor: not-allowed; }
[hidden] { display: none !important; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0.55rem; font-size: clamp(2rem, 4vw, 2.8rem); font-weight: 600; line-height: 1.08; letter-spacing: -0.035em; }
h2 { margin-bottom: 0.4rem; font-size: clamp(1.4rem, 2vw, 1.9rem); font-weight: 600; letter-spacing: -0.025em; }
code { overflow-wrap: anywhere; }

.eyebrow { margin-bottom: 0.65rem; color: var(--brand-deep); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.lede { color: var(--text-muted); line-height: 1.55; }

.login-screen { display: grid; min-height: 100svh; grid-template-columns: minmax(28rem, 52%) 1fr; }
.brand-plane { position: relative; display: grid; align-items: center; overflow: hidden; background: var(--navy); color: white; }
.brand-plane::after { position: absolute; right: 6%; bottom: 8%; width: 42%; height: 36%; border: 1px solid rgb(0 187 155 / 55%); content: ""; }
.brand-content { position: relative; z-index: 2; width: min(80%, 35rem); margin: auto; }
.brand-logo { width: min(52%, 15rem); height: auto; margin-bottom: clamp(4rem, 10vh, 7rem); }
.brand-title { max-width: 32rem; margin-bottom: 1.25rem; color: white; font-size: clamp(2.45rem, 4.1vw, 4rem); font-weight: 600; line-height: 1.08; letter-spacing: -0.045em; }
.brand-copy { max-width: 31rem; margin: 0; color: #c5d0d9; font-size: clamp(1rem, 1.3vw, 1.18rem); line-height: 1.6; }
.brand-orb { position: absolute; z-index: 1; display: block; background: var(--brand); }
.brand-orb-top { width: 12rem; height: 0.85rem; top: 17%; right: -3rem; }
.brand-orb-bottom { width: 0.85rem; height: 13rem; right: 12%; bottom: -3rem; }
.login-plane { display: grid; place-items: center; padding: 3rem; background: var(--surface); }
.login-form { width: min(100%, 27rem); }
.login-form label, .batch-label-row label { display: block; margin: 1.8rem 0 0.5rem; font-size: 0.9rem; font-weight: 650; }
input, select { width: 100%; min-height: 3rem; border: 1px solid var(--border); border-radius: var(--control-radius); padding: 0.65rem 0.85rem; background: var(--surface); color: var(--text); transition: border-color 160ms ease, box-shadow 160ms ease; }
input:hover, select:hover { border-color: #a8b4c0; }
input:focus, select:focus { border-color: var(--brand-hover); box-shadow: 0 0 0 3px rgb(0 187 155 / 12%); }
input:focus-visible, select:focus-visible, button:focus-visible, label.button:focus-within, summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.login-form .button { width: 100%; margin-top: 1rem; }
.inline-error { margin: 0.7rem 0 0; color: var(--danger); font-size: 0.88rem; }
.copyright { margin-top: 2rem; color: var(--text-muted); font-size: 0.75rem; text-align: center; }
.mobile-brand { display: none; }

.button { display: inline-flex; min-height: 3rem; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: var(--control-radius); padding: 0.7rem 1.35rem; font-weight: 600; line-height: 1; text-decoration: none; transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease; }
.button:active:not(:disabled) { transform: translateY(1px); }
.button-primary { border-color: var(--brand); background: var(--brand); color: var(--navy); }
.button-primary:hover:not(:disabled) { border-color: var(--brand-hover); background: var(--brand-hover); color: white; }
.button-primary:disabled { border-color: var(--border); background: var(--surface-muted); color: var(--text-muted); }
.button-secondary { border-color: var(--navy); background: transparent; color: var(--navy); }
.button-secondary:hover:not(:disabled) { border-color: var(--navy); background: var(--navy); color: white; }
:root[data-theme="dark"] .button-secondary { border-color: var(--border); color: var(--text); }
:root[data-theme="dark"] .button-secondary:hover:not(:disabled) { border-color: var(--brand); background: var(--brand); color: var(--navy); }
.button-large { min-height: 3.25rem; }

.app-shell { width: 100%; min-width: 0; }
.app-header { position: sticky; z-index: 20; top: 0; width: 100%; height: var(--header-height); border-bottom: 1px solid rgb(255 255 255 / 12%); background: var(--navy); }
.header-inner { display: flex; width: 100%; height: 100%; align-items: center; justify-content: space-between; padding: 0 1.5rem; }
.header-home-link { display: inline-flex; border-radius: var(--control-radius); }
.header-home-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
.header-logo { width: auto; height: 2.35rem; }
.header-actions { display: flex; align-items: center; gap: 0.65rem; color: white; }
.tenant-badge { color: #c5d0d9; font-size: 0.76rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.icon-button, .header-button { min-width: 2.75rem; min-height: 2.75rem; border: 1px solid rgb(255 255 255 / 28%); border-radius: var(--control-radius); background: transparent; color: white; }
.header-button { padding: 0 0.9rem; }
.icon-button:hover, .header-button:hover { border-color: var(--brand); background: var(--brand); color: var(--navy); }

.workspace { width: 100%; padding: 3.5rem clamp(1rem, 4vw, 4rem) 5rem; }
.title-row, .section-heading, .action-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; }
.title-actions { display: flex; align-items: flex-end; gap: 0.75rem; flex-wrap: wrap; justify-content: flex-end; }
.title-actions .button { white-space: nowrap; }
.tenant-select-label, .tenant-fixed { width: min(15rem, 100%); color: var(--text-muted); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; }
.tenant-select-label select { margin-top: 0.4rem; color: var(--text); font-size: 0.9rem; text-transform: none; }
.tenant-fixed { display: flex; flex-direction: column; gap: 0.4rem; }
.tenant-fixed strong { min-height: 3rem; border: 1px solid var(--border); border-radius: var(--control-radius); padding: 0.85rem 1rem; background: var(--surface); color: var(--text); font-size: 0.9rem; text-transform: none; }
.tenant-fixed[hidden], .tenant-select-label[hidden] { display: none; }

.stage-rail { margin: 2.6rem 0 0; border: 1px solid var(--border); border-radius: var(--surface-radius); padding: 1.15rem 1.4rem 1.3rem; background: var(--surface-soft); }
.stage-rail-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.stage-kicker, .stage-status { margin: 0; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.055em; text-transform: uppercase; }
.stage-kicker { color: var(--text); }
.stage-status { color: var(--text-muted); }
.stage-rail ol { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0; padding: 0; list-style: none; }
.stage-rail li { position: relative; display: flex; min-width: 0; align-items: center; gap: 0.6rem; color: var(--text-muted); font-size: 0.82rem; }
.stage-rail li:not(:last-child)::after { position: absolute; z-index: 0; top: 50%; right: 0.8rem; left: 2.15rem; height: 1px; background: var(--border); content: ""; }
.stage-rail li span, .stage-rail li strong { position: relative; z-index: 1; }
.stage-rail li span { display: grid; width: 1.8rem; height: 1.8rem; flex: 0 0 auto; place-items: center; border: 1px solid var(--border); border-radius: var(--control-radius); background: var(--surface); font-size: 0.75rem; }
.stage-rail li strong { padding-right: 0.75rem; background: var(--surface-soft); }
.stage-rail li.current { color: var(--text); }
.stage-rail li.current span { border: 2px solid var(--brand); color: var(--navy); }
:root[data-theme="dark"] .stage-rail li.current span { color: var(--text); }
.stage-rail li.complete span { border-color: var(--brand); background: var(--brand); color: var(--navy); }
.mobile-stage { display: none; }

.stage-panel { margin-top: 1.5rem; animation: stage-in 180ms ease both; }
.stage-panel:not(#folder-stage) { border: 1px solid var(--border); border-radius: var(--surface-radius); padding: clamp(1.5rem, 3vw, 2.5rem); background: var(--surface); box-shadow: 0 1px 2px rgb(7 31 53 / 5%); }
.drop-zone { border: 1px dashed #a8b4c0; border-radius: var(--surface-radius); padding: clamp(2.5rem, 8vw, 5rem) 2rem; background: var(--surface-soft); text-align: center; transition: border-color 160ms ease, background-color 160ms ease; }
.drop-zone.dragover { border-color: var(--brand); background: var(--surface-soft); }
.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  border: 0;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.folder-symbol { display: grid; width: 3.5rem; height: 3.5rem; place-items: center; margin: 0 auto 1.15rem; border-radius: var(--surface-radius); background: var(--brand); color: var(--navy); font-size: 1.65rem; }
.support-copy { margin: 1rem 0 0; color: var(--text-muted); font-size: 0.8rem; }
.ingestion-upload-entry { display: flex; justify-content: center; margin-top: 1rem; }
.ingestion-upload-panel { margin-top: 1.5rem; padding: clamp(1.25rem, 3vw, 2rem); border: 1px solid var(--border); border-radius: var(--surface-radius); background: var(--surface); }
.ingestion-upload-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 1rem; margin-top: 1.5rem; }
.ingestion-upload-fields label { display: grid; gap: 0.5rem; color: var(--text-muted); font-size: 0.85rem; font-weight: 700; }
.ingestion-upload-fields select, .ingestion-upload-fields input { width: 100%; }
@media (max-width: 640px) { .ingestion-upload-fields { grid-template-columns: 1fr; } }
.resume-panel { margin-top: 1.5rem; border-top: 1px solid var(--border); padding-top: 1.5rem; }
.section-heading { margin-bottom: 1.5rem; border-bottom: 1px solid var(--border); padding-bottom: 1rem; }
.error-summary, .message { margin-bottom: 1.25rem; border-left: 4px solid var(--danger); border-radius: 0 var(--control-radius) var(--control-radius) 0; padding: 0.9rem 1rem; background: color-mix(in srgb, var(--danger) 8%, var(--surface)); color: var(--text); }
.message.success { border-color: var(--success); background: color-mix(in srgb, var(--success) 8%, var(--surface)); }
.summary-band { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0 0 1.5rem; border-block: 1px solid var(--border); padding: 1rem 0; }
.summary-band div { padding: 0 1rem; border-right: 1px solid var(--border); }
.summary-band div:first-child { padding-left: 0; }
.summary-band div:last-child { border: 0; }
.summary-band dt { color: var(--text-muted); font-size: 0.72rem; text-transform: uppercase; }
.summary-band dd { margin: 0.3rem 0 0; font-size: 1.4rem; font-weight: 600; }
.folder-tree { border-bottom: 1px solid var(--border); }
.folder-tree details { border-top: 1px solid var(--border); }
.folder-tree summary { display: flex; min-height: 3rem; align-items: center; justify-content: space-between; padding: 0.7rem 0; font-weight: 650; }
.case-list { margin: 0 0 0.8rem; padding: 0 0 0 1.2rem; color: var(--text-muted); }
.case-list li { margin: 0.35rem 0; overflow-wrap: anywhere; }
.batch-label-row { width: min(28rem, 100%); }
.batch-label-row label span { color: var(--text-muted); font-size: 0.78rem; font-weight: 400; }
.action-row { justify-content: flex-end; margin-top: 2rem; }

.batch-id { color: var(--text-muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.78rem; overflow-wrap: anywhere; }
.progress-copy { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 0.6rem; }
progress { width: 100%; height: 0.45rem; border: 0; border-radius: 0; background: var(--surface-muted); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--surface-muted); }
progress::-webkit-progress-value { background: var(--brand); transition: width 180ms ease; }
progress::-moz-progress-bar { background: var(--brand); }
.status-list { max-height: 25rem; margin-top: 1.5rem; border-block: 1px solid var(--border); overflow: auto; }
.status-row { display: grid; grid-template-columns: 1fr auto; gap: 1rem; border-bottom: 1px solid var(--border); padding: 0.75rem 0; font-size: 0.84rem; }
.status-row:last-child { border: 0; }
.status-path { overflow-wrap: anywhere; }
.status-value { color: var(--text-muted); font-weight: 650; }
.status-row.failed .status-value { color: var(--danger); }
.status-row.done .status-value { color: var(--success); }

.promotion-groups { display: grid; gap: 1.5rem; }
.promotion-group { border-top: 3px solid var(--border); padding-top: 0.8rem; }
.promotion-group.copy { border-color: var(--success); }
.promotion-group.replace { border-color: var(--warning); }
.promotion-group.conflict { border-color: var(--danger); }
.promotion-group h3 { display: flex; justify-content: space-between; margin: 0 0 0.5rem; font-size: 1rem; }
.promotion-item { border-top: 1px solid var(--border); padding: 0.75rem 0; overflow-wrap: anywhere; }
.promotion-item code { display: block; color: var(--text-muted); font-size: 0.72rem; }
.acknowledgement { display: flex; align-items: center; gap: 0.7rem; margin-top: 1.5rem; border: 1px solid color-mix(in srgb, var(--warning) 45%, var(--border)); border-radius: var(--control-radius); padding: 1rem; background: color-mix(in srgb, var(--warning) 8%, var(--surface)); cursor: pointer; }
.acknowledgement input { width: 1.2rem; min-height: 1.2rem; accent-color: var(--brand); }
.cli-alternative { margin-top: 1.5rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.cli-alternative summary { width: fit-content; color: var(--text-muted); font-size: 0.85rem; font-weight: 650; }
.cli-alternative[open] summary { margin-bottom: 0.75rem; color: var(--text); }

.completion { width: 100%; text-align: center; }
.completion > p:not(.eyebrow) { max-width: 42rem; margin-right: auto; margin-left: auto; }
.completion .action-row { justify-content: center; }
.success-mark { display: grid; width: 4rem; height: 4rem; place-items: center; margin: 0 auto 1.2rem; border-radius: var(--surface-radius); background: var(--brand); color: var(--navy); font-size: 2rem; }
.receipt-summary { display: grid; width: min(100%, 60rem); grid-template-columns: repeat(3, 1fr); margin: 2rem auto; border-block: 1px solid var(--border); padding: 1rem 0; }
.receipt-summary dt { color: var(--text-muted); font-size: 0.75rem; }
.receipt-summary dd { margin: 0.3rem 0 0; font-weight: 750; }
.command-block { display: flex; align-items: center; gap: 1rem; border-radius: var(--surface-radius); padding: 1rem; background: var(--surface-muted); text-align: left; }
.command-block code { flex: 1; font-size: 0.78rem; }

@keyframes stage-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 760px) {
  .login-screen { display: block; background: var(--surface); }
  .brand-plane { display: none; }
  .mobile-brand { display: grid; min-height: 7.5rem; place-items: center; margin: -2rem -1rem 3rem; background: var(--navy); }
  .mobile-brand img { width: 12rem; }
  .login-plane { min-height: 100svh; padding: 2rem 1rem; }
  .workspace { padding: 2rem 1rem 7rem; }
  .title-row, .section-heading { align-items: flex-start; flex-direction: column; }
  .title-actions { width: 100%; align-items: stretch; flex-direction: column; }
  .title-actions .button { width: 100%; }
  .tenant-select-label, .tenant-fixed { width: 100%; }
  .stage-rail { padding: 1rem; }
  .stage-rail-header { margin-bottom: 0.55rem; }
  .stage-rail ol { display: none; }
  .mobile-stage { display: block; margin: 0; color: var(--text); font-size: 0.86rem; font-weight: 650; }
  .stage-panel:not(#folder-stage) { padding: 1.25rem; }
  .summary-band { grid-template-columns: repeat(2, 1fr); }
  .summary-band div { border-bottom: 1px solid var(--border); padding: 0.8rem; }
  .summary-band div:nth-child(2) { border-right: 0; }
  .summary-band div:nth-last-child(-n + 2) { border-bottom: 0; }
  .header-inner { padding: 0 1rem; }
  .header-logo { height: 2rem; }
  .tenant-badge { display: none; }
  .sticky-mobile-actions { position: fixed; z-index: 10; right: 0; bottom: 0; left: 0; margin: 0; border-top: 1px solid var(--border); padding: 0.8rem max(1rem, env(safe-area-inset-right)) calc(0.8rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); }
  .receipt-summary { grid-template-columns: 1fr; gap: 1rem; }
  .command-block { align-items: stretch; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
