:root {
  font-family: Inter, "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  color: #17243a;
  background: #f4f6fa;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
  --surface: #fff;
  --line: #dbe3ef;
  --muted: #596984;
  --brand: #2356c8;
  --brand-hover: #1946a9;
  --danger: #a32f3f;
  --radius: 12px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #5684ed;
  outline-offset: 2px;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.65rem, 3vw, 2.1rem); letter-spacing: -.025em; line-height: 1.25; overflow-wrap: anywhere; }
h2 { font-size: 1.19rem; line-height: 1.35; }
h3 { font-size: 1rem; }
.subtle { color: var(--muted); font-size: .9375rem; overflow-wrap: anywhere; }
.secondary { color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.block { display: block; margin-top: 4px; }
.code-inline { font-family: ui-monospace, Consolas, monospace; }

.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(100%, 440px);
  padding: clamp(24px, 6vw, 42px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid var(--brand);
  border-radius: 16px;
  box-shadow: 0 16px 40px #17243a12;
}
.login-card .brand-mark { margin-bottom: 22px; }
.login-card h1 { margin-bottom: 8px; }
.login-card form { display: grid; gap: 14px; margin-top: 25px; }

.shell { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar { background: #131f37; color: #fff; display: flex; flex-direction: column; gap: 32px; min-height: 100%; padding: 28px 20px; }
.brand { display: flex; align-items: center; gap: 11px; font-size: 1.15rem; font-weight: 700; white-space: nowrap; }
.brand-mark { width: 40px; height: 40px; flex: none; display: grid; place-items: center; background: var(--brand); color: #fff; border-radius: 10px; font-size: .93rem; font-weight: 800; letter-spacing: .02em; }
.sidebar nav { display: grid; gap: 6px; }
.nav-item, .logout { border: 0; border-radius: 8px; background: transparent; color: #dce7fa; padding: 10px 14px; text-align: left; }
.nav-item:hover, .nav-item[aria-current="page"], .logout:hover { background: #253757; color: #fff; }
.nav-item[aria-current="page"] { font-weight: 650; }
.logout { margin-top: auto; align-self: flex-start; }
.main { width: 100%; max-width: 1456px; padding: clamp(20px, 4vw, 52px); margin: 0 auto; }
#screen, .stack { display: grid; gap: 16px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 7px; }
.page-heading { min-width: 0; }
.page-heading p { margin-top: 7px; }
.page-heading .text-button { margin-bottom: 7px; }

.panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-pad { padding: clamp(16px, 2vw, 24px); }
.panel-header { padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.panel-body { display: grid; gap: 12px; padding: 0 20px 18px; }
.stack > .actions { margin-top: 3px; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.button, .text-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: #283c5a;
  text-decoration: none;
  font-size: .9375rem;
  font-weight: 630;
  line-height: 1.3;
}
.button:hover:not(:disabled) { background: #f3f6fd; border-color: #aab9d1; }
.button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.button.primary:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }
.button.danger { color: var(--danger); }
.button.compact { padding: 6px 10px; min-height: 34px; font-size: .875rem; }
.text-button { background: transparent; border-color: transparent; padding: 0; color: var(--brand); min-height: 32px; }
.text-button:hover:not(:disabled) { text-decoration: underline; }

.table-scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 13px 16px; text-align: left; vertical-align: top; }
thead { background: #f0f4fa; }
th { font-size: .875rem; font-weight: 690; color: #485d7c; white-space: nowrap; }
td { border-top: 1px solid #e7edf6; overflow-wrap: anywhere; }
tbody tr:hover { background: #f8faff; }
.task-table { min-width: 630px; }
.case-table { min-width: 730px; }
.model-table { min-width: 690px; }
.case-title { min-width: 146px; }
.select-case { width: 46px; }
.case-actions { min-width: 160px; }
.empty-state { padding: 38px 20px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 99px; background: #edf1f7; color: #415570; font-weight: 660; font-size: .875rem; white-space: nowrap; }
.badge.positive { background: #e5f4eb; color: #186040; }
.badge.caution { background: #fff1d6; color: #7b490a; }
.badge.negative { background: #fbe8ec; color: #962d3c; }
.badge.progress { background: #e4edff; color: #254c9a; }
.badge + .badge { margin-left: 5px; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 10px; }
.metric { display: grid; gap: 4px; padding: 12px 15px; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.metric strong { font-size: 1.47rem; font-variant-numeric: tabular-nums; }
.metric span, .facts dt { color: var(--muted); font-size: .875rem; }
.job-line { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.job-line .button { margin-left: auto; }
.linked-note { margin-top: 8px; }
.summary-detail { padding: 15px 20px; }
.summary-detail > summary { cursor: pointer; font-weight: 650; }
.facts { display: grid; gap: 8px 20px; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); margin: 14px 0 0; }
.facts dd { margin: 3px 0 0; overflow-wrap: anywhere; }
.sources { margin: 5px 0 0; padding-left: 21px; }

form label { display: grid; gap: 5px; color: #263857; font-weight: 620; font-size: .9375rem; }
form label .subtle { font-weight: 400; }
input:not([type="checkbox"]), select, textarea {
  width: 100%;
  min-height: 43px;
  padding: 8px 11px;
  border: 1px solid #b7c5d9;
  border-radius: 8px;
  background-color: #fff;
  color: #17243a;
  font-weight: 400;
  font-size: 1rem;
}
input[readonly] { background: #f0f3f8; color: #45536c; }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--brand); margin: 4px 2px 0 0; }
select { padding-right: 34px; appearance: none; background-image: linear-gradient(45deg, transparent 49%, #526787 50%), linear-gradient(135deg, #526787 49%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-repeat: no-repeat; background-size: 5px 5px; }
textarea { display: block; resize: vertical; }
.editor { display: grid; gap: 20px; padding: clamp(16px, 3vw, 27px); }
.editor fieldset { min-width: 0; padding: 0; margin: 0; border: 0; }
.editor legend { font-weight: 700; padding: 0 0 10px; }
.editor-options { border-top: 1px solid var(--line); padding-top: 14px; }
.editor-options > summary, .branch-browser > summary { color: #283c5a; font-weight: 650; cursor: pointer; }
.editor-options[open] > :not(summary) { margin-top: 12px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 15px; }
.span-two { grid-column: 1 / -1; }
.check-label { display: flex; align-items: center; }
.material-group, .material-list { display: grid; gap: 9px; }
.material-list:empty { display: none; }
.material-card {
  display: grid;
  min-width: 0;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faff;
}
.material-title { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; }
.material-link { color: var(--brand); overflow-wrap: anywhere; text-underline-offset: 3px; }
.material-title > .material-link { font-size: .875rem; }
.branch-options, .selected-branches { display: flex; flex-wrap: wrap; gap: 6px 13px; }
.branch-options label { display: flex; align-items: flex-start; font-weight: 500; overflow-wrap: anywhere; }
.branch-options input { flex: none; }
.branch-browser { font-size: .875rem; }
.branch-browser[open] > :not(summary) { margin: 7px 0 0; }
.branch-browser > p:empty { display: none; }
.branch-latest { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 215px), 1fr)); max-height: 154px; overflow: auto; padding: 4px 6px; }
.branch-entry { display: flex; align-items: center; gap: 8px; }
.branch-entry > input { min-width: 0; min-height: 34px; padding: 5px 8px; font-size: .875rem; }
.branch-entry > button { flex: none; }
.branch-chip { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-size: .875rem; overflow-wrap: anywhere; }
.branch-chip button { flex: none; min-height: 29px; font-size: .875rem; }
.file-picker { width: min(100%, 17em); min-width: 0; }
.file-picker input[type="file"] { min-height: 34px; padding: 4px 6px; font-size: .875rem; }
.file-picker input::file-selector-button { border: 0; padding: 4px 8px; border-radius: 4px; color: #283c5a; background: #edf1f7; cursor: pointer; }
.model-fields { min-width: 0; margin: 0; padding: 0; border: 0; }
.code { font: .9375rem/1.6 ui-monospace, Consolas, monospace; }

.feedback { padding: 9px 12px; border: 1px solid #b7c9ed; border-radius: 8px; background: #eaf1ff; color: #20477d; overflow-wrap: anywhere; }
.feedback.error { background: #fff0f1; border-color: #f1c4ca; color: #972c3b; }
.notice { margin-bottom: 16px; }
dialog { width: min(680px, calc(100% - 28px)); max-height: calc(100% - 28px); margin: auto; padding: 22px; border: 1px solid var(--line); border-radius: 14px; color: #17243a; box-shadow: 0 12px 45px #101c3a45; }
dialog::backdrop { background: #15233bbb; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
#dialog-feedback { margin-bottom: 12px; }
.evidence-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.evidence-list button { overflow-wrap: anywhere; white-space: normal; text-align: left; justify-content: flex-start; max-width: 100%; }
.evidence-image { display: block; max-width: 100%; height: auto; margin: 0 auto; border: 1px solid var(--line); border-radius: 8px; }
pre.code { overflow: auto; max-height: 52vh; margin: 0; padding: 12px; background: #f0f4fa; border: 1px solid var(--line); border-radius: 8px; }

@media (min-width: 781px) {
  .case-table :is(th, td):nth-child(4) { min-width: 8rem; }
  .case-table td:nth-child(4) .text-button { white-space: nowrap; }
}

@media (max-width: 780px) {
  .shell { grid-template-columns: minmax(0, 1fr); align-content: start; }
  .sidebar { min-height: 0; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 15px; padding: 10px 14px; }
  .brand { font-size: 1rem; }
  .brand-mark { width: 34px; height: 34px; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav-item, .logout { padding: 8px; font-size: .9375rem; }
  .logout { margin: 0 0 0 auto; align-self: center; }
  .main { padding: 18px 14px; }
  .field-grid { grid-template-columns: minmax(0, 1fr); }
  .table-scroll table, .table-scroll tbody, .table-scroll tr { display: block; min-width: 0; }
  .table-scroll thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table-scroll tbody tr { border-top: 1px solid #e7edf6; padding: 7px 0; }
  .table-scroll td { display: flex; align-items: flex-start; gap: 8px; width: auto; min-width: 0; border: 0; padding: 6px 14px; }
  .table-scroll td::before { content: attr(data-label); flex: 0 0 5em; font-size: .875rem; color: #485d7c; padding-top: 2px; }
  .cell-content { flex: 1; min-width: 0; overflow-wrap: anywhere; }
}
