:root {
  --bg: #F7F8FA;
  --panel: #FFFFFF;
  --ink: #1F2430;
  --ink-2: #5B6270;
  --ink-3: #9AA1AE;
  --line: #E6E8EC;
  --primary: #5B8DEF;
  --primary-ink: #FFFFFF;
  --primary-soft: #E7EEFD;
  --ok: #2E9E6A;
  --warn: #C98A12;
  --danger: #E5484D;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 6px rgba(16, 24, 40, .06);
  --radius: 4px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 'Inter', system-ui, sans-serif; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 600; margin: 0; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
.shell { display: flex; min-height: 100vh; }
.rail { width: 84px; flex: 0 0 84px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding: 18px 0 16px; gap: 8px; position: sticky; top: 0; height: 100vh; }
.rail .brand { margin-bottom: 14px; }
.rail .brand:hover { background: transparent; }
.rail .brand img { width: 40px; height: 40px; display: block; }
.auth-mark { width: 56px; height: 56px; display: block; margin-bottom: 14px; }
.rail a { width: 48px; height: 48px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--ink-2); position: relative; }
.rail a:hover { background: var(--bg); text-decoration: none; }
.rail a.active { background: var(--primary-soft); color: var(--primary); }
.rail a .tip { display: none; position: absolute; left: 56px; white-space: nowrap; background: #333; color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 4px; z-index: 5; }
.rail a:hover .tip { display: block; }
.rail .spacer { flex: 1; }
.rail svg { width: 24px; height: 24px; }
.main { flex: 1; min-width: 0; padding: 28px 32px 48px; max-width: 1200px; }
.topline { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.sub { color: var(--ink-2); font-size: 13px; }
.panel { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.grid { display: grid; gap: 16px; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid.two { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); font-weight: 500; }
.btn.primary:hover { filter: brightness(.96); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.link { border: 0; background: transparent; color: var(--danger); padding: 0 4px; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 500; }
.btn.danger:hover { filter: brightness(.95); background: var(--danger); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.danger-zone { border: 1px solid #F5C2C4; }
.danger-zone h2 { color: var(--danger); }
label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; }
input, select, textarea { width: 100%; font: inherit; font-size: 14px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 12px; align-items: center; }
.row > * { flex: 1; }
.case-card { display: flex; flex-direction: column; gap: 10px; }
.case-card h3 { margin: 0; font-size: 15px; font-weight: 600; }
.case-card h3 a { color: var(--ink); }
.meta { font-size: 12px; color: var(--ink-3); }
.avatars { display: flex; gap: 4px; }
.avatar { width: 27px; height: 27px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; font-weight: 600; background: var(--ink-3); flex: 0 0 27px; }
.avatar.surgeon { background: #3FA796; }
.avatar.engineer { background: #F5B544; }
.avatar.admin { background: #8E6CD8; }
.chip { display: inline-flex; align-items: center; height: 22px; white-space: nowrap; padding: 0 8px; border-radius: 11px; font-size: 11px; font-weight: 500; background: var(--bg); color: var(--ink-2); }
.chip.live { background: #E3F5EC; color: var(--ok); }
.chip.requested { background: var(--primary-soft); color: var(--primary); }
.chip.in_design, .chip.in_review { background: #FDF3DD; color: var(--warn); }
.chip.approved, .chip.manufacturing, .chip.delivered { background: #E3F5EC; color: var(--ok); }
.chip.cancelled { background: #FCE8E8; color: var(--danger); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--ink-3); font-size: 12px; padding: 8px; border-bottom: 1px solid var(--line); }
td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item { display: flex; gap: 10px; align-items: center; }
.list-item .grow { flex: 1; min-width: 0; }
.empty { color: var(--ink-3); font-size: 13px; padding: 12px 0; }
.error { background: #FCE8E8; color: var(--danger); padding: 8px 12px; border-radius: var(--radius); font-size: 13px; margin-bottom: 12px; }
.ok { background: #E3F5EC; color: var(--ok); padding: 8px 12px; border-radius: var(--radius); font-size: 13px; margin-bottom: 12px; }
pre.req { white-space: pre-wrap; font: 12px/1.5 ui-monospace, monospace; background: var(--bg); padding: 8px; border-radius: var(--radius); margin: 6px 0 0; max-height: 160px; overflow: auto; }
details summary { cursor: pointer; font-size: 12px; color: var(--primary); }
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth .panel { width: 100%; max-width: 380px; padding: 28px; }
.logo { font-size: 24px; font-weight: 500; margin-bottom: 4px; }
.logo b { color: var(--primary); font-weight: 500; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.filters a { font-size: 12px; padding: 4px 10px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); color: var(--ink-2); }
.filters a.on { background: var(--primary-soft); border-color: var(--primary-soft); color: var(--primary); }
.tabbar { display: none; }
@media (max-width: 760px) {
  .rail { display: none; }
  .main { padding: calc(16px + env(safe-area-inset-top)) 16px calc(88px + env(safe-area-inset-bottom)); }
  h1 { font-size: 20px; }
  .grid.two, .grid.cards { grid-template-columns: 1fr; }
  table { display: block; overflow-x: auto; }
  input, select, textarea { font-size: 16px; } /* stops iOS zooming into fields */
  .btn { height: 44px; }
  .btn.small { height: 36px; }
  .topline > .row { width: 100%; }
  .topline > .row .btn { flex: 1; justify-content: center; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    background: var(--panel); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--ink-2); padding: 4px 0; border-radius: 8px; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.active { color: var(--primary); }
  .tabbar svg { width: 24px; height: 24px; }
  .auth + .tabbar, body:has(.auth) .tabbar { display: none; }
}

/* Cases list (SurgiCase, Figma node 15:182) ------------------------------------------------ */
.main.wide { max-width: none; padding: 8px 24px 32px 19px; }
.sc-appbar { display: flex; justify-content: space-between; align-items: center; background: var(--panel); border: 1px solid #DCDCDC; border-radius: var(--radius); padding: 4px; margin: 0 0 16px; }
.sc-appbar-side { display: flex; align-items: center; gap: 8px; }
.sc-appbar-logo { font-size: 20px; margin: 0; padding: 0 8px; color: #323232; }
.sc-appbar-logo b { color: #598BE4; }
.sc-vline { width: 1px; height: 24px; background: #DCDCDC; }
.sc-iconbtn { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; border-radius: var(--radius); cursor: pointer; position: relative; padding: 0; }
.sc-iconbtn:hover { background: var(--bg); text-decoration: none; }
.sc-iconbtn img { display: block; }
.sc-iconbtn.disabled { opacity: .3; cursor: not-allowed; }
.sc-iconbtn.disabled:hover { background: transparent; }
.sc-iconbtn.on { background: var(--primary-soft); }
.sc-bell-count { position: absolute; top: 4px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: #EF7158; color: #fff; font-size: 10px; font-weight: 600; line-height: 16px; text-align: center; }
.sc-me { display: inline-flex; align-items: center; gap: 8px; padding: 0 16px 0 8px; height: 40px; color: #000; font-size: 16px; font-weight: 500; border-radius: var(--radius); }
.sc-me:hover { background: var(--bg); text-decoration: none; }
.sc-me-avatar { width: 32px; height: 32px; border-radius: 50%; background: #2F80ED; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 500; }
.sc-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 0 0 8px; flex-wrap: wrap; }
.sc-crumbs { display: flex; align-items: center; gap: 24px; padding-left: 4px; }
.sc-arrow { width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; padding: 0; cursor: pointer; }
.sc-arrow.disabled { opacity: .35; cursor: default; }
.sc-crumb { font-size: 16px; font-weight: 500; color: #000; }
.sc-tools { display: flex; align-items: center; gap: 8px; }
.sc-search { width: 400px; max-width: 100%; height: 48px; display: flex; align-items: center; gap: 10px; padding: 0 16px; background: var(--panel); border: 1px solid #C8C8C8; border-radius: 65px; }
.sc-search input { border: 0; padding: 0; height: 100%; font-size: 14px; background: transparent; outline: none; }
.sc-search input::placeholder { color: #969696; }
.sc-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.sc-filter { position: relative; }
.sc-filter summary { list-style: none; cursor: pointer; width: 48px; height: 48px; border-radius: var(--radius); }
.sc-filter summary::-webkit-details-marker { display: none; }
.sc-filter summary img { display: block; }
.sc-filter summary.on, .sc-filter[open] summary { box-shadow: 0 0 0 2px var(--primary); }
.sc-filter-menu { position: absolute; right: 0; top: 56px; width: 260px; z-index: 5; box-shadow: 0 8px 24px rgba(16, 24, 40, .14); }
.sc-new { display: inline-flex; align-items: center; gap: 4px; height: 48px; padding: 0 16px; margin-left: 8px; border: 0; border-radius: var(--radius); background: #598BE4; color: #fff; font: 600 16px/1 Inter, system-ui, sans-serif; cursor: pointer; }
.sc-new:hover { filter: brightness(.95); }
.sc-note { justify-content: space-between; flex-wrap: wrap; margin: 4px 0 8px; }
.sc-note > span { flex: 1 1 auto; }
.sc-tabs { display: flex; align-items: center; margin-top: 8px; }
.sc-tab { height: 28px; padding: 4px 16px; font-size: 14px; color: #000; border: 1px solid transparent; border-bottom: 0; border-radius: 4px 4px 0 0; white-space: nowrap; }
.sc-tab:hover { text-decoration: none; background: rgba(255, 255, 255, .6); }
.sc-tab.on { background: var(--panel); border-color: #DCDCDC; font-weight: 500; position: relative; top: 1px; }
.sc-tab-sep { width: 1px; height: 18px; background: #DCDCDC; }
.sc-tab-end { margin-left: auto; color: var(--ink-2); font-size: 13px; }
.sc-table-card { background: var(--panel); border: 1px solid #DCDCDC; border-radius: 0 4px 4px 4px; overflow-x: auto; }
.sc-table { width: 100%; min-width: 1180px; border-collapse: collapse; font-size: 12px; letter-spacing: -.01em; color: #000; }
.sc-table th { padding: 18px 8px; font-weight: 400; color: #787878; border-bottom: 0; white-space: nowrap; }
.sc-table td { padding: 16px 8px; vertical-align: middle; border-bottom: 1px solid #DCDCDC; }
.sc-table tbody tr:last-child td { border-bottom: 0; }
.sc-table tr > :first-child { padding-left: 24px; }
.sc-table tr > :last-child { padding-right: 16px; }
.sc-table tbody tr:hover td { background: #FAFBFC; }
.sc-table .c-id { width: 128px; }
.sc-table .c-patient { width: 208px; }
.sc-table .c-type { width: 168px; }
.sc-table .c-date { width: 128px; }
.sc-table .c-upload { width: 128px; text-align: center; }
.sc-table .c-files { width: 128px; }
.sc-table .c-orders { width: 168px; }
.sc-table .c-actions { text-align: center; }
.sc-th-help { display: inline-flex; align-items: center; gap: 2px; }
.sc-th-help img { cursor: help; }
.sc-code { color: #000; white-space: nowrap; }
.sc-live { display: block; width: max-content; margin-top: 4px; font-size: 10px; font-weight: 500; color: var(--ok); background: #E3F5EC; border-radius: 8px; padding: 1px 6px; }
.sc-pipe { margin: 0 8px; }
.sc-muted { color: var(--ink-3); }
.sc-upload { display: inline-flex; align-items: center; gap: 4px; padding: 8px; background: var(--panel); border: 1px solid #DCDCDC; border-radius: var(--radius); color: #000; font-size: 12px; }
.sc-upload:hover { background: var(--bg); text-decoration: none; }
.sc-file { display: flex; align-items: flex-start; max-width: 120px; line-height: 16px; }
.sc-file + .sc-file { margin-top: 4px; }
.sc-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-file img { flex: 0 0 4px; }
.sc-order-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; line-height: 17px; }
.sc-order-line + .sc-order-line { margin-top: 4px; }
.sc-order-line > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-badge { flex: 0 0 auto; padding: 3px 8px; border-radius: 8px; font-size: 8px; line-height: 11px; color: #fff; background: var(--ink-3); }
.sc-badge.progress { background: #68A3FE; }
.sc-badge.pending { background: #EF7158; }
.sc-badge.done { background: #2E9E6A; }
.sc-actions { display: flex; justify-content: center; align-items: center; gap: 4px; }
.sc-actions form { margin: 0; display: contents; }
.sc-empty { text-align: center; color: var(--ink-3); padding: 40px 16px !important; font-size: 13px; }
.sc-pager { display: flex; justify-content: flex-end; align-items: center; gap: 24px; padding: 12px 8px 0; font-size: 14px; }
.sc-dialog { border: 0; border-radius: 8px; padding: 24px; width: min(520px, calc(100vw - 32px)); box-shadow: 0 16px 48px rgba(16, 24, 40, .24); color: var(--ink); }
.sc-dialog::backdrop { background: rgba(16, 24, 40, .35); }
.sc-dialog h2 { font-size: 18px; margin-bottom: 16px; }
.sc-form-row { display: flex; gap: 12px; }
.sc-form-row .field { flex: 0 0 110px; }
.sc-form-row .field.grow { flex: 1; }
.sc-dialog-actions { justify-content: flex-end; margin-top: 8px; }
.sc-code-preview { margin: -4px 0 12px; }
.sc-edit-case { max-width: 760px; }
.sc-code-field { background: var(--bg); border-radius: var(--radius); padding: 10px 12px; font-size: 13px; }
.sc-code-field .meta { margin: 4px 0 0; }
.sc-check { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; font-size: 13px; color: var(--ink); cursor: pointer; }
.sc-check input { width: auto; margin: 0; }
.sc-code-preview b { color: var(--ink); font-weight: 600; letter-spacing: .02em; }
.sc-dialog-actions > * { flex: 0 0 auto; }
.sc-help { padding-left: 18px; margin: 0; font-size: 13px; line-height: 1.6; color: var(--ink-2); }
.sc-help li + li { margin-top: 6px; }
@media (max-width: 1100px) {
  .sc-search { width: 280px; }
}
@media (max-width: 760px) {
  .main.wide { padding: calc(8px + env(safe-area-inset-top)) 12px calc(88px + env(safe-area-inset-bottom)); }
  .sc-tools { width: 100%; }
  .sc-search { flex: 1; width: auto; }
  .sc-new span { display: none; }
  .sc-new { padding: 0 12px; margin-left: 0; }
  .sc-tab { padding: 4px 10px; }
  .sc-tab-end { display: none; }
  .sc-form-row { flex-wrap: wrap; }
  .sc-form-row .field { flex: 1 1 100px; }
  .sc-me-name { display: none; }
  .sc-me { padding: 0 4px; }
}
