:root {
  color-scheme: light;
  --ink: #17211b;
  --muted: #637168;
  --line: #d9e0db;
  --surface: #ffffff;
  --canvas: #f4f7f5;
  --green: #076b3d;
  --green-dark: #04552f;
  --gold: #aa7b18;
  --red: #b42318;
  --blue: #235aa6;
  --shadow: 0 10px 30px rgba(22, 48, 32, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); min-height: 100vh; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
a { color: var(--green); text-decoration: none; }
.topbar { height: 68px; background: #fff; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 240px 1fr auto; align-items: center; padding: 0 28px; position: sticky; top: 0; z-index: 20; }
.brand { display: flex; gap: 10px; align-items: center; color: var(--ink); }
.brand img { width: 38px; height: 38px; object-fit: contain; }
.brand span, .user-menu > span { display: flex; flex-direction: column; }
.brand small, .user-menu small { color: var(--muted); font-size: 12px; }
nav { display: flex; align-self: stretch; gap: 6px; }
nav a { color: #465149; display: flex; align-items: center; padding: 0 14px; border-bottom: 3px solid transparent; font-size: 14px; font-weight: 650; }
nav a.active { color: var(--green); border-bottom-color: var(--green); }
.user-menu { display: flex; align-items: center; gap: 14px; text-align: right; font-size: 13px; }
.app-shell { width: min(1460px, calc(100% - 48px)); margin: 0 auto; padding: 34px 0 70px; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #eef4f0; }
.auth-panel { width: min(440px, 100%); background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); padding: 40px; border-radius: 8px; }
.auth-logo { width: 84px; height: 84px; object-fit: contain; display: block; margin: 0 auto 18px; }
.auth-heading { text-align: center; margin-bottom: 28px; }
h1, h2, p { margin-top: 0; }
h1 { font-size: 28px; line-height: 1.2; margin-bottom: 7px; letter-spacing: 0; }
h2 { font-size: 18px; margin-bottom: 0; letter-spacing: 0; }
.auth-heading p, .page-heading p { color: var(--muted); margin: 0; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 28px; }
.back-link { display: block; font-size: 13px; margin-bottom: 10px; }
.actions, .form-actions, .action-strip { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.button { min-height: 42px; padding: 0 16px; border: 1px solid transparent; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.button img, .alert img { width: 17px; height: 17px; }
.button.primary { background: var(--green); color: white; }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { background: white; color: var(--ink); border-color: #bfcac2; }
.button.ghost { background: transparent; color: var(--muted); }
.button.warning { background: #fff7db; border-color: #e3c55c; color: #6b4b00; }
.button.danger { background: #fff; border-color: #e6a39d; color: var(--red); }
.button.full { width: 100%; }
.button.small { min-height: 34px; padding: 0 11px; font-size: 12px; }
.icon-button { width: 38px; height: 38px; border: 1px solid transparent; background: transparent; border-radius: 6px; display: inline-grid; place-items: center; cursor: pointer; }
.icon-button:hover { background: #edf3ef; border-color: var(--line); }
.icon-button img { width: 19px; height: 19px; }
.form-stack { display: grid; gap: 18px; }
.form-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 26px; margin-bottom: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 24px; }
.form-grid.compact { gap: 14px 18px; }
.full-span { grid-column: 1 / -1; }
label { display: grid; gap: 7px; color: #313c35; font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #bfcac2; background: #fff; color: var(--ink); border-radius: 6px; padding: 11px 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(7,107,61,.12); }
textarea { resize: vertical; }
.optional { color: var(--muted); font-weight: 500; }
.alert { min-height: 46px; display: flex; align-items: center; gap: 10px; border: 1px solid; border-radius: 6px; padding: 10px 14px; margin-bottom: 18px; font-weight: 650; }
.alert.success { background: #eaf7ef; border-color: #9fd4b2; color: #145c34; }
.alert.error { background: #fff0ee; border-color: #e6aaa4; color: #8d1b13; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); background: white; margin-bottom: 26px; }
.summary-item { padding: 20px 22px; border-right: 1px solid var(--line); display: flex; align-items: baseline; justify-content: space-between; }
.summary-item:last-child { border-right: 0; }
.summary-item span { color: var(--muted); font-size: 13px; }
.summary-item strong { font-size: 25px; }
.table-section, .data-section { background: white; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 25px; }
.section-heading { min-height: 58px; display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.section-heading > span { color: var(--muted); font-size: 13px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { color: var(--muted); text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; background: #fafcfb; }
th, td { padding: 13px 16px; border-bottom: 1px solid #e5ebe7; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
td strong, td small { display: block; }
td small { color: var(--muted); margin-top: 3px; }
.status { display: inline-flex; align-items: center; min-height: 27px; padding: 0 9px; border-radius: 999px; font-size: 11px; font-weight: 800; text-transform: capitalize; background: #e9eeeb; color: #425047; }
.status-ready, .status-completed, .status-initial_sync_complete { background: #dcf5e5; color: #126136; }
.status-running, .status-queued, .status-preflight_running { background: #e4effd; color: #174f96; }
.status-failed, .status-preflight_failed, .status-credentials_expired { background: #fde6e3; color: #9a2017; }
.status-needs_admin_approval, .status-cancel_requested, .status-interrupted { background: #fff2c7; color: #725100; }
.status-band { background: #18261e; color: white; padding: 20px 24px; margin-bottom: 24px; display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.status-band > div:first-child { display: flex; align-items: center; gap: 14px; }
.status-band dl { display: flex; margin: 0; gap: 32px; }
.status-band dl div { display: grid; gap: 3px; }
.status-band dt { color: #a8b8ae; font-size: 11px; }
.status-band dd { margin: 0; font-size: 18px; font-weight: 800; }
.inline-error { color: #ffb9b3; margin: 0; font-size: 12px; }
.action-strip { margin-bottom: 24px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; margin: 0; }
.facts div { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--muted); font-size: 12px; }
.facts dd { margin: 6px 0 0; font-weight: 800; }
.folder-order { margin: 16px 18px 10px 38px; padding: 0; }
.folder-order li { padding: 5px; }
.muted { color: var(--muted); font-size: 12px; margin: 12px 18px 18px; }
.empty-state { color: var(--muted); text-align: center; padding: 28px !important; }
.worker-state { display: inline-flex; align-items: center; gap: 7px; }
.worker-state i { width: 8px; height: 8px; border-radius: 50%; background: #aeb8b1; }
.worker-state.online i { background: #20a35a; }
.narrow-page { width: min(700px, 100%); margin: 0 auto; }
.totp-layout { background: white; border: 1px solid var(--line); padding: 26px; display: grid; grid-template-columns: 220px 1fr; gap: 30px; align-items: center; }
.qr-code { width: 220px; height: 220px; }
.secret-output { font: 600 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: #edf2ef; border: 1px solid var(--line); padding: 10px; overflow-wrap: anywhere; }
.csv-schema { border-left: 3px solid var(--green); padding: 8px 14px; display: grid; gap: 5px; color: var(--muted); }
.csv-schema code { color: var(--ink); font-weight: 700; }
.validation-panel { background: #fff7e3; border: 1px solid #dfbf6b; padding: 22px; margin-bottom: 20px; }
.validation-panel ul { max-height: 280px; overflow: auto; }
.confirm-strip { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 18px; border-top: 1px solid var(--line); }
details summary { cursor: pointer; color: var(--green); font-weight: 700; }
.inline-form { min-width: 300px; display: grid; gap: 8px; padding: 10px 0; }
.check { display: flex; align-items: center; gap: 7px; font-weight: 600; }
.check input { width: auto; }
@media (max-width: 900px) {
  .topbar { height: auto; min-height: 68px; grid-template-columns: 1fr auto; padding: 12px 18px; }
  nav { grid-column: 1 / -1; order: 3; overflow-x: auto; }
  nav a { min-height: 42px; padding: 0 10px; }
  .user-menu > span { display: none; }
  .app-shell { width: min(100% - 28px, 1460px); padding-top: 24px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary-item:nth-child(2) { border-right: 0; }
  .summary-item:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .detail-grid { grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 640px) {
  .page-heading { align-items: stretch; flex-direction: column; }
  .actions .button { flex: 1; }
  .form-grid, .totp-layout { grid-template-columns: 1fr; }
  .full-span { grid-column: auto; }
  .summary-grid { grid-template-columns: 1fr; }
  .summary-item { border-right: 0; border-bottom: 1px solid var(--line); }
  .status-band { align-items: flex-start; flex-direction: column; }
  .status-band dl { width: 100%; justify-content: space-between; gap: 12px; }
  .auth-panel { padding: 28px 22px; }
  .qr-code { width: min(220px, 100%); height: auto; justify-self: center; }
}
