:root {
  font-size: 112.5%;
  --bg: #f5f6f7;
  --card: #fff;
  --ink: #302b27;
  --muted: #6e655f;
  --line: #e4ddd7;
  --soft: #f8f4f0;
  --accent: #96583e;
  --accent-hover: #81472f;
  --accent-text: #96583e;
  --button-ink: #fff;
  --header: #27211e;
  --header-ink: #faf5f1;
  --header-muted: #d4c9c2;
  --danger: #9c3c32;
  --warning: #815015;
  --warning-bg: #fff7e8;
  --focus: #b87557;
  --shadow: 0 1px 3px #302b2708, 0 5px 16px #302b2706;
  --radius: 13px;
  --control-height: 2.65rem;
  --compact-control-height: 2.3rem;
  --card-padding-inline: 1.35rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #211d1a;
    --card: #2c2622;
    --ink: #f4ece5;
    --muted: #c3b4aa;
    --line: #51443d;
    --soft: #342b25;
    --accent: #dcab93;
    --accent-hover: #edbea5;
    --accent-text: #e3ab91;
    --button-ink: #2b1d17;
    --header: #1c1816;
    --danger: #ffaca2;
    --warning: #f0cd9d;
    --warning-bg: #402f20;
    --focus: #edaf91;
    --shadow: 0 1px 3px #0004;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1rem/1.5 system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
}
button, input, textarea { font: inherit; }
button, input[type="file"]::file-selector-button {
  min-height: var(--control-height);
  padding: .45rem 1rem;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--accent);
  color: var(--button-ink);
  font-size: .9rem;
  font-weight: 650;
  cursor: pointer;
}
button:hover { background: var(--accent-hover); }
button:disabled { opacity: .58; cursor: wait; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
button.secondary, input[type="file"]::file-selector-button {
  background: var(--card);
  color: var(--ink);
  border-color: var(--line);
}
button.secondary:hover, input[type="file"]::file-selector-button:hover { background: var(--soft); }
button.quiet { padding-left: 0; padding-right: 0; background: none; color: var(--accent-text); }
button.quiet:hover { text-decoration: underline; text-underline-offset: 3px; }
.rail { width: min(100% - clamp(32px, 4vw, 56px), 1360px); margin-inline: auto; }
.top { background: var(--header); color: var(--header-ink); }
.top-inner { min-height: 4.15rem; display: flex; align-items: center; justify-content: space-between; gap: 1.15rem; }
.brand { display: flex; align-items: center; gap: .85rem; }
.brand img { display: block; width: 8.15rem; height: auto; flex: none; }
.brand strong { border-left: 1px solid var(--header-muted); padding-left: .85rem; font-size: .95rem; font-weight: 560; }
.top-nav { flex: 1; display: flex; gap: 4px; min-width: 0; }
.top-nav a {
  padding: .45rem .8rem;
  border-radius: 6px;
  color: var(--header-muted);
  font-size: .9rem;
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
}
.top-nav a:hover { color: var(--header-ink); }
.top-nav a[aria-current="page"] { background: var(--header-ink); color: var(--header); }
.top-tools { display: flex; align-items: center; gap: .45rem; min-width: 0; margin-left: auto; }
.settings { position: relative; }
.settings-toggle { display: grid; place-items: center; width: var(--control-height); min-height: var(--control-height); padding: 0; background: transparent; color: var(--header-muted); border-radius: 10px; }
.settings-toggle svg { width: 1.2rem; height: 1.2rem; }
.settings-toggle:hover, .settings-toggle[aria-expanded="true"] { color: var(--header-ink); background: color-mix(in srgb, var(--header-ink) 12%, var(--header)); }
.settings-items, .account-items { position: absolute; z-index: 4; top: calc(100% + 8px); right: 0; width: 14rem; max-width: calc(100vw - 32px); padding: 8px; border: 1px solid var(--line); border-radius: 13px; background: var(--card); box-shadow: 0 8px 24px #39261c26; }
.settings-items a { display: block; padding: .65rem .75rem; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: .95rem; font-weight: 600; }
.settings-items a:hover, .settings-items a[aria-current="page"] { background: var(--soft); color: var(--accent-text); }
.local { color: var(--header-muted); font-size: .85rem; white-space: nowrap; }
.account { position: relative; min-width: 0; }
.account-toggle {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .5rem; align-items: center;
  max-width: min(16.5rem, calc(100vw - 5.8rem)); padding: .35rem .6rem .35rem .4rem;
  color: var(--header-ink); text-align: left; font-weight: 500; line-height: 1.25;
  border-color: color-mix(in srgb, var(--header-ink) 15%, transparent); border-radius: 11px;
  background: color-mix(in srgb, var(--header-ink) 6%, var(--header));
}
.account-toggle:hover, .account-toggle[aria-expanded="true"] { background: color-mix(in srgb, var(--header-ink) 12%, var(--header)); }
.account-initials {
  display: grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 38%, var(--header)); color: var(--header-ink);
  font-size: .73rem; font-weight: 700; letter-spacing: .035em;
}
.account-identity { display: grid; min-width: 0; gap: 2px; }
.account-name, .account-department { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-name { font-size: .85rem; font-weight: 650; }
.account-department { color: var(--header-muted); font-size: .72rem; }
.account-chevron { color: var(--header-muted); }
.account-toggle[aria-expanded="true"] .account-chevron { transform: rotate(180deg); }
.account-items { width: 15rem; }
.account-email { padding: .35rem .65rem .55rem; margin-bottom: .25rem; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .78rem; overflow-wrap: anywhere; }
#sign-out { display: flex; align-items: center; gap: .5rem; min-height: var(--compact-control-height); width: 100%; padding: .45rem .65rem; background: transparent; color: var(--ink); text-align: left; font-size: .85rem; }
#sign-out:hover { background: var(--soft); }
#sign-out svg { flex: none; color: var(--muted); }
main { padding-block: 2rem 3.5rem; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.6rem, 4vw, 1.95rem); letter-spacing: -.028em; line-height: 1.25; }
h2 { font-size: 1.15rem; line-height: 1.4; }
#calculation-intro, #history-heading { margin-bottom: 1.35rem; }
#calculation-intro { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 16px; }
#calculation-intro .quiet { min-height: var(--compact-control-height); color: var(--muted); }
#calculation-intro .quiet:hover { color: var(--accent-text); }
.card, dialog {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.signin { max-width: 30rem; margin: clamp(20px, 8vh, 96px) auto 0; padding: clamp(22px, 5vw, 40px); }
.signin .message { margin-top: 16px; }
.signin .message:empty { display: none; }
.signin button { width: 100%; margin-top: 24px; }
.signin button:disabled { cursor: default; }
.card-head, .card-foot {
  padding: .95rem var(--card-padding-inline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-head { border-bottom: 1px solid var(--line); }
.card-body { padding: 1.15rem var(--card-padding-inline); }
.card-foot { border-top: 1px solid var(--line); }
.card-foot button[type="submit"] { min-width: 7rem; }
textarea {
  display: block;
  width: 100%;
  min-height: 156px;
  resize: vertical;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--soft);
  font-family: ui-monospace, Menlo, "PingFang SC", monospace;
}
textarea::placeholder { color: var(--muted); }
.sc-entry { border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.sc-entry textarea { min-height: 9rem; padding: .9rem; border: 0; background: transparent; }
.sc-entry textarea::placeholder { font-family: system-ui, "PingFang SC", "Microsoft YaHei", sans-serif; }
.sc-entry textarea:focus-visible { outline: 0; }
.sc-entry:focus-within { border-color: var(--focus); outline: 2px solid var(--focus); outline-offset: 1px; }
.sc-entry-actions { padding: .2rem .8rem .8rem; }
.sc-entry-actions button { min-height: var(--compact-control-height); padding-block: .3rem; }
.sc-entry.is-over { border-color: var(--accent); outline: 2px solid var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--card)); }
#lookup .card-body { padding-block: 1.4rem; }
#lookup .card-foot { justify-content: flex-end; background: color-mix(in srgb, var(--soft) 55%, var(--card)); }
#lookup-button { min-width: 7.5rem; }
.history-task-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.task-retry { min-width: var(--compact-control-height); min-height: var(--compact-control-height); padding: .2rem .5rem; font-size: 1.05rem; }
.task-retry:disabled { cursor: default; }
.muted { color: var(--muted); font-size: .9rem; }
#sc-count { padding: 3px 9px; color: var(--muted); background: var(--soft); border: 1px solid var(--line); border-radius: 6px; font-size: .8125rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.message { margin-top: 10px; color: var(--muted); font-size: .9rem; }
.message.error { color: var(--danger); }
.save-status { margin: 0; padding: 10px 20px; }
.lookup-progress { max-width: 48rem; margin: 16px auto 0; padding: 1.75rem 1.5rem 2rem; text-align: center; }
.lookup-progress h2 { margin: 5px 0 8px; font-size: 1.4rem; }
#lookup-progress-status { min-height: 2.75em; overflow-wrap: anywhere; }
.lookup-estimate { display: flex; justify-content: center; align-items: baseline; gap: 10px; margin: 10px 0 17px; color: var(--muted); font-size: .9rem; }
.lookup-estimate strong { color: var(--ink); font-size: 1.55rem; font-variant-numeric: tabular-nums; }
.lookup-estimate strong:empty { display: none; }
.lookup-activity { height: 4px; max-width: 420px; margin: 0 auto 25px; background: var(--soft); overflow: hidden; border-radius: 8px; }
.lookup-activity span { display: block; width: 32%; height: 100%; background: var(--accent); border-radius: inherit; animation: lookup-motion 1.8s ease-in-out infinite alternate; }
@keyframes lookup-motion { to { transform: translateX(212%); } }
@media (prefers-reduced-motion: reduce) { .lookup-activity span { animation: none; } }
.lookup-stages { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; max-width: 480px; margin: 0 auto; padding: 0; list-style: none; color: var(--muted); font-size: .875rem; }
.lookup-stages li { display: grid; justify-items: center; gap: 7px; }
.lookup-stages li span { display: grid; place-items: center; width: 27px; height: 27px; border: 1px solid var(--line); border-radius: 50%; }
.lookup-stages li[aria-current], .lookup-stages li.done { color: var(--ink); }
.lookup-stages li[aria-current] span, .lookup-stages li.done span { background: var(--accent); color: var(--button-ink); border-color: var(--accent); }
.lookup-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px 20px; margin-top: 23px; }
.lookup-links a, .task-link { color: var(--accent-text); font-size: .875rem; font-weight: 600; text-underline-offset: 3px; }
.history-state { min-width: 8rem; max-width: 17rem; white-space: normal; }
.history-state-label { display: inline-block; padding: 2px 7px; border-radius: 5px; background: var(--soft); color: var(--ink); font-weight: 600; }
.history-state-label[data-state="failed"] { color: var(--danger); }
.history-state-label[data-state="partial"] { color: var(--warning); }
.history-state-label[data-state="running"], .history-state-label[data-state="ready"] { color: var(--accent-text); }
.history-state .task-link { display: inline-block; margin-top: 7px; }
.history-job-status { margin-top: 4px; overflow-wrap: anywhere; font-size: .8125rem; }
.history-job-status.error { color: var(--danger); }
.history-job-progress {
  display: block; appearance: none; width: min(100%, 320px); height: 5px; margin-top: 9px;
  border: 0; border-radius: 8px; overflow: hidden; background: var(--soft);
}
.history-job-progress::-webkit-progress-bar { background: var(--soft); }
.history-job-progress::-webkit-progress-value { background: var(--accent); }
.history-job-progress::-moz-progress-bar { background: var(--accent); }
.history-job-progress:indeterminate { background-image: linear-gradient(var(--accent),var(--accent)); background-repeat: no-repeat; background-size: 32% 100%; animation: progress-travel 1.8s ease-in-out infinite alternate; }
.history-job-progress:indeterminate::-webkit-progress-bar { background: transparent; }
@keyframes progress-travel { to { background-position-x: 100%; } }
@media (prefers-reduced-motion: reduce) { .history-job-progress:indeterminate { animation: none; } }
.result { margin-top: 20px; }
.result .card-head { flex-wrap: wrap; }
.result .muted { margin-top: 3px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.operator-field { align-self: center; color: var(--muted); font-size: .875rem; }
.history-department { display: block; color: var(--muted); font-size: .8rem; }
#operator {
  width: 10em; max-width: 100%; min-height: var(--control-height); padding: .5rem;
  border: 1px solid var(--line); border-radius: 7px; background: var(--soft); color: var(--ink);
}
.warnings { padding: 10px 20px; background: var(--warning-bg); color: var(--warning); font-size: .9rem; }
.warnings summary { cursor: pointer; }
.warnings ul { margin: 8px 0; padding-left: 22px; }
.table-scroll { overflow: auto; max-height: min(72vh, 37rem); }
.table-scroll:focus-visible { outline-offset: -3px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; white-space: nowrap; font-size: .9rem; }
th, td { padding: .68rem .75rem; text-align: left; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { padding-left: var(--card-padding-inline); }
th:last-child, td:last-child { padding-right: var(--card-padding-inline); }
th { position: sticky; top: 0; background: var(--soft); z-index: 1; }
td { font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
td:last-child { font-weight: 650; }
.num { text-align: right; }
#history-table td { vertical-align: middle; }
#history-table tbody tr { cursor: pointer; }
#history-table tbody tr:hover, #history-table tbody tr:focus-within { background: var(--soft); }
#history-table .history-brand { max-width: 15rem; white-space: normal; overflow-wrap: anywhere; }
#history-table .history-amount { min-width: 11rem; max-width: 16rem; white-space: normal; }
.history-amount-value { display: block; font-weight: 650; white-space: nowrap; }
.history-amount-note { display: block; margin-top: 3px; color: var(--warning); font-size: .8125rem; font-weight: 400; line-height: 1.35; overflow-wrap: anywhere; }
button.history-sc { min-height: var(--compact-control-height); padding-block: 2px; text-align: left; }
.history-download {
  display: inline-flex; align-items: center; min-height: var(--compact-control-height); padding: .25rem .55rem;
  border: 1px solid var(--line); border-radius: 7px; background: var(--card);
  color: var(--accent-text); text-decoration: none; font-size: .875rem; font-weight: 600; white-space: nowrap;
}
.history-download:hover { background: var(--soft); }
.history-download:disabled { cursor: default; }
dialog { color: var(--ink); width: min(36rem, 100% - 32px); padding: 0; }
dialog.history-preview { width: min(68rem, 100% - 32px); }
.history-preview .table-scroll { max-height: min(68vh, 35rem); }
.history-preview .muted { margin-top: 3px; }
dialog::backdrop { background: #211a1778; }
dialog .card-foot { justify-content: flex-end; }
.file-list { display: grid; gap: 8px; }
.file-list label { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.file-list label span { color: var(--muted); font-size: .875rem; }
input[type="file"] { max-width: 100%; color: var(--muted); font-size: .9rem; }
input[type="file"]::file-selector-button { margin-right: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.roles-body { display: grid; gap: 20px; }
.role-filters, .role-edit-fields { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.role-filters label, .role-edit-fields label, .report-filter-controls label { display: grid; gap: 5px; min-width: 0; color: var(--muted); font-weight: 600; font-size: .875rem; }
.role-filters label:first-child, .role-edit-fields label:first-child { flex: 1 1 220px; }
.role-filters input, .role-edit-fields input, .role-edit-fields select,
.report-filter-controls input, .report-filter-controls select, #role-brand-search {
  min-height: var(--control-height); max-width: 100%; padding: .45rem .65rem; border: 1px solid var(--line); border-radius: 7px; background: var(--card); color: var(--ink); font: inherit;
}
.role-results { min-width: 0; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.role-result-head, .role-result-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 10px 14px; }
.role-result-foot:has(#role-status:empty):has(#role-pagination[hidden]) { display: none; }
.role-result-foot .message { margin: 0; }
.roles-table { min-width: 52rem; }
.roles-table td { vertical-align: middle; }
.role-pagination { display: flex; align-items: center; gap: 9px; margin-left: auto; font-size: .85rem; }
.role-edit-button, .role-pagination button { min-height: var(--compact-control-height); padding: .25rem .6rem; }
.role-secondary { display: block; color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.role-assigned { min-width: 122px; max-width: 230px; overflow-wrap: anywhere; }
.role-badge { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--soft); color: var(--ink); font-size: .8rem; font-weight: 600; white-space: nowrap; }
.role-badge[data-role="it-admin"] { color: var(--accent-text); }
.role-filters label:first-child { flex: 0 1 24rem; }
.report-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0; }
.report-metrics:has(> div:nth-child(6)) { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.report-metrics > div { padding: .8rem .95rem; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); }
.report-metrics dt { color: var(--muted); font-size: .85rem; }
.report-metrics dd { margin: .15rem 0 0; font-size: 1.35rem; font-weight: 680; font-variant-numeric: tabular-nums; }
.report-table { min-width: 48rem; }
.report-table td { vertical-align: middle; }
.report-table td:last-child { font-weight: inherit; }
.report-column-filter {
  display: inline-flex; align-items: center; gap: .3em; min-height: 1.7rem; padding: 0 .3em; margin-inline: -.3em;
  background: transparent; color: var(--ink); font: inherit; font-weight: 650; white-space: nowrap;
}
.report-column-filter:hover, .report-column-filter[data-filtered="true"] {
  background: color-mix(in srgb, var(--accent) 13%, var(--soft)); color: var(--accent-text);
}
.report-filter-marker {
  width: .58em; height: .58em; background: currentColor; opacity: .58;
  clip-path: polygon(0 0, 100% 0, 62% 48%, 62% 84%, 38% 100%, 38% 48%);
}
.report-column-filter[data-filtered="true"] .report-filter-marker { opacity: 1; }
.report-filter-dialog { width: min(100% - 32px, 26rem); }
.report-filter-controls { display: grid; gap: 12px; }
.report-event[data-event="failed"] { color: var(--danger); }
.report-sc { display: block; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.report-sort { color: var(--accent-text); }
#report-status:empty { display: none; }
#report-results .role-result-foot:has(#report-status:empty):has(#report-pagination[hidden]) { display: none; }
.role-editor { width: min(100% - 32px, 36rem); max-height: calc(100dvh - 32px); overflow: auto; }
.role-editor-body { display: grid; gap: 16px; }
.role-editor-body .message:empty { display: none; }
.brand-fieldset { min-width: 0; margin: 0; padding: 10px 12px 12px; border: 1px solid var(--line); border-radius: 8px; }
.brand-fieldset legend { padding-inline: 4px; font-weight: 600; }
#role-brand-search { width: 100%; }
.role-brand-list { display: grid; gap: 3px; max-height: 230px; overflow-y: auto; margin-top: 8px; }
.role-brand-list label { display: flex; align-items: baseline; gap: 8px; padding: 5px 3px; overflow-wrap: anywhere; }
.role-brand-list input { accent-color: var(--accent); }
#retry-brand-catalog { margin-top: 8px; }
@media (max-width: 800px) {
  .top-inner { flex-wrap: wrap; gap: 10px; padding-block: 12px; }
  .top-nav { order: 2; flex: 1 0 100%; overflow-x: auto; }
  .top-tools { position: relative; gap: 8px; }
  .settings { position: static; }
  .settings-items { right: 0; }
  .report-metrics:has(> div:nth-child(6)) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  :root { --card-padding-inline: 1rem; }
  main { padding-block: 1.5rem 2.5rem; }
  .brand { gap: 10px; }
  .brand strong { padding-left: 10px; }
  .brand img { width: 7.05rem; }
  .local { display: none; }
  .role-filters label:first-child { flex-basis: 100%; }
  .report-metrics, .report-metrics:has(> div:nth-child(6)) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-metrics > div { padding-inline: .65rem; }
}
@media (max-width: 480px) { :root { font-size: 106.25%; } }
