:root {
  --ink: #18252b;
  --muted: #617078;
  --line: #d6dee1;
  --surface: #ffffff;
  --canvas: #f3f6f6;
  --teal: #15586a;
  --teal-dark: #0d4351;
  --blue-soft: #e4f0f3;
  --green: #23724b;
  --green-soft: #e6f4eb;
  --amber: #a76610;
  --amber-soft: #fff3d8;
  --red: #a63c35;
  --red-soft: #fbe9e7;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .52; }

.topbar {
  position: sticky; top: 0; z-index: 10; height: 64px; padding: 0 24px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  background: #fff; border-bottom: 1px solid var(--line);
}
.topbar-brand, .user-menu, .topnav { display: flex; align-items: center; }
.topbar-brand { gap: 10px; font-weight: 700; }
.user-menu { justify-content: flex-end; gap: 14px; color: var(--muted); }
.user-menu form { margin: 0; }
.topnav { height: 100%; gap: 4px; }
.nav-button { height: 100%; padding: 0 18px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); }
.nav-button.active { color: var(--teal-dark); border-color: var(--teal); font-weight: 700; }
.brand-mark { width: 54px; height: 54px; display: grid; place-items: center; background: var(--teal); color: #fff; font-weight: 800; font-size: 20px; }
.brand-mark.small { width: 34px; height: 34px; font-size: 13px; }

main { max-width: 1480px; margin: 0 auto; padding: 32px; }
.view { display: none; }
.view.active { display: block; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 24px; }
.page-heading h1 { margin: 3px 0 0; font-size: 30px; line-height: 1.18; letter-spacing: 0; }
.eyebrow { margin: 0; color: var(--teal); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.quiet { color: var(--muted); line-height: 1.5; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.form-panel, .summary-panel { background: var(--surface); border: 1px solid var(--line); }
.form-panel { padding: 26px; }
.summary-panel { padding: 24px; position: sticky; top: 88px; }
.summary-panel h2 { margin: 0 0 18px; font-size: 19px; }
.section-title { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.section-title.compact { margin-top: 30px; }
.section-title > span { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--blue-soft); color: var(--teal-dark); font-weight: 800; }
.section-title h2 { margin: 1px 0 4px; font-size: 19px; }
.section-title p { margin: 0; color: var(--muted); }

.source-switch, .system-tabs { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.segment, .system-tab { padding: 11px 16px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); }
.segment.active, .system-tab.active { color: var(--teal-dark); border-color: var(--teal); font-weight: 700; }
.source-pane { display: none; }
.source-pane.active { display: block; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
label { display: grid; gap: 7px; color: #415058; font-size: 13px; font-weight: 700; }
input, select { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #bfcbd0; border-radius: 4px; background: #fff; color: var(--ink); outline: 0; }
input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(21, 88, 106, .12); }
.check-line { display: flex; align-items: center; gap: 9px; min-height: 42px; padding-top: 19px; }
.check-line input { width: 18px; min-height: 18px; height: 18px; }
.file-drop { min-height: 84px; padding: 18px; align-content: center; border: 1px dashed #8fa4ad; background: #f8fbfb; text-align: center; cursor: pointer; }
.file-drop span { color: var(--muted); font-weight: 400; }

.primary, .secondary, .danger, .ghost, .icon-button { min-height: 40px; padding: 9px 15px; border-radius: 4px; border: 1px solid transparent; font-weight: 700; }
.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.primary:hover { background: var(--teal-dark); }
.secondary { background: #fff; border-color: #aab9bf; color: #30424a; }
.danger { background: #fff; border-color: #ca8e89; color: var(--red); }
.ghost { min-height: 34px; padding: 6px 9px; background: transparent; color: var(--teal-dark); }
.wide { width: 100%; }
.icon-button { padding: 4px 10px; border: 0; background: transparent; font-size: 24px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

.status-pill { padding: 8px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.neutral { background: #e8edef; color: #506069; }
.success { background: var(--green-soft); color: var(--green); }
.warning { background: var(--amber-soft); color: var(--amber); }
.error { background: var(--red-soft); color: var(--red); }
.summary-list { margin: 0 0 18px; }
.summary-list div { padding: 13px 0; border-top: 1px solid var(--line); }
.summary-list div:last-child { border-bottom: 1px solid var(--line); }
.summary-list dt { margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.summary-list dd { margin: 0; font-weight: 700; line-height: 1.4; }

.results-band { margin-top: 24px; padding: 26px; background: var(--surface); border: 1px solid var(--line); }
.result-header, .system-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.result-header h2, .system-toolbar h3 { margin: 3px 0 0; }
.system-tabs { margin-top: 22px; }
.system-panel { display: none; }
.system-panel.active { display: block; }
.system-toolbar { margin-bottom: 18px; }
.system-toolbar p { margin: 6px 0 0; color: var(--muted); }
.table-wrap { overflow: auto; border: 1px solid var(--line); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 11px 12px; background: #e8eff1; text-align: left; color: #3b4c54; font-size: 12px; white-space: nowrap; }
td { padding: 11px 12px; border-top: 1px solid var(--line); vertical-align: top; line-height: 1.4; }
tbody tr:hover { background: #f8fbfb; }
.value-cell { max-width: 760px; white-space: pre-wrap; overflow-wrap: anywhere; }
.empty-state { padding: 36px; border: 1px dashed #aebbc0; color: var(--muted); text-align: center; }
.inline-facts { display: flex; gap: 28px; margin-bottom: 16px; }
.inline-facts div { display: grid; gap: 4px; }
.inline-facts span { color: var(--muted); font-size: 12px; }
.status-check { display: grid; grid-template-columns: minmax(180px, 280px) auto; gap: 12px; align-items: end; margin-top: 18px; }
.journal-table { max-height: calc(100vh - 180px); }

dialog { width: min(520px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 20px 70px rgba(15, 34, 42, .25); }
dialog::backdrop { background: rgba(15, 34, 42, .48); }
#userForm { display: grid; gap: 15px; padding: 22px; }
.dialog-heading, .dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-heading h2 { margin: 0; }
.dialog-actions { justify-content: flex-end; margin-top: 8px; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: 460px; padding: 14px 17px; border-radius: 5px; background: #21333b; color: #fff; box-shadow: 0 12px 34px rgba(0,0,0,.24); transform: translateY(20px); opacity: 0; pointer-events: none; transition: .18s ease; z-index: 30; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: #81332e; color: #fff; }

.login-page { min-height: 100vh; display: grid; place-items: center; background: #eaf0f1; }
.login-shell { width: min(980px, calc(100% - 32px)); min-height: 560px; margin: 32px auto; padding: 0; display: grid; grid-template-columns: 1.15fr .85fr; background: #fff; border: 1px solid var(--line); box-shadow: 0 20px 70px rgba(15, 34, 42, .14); }
.login-brand { padding: 64px; display: flex; flex-direction: column; justify-content: center; background: var(--teal-dark); color: #fff; }
.login-brand .eyebrow { margin-top: 28px; color: #a9d0d8; }
.login-brand h1 { margin: 12px 0 18px; max-width: 520px; font-size: 38px; line-height: 1.15; letter-spacing: 0; }
.login-brand p:last-child { max-width: 500px; color: #d3e4e8; font-size: 17px; line-height: 1.6; }
.login-form-wrap { padding: 54px; display: grid; align-items: center; }
.login-form { display: grid; gap: 18px; }
.login-form h2 { margin: 0 0 10px; font-size: 26px; }
.form-error { margin: 0; padding: 11px 12px; background: var(--red-soft); color: var(--red); }

@media (max-width: 900px) {
  .topbar { height: auto; min-height: 64px; grid-template-columns: 1fr auto; padding: 10px 16px; }
  .topnav { grid-column: 1 / -1; order: 3; overflow-x: auto; }
  .nav-button { height: 42px; }
  main { padding: 22px 16px; }
  .workspace-grid { grid-template-columns: 1fr; }
  .summary-panel { position: static; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { padding: 36px; }
  .login-brand h1 { font-size: 30px; }
  .login-form-wrap { padding: 36px; }
}

@media (max-width: 620px) {
  .topbar-brand > span:last-child, .user-menu > span { display: none; }
  .page-heading, .result-header, .system-toolbar { align-items: flex-start; flex-direction: column; }
  .field-grid { grid-template-columns: 1fr; }
  .actions { justify-content: flex-start; }
  .status-check { grid-template-columns: 1fr; }
  .form-panel, .summary-panel, .results-band { padding: 18px; }
}
