:root {
  color-scheme: light;
  --ink: #303133;
  --muted: #606266;
  --line: #dcdfe6;
  --line-light: #e4e7ed;
  --canvas: #fafbfc;
  --surface: #fff;
  --table-head: #f8f8f9;
  --stripe: #fafafa;
  --row-hover: #f5f7fa;
  --accent: #409eff;
  --primary: #176bb6;
  --primary-hover: #115c9e;
  --primary-soft: #ecf5ff;
  --sidebar: #161618;
  --menu-text: #bfcbd9;
  --menu-hover: #28282b;
  --menu-active: #42a1ff;
  --menu-selected: rgb(64 158 255 / 12%);
  --sidebar-width: 240px;
  --radius: 4px;
  --wash: var(--primary-soft);
  font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-size: 14px;
  line-height: 1.5;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
a { color: var(--primary); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 18px; line-height: 1.4; font-weight: 600; }
h2 { font-size: 15px; line-height: 1.4; font-weight: 600; }
h3 { font-size: 14px; line-height: 1.4; }
p { line-height: 1.6; }
small { color: var(--muted); }

input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%; min-height: 32px; padding: 4px 10px;
  border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink); background: var(--surface);
}
input[type=checkbox], input[type=radio] { accent-color: var(--primary); }
textarea { min-height: 80px; resize: vertical; }
select { padding-right: 22px; }
::placeholder { color: #73767a; }
[hidden] { display: none !important; }

.shell { min-height: 100dvh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.shell > div { min-width: 0; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; min-width: 0;
  padding: 0 8px 12px; background: var(--sidebar); color: var(--menu-text); overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 8px; min-height: 50px;
  padding: 0 12px; margin: 0 0 5px; color: #f4f4f5;
}
.brand-mark {
  flex: 0 0 22px; height: 22px; border-radius: var(--radius); display: grid; place-items: center;
  background: var(--primary); color: #fff; font-size: 17px; line-height: 1;
}
.brand-name { font-size: 16px; font-weight: 600; }
.sidebar-nav ul { list-style: none; margin: 0; padding: 0; }
.nav-section + .nav-section { margin-top: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 11px; min-height: 44px;
  padding: 0 12px; border-radius: 6px; color: var(--menu-text); text-decoration: none;
}
.nav-link > .icon:last-child { margin-left: auto; color: #a6acb5; }
.nav-section.active > .nav-link { color: #f4f4f5; }
.nav-link:hover, .nav-sublink:hover { background: var(--menu-hover); color: #f4f4f5; }
.nav-sublink {
  display: flex; align-items: center; min-height: 36px; margin: 1px 0; padding: 0 10px 0 40px;
  border-radius: 6px; color: var(--menu-text); text-decoration: none; font-size: 13px;
}
.nav-sublink[aria-current="page"], .sidebar-collapsed .nav-section.active > .nav-link {
  color: var(--menu-active); background: var(--menu-selected);
}
.nav-link .icon:is(.icon-workbench, .icon-participants, .icon-calendar, .icon-checks, .icon-delivery, .icon-quality) {
  position: relative; font-size: 0;
}
.nav-link .icon::before, .nav-link .icon::after { position: absolute; box-sizing: border-box; }
.nav-link .icon-workbench::before {
  content: ""; inset: 2px;
  border: 1px solid currentColor; border-radius: 1px;
}
.nav-link .icon-workbench::after {
  content: ""; inset: 6px 3px 3px 7px; border: solid currentColor; border-width: 1px 0 0 1px;
}
.nav-link .icon-participants::before {
  content: ""; top: 1px; left: 5px; width: 7px; height: 7px; border: 1px solid currentColor; border-radius: 50%;
}
.nav-link .icon-participants::after {
  content: ""; bottom: 2px; left: 2px; width: 13px; height: 6px;
  border: 1px solid currentColor; border-radius: 5px 5px 1px 1px;
}
.nav-link .icon-calendar::before, .nav-link .icon-checks::before, .nav-link .icon-delivery::before {
  content: ""; inset: 3px 2px 2px; border: 1px solid currentColor; border-radius: 2px;
}
.nav-link .icon-calendar::after { content: ""; inset: 7px 3px auto; border-top: 1px solid currentColor; }
.nav-link .icon-checks::after {
  content: ""; width: 6px; height: 4px; border: solid currentColor; border-width: 0 0 1px 1px; transform: rotate(-45deg);
}
.nav-link .icon-delivery::after {
  content: ""; width: 5px; height: 5px; border: solid currentColor; border-width: 1px 1px 0 0; transform: rotate(45deg);
}
.nav-link .icon-quality::before {
  content: ""; width: 10px; height: 10px; border: 1px solid currentColor; transform: rotate(45deg);
}
.sidebar-foot { margin-top: auto; padding: 16px 12px 2px; color: #a6acb5; font-size: 12px; }

.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  min-height: 50px; gap: 12px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line-light);
}
.top-context, .top-actions { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-context label { display: flex; align-items: center; gap: 6px; min-width: 0; }
.top-context label > span { font-size: 12px; color: var(--muted); white-space: nowrap; }
.top-context select { max-width: 206px; min-height: 32px; font-size: 13px; }
.top-actions { justify-content: flex-end; }
.top-actions .button { min-height: 32px; padding: 5px 7px; color: var(--muted); white-space: nowrap; }
.top-user { display: inline-flex; align-items: center; gap: 6px; }
.user-avatar {
  display: inline-grid; place-items: center; width: 24px; height: 24px;
  border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-size: 12px; font-weight: 650;
}
.icon {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  width: var(--icon-size, 16px); height: var(--icon-size, 16px); font-size: var(--icon-size, 16px);
  line-height: 1; font-family: system-ui, sans-serif;
}
.mobile-menu, .drawer-close, .drawer-scrim { display: none; }
.sidebar-toggle { min-width: 32px; color: var(--muted); }
.sidebar-toggle:hover:not(:disabled) { color: var(--primary); }
.main { width: 100%; margin: 0 auto; padding: 16px 16px 32px; outline: none; }

.page-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 32px; margin-bottom: 12px; }
.page-header p { max-width: 680px; margin-top: 3px; color: var(--muted); font-size: 13px; }
.eyebrow { margin-bottom: 4px; color: var(--muted); font-size: 13px; }
.eyebrow button { padding: 0; background: transparent; border: 0; color: var(--primary); }
.page-actions, .page-title, .page-meta, .inline { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.page-actions { flex-shrink: 0; justify-content: flex-end; }
.page-meta { color: var(--muted); font-size: 12px; }

.page-tabs {
  display: flex; align-items: stretch; gap: 19px; overflow-x: auto;
  margin-bottom: 12px; padding: 0 2px; border-bottom: 1px solid var(--line-light);
}
.page-tabs button {
  flex: 0 0 auto; min-height: 36px; padding: 5px 3px;
  border: 0; border-bottom: 2px solid transparent; background: transparent;
  color: var(--muted); font-size: 14px; font-weight: 400; white-space: nowrap;
}
.page-tabs button:hover { color: var(--primary); }
.page-tabs button:focus-visible { outline-offset: -2px; }
.page-tabs button.active { border-bottom-color: var(--accent); color: var(--primary); font-weight: 500; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 32px;
  padding: 4px 12px; border: 1px solid transparent; border-radius: var(--radius);
  font-size: 14px; line-height: 1.25; font-weight: 400; text-decoration: none;
}
.button-primary { border-color: var(--primary); background: var(--primary); color: #fff; }
.button-primary:hover:not(:disabled) { border-color: var(--primary-hover); background: var(--primary-hover); }
.button-secondary { border-color: var(--line); background: var(--surface); color: var(--ink); }
.button-secondary:hover:not(:disabled) { border-color: #a0cfff; background: var(--primary-soft); color: var(--primary); }
.button-ghost { background: transparent; color: var(--primary); }
.button-ghost:hover:not(:disabled) { background: var(--primary-soft); }
.button-danger { background: #ae3635; color: #fff; }
.button-danger:hover:not(:disabled) { background: #922727; }
.text-link { padding: 2px 0; border: 0; background: none; color: var(--primary); text-align: left; }
.text-link:hover { text-decoration: underline; }

.badge {
  display: inline-flex; align-items: center; padding: 2px 7px;
  border: 1px solid transparent; border-radius: var(--radius);
  font-size: 12px; line-height: 1.25; white-space: nowrap;
}
.badge-neutral { border-color: #e9e9eb; background: #f4f4f5; color: #606266; }
.badge-teal { border-color: #d1edc4; background: #f0f9eb; color: #3c6828; }
.badge-blue { border-color: #c6e2ff; background: var(--primary-soft); color: var(--primary); }
.badge-amber { border-color: #f5dab1; background: #fdf6ec; color: #855b1e; }
.badge-red { border-color: #fbc4c4; background: #fef0f0; color: #a13030; }

.panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.panel-header {
  display: flex; align-items: center; justify-content: space-between; gap: 9px;
  padding: 10px 12px; border-bottom: 1px solid var(--line-light);
}
.panel-header p { margin-top: 3px; color: var(--muted); font-size: 12px; }
.panel-body { min-width: 0; padding: 12px; }
.panel + .panel { margin-top: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack > .panel + .panel, .grid-2 > .panel + .panel, .grid-3 > .panel + .panel { margin-top: 0; }
.grid-2, .grid-3, .form-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split { display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.strong { font-weight: 600; }
.muted { color: var(--muted); }
.subtle { padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: #f7f8fa; }
.callout {
  padding: 9px 11px; border: 1px solid #d8e3f2; border-radius: var(--radius);
  background: #f0f5fc; color: #34577f; line-height: 1.55;
}
.callout.amber { border-color: #eddfbf; background: #fbf5e8; color: #765319; }
.callout.red { border-color: #efd5d3; background: #fcefee; color: #963d39; }
.callout.blue { border-color: #d8e3f2; background: #f0f5fc; color: #34577f; }

.table-wrap { max-width: 100%; overflow: auto; border: 1px solid var(--line-light); }
table { width: 100%; min-width: 435px; border-collapse: collapse; font-size: 14px; text-align: left; }
th, td { padding: 7px 11px; border-bottom: 1px solid var(--line-light); vertical-align: middle; }
:is(th, td):not(:last-child) { border-right: 1px solid var(--line-light); }
thead th {
  background: var(--table-head); color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap;
}
tbody th { font-weight: 600; }
tbody tr:last-child > * { border-bottom: 0; }
tbody tr:nth-child(even) > * { background: var(--stripe); }
tbody tr:hover > * { background: var(--row-hover); }
td small, tbody th small { display: block; margin-top: 1px; font-size: 12px; }
.field { display: grid; align-content: start; gap: 5px; min-width: 0; margin: 0; }
.field > span { color: var(--muted); font-size: 13px; }
.field > small { color: var(--muted); font-size: 11px; line-height: 1.5; }
.field-full { grid-column: 1 / -1; }
.empty {
  display: grid; align-content: center; justify-items: center; gap: 7px; min-height: 116px;
  padding: 18px 15px; text-align: center;
}
.empty strong { color: var(--muted); font-weight: 400; }
.empty p { max-width: 440px; color: var(--muted); font-size: 13px; }
.history { list-style: none; margin: 0; padding: 0 0 0 8px; }
.history li { position: relative; padding: 0 0 12px 13px; border-left: 1px solid var(--line); }
.history li::before {
  position: absolute; top: 5px; left: -4px; width: 7px; height: 7px;
  border-radius: 50%; background: #6688bc; content: "";
}
.history li:last-child { padding-bottom: 0; }
.history strong { font-size: 13px; }
.history time, .history p { color: var(--muted); font-size: 12px; }
.history p { margin-top: 4px; }

.worklist-results { min-width: 0; padding: 12px 12px 0; border: 1px solid var(--line-light); border-radius: var(--radius); background: var(--surface); }
.list-loading { display: grid; place-items: center; min-height: 116px; padding: 18px 15px; color: var(--muted); }
.filter-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  margin-bottom: 12px; padding: 12px;
  border: 1px solid var(--line-light); border-radius: var(--radius); background: var(--surface);
}
.filter-bar > .field { display: flex; align-items: center; gap: 8px; flex: 0 1 158px; }
.filter-bar > .field:first-child { flex-basis: 268px; }
.filter-bar > .field > span { flex: 0 0 auto; }
.filter-actions, .table-pagination, .pager-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.table-pagination {
  justify-content: flex-end; min-height: 48px; padding: 8px 0; color: var(--muted); font-size: 13px;
}
.table-pagination .button { min-height: 28px; padding: 3px 8px; font-size: 13px; }
.queue { display: grid; }
.queue-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--line-light);
}
.queue-item:first-child { padding-top: 0; }
.queue-item:last-child { padding-bottom: 0; border-bottom: 0; }
.queue-item p { color: var(--muted); font-size: 12px; }
.code { font-size: 12px; font-variant-numeric: tabular-nums; }

dialog {
  width: min(600px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); margin: auto; padding: 0;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink);
  box-shadow: 0 8px 24px rgb(0 0 0 / 16%);
}
dialog::backdrop { background: rgb(0 0 0 / 45%); }
.modal-header { padding: 13px 16px; border-bottom: 1px solid var(--line); }
.modal-header h2 { font-size: 17px; }
.modal-header p { margin-top: 4px; color: var(--muted); font-size: 13px; }
.modal-header .button { align-self: start; margin: -2px -5px 0 0; }
.modal-body { display: grid; gap: 11px; padding: 15px 16px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 7px; padding: 10px 16px;
  border-top: 1px solid var(--line-light); background: var(--surface);
}
.modal-error { margin: 0 16px 11px; }
#toast { position: fixed; bottom: 18px; right: 18px; z-index: 10; max-width: min(420px, calc(100% - 36px)); }
.toast-message {
  padding: 9px 12px; border: 1px solid #d1edc4; border-radius: var(--radius);
  background: #f0f9eb; color: #3c6828; line-height: 1.5;
}
.toast-message.error { border-color: #fbc4c4; background: #fef0f0; color: #a13030; }

.login-shell {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  min-height: 100dvh; padding: 24px 16px; background: var(--canvas);
}
.login-brand, .login-panel { width: min(100%, 380px); }
.login-brand { padding: 0 2px 15px; }
.login-wordmark { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; color: var(--ink); font-size: 18px; }
.login-wordmark .brand-mark { width: 22px; }
.login-brand h1 { color: var(--muted); font-size: 14px; font-weight: 590; }
.login-brand p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.login-environment { display: inline-block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.login-panel form {
  display: grid; gap: 11px; padding: 17px 19px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface);
}
.login-panel h2 { font-size: 17px; }
.login-panel p { margin-top: -4px; color: var(--muted); font-size: 13px; }
.login-panel .button { min-height: 36px; margin-top: 4px; }

@media (min-width: 821px) {
  .shell.sidebar-collapsed { grid-template-columns: 54px minmax(0, 1fr); }
  .sidebar-collapsed .sidebar { padding-inline: 4px; }
  .sidebar-collapsed .brand { justify-content: center; padding-inline: 0; }
  .sidebar-collapsed :is(.brand-name, .nav-label, .nav-link > .icon:last-child, .nav-children, .sidebar-foot) { display: none; }
  .sidebar-collapsed .nav-link { justify-content: center; padding-inline: 0; }
}

@media (max-width: 1120px) {
  :root { --sidebar-width: 208px; }
  .topbar { padding: 0 14px; }
  .main { padding-right: 15px; padding-left: 15px; }
  .top-context label > span { display: none; }
}

@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar-toggle { display: none; }
  .mobile-menu { display: block; flex: 0 0 auto; }
  .mobile-menu .button { padding: 5px 6px; gap: 4px; white-space: nowrap; }
  .sidebar { position: fixed; z-index: 8; display: none; width: min(var(--sidebar-width), calc(100vw - 48px)); }
  .sidebar.open { display: flex; }
  .drawer-close { display: block; align-self: flex-end; margin-top: 6px; color: var(--menu-text); }
  .drawer-close:hover:not(:disabled) { background: var(--menu-hover); }
  .drawer-scrim { display: block; position: fixed; inset: 0; z-index: 7; border: 0; background: rgb(0 0 0 / 38%); }
  .topbar { padding: 0 9px; }
  .top-context, .top-actions { gap: 6px; }
  .top-context { flex: 1 1 auto; }
  .top-actions { flex-shrink: 0; }
  .top-context select { max-width: 160px; }
  .main { padding: 14px 11px 32px; }
  .page-header { align-items: flex-start; flex-wrap: wrap; gap: 8px; }
}

@media (max-width: 620px) {
  .top-actions .role-name, .top-context .site-context, .top-actions .optional-action { display: none; }
  .top-context select { font-size: 12px; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .panel-header, .panel-body { padding-right: 10px; padding-left: 10px; }
  .page-actions { flex-shrink: 1; justify-content: flex-start; }
  .filter-bar { padding: 10px; }
  .filter-bar > .field:first-child { flex-basis: 100%; }
}

.monitor-portal { max-width: 1240px; margin: 0 auto; }
.monitor-scope { min-width: 0; padding: 12px; border: 1px solid var(--border, #d9e0e7); }
.monitor-scope label { display: block; padding: 4px 0; }
.monitor-response { padding: 12px 0; margin-top: 12px; border-top: 1px solid var(--border, #d9e0e7); }
.finding-record p { white-space: pre-wrap; overflow-wrap: anywhere; }
.document-preview { white-space: pre-wrap; overflow-wrap: anywhere; padding: 12px; background: #f3f6fa; }
.document-filters { flex-wrap: wrap; margin-bottom: 12px; }
