/* Derma2go KB review web app. No external fonts or libraries. */
:root {
  --bg: #f5f6f8; --panel: #ffffff; --ink: #18202c; --muted: #5b6577; --line: #dde2ea; --line-strong: #c5ccd8;
  --accent: #1d5fc4; --accent-ink: #ffffff; --accent-soft: #e7effc;
  --ok: #217a49; --ok-soft: #e4f4ea; --warn: #9a6400; --warn-soft: #fdf1dc; --bad: #b3261e; --bad-soft: #fbe7e5;
  --emergency: #b3261e; --urgent: #c4520c; --soon: #8a6d00; --routine: #217a49; --notify: #6a3fb5;
  --chip: #eef1f5; --focus: #f2b705; --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 2px 8px rgba(20, 30, 50, .04);
  --radius: 10px; --fs: 15px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10141b; --panel: #171d26; --ink: #e6eaf0; --muted: #9aa5b5; --line: #29323f; --line-strong: #3a4556;
    --accent: #6ea8ff; --accent-ink: #0b1220; --accent-soft: #1b2a44;
    --ok: #5fcf8f; --ok-soft: #173326; --warn: #f2b75b; --warn-soft: #3a2c12; --bad: #ff8a80; --bad-soft: #3b1a18;
    --emergency: #ff8a80; --urgent: #ffa36b; --soon: #e6c35c; --routine: #5fcf8f; --notify: #b99cff;
    --chip: #222a36; --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: var(--fs)/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: .2rem 0 .3rem; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
h4 { font-size: .92rem; margin: .8rem 0 .3rem; color: var(--muted); font-weight: 600; }
p { margin: .4rem 0; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }
[hidden] { display: none !important; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }

/* ---------------------------------------------------------------- shell */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 10px 20px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand strong { display: block; font-size: 1rem; }
.brand .sub { display: block; font-size: .78rem; color: var(--muted); }
.logo { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: .8rem; letter-spacing: .02em; }
.mainnav { display: flex; flex-wrap: wrap; gap: 2px; }
.mainnav a { padding: 7px 11px; border-radius: 8px; text-decoration: none; color: var(--ink); font-weight: 500; }
.mainnav a:hover { background: var(--chip); }
.mainnav a.on { background: var(--accent-soft); color: var(--accent); }
.spacer { flex: 1; }
.topnav { display: flex; flex: 1; align-items: center; gap: 10px 14px; min-width: 0; }
.menu-toggle { display: none; margin-left: auto; }
.usermenu { position: relative; }
.usermenu > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 4px; padding: 7px 10px; border-radius: 8px;
  border: 1px solid var(--line); }
