:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-muted: #eef1ed;
  --ink: #15201b;
  --muted: #66706a;
  --line: #d7ddd8;
  --line-strong: #bcc6bf;
  --green: #126b45;
  --green-dark: #0c5234;
  --green-soft: #e5f2eb;
  --amber: #925b09;
  --amber-soft: #fff3d8;
  --red: #a33a34;
  --red-soft: #fce9e7;
  --shadow: 0 18px 45px rgba(24, 42, 32, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--bg); }
button, input, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
h1, h2, p { margin: 0; }
h1 { font-size: 24px; line-height: 1.2; letter-spacing: 0; }
h2 { font-size: 20px; line-height: 1.3; letter-spacing: 0; }

.public-shell { width: min(980px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 26px; }
.public-header { min-height: 98px; display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.brand-lockup { display: flex; align-items: center; gap: 13px; }
.brand-lockup p { margin-top: 3px; color: var(--muted); font-size: 13px; }
.brand-lockup.compact h1 { font-size: 20px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 6px; background: var(--ink); color: #fff; font-size: 20px; font-weight: 800; }
.extract-tool { margin-top: 34px; padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.tool-heading, .section-heading.inline { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.eyebrow { margin-bottom: 5px; color: var(--green); font-size: 12px; font-weight: 750; text-transform: uppercase; }
.count-badge { min-width: 38px; height: 30px; padding: 0 10px; display: grid; place-items: center; border-radius: 999px; background: var(--surface-muted); color: var(--muted); font-variant-numeric: tabular-nums; }
.extract-tool form { margin-top: 24px; }
.field-label { display: block; margin-bottom: 7px; color: var(--ink); font-size: 13px; font-weight: 700; }
textarea, input:not([type="checkbox"]):not([type="file"]) { width: 100%; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; color: var(--ink); outline: none; }
textarea { min-height: 124px; padding: 14px; resize: vertical; line-height: 1.55; font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 15px; text-transform: uppercase; }
input:not([type="checkbox"]):not([type="file"]) { height: 44px; padding: 0 12px; }
textarea:focus, input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(18, 107, 69, 0.12); }
.form-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 16px; }
.field-hint { color: var(--muted); font-size: 12px; line-height: 1.5; }
.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 14px; border: 1px solid transparent; border-radius: 6px; cursor: pointer; text-decoration: none; font-weight: 700; }
.button.primary { background: var(--green); color: #fff; }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { background: #fff; border-color: var(--line-strong); color: var(--ink); }
.button.secondary:hover { background: var(--surface-muted); }
.button.danger-button { min-height: 38px; background: #fff; border-color: #d9aaa6; color: var(--red); }
.button.danger-button:hover:not(:disabled) { background: var(--red-soft); }
.button.full { width: 100%; }
.button:disabled { opacity: 0.55; cursor: wait; }
.status { min-height: 24px; margin-top: 14px; color: var(--muted); font-size: 13px; }
.status.success { color: var(--green); }
.status.error { color: var(--red); }
.public-footer { margin-top: 38px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-panel { width: min(420px, 100%); padding: 30px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.stack-form { display: flex; flex-direction: column; }
.login-panel .stack-form { margin-top: 28px; }
.login-panel input { margin-bottom: 16px; }

.admin-shell { width: min(1320px, calc(100% - 36px)); margin: 0 auto; padding-bottom: 50px; }
.admin-header { min-height: 86px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-button { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; color: var(--ink); cursor: pointer; font-size: 19px; }
.icon-button:hover { background: var(--surface-muted); }
.stats-strip { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.stats-strip > div { padding: 24px 20px; border-right: 1px solid var(--line); }
.stats-strip > div:first-child { padding-left: 0; }
.stats-strip > div:last-child { border-right: 0; }
.stats-strip span { display: block; color: var(--muted); font-size: 12px; }
.stats-strip strong { display: block; margin-top: 7px; font-size: 26px; line-height: 1; font-variant-numeric: tabular-nums; }
.admin-layout { display: grid; grid-template-columns: minmax(320px, 440px) minmax(0, 1fr); gap: 40px; padding: 34px 0; border-bottom: 1px solid var(--line); }
.upload-section, .created-section { min-width: 0; }
.section-heading { margin-bottom: 20px; }
.drop-zone { min-height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border: 1px dashed var(--line-strong); border-radius: 6px; background: var(--surface); cursor: pointer; text-align: center; }
.drop-zone:hover { border-color: var(--green); background: var(--green-soft); }
.drop-zone input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.drop-zone span:last-of-type { max-width: 88%; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.drop-icon { color: var(--green); font-size: 28px; }
.check-row { display: flex; align-items: flex-start; gap: 9px; margin: 14px 0 18px; color: var(--muted); font-size: 13px; }
.check-row input { width: 17px; height: 17px; accent-color: var(--green); }
.code-mode-row { margin-top: 0; padding: 13px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }
.code-mode-row span { min-width: 0; }
.code-mode-row strong, .code-mode-row small { display: block; }
.code-mode-row small { margin-top: 3px; color: var(--muted); line-height: 1.4; }
.upload-section textarea { margin-bottom: 16px; }
.input-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.upload-section .field-hint { margin: 7px 0 16px; }
.created-section { padding-left: 30px; border-left: 1px solid var(--line); }
.created-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.created-hint { margin: -10px 0 10px; }
.created-section textarea { min-height: 250px; background: #fbfcfb; text-transform: none; }
.records-section, .audit-section { padding-top: 34px; }
.records-section { border-bottom: 1px solid var(--line); padding-bottom: 34px; }
.bulk-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.bulk-select { min-height: 38px; display: inline-flex; align-items: center; gap: 7px; padding: 0 5px; color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 700; }
.bulk-select input, .row-checkbox { width: 17px; height: 17px; margin: 0; accent-color: var(--green); cursor: pointer; }
.bulk-select:has(input:disabled) { opacity: 0.55; cursor: default; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th, td { padding: 13px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; overflow-wrap: anywhere; }
th { color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; }
td { font-size: 13px; }
th:nth-child(1) { width: 4%; } th:nth-child(2) { width: 13%; } th:nth-child(3) { width: 24%; } th:nth-child(4) { width: 9%; } th:nth-child(5) { width: 9%; } th:nth-child(6) { width: 9%; } th:nth-child(7) { width: 19%; } th:nth-child(8) { width: 13%; }
.selection-cell { text-align: center; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; }
.muted { color: var(--muted); }
.status-pill { display: inline-flex; align-items: center; min-height: 25px; padding: 2px 8px; border-radius: 999px; background: var(--green-soft); color: var(--green-dark); font-size: 11px; font-weight: 750; }
.status-pill.disabled { background: var(--red-soft); color: var(--red); }
.row-actions { display: flex; align-items: center; gap: 6px; }
.row-actions button { min-height: 32px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 5px; background: #fff; color: var(--ink); cursor: pointer; font-size: 12px; }
.row-actions button.danger { color: var(--red); }
.empty-state { padding: 40px 16px; color: var(--muted); text-align: center; }
.audit-list { border-top: 1px solid var(--line); }
.audit-item { display: grid; grid-template-columns: 28px 170px 150px 150px 1fr; gap: 14px; align-items: center; padding: 11px 8px; border-bottom: 1px solid var(--line); font-size: 12px; }
.audit-item span { overflow-wrap: anywhere; }
.audit-check { display: grid; place-items: center; }

@media (max-width: 900px) {
  .admin-layout { grid-template-columns: 1fr; gap: 28px; }
  .created-section { padding: 28px 0 0; border-left: 0; border-top: 1px solid var(--line); }
  .audit-item { grid-template-columns: 28px 1fr 1fr; }
  .audit-check { grid-row: 1 / span 2; }
  .audit-action { grid-column: 2; }
  .audit-detail { grid-column: 3; }
  table { min-width: 960px; }
}

@media (max-width: 640px) {
  .public-shell, .admin-shell { width: min(100% - 20px, 980px); }
  .public-header { min-height: 82px; }
  .extract-tool { margin-top: 20px; padding: 18px; }
  .form-footer { align-items: stretch; flex-direction: column; }
  .form-footer .button { width: 100%; }
  .admin-header { align-items: flex-start; padding: 16px 0; }
  .header-actions .button { display: none; }
  .stats-strip { grid-template-columns: 1fr 1fr; }
  .stats-strip > div, .stats-strip > div:first-child { padding: 17px 10px; border-right: 1px solid var(--line); }
  .stats-strip > div:nth-child(2) { border-right: 0; }
  .stats-strip > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .input-grid { grid-template-columns: 1fr; }
  .section-heading.inline { align-items: flex-start; }
  .bulk-actions { justify-content: flex-start; }
  .audit-item { grid-template-columns: 28px minmax(0, 1fr); gap: 5px 10px; }
  .audit-check { grid-row: 1 / span 4; }
  .audit-action, .audit-detail { grid-column: 2; }
}
