:root {
  color-scheme: light;
  --nav: #122837;
  --nav-hover: #1d3a48;
  --canvas: #f3f6f8;
  --paper: #fff;
  --line: #dce5e9;
  --line-dark: #c5d3da;
  --ink: #192f3b;
  --muted: #536976;
  --teal: #12695c;
  --teal-dark: #0c574c;
  --teal-pale: #e8f3ef;
  --warn: #805311;
  --danger: #a12c39;
  font: 14px/1.5 Inter, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--canvas);
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--teal); text-decoration: none; }
a, button { -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 2px solid #22867b; outline-offset: 3px; }
[hidden] { display: none !important; }
.sr { position: absolute; height: 1px; width: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.muted, small { color: var(--muted); }
small { font-size: .85rem; }
.mobile-only { display: none !important; }

button, .button {
  appearance: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line-dark);
  border-radius: 7px;
  padding: 8px 13px;
  min-height: 37px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
}
button:hover, .button:hover { background: #f2f7f8; border-color: #a6bbc3; }
button:disabled, .button[aria-disabled="true"] { opacity: .53; cursor: default; }
.primary, a.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.primary:hover, a.primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); }
.icon-button { min-width: 39px; padding: 4px; }
.quiet { background: transparent; border-color: transparent; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

input:not([type="file"]), select, textarea {
  display: block;
  width: 100%;
  border: 1px solid var(--line-dark);
  border-radius: 7px;
  background: var(--paper);
  padding: 9px 11px;
  min-height: 40px;
  color: var(--ink);
}
input::placeholder, textarea::placeholder { color: #627885; }
input[readonly], textarea[readonly], select:disabled { background: #f0f5f7; }
textarea { resize: vertical; }
label { display: block; font-weight: 650; }
label > input, label > select, label > textarea { margin-top: 5px; font-weight: 400; }
label > small { display: block; font-weight: 400; margin-top: 5px; }
fieldset { border: 0; min-width: 0; padding: 0; margin: 0; }
.required, .field-error, .counter.invalid { color: var(--danger) !important; }

.app { min-height: 100dvh; display: grid; grid-template-columns: 222px minmax(0, 1fr); }
.rail {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
  overflow: auto;
  padding: 25px 14px 16px;
  color: white;
  background: var(--nav);
}
.wordmark { display: flex; align-items: center; gap: 12px; color: inherit; font-size: 22px; font-weight: 720; line-height: 1.12; }
.wordmark small { display: block; color: #acc1c9; font-size: 12px; margin-top: 5px; font-weight: 500; }
.rail > .wordmark { margin: 0 8px 34px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 37px;
  height: 37px;
  flex: none;
  border-radius: 11px 4px 11px 4px;
  background: #8ef0c6;
  color: #173d36;
  font-size: 23px;
  font-weight: 850;
}
.rail-nav { display: grid; gap: 5px; }
.rail-nav.secondary { border-top: 1px solid #31505b; padding-top: 16px; margin-top: 18px; }
.rail-link {
  min-height: 43px;
  padding: 6px 11px;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #d0dfe4;
  font-weight: 570;
}
.rail-link:hover { background: var(--nav-hover); color: white; }
.rail-link[aria-current="page"] { color: #b9f6dd; border-color: #33565e; background: #254650; }
.nav-icon { display: inline-grid; place-items: center; width: 20px; color: #9fc2c7; font: 21px/1 Arial, sans-serif; }
.rail-foot { color: #a5bdc6; font-size: 12px; margin: auto 10px 0; padding-top: 32px; display: flex; align-items: center; gap: 7px; }
.rail-foot span { width: 7px; height: 7px; background: #8ef0c6; border-radius: 50%; }
.rail-shade { display: none; }

.bar {
  height: 65px;
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 0 clamp(16px, 3.5vw, 46px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.bar-location { min-width: 0; display: flex; gap: 10px; align-items: center; color: var(--muted); }
.bar-location a { color: var(--muted); white-space: nowrap; }
#breadcrumb { color: var(--ink); font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account { position: relative; flex: none; }
.account summary { display: flex; gap: 9px; align-items: center; cursor: pointer; font-weight: 650; list-style: none; }
.account summary::-webkit-details-marker { display: none; }
.avatar { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: #e0eeed; color: #154f46; font-size: 13px; }
.caret { color: var(--muted); font-size: 16px; }
.account-menu {
  position: absolute; right: 0; top: calc(100% + 13px); width: 145px;
  padding: 5px; background: var(--paper); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 8px 28px #142f421a;
}
.account-menu a, .account-menu button { display: flex; text-align: left; justify-content: flex-start; width: 100%; color: var(--ink); background: none; padding: 8px; border: 0; border-radius: 5px; font-weight: 550; }
.account-menu a:hover, .account-menu button:hover { background: var(--teal-pale); }

.main { margin: 0 auto; max-width: 1570px; padding: 32px clamp(16px, 3.5vw, 46px) 58px; }
.main:focus:not(:focus-visible) { outline: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 23px; }
.page-head h1 { font-size: clamp(26px, 3vw, 34px); line-height: 1.26; letter-spacing: -.035em; font-weight: 750; }
.page-head p { margin-top: 7px; }
.page-head > .primary { min-height: 44px; }
.stages { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 20px; border: 1px solid var(--line); border-radius: 13px; overflow: clip; background: var(--paper); }
.stage { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 11px; padding: 17px 14px; min-height: 81px; color: var(--ink); }
.stage + .stage { border-left: 1px solid var(--line); }
.stage:hover, .stage[aria-current="page"] { background: #edf7f4; }
.stage[aria-current="page"] { box-shadow: inset 0 -3px var(--teal); }
.stage:focus-visible { outline-offset: -4px; }
.stage-number { display: grid; width: 37px; height: 37px; place-items: center; border-radius: 8px; color: #155e56; background: #e5f1ee; font-size: 14px; font-weight: 740; font-variant-numeric: tabular-nums; }
.stage-copy small { display: block; margin-top: 2px; }
.stage-count { color: var(--muted); font-weight: 710; font-variant-numeric: tabular-nums; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 13px; min-width: 0; overflow: hidden; }
.queue-top { padding: 16px 19px 0; display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; }
.queue-top h2, .panel-title { font-size: 18px; font-weight: 720; line-height: 1.35; }
.queue-links { display: flex; flex-wrap: wrap; gap: 4px; }
.queue-links a { padding: 6px 9px; color: var(--muted); border-radius: 6px; font-weight: 590; white-space: nowrap; }
.queue-links a:hover, .queue-links [aria-current="page"] { background: var(--teal-pale); color: var(--teal-dark); }
.queue-links span { font-variant-numeric: tabular-nums; }

.filter { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 14px 19px; }
.filter input { flex: 1 0 170px; max-width: 290px; }
.filter select { width: auto; max-width: 100%; }
.refresh { margin-left: auto; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 12px 13px; vertical-align: middle; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { padding-left: 19px; }
th:last-child, td:last-child { padding-right: 19px; }
th { background: #eef3f6; color: #425c6a; font-size: 12px; font-weight: 710; white-space: nowrap; border-top: 1px solid var(--line); }
tbody tr:hover:not(:has(.empty-cell)) { background: #f7fbfa; }
.empty-cell { padding: 0 !important; }
.empty { min-height: 215px; text-align: center; display: grid; place-content: center; justify-items: center; gap: 6px; padding: 26px 12px; }
.empty strong { font-size: 15px; }
.empty-mark { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 11px; color: #417b73; background: #ecf4f2; font-size: 22px; margin-bottom: 3px; }
.empty button { margin-top: 5px; }
.table-foot { padding: 11px 19px; color: var(--muted); font-size: 12px; }
.product-name { min-width: 120px; max-width: 285px; }
.product-name strong { display: block; overflow-wrap: anywhere; }
.product-name small, .step-cell small { display: block; margin-top: 2px; overflow-wrap: anywhere; }
.step-cell { min-width: 100px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 4px; min-width: 62px; }
.row-actions button { min-height: 30px; padding: 4px 7px; font-size: 12px; }
.row-actions .small-primary { color: var(--teal-dark); border-color: #a7cbbf; background: #f0f8f5; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; color: #485d6a; background: #eef2f4; }
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.working { color: #2e597e; background: #e9f2fd; }
.badge.attention { color: var(--warn); background: #fff2d8; }
.badge.success { color: #276150; background: #e6f5ee; }
.badge.danger { color: var(--danger); background: #fcecf0; }
.progress { min-width: 65px; }
.track { display: flex; gap: 3px; margin: 2px 0 4px; }
.track i { height: 5px; width: 18px; background: #d9e4e8; border-radius: 3px; }
.track .done { background: #398675; }
.track .current { background: #83b8ae; }

.module-grid { display: grid; grid-template-columns: 201px minmax(0, 1fr); gap: 14px; align-items: start; }
.module-menu { border: 1px solid var(--line); padding: 10px 8px; border-radius: 10px; background: var(--paper); }
.module-menu section + section { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 8px; }
.module-menu h2 { font-size: 12px; color: var(--muted); padding: 6px 9px; }
.module-menu a { display: block; border-radius: 6px; padding: 7px 9px; color: var(--ink); }
.module-menu a:hover, .module-menu [aria-current="page"] { background: var(--teal-pale); color: var(--teal-dark); }
.module-menu [aria-current="page"] { font-weight: 700; }
.panel-title { padding: 17px 19px 0; }
.placeholder .filter { justify-content: flex-start; }
.placeholder-body { padding: 16px 19px; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 8px; padding: 0 19px 15px; }
.metrics > div, .overview-grid > section { border: 1px solid var(--line); padding: 13px; border-radius: 8px; }
.metrics span { display: block; color: var(--muted); }
.metrics strong { font-size: 23px; }
.overview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 8px; padding: 0 19px 18px; }
.overview-grid h3 { font-size: 14px; margin-bottom: 8px; }

.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: var(--nav); }
.login-panel { background: var(--paper); padding: clamp(24px, 6vw, 41px); border-radius: 16px; width: min(100%, 420px); }
.login-panel h1 { margin: 20px 0 5px; font-size: 28px; line-height: 1.22; letter-spacing: -.03em; }
.login-panel #sign-in { width: 100%; min-height: 44px; margin-top: 23px; }
.login-panel .field-error { margin-top: 12px; }
.toast { position: fixed; z-index: 21; bottom: 22px; right: 22px; max-width: min(470px, calc(100% - 44px)); padding: 12px 16px; border-radius: 9px; box-shadow: 0 8px 32px #19394838; color: #fff; background: #234d49; overflow-wrap: anywhere; }
.toast.danger { background: #89313e; }

dialog { border: 1px solid var(--line-dark); border-radius: 15px; padding: 0; width: min(780px, calc(100vw - 36px)); max-height: calc(100dvh - 32px); color: var(--ink); background: var(--paper); overflow: hidden; }
dialog::backdrop { background: #132d3b8a; }
dialog form, .dialog-frame { display: flex; flex-direction: column; max-height: calc(100dvh - 34px); }
.result-dialog { width: min(1040px, calc(100vw - 36px)); }
.compact-dialog { width: min(500px, calc(100vw - 36px)); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font-size: 22px; letter-spacing: -.035em; line-height: 1.3; }
.dialog-head p { margin-top: 5px; overflow-wrap: anywhere; }
.close { font-size: 23px; line-height: 1; }
.dialog-body { flex: 1 1 auto; overflow: auto; overscroll-behavior: contain; min-height: 0; padding: 17px 22px; }
.dialog-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); padding: 13px 22px; }
.dialog-foot > p { font-size: 12px; }
.dialog-foot > .actions { margin-left: auto; }
#intake-fields, .extra-fields { display: grid; gap: 15px; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.section-head { margin-bottom: 10px; }
.section-head h3 { font-size: 15px; }
.section-head p { color: var(--muted); margin-top: 2px; }
.evidence { padding: 13px; background: #f7fafb; border: 1px solid var(--line); border-radius: 10px; }
.drop-zone { display: flex; align-items: center; gap: 9px; margin-top: 11px; border: 1px dashed #9dbbb8; padding: 11px; background: #f2f9f7; border-radius: 8px; }
.drop-zone.over { background: #d9f3e9; }
.drop-zone:focus-within { outline: 2px solid #22867b; }
.upload-mark { display: grid; place-items: center; width: 35px; height: 35px; flex: none; background: #dcefe9; color: var(--teal-dark); border-radius: 8px; font-size: 23px; }
.drop-zone small { display: block; margin-top: 2px; }
.file-button { margin-left: auto; }
.attachments { padding: 0; margin: 0; list-style: none; }
.attachments li { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding: 4px 0; margin-top: 6px; }
.attachments :is(a,span) { min-width: 0; overflow-wrap: anywhere; }
.attachments small { white-space: nowrap; }
.attachments button { margin-left: auto; }
.extra { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.extra summary, .record summary { font-weight: 650; cursor: pointer; }
.extra summary span { margin-left: 8px; color: var(--muted); font-size: 12px; font-weight: 400; }
.extra-fields { margin-top: 12px; }
.banner { padding: 8px 10px; border-radius: 7px; margin-bottom: 12px; }
.banner.error { color: var(--danger); background: #feeff1; }

.result-tabs { display: flex; flex: none; gap: 7px; padding: 9px 22px 0; overflow-x: auto; }
.result-tabs button { border: 1px solid transparent; border-radius: 7px 7px 0 0; color: var(--muted); }
.result-tabs button[aria-selected="true"] { color: var(--teal-dark); background: var(--teal-pale); box-shadow: inset 0 -2px var(--teal); }
.result-tabs span { font-size: 11px; background: #eaf0f2; border-radius: 5px; padding: 0 5px; }
#result-content { background: #f3f7f8; border-top: 1px solid var(--line); min-height: 235px; }
.result-block { padding: 15px; background: var(--paper); border: 1px solid var(--line); border-radius: 9px; margin-bottom: 12px; }
.result-block h3 { font-size: 15px; margin-bottom: 11px; }
.result-block h4 { font-size: 13px; margin: 10px 0 4px; }
.result-block ul { padding-left: 18px; margin: 5px 0; }
.result-field + .result-field { margin-top: 11px; }
.result-field > span { display: flex; justify-content: space-between; gap: 10px; }
.counter { font-weight: 500; font-variant-numeric: tabular-nums; }
.details-table { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; margin: 7px 0; }
.details-table dt { color: var(--muted); }
.details-table dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 1100px) {
  .app { grid-template-columns: 184px minmax(0, 1fr); }
  .stage { padding: 13px 9px; gap: 6px; }
  .stage-number { width: 29px; height: 29px; }
  th, td { padding-left: 9px; padding-right: 9px; }
}

@media (max-width: 760px) {
  .mobile-only { display: inline-flex !important; }
  .app { display: block; }
  .rail { position: fixed; inset: 0 auto 0 0; z-index: 6; width: min(240px, 82vw); visibility: hidden; translate: -100% 0; }
  .nav-open .rail { visibility: visible; translate: 0 0; }
  .rail-shade { position: fixed; display: block; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; border-radius: 0; z-index: 5; background: #152e3d78; }
  .rail-shade:hover { background: #152e3d78; }
  .bar { height: 56px; }
  .bar-location > a, .bar-location > span[aria-hidden] { display: none; }
  .main { padding-top: 22px; }
  .page-head { align-items: flex-start; flex-wrap: wrap; gap: 12px; margin-bottom: 15px; }
  .stages { margin-bottom: 13px; }
  .stage { gap: 5px; grid-template-columns: 1fr auto; grid-template-rows: 28px auto; align-content: start; padding: 11px 8px; }
  .stage-copy { grid-row: 2; grid-column: 1 / -1; font-size: 12px; }
  .stage-copy small { display: none; }
  .stage-count { grid-row: 1; grid-column: 2; }
  .queue-top, .filter { padding-left: 12px; padding-right: 12px; }
  .queue-top { align-items: flex-start; flex-wrap: wrap; }
  .filter input { max-width: none; }
  .module-grid { display: block; }
  .module-menu { margin-bottom: 12px; }
  .module-menu section { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; }
  .module-menu h2 { width: 100%; }
  .module-menu a { min-height: 44px; display: flex; align-items: center; }
  button, .button { min-height: 44px; }
  .row-actions button { min-height: 44px; }
  #rail-toggle { min-width: 44px; }
}

@media (max-width: 460px) {
  .dialog-head, .dialog-body, .dialog-foot { padding: 12px 13px; }
  .dialog-head h2 { font-size: 19px; }
  dialog, .result-dialog, .compact-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  dialog form, .dialog-frame { max-height: calc(100dvh - 18px); }
  .form-grid { grid-template-columns: 1fr; }
  .dialog-foot { flex-wrap: wrap; }
  .dialog-foot > .actions { justify-content: flex-end; }
  .drop-zone { flex-wrap: wrap; }
  .drop-zone > div:nth-child(2) { flex: 1 0 64%; }
  .result-tabs { padding-left: 10px; padding-right: 10px; gap: 1px; }
  .result-tabs button { font-size: 12px; padding: 6px; }
}