.usermenu > summary::-webkit-details-marker { display: none; }
.usermenu .who { font-weight: 600; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu-pop { position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .15); padding: 12px; min-width: 240px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.usermenu-pop button { justify-content: center; }
select.lang { width: auto; }
.draft-banner { background: var(--bad-soft); color: var(--bad); text-align: center; padding: 5px 16px; font-size: .85rem; font-weight: 600; }
main { outline: none; }
.page { max-width: 1240px; margin: 0 auto; padding: 18px 20px 80px; }
.page-head { margin: 6px 0 14px; }
.lead { color: var(--muted); font-size: 1.02rem; margin-top: 0; }
.alt-name { color: var(--muted); margin: 0 0 6px; }
.summary { max-width: 900px; }
.crumbs { font-size: .85rem; color: var(--muted); }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.empty { color: var(--muted); padding: 10px 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 12px 0; box-shadow: var(--shadow); }
.notice { border-radius: 8px; padding: 10px 14px; margin: 10px 0; background: var(--accent-soft); }
.notice.err { background: var(--bad-soft); color: var(--bad); }
.notice.hypo { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 22px; }

/* ---------------------------------------------------------------- forms & buttons */
button, .button { font: inherit; border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; min-height: 38px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; line-height: 1.2; }
button:hover, .button:hover { border-color: var(--accent); }
button:disabled { opacity: .55; cursor: default; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.big, .button.big { padding: 11px 18px; font-size: 1rem; }
button.small, .button.small { padding: 4px 10px; min-height: 30px; font-size: .86rem; }
button.subtle, .button.subtle { background: transparent; border-color: var(--line); color: var(--muted); }
button.link { border: none; background: none; color: var(--accent); padding: 2px 4px; min-height: auto; text-decoration: underline; }
button.ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); font-weight: 600; }
button.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
button.bad { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 600; }
button.icon { border: none; background: none; font-size: 1.3rem; min-height: auto; padding: 0 6px; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 8px 10px; width: 100%; min-height: 38px; }
textarea { resize: vertical; }
input[type=checkbox], input[type=radio] { width: auto; min-height: auto; accent-color: var(--accent); }
input[type=range] { padding: 0; border: none; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
.field label, .label { font-weight: 600; font-size: .9rem; }
.hint { color: var(--muted); font-size: .85rem; margin: 2px 0; }
.hint.warn { color: var(--warn); }
.form-error { color: var(--bad); font-weight: 600; min-height: 1.2em; margin: 6px 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 4px 18px; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; margin: 6px 0; }
.inline.wrap { flex-wrap: wrap; }
.inline select, .inline input { width: auto; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; margin: 4px 12px 4px 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.radio-list { display: flex; flex-direction: column; gap: 4px; }
.radio { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.radio.current { background: var(--chip); }
.small-input { width: 90px !important; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 10px 0; }
legend { font-weight: 600; font-size: .9rem; padding: 0 4px; }

/* ---------------------------------------------------------------- chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--chip); color: var(--ink); border: 1px solid transparent;
  border-radius: 999px; padding: 3px 10px; font-size: .85rem; line-height: 1.35; white-space: nowrap; text-decoration: none; }
.chip.small { font-size: .78rem; padding: 2px 8px; }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.src { background: transparent; border-color: var(--line); color: var(--muted); font-size: .76rem; padding: 1px 7px; }
a.chip.src:hover { border-color: var(--accent); color: var(--accent); }
.chip.code { font-family: ui-monospace, Menlo, monospace; }
button.chip { min-height: 34px; cursor: pointer; border-color: var(--line-strong); background: var(--panel); white-space: normal; text-align: left; }
button.chip.small { min-height: 28px; }
button.chip.toggle.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.chip.tri .tri-mark { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid var(--line-strong); }
button.chip.tri.yes { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); font-weight: 600; }
button.chip.tri.yes .tri-mark { background: var(--ok); border-color: var(--ok); }
button.chip.tri.yes .tri-mark::after { content: "✓"; color: #fff; font-size: 11px; display: block; text-align: center; line-height: 12px; }
button.chip.tri.no { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); text-decoration: line-through; }
button.chip.tri.no .tri-mark { border-color: var(--bad); }
button.chip.tri.no .tri-mark::after { content: "✕"; font-size: 11px; display: block; text-align: center; line-height: 12px; }
.sens { color: var(--warn); }
.st { font-weight: 600; }
.st-unreviewed { background: var(--chip); color: var(--muted); }
.st-in_review { background: var(--accent-soft); color: var(--accent); }
.st-approved { background: var(--ok-soft); color: var(--ok); }
.st-changes_requested { background: var(--warn-soft); color: var(--warn); }
.st-rejected { background: var(--bad-soft); color: var(--bad); }
.st-stale_approval { background: var(--warn-soft); color: var(--warn); }
.freq { font-weight: 600; background: var(--accent-soft); color: var(--accent); }
.freq-excluded, .freq-very_rare { background: var(--chip); color: var(--muted); }
.role { background: #efe7fb; color: #5b2fa0; }
.role.exclusionary { background: var(--bad-soft); color: var(--bad); }
@media (prefers-color-scheme: dark) { .role { background: #2c2140; color: #c9b2ff; } }
.lvl { font-weight: 700; }
.lvl-emergency { background: var(--bad-soft); color: var(--emergency); }
.lvl-urgent { background: #fde9dc; color: var(--urgent); }
.lvl-soon { background: var(--warn-soft); color: var(--soon); }
.lvl-routine { background: var(--ok-soft); color: var(--routine); }
.lvl-notify { background: #efe7fb; color: var(--notify); }
@media (prefers-color-scheme: dark) { .lvl-urgent { background: #3d2516; } .lvl-notify { background: #2c2140; } }
.pl-typical { background: var(--ok-soft); color: var(--ok); } .pl-possible { background: var(--accent-soft); color: var(--accent); }
.pl-rare { background: var(--warn-soft); color: var(--warn); } .pl-excluded { background: var(--bad-soft); color: var(--bad); }

/* ---------------------------------------------------------------- progress */
.progress { height: 8px; background: var(--chip); border-radius: 999px; overflow: hidden; min-width: 80px; flex: 1; }
.progress .bar { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.progress.approved .bar { background: var(--ok); }

/* ---------------------------------------------------------------- login */
.login-wrap { min-height: 70vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 420px; padding: 26px 28px; }
.login-card button[type=submit] { width: 100%; justify-content: center; margin-top: 6px; }
.login-card .code-input { font-size: 1.6rem; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- home */
.home-top { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.home-top .card { margin: 0; }
.stat-card .button { margin-top: 10px; }
.drow { display: grid; grid-template-columns: minmax(200px, 2.2fr) minmax(110px, 1fr) minmax(140px, 1.2fr) auto; gap: 12px; align-items: center;
  padding: 9px 8px; border-radius: 8px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); }
.drow:last-child { border-bottom: none; }
.drow:hover { background: var(--chip); }
.drow.assigned .dname { font-weight: 600; }
.dname { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dcodes { color: var(--muted); font-size: .84rem; font-family: ui-monospace, Menlo, monospace; }
.dprog { display: flex; align-items: center; gap: 8px; }
.stat-chips { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.group h3 { margin-top: 0; }
input.filter { max-width: 320px; }

/* ---------------------------------------------------------------- review list */
.review-toolbar { position: sticky; top: var(--topbar-h, 60px); z-index: 10; display: flex; flex-wrap: wrap; gap: 10px 24px; align-items: center; padding: 10px 16px; }
.prog-box { flex: 1; min-width: 260px; display: flex; flex-direction: column; gap: 4px; }
.prog-line { display: flex; align-items: center; gap: 10px; font-size: .88rem; }
.prog-line span { min-width: 210px; }
.tb-right { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tb-right input.filter { width: 200px; }
.kbd-hint { font-size: .78rem; color: var(--muted); }
.sec-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 4px; }
.sec-head h2 { margin: 0; }
.sec-head button { margin-left: auto; }
.item { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr); gap: 16px; padding: 12px 10px 12px 14px;
  border-bottom: 1px solid var(--line); border-left: 4px solid transparent; outline: none; border-radius: 6px; }
.item:last-child { border-bottom: none; }
.item:focus { box-shadow: 0 0 0 3px var(--focus); }
.item.mine-done { border-left-color: var(--ok); }
.item.mine-done[data-status="changes_requested"], .item.mine-done[data-status="rejected"] { border-left-color: var(--warn); }
.item.mine-outdated { border-left-color: var(--warn); background: var(--warn-soft); }
.item.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
.only-open .item.mine-done { display: none; }
.item-title { font-weight: 600; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
.item-title .alt { font-weight: 400; color: var(--muted); font-size: .86rem; }
.item-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 5px 0; }
.item-note { color: var(--ink); opacity: .85; font-size: .9rem; margin: 4px 0; }
.srcs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.item-review { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.actions-inline { display: flex; flex-wrap: wrap; gap: 4px; }
.mine { font-size: .9rem; }
.dec { font-weight: 700; }
.dec-approve { color: var(--ok); } .dec-request_change { color: var(--warn); } .dec-reject { color: var(--bad); } .dec-comment { color: var(--muted); }
.chip.dec-approve { background: var(--ok-soft); } .chip.dec-request_change { background: var(--warn-soft); } .chip.dec-reject { background: var(--bad-soft); }
.outdated { color: var(--warn); font-size: .86rem; font-weight: 600; }
.others { display: flex; flex-direction: column; gap: 4px; width: 100%; }
.entry { border-left: 3px solid var(--line-strong); padding: 2px 0 2px 8px; font-size: .86rem; }
.entry.dec-approve { border-color: var(--ok); } .entry.dec-request_change { border-color: var(--warn); } .entry.dec-reject { border-color: var(--bad); }
.proposal { font-weight: 600; font-size: .88rem; }
.comment { white-space: pre-wrap; font-size: .88rem; }
.thread summary { cursor: pointer; font-size: .86rem; color: var(--muted); }
.cat-table { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 14px; margin: 6px 0; }
.cat { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: .88rem; }
.levels { margin: 6px 0; padding-left: 20px; }
.levels li { margin: 4px 0; }
.rule { font-family: ui-monospace, Menlo, monospace; font-size: .84rem; background: var(--chip); border-radius: 6px; padding: 4px 8px; margin-top: 2px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 8px 0; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.codes { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; }
.code-line .code { font-family: ui-monospace, Menlo, monospace; font-weight: 700; background: var(--accent-soft); color: var(--accent);
  padding: 1px 7px; border-radius: 6px; }
.code-line .code.bad { background: var(--bad-soft); color: var(--bad); }
.question { font-style: italic; }
.cfg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.sources ol { padding-left: 20px; }
.sources li { margin: 6px 0; }
.sources summary { cursor: pointer; font-weight: 600; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table.grid { border-collapse: collapse; width: 100%; font-size: .9rem; }
table.grid th, table.grid td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid th { color: var(--muted); font-weight: 600; font-size: .82rem; }
table.grid.small { font-size: .84rem; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.right { text-align: right; white-space: nowrap; }
td.right button { margin-left: 4px; }
tr.inactive { opacity: .55; }

/* ---------------------------------------------------------------- admin */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.tabs a, .tabs button { padding: 8px 14px; border-radius: 8px 8px 0 0; text-decoration: none; color: var(--ink); border: 1px solid transparent; background: none; }
.tabs a.on, .tabs button.on { border-color: var(--line); border-bottom-color: var(--panel); background: var(--panel); color: var(--accent); font-weight: 600; }
.tabs.small { border: none; } .tabs.small button { border-radius: 8px; border: 1px solid var(--line); }
.tabs.small button.on { background: var(--accent-soft); }
.assign-grid { display: grid; grid-template-columns: 240px 1fr; gap: 16px; }
.user-pick { display: flex; flex-direction: column; gap: 4px; }
.user-pick .pick { justify-content: flex-start; text-align: left; }
.user-pick .pick.on { background: var(--accent-soft); border-color: var(--accent); }
.assign-group label.check { min-width: 260px; }
.change-list { display: flex; flex-direction: column; gap: 4px; }
.change header { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-weight: 600; }
.change.dec-request_change { border-left: 4px solid var(--warn); } .change.dec-reject { border-left: 4px solid var(--bad); }
.change.dec-comment { border-left: 4px solid var(--line-strong); }
.secret { display: flex; gap: 10px; align-items: center; font-size: 1.2rem; margin: 8px 0 14px; }
.secret code { background: var(--chip); padding: 6px 12px; border-radius: 8px; letter-spacing: .05em; }

/* ---------------------------------------------------------------- dialogs + notices */
dialog.modal { border: none; border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  background: var(--panel); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog.modal.wide { width: min(1100px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(15, 20, 30, .5); }
dialog.modal > header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--panel); z-index: 2; }
dialog.modal > header h2 { margin: 0; font-size: 1.1rem; }
.modal-body { padding: 14px 18px; overflow: auto; max-height: calc(100vh - 170px); }
dialog.modal > footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line);
  position: sticky; bottom: 0; background: var(--panel); }
.dlg-item { font-weight: 600; background: var(--chip); border-radius: 8px; padding: 8px 10px; }
.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast { background: var(--ink); color: var(--panel); padding: 10px 16px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  transition: opacity .4s, transform .4s; max-width: 380px; }
.toast.err { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------------------------------------------------------------- typeahead */
.ta-wrap { position: relative; }
.typeahead { display: flex; flex-direction: column; margin-top: 4px; }
.ta-item { justify-content: space-between; border-radius: 0; border-width: 0 0 1px; text-align: left; }
.ta-item:first-child { border-radius: 8px 8px 0 0; }

/* ---------------------------------------------------------------- case tool */
.case-toolbar { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: flex-end; }
.case-toolbar .field { margin: 0; }
.case-toolbar .grow { flex: 1; min-width: 220px; }
.tb-actions { display: flex; gap: 6px; flex-wrap: wrap; padding-bottom: 1px; }
.case-toolbar details.notes { flex-basis: 100%; }
.case-toolbar details.notes summary { cursor: pointer; color: var(--muted); font-size: .88rem; }
.case-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
.case-input .card:first-child { margin-top: 12px; }
.case-result { position: sticky; top: calc(var(--topbar-h, 60px) + 12px); max-height: calc(100vh - var(--topbar-h, 60px) - 24px); overflow: auto; }
.result-head { display: flex; align-items: center; justify-content: space-between; }
.panel > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary h2 { margin: 0; }
.panel > summary h2::before { content: "▸ "; color: var(--muted); }
.panel[open] > summary h2::before { content: "▾ "; }
.panel > summary .count { color: var(--accent); font-weight: 600; font-size: .86rem; }
.panel[open] > summary { margin-bottom: 8px; }
.subgroup { margin-top: 8px; }
.subgroup h3 { font-size: .9rem; color: var(--muted); margin: 10px 0 2px; }
.q-row { display: grid; grid-template-columns: minmax(150px, 220px) minmax(160px, 320px); gap: 4px 14px; align-items: center; padding: 6px 0;
  border-bottom: 1px dashed var(--line); }
.q-row label { font-weight: 600; }
.q-details { grid-column: 1 / -1; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 9px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: none; border-radius: 0; border-right: 1px solid var(--line); min-height: 36px; }
.seg button:last-child { border-right: none; }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
input.age { width: 90px; } input.size { width: 80px; }
.lesion-list { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.lesion-card { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.lesion-text strong { display: block; }
.lesion-actions { display: flex; gap: 6px; }
.les-icon { width: 56px; height: 38px; color: var(--ink); }
.lesion-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.lesion-editor h3 { margin-top: 4px; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; }
.type-card { flex-direction: column; justify-content: flex-start; padding: 6px 4px; text-align: center; font-size: .8rem; min-height: 84px; gap: 2px; }
.type-card .les-icon { width: 54px; height: 36px; }
.type-card.on { background: var(--accent-soft); border: 2px solid var(--accent); font-weight: 700; }
.bodymap { display: flex; flex-direction: column; gap: 8px; }
.bm-figure { background: var(--chip); border-radius: 12px; padding: 6px; }
.bodymap-svg { width: 100%; max-height: 430px; display: block; }
.bm-r { fill: #e9d2c2; stroke: #8a6d5a; stroke-width: 1; cursor: pointer; }
.bm-r:hover, .bm-r:focus { fill: #f3b9a3; outline: none; }
.bm-r.on, .bm-r.on:hover, .bm-r.on:focus { fill: var(--accent); stroke: #0b3a80; stroke-width: 1.5; }
@media (prefers-color-scheme: dark) { .bm-r { fill: #6b5548; stroke: #c9a993; } .bm-r:hover, .bm-r:focus { fill: #8c6a58; } .bm-r.on { fill: var(--accent); stroke: #dbe8ff; } }
.bm-caption { font-size: 12px; fill: var(--muted); }
.bm-side { font-size: 13px; font-weight: 700; fill: var(--muted); }
.bm-chips { display: flex; flex-direction: column; gap: 4px; max-height: 210px; overflow: auto; padding-right: 4px; }
.bm-group { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.bm-group-label { font-size: .76rem; color: var(--muted); width: 84px; }
.bm-group .chip { min-height: 26px; font-size: .78rem; padding: 2px 8px; }
.extra-item { display: inline-flex; align-items: center; }
ul.plain { list-style: none; padding: 0; margin: 4px 0; }
ul.plain li { margin: 3px 0; }
li.done { color: var(--muted); }
.esc { border-radius: 10px; padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.esc strong { font-size: 1.05rem; }
.esc-routine { background: var(--ok-soft); color: var(--routine); }
.esc-soon { background: var(--warn-soft); color: var(--soon); }
.esc-urgent { background: #fde9dc; color: var(--urgent); }
.esc-emergency { background: var(--emergency); color: #fff; }
@media (prefers-color-scheme: dark) { .esc-urgent { background: #3d2516; } .esc-emergency { color: #1b0b0a; } }
.rf-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.rf { border-left: 4px solid var(--warn); padding: 6px 10px; background: var(--chip); border-radius: 6px; font-size: .9rem; }
.rf-emergency { border-color: var(--emergency); } .rf-urgent { border-color: var(--urgent); } .rf-notify { border-color: var(--notify); }
.rf-action { font-weight: 600; margin-top: 2px; }
ol.ddx { list-style: none; padding: 0; margin: 4px 0; }
.ddx-item, .ddx-other { padding: 8px 0; border-bottom: 1px solid var(--line); }
.ddx-head { display: flex; justify-content: space-between; gap: 10px; }
.ddx-name { font-weight: 600; }
.ddx-p { font-variant-numeric: tabular-nums; font-weight: 700; }
.pbar { height: 6px; background: var(--chip); border-radius: 999px; overflow: hidden; margin: 4px 0; }
.pbar > div { height: 100%; background: var(--accent); }
.pbar.other > div { background: var(--muted); }
.ddx-meta { font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ddx-detail { font-size: .86rem; padding: 4px 0 0 6px; }
.ddx-other .ddx-name { font-weight: 400; color: var(--muted); }
.nq h3 { margin-top: 14px; }
.nq-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.nq-actions { display: flex; gap: 4px; flex-shrink: 0; }
.possible summary { cursor: pointer; font-size: .88rem; color: var(--warn); font-weight: 600; margin-top: 10px; }
.disclaimer { font-size: .78rem; color: var(--muted); margin-top: 14px; }
.to-result { display: none; }

/* ---------------------------------------------------------------- help */
.prose p, .prose li { max-width: 820px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1000px) {
  .case-grid { grid-template-columns: 1fr; }
  .case-result { position: static; max-height: none; }
  .to-result { display: block; position: fixed; right: 16px; bottom: 16px; background: var(--accent); color: var(--accent-ink); padding: 10px 16px;
    border-radius: 999px; text-decoration: none; font-weight: 600; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); z-index: 30; }
  .lesion-editor { grid-template-columns: 1fr; }
  .home-top { grid-template-columns: 1fr; }
  .item { grid-template-columns: 1fr; }
  .assign-grid { grid-template-columns: 1fr; }
  .review-toolbar { position: static; }
}
@media (max-width: 900px) {
  .menu-toggle { display: inline-flex; }
  .topnav { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; }
  .topbar.open .topnav { display: flex; }
  .mainnav { flex-direction: column; }
  .mainnav a { padding: 10px 12px; }
  .usermenu-pop { position: static; box-shadow: none; margin-top: 6px; }
  select.lang { width: 100%; }
}
@media (max-width: 640px) {
  .page { padding: 12px 16px 70px; }
  .topbar { padding: 8px 12px; }
  .drow { grid-template-columns: 1fr; gap: 4px; }
  .stat-chips { justify-content: flex-start; }
  .q-row { grid-template-columns: 1fr; }
  .prog-line span { min-width: 0; }
  .kv { grid-template-columns: 1fr; }
  .lesion-card { grid-template-columns: 48px 1fr; }
  .lesion-actions { grid-column: 1 / -1; }
  h1 { font-size: 1.35rem; }
}
@media print {
  .topbar, .review-toolbar, .actions, .actions-inline, .to-result, .toasts { display: none !important; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* ---------------------------------------------------------------- photo + text studio */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.studio-page { max-width: 1400px; }
.studio-top { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.3fr); gap: 16px; align-items: start; }
.studio-top .card { margin: 0; }
.studio-page h2 { display: flex; align-items: center; gap: 8px; }
.studio-page h2 .num { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-size: .8rem; }
.srv { display: inline-flex; align-items: center; gap: 8px; font-size: .85rem; padding: 4px 12px; border-radius: 999px; background: var(--chip); }
.srv .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.srv.on .dot { background: var(--ok); }
.srv.off { background: var(--warn-soft); color: var(--warn); }
.srv.off .dot { background: var(--warn); }
.case-list { margin-top: 8px; }
.case-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.case-table th { text-align: left; color: var(--muted); font-weight: 600; font-size: .8rem; padding: 4px 6px; border-bottom: 1px solid var(--line-strong); }
.case-table td { padding: 6px; border-bottom: 1px solid var(--line); }
.case-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.case-table tbody tr { cursor: pointer; }
.case-table tbody tr:hover, .case-table tbody tr:focus { background: var(--chip); outline: none; }
.case-table tbody tr.sel { background: var(--accent-soft); }
.dropzone { display: block; border: 2px dashed var(--line-strong); border-radius: 10px; padding: 22px 14px; text-align: center;
  color: var(--muted); cursor: pointer; margin: 8px 0; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.check.confirm { font-weight: 600; color: var(--warn); }
.case-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; align-items: center; margin-bottom: 4px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.thumb-wrap { position: relative; }
.thumb { display: block; width: 150px; height: 150px; padding: 0; border-radius: 8px; overflow: hidden; border: 1px solid var(--line);
  background: var(--chip); min-height: 0; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.sm { width: 92px; height: 92px; }
.thumbs.small { margin-bottom: 10px; }
.thumb-x { position: absolute; top: 4px; right: 4px; min-height: 0; width: 26px; height: 26px; padding: 0; justify-content: center;
  border-radius: 50%; background: rgba(0, 0, 0, .6); color: #fff; border: none; font-size: 1rem; }
.photo-big img { max-width: 100%; max-height: 75vh; display: block; margin: auto; border-radius: 6px; }
.facts .neg, .facts li.neg { color: var(--muted); }
details.facts, details.intake, details.json { margin: 8px 0; }
details.facts > summary, details.intake > summary, details.json > summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
.intake-group h4 { margin: 8px 0 2px; }
.intake li.no { color: var(--muted); }
.intake .tick { font-size: .95rem; }
.stepper { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; list-style: none; padding: 0; margin: 22px 0 4px; }
.stepper .st-step { display: inline-flex; gap: 4px; align-items: center; padding: 6px 14px; border-radius: 999px; background: var(--chip);
  font-size: .9rem; font-weight: 600; color: var(--muted); }
.stepper .arrow { color: var(--muted); }
.st-step.running { background: var(--accent-soft); color: var(--accent); }
.st-step.done { background: var(--ok-soft); color: var(--ok); }
.st-step.error { background: var(--bad-soft); color: var(--bad); }
.st-step.skipped { opacity: .5; text-decoration: line-through; }
.step-card.running { border-color: var(--accent); }
.step-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.step-meta { font-size: .8rem; color: var(--muted); }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--accent); border-right-color: transparent; border-radius: 50%;
  animation: spin .8s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.story { white-space: pre-wrap; background: var(--chip); padding: 10px 12px; border-radius: 8px; line-height: 1.65; font-size: .95rem; }
mark.hl-kept { background: #fff0a0; color: inherit; border-radius: 3px; padding: 0 1px; }
mark.hl-dropped { background: var(--bad-soft); color: var(--bad); text-decoration: line-through; border-radius: 3px; }
@media (prefers-color-scheme: dark) { mark.hl-kept { background: #5c4c0a; } }
tr.dropped td { color: var(--muted); }
td.quote { font-style: italic; }
.table-wrap.tall { max-height: 460px; overflow: auto; }
.sec h4 { margin: 10px 0 4px; }
.fchip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); font-size: .86rem; }
.fchip .fp { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .78rem; }
.fchip .vf { color: var(--accent); font-weight: 700; }
.lv { font-size: .72rem; padding: 1px 7px; border-radius: 999px; font-weight: 700; white-space: nowrap; }
.lv-definite, .lv-present { background: var(--accent); color: var(--accent-ink); }
.lv-probable { background: var(--accent-soft); color: var(--accent); }
.lv-possible { background: var(--chip); color: var(--muted); border: 1px dashed var(--line-strong); }
.lv-absent { background: var(--bad-soft); color: var(--bad); }
.ref-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; }
.ref-card { margin: 0; }
.checks li { margin: 3px 0; line-height: 1.45; }
.checks .lv { margin-left: 2px; }
.topn li { margin: 2px 0; }
.chip.bad-chip { background: var(--bad-soft); color: var(--bad); }
tr.muted td { color: var(--muted); }
.ref-card .thumb { width: 100%; height: auto; aspect-ratio: 1; }
.ref-card figcaption { margin-top: 4px; display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.chip.src { border: 1px solid transparent; }
.chip.src-photo { background: #e6f0ff; color: #1d4f9c; }
.chip.src-text { background: #f3e8ff; color: #6a3fb5; }
.chip.src-form { background: #e6f6ee; color: #1d6b43; }
.chip.src-answer { background: #fff2d9; color: #8a5a00; }
.chip.src-derived { background: var(--chip); color: var(--muted); }
@media (prefers-color-scheme: dark) {
  .chip.src-photo { background: #1b2a44; color: #8fb8ff; } .chip.src-text { background: #2a1f3d; color: #c6a8ff; }
  .chip.src-form { background: #173326; color: #7fd8a4; } .chip.src-answer { background: #3a2c12; color: #f2c46b; }
}
ul.cols { columns: 2 260px; column-gap: 24px; }
ul.cols li { break-inside: avoid; }
table.grid tr.absent td:first-child { color: var(--muted); }
.ddx-item.is-ref { background: var(--ok-soft); border-radius: 6px; padding-left: 6px; padding-right: 6px; }
.ref-rank { font-size: 1.05rem; font-weight: 700; }
.step-card.reveal { border-style: dashed; }
@media (max-width: 1000px) { .studio-top, .two-col { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .thumb { width: 104px; height: 104px; } }
.srv.local { background: var(--accent-soft); color: var(--accent); }
.srv.local .dot { background: var(--accent); }
.chip.where-local { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.chip.where-fleet { background: var(--ok-soft); color: var(--ok); }
