/* 3D→2D Converter — design tokens + components (mockup: Proposal §5). No external UI library. */
:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f2f4f7; --surface-3: #e9edf2; --border: #e2e6ec; --border-strong: #cdd3db;
  --text: #0f1419; --text-2: #5b6573; --text-3: #8a94a3;
  --accent: #1273e6; --accent-ink: #ffffff; --accent-soft: #dfeeff; --accent-line: #9cc8fb;
  --good: #137a3f; --good-soft: #def5e6; --bad: #b42318; --bad-soft: #fdecea; --warn: #a15c00; --warn-soft: #fff0d9;
  --radius: 12px; --radius-sm: 8px; --shadow: 0 1px 2px rgb(16 24 40 / .05); --shadow-lg: 0 12px 32px rgb(16 24 40 / .14);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --sidebar-w: 248px; --topbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117; --surface: #151b23; --surface-2: #1b222c; --surface-3: #232c38; --border: #2a3442; --border-strong: #3a4656;
    --text: #e6edf3; --text-2: #9aa7b6; --text-3: #6f7c8c;
    --accent: #4c8df6; --accent-ink: #ffffff; --accent-soft: #15243c; --accent-line: #2d5aa0;
    --good: #4ac26b; --good-soft: #12261a; --bad: #f47067; --bad-soft: #2d1514; --warn: #e0a645; --warn-soft: #2b2111;
    --shadow: none; --shadow-lg: 0 12px 32px rgb(0 0 0 / .45); color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font: 700 24px/1.2 var(--display); margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font: 600 18px/1.3 var(--display); margin: 0 0 6px; }
h3 { font-size: 15px; font-weight: 600; margin: 6px 0; }
img, svg { display: block; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1:focus, h1:focus-visible { outline: none; }
.icon { width: 18px; height: 18px; flex: none; }
.icon-sm { width: 16px; height: 16px; }

/* ---------- Shell: sidebar + topbar (full width) ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100dvh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; z-index: 40; }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 20px; height: 72px; border-bottom: 1px solid var(--border); color: var(--text); }
.brand:hover { text-decoration: none; }
.brand strong { font: 700 15px var(--display); display: block; }
.brand small { display: block; color: var(--text-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; background: var(--text); color: var(--bg); display: grid; place-items: center; font: 700 12px var(--display); flex: none; }
.brand-mark.lg { width: 44px; height: 44px; font-size: 15px; margin: 0 auto 16px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; padding: 16px 12px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; }
.nav-item:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }
.sidebar-foot .who { flex: 1; min-width: 0; }
.sidebar-foot strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot small { display: block; color: var(--text-2); font-size: 12px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 600; font-size: 11.5px; flex: none; position: relative; }
.avatar.online::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 8px; height: 8px; border-radius: 50%; background: var(--good); border: 2px solid var(--surface); }
.icon-btn { display: inline-grid; place-items: center; border: 1px solid transparent; background: transparent; color: var(--text-2); border-radius: var(--radius-sm); width: 34px; height: 34px; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 32px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar .menu-btn { display: none; margin-left: -8px; }
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13.5px; color: var(--text-2); }
.crumbs a { color: var(--text-2); white-space: nowrap; }
.crumbs a:hover { color: var(--text); }
.crumbs .current { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs .sep { color: var(--text-3); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.content { padding: 28px 32px 48px; width: 100%; min-width: 0; }
.content-public { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.scrim { display: none; }

/* ---------- Layout pieces ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-label { font: 600 12px var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.stack { display: grid; gap: 16px; align-content: start; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.stat strong { display: block; font: 700 28px/1.2 var(--display); letter-spacing: -.02em; }
.stat span { color: var(--text-2); font-size: 13px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.workspace.left-panel { grid-template-columns: 360px minmax(0, 1fr); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 13.5px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; text-align: right; font-weight: 500; overflow-wrap: anywhere; }
.empty { text-align: center; padding: 56px 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.empty .icon { width: 32px; height: 32px; margin: 0 auto 10px; color: var(--text-3); }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.note { background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--text); border-radius: var(--radius); padding: 14px 16px; font-size: 13px; }

/* ---------- Forms & buttons ---------- */
label { display: block; font-size: 13px; font-weight: 500; margin: 12px 0 6px; }
input, select, textarea { width: 100%; height: 38px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: 14px var(--font); transition: border-color .15s, box-shadow .15s; }
textarea { height: auto; padding: 10px 12px; min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; padding: 0; accent-color: var(--accent); }
input[type=color] { width: 36px; height: 28px; padding: 2px; cursor: pointer; }
input[type=range] { height: auto; padding: 0; border: none; accent-color: var(--accent); }
input[type=range]:focus { box-shadow: none; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.search { position: relative; width: 240px; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 16px; height: 16px; }
.search input { padding-left: 34px; height: 36px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: 600 14px var(--font); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover:not(:disabled) { background: var(--surface-2); text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
.btn-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--warn); }
.btn-danger { color: var(--bad); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-block { width: 100%; }
.btn-lg { height: 46px; font-size: 15px; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.segmented button { border: none; background: transparent; color: var(--text-2); font: 600 13.5px var(--font); padding: 7px 14px; border-radius: 7px; cursor: pointer; }
.segmented button[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); }

/* ---------- Badges, alerts, progress ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.chip-good { background: var(--good-soft); color: var(--good); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-bad { background: var(--bad-soft); color: var(--bad); }
.chip-info { background: var(--accent-soft); color: var(--accent); }
.chip-outline { background: transparent; border: 1px solid var(--border-strong); color: var(--text); }
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-ok { background: var(--good-soft); color: var(--good); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-busy { background: var(--accent-soft); color: var(--accent); }
.badge-idle { background: var(--surface-3); color: var(--text-2); }
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin: 0 0 16px; }
.alert-bad { background: var(--bad-soft); color: var(--bad); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-ok { background: var(--good-soft); color: var(--good); }
.statusbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 16px; font-size: 13.5px; }
.statusbar .ok { color: var(--good); display: inline-flex; align-items: center; gap: 6px; }
.statusbar .warn { color: var(--warn); display: inline-flex; align-items: center; gap: 6px; }
.statusbar .divider { width: 1px; height: 18px; background: var(--border); }
.progress { display: block; height: 6px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.progress-bar { display: block; height: 100%; background: var(--good); border-radius: 6px; transition: width .3s; }
.progress-bar.accent { background: var(--accent); }
.progress-bar.indeterminate { width: 35%; background: var(--accent); animation: slide 1.2s infinite ease-in-out; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
.skeleton { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border: 1px solid var(--border); border-radius: var(--radius); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; position: relative; } /* contains absolutely positioned .sr-only labels: no page-wide horizontal scroll */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tr.dim td { opacity: .55; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border); vertical-align: middle; }
td input, td select { height: 32px; }
.cell-icon { width: 30px; height: 30px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); display: inline-grid; place-items: center; margin-right: 10px; vertical-align: middle; }
.cell-icon .icon { width: 16px; height: 16px; }

/* ---------- Project cards ---------- */
.project-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; color: var(--text); transition: border-color .15s, box-shadow .15s, transform .15s; }
.project-card:hover { border-color: var(--accent-line); box-shadow: var(--shadow-lg); transform: translateY(-2px); text-decoration: none; }
.project-thumb { aspect-ratio: 16 / 8; background: var(--accent-soft); display: grid; place-items: center; overflow: hidden; border-bottom: 1px solid var(--border); }
.project-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: center 35%; background: #fff; }
.project-thumb svg { width: 140px; height: 90px; color: var(--accent); }
.project-body { padding: 14px 16px 0; flex: 1; }
.project-title { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.project-title strong { font: 600 15px/1.3 var(--display); }
.project-body p { margin: 4px 0 0; color: var(--text-2); font-size: 12.5px; }
.project-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 12px 16px 14px; padding-top: 10px; border-top: 1px solid var(--border); }
.project-foot .mono { color: var(--text-3); font-size: 11.5px; }
.open-link { display: inline-flex; align-items: center; gap: 2px; color: var(--accent); font-weight: 600; font-size: 13px; white-space: nowrap; }

/* ---------- Viewers ---------- */
.viewer-stage { position: relative; height: calc(100dvh - var(--topbar-h) - 56px); min-height: 460px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; touch-action: none; background-color: var(--surface);
  background-image: radial-gradient(var(--surface-3) 1px, transparent 1px); background-size: 18px 18px; }
.viewer-stage:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.viewer-canvas { position: absolute; inset: 0; }
.viewer-stage canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.viewer-stage canvas:active { cursor: grabbing; }
.viewer-tools { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; gap: 6px; z-index: 2; flex-wrap: wrap; align-items: center; pointer-events: none; }
.viewer-tools > * { pointer-events: auto; }
.viewer-tools .icon-btn { background: var(--surface); border-color: var(--border); }
.viewer-tools .icon-btn[aria-pressed=true] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.viewer-tools .seg { display: inline-flex; }
.viewer-tools .seg .icon-btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.viewer-tools .seg .icon-btn:last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }
.viewer-select, .viewer-text-btn { width: auto; height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-2); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.viewer-text-btn[aria-pressed=true] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.viewer-select:disabled, .viewer-text-btn:disabled { opacity: .5; cursor: default; }
.viewer-help { position: absolute; top: 56px; left: 12px; z-index: 4; max-width: min(420px, calc(100% - 24px)); padding: 12px 14px; font-size: 12.5px; box-shadow: 0 8px 24px rgb(0 0 0 / .12); }
.viewer-help .kv { grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 12.5px; }
.viewer-help .kv dd { text-align: left; font-weight: 500; }
.viewer-selection { position: absolute; z-index: 2; left: 12px; bottom: 40px; display: flex; align-items: center; gap: 8px; max-width: calc(100% - 24px); padding: 4px 4px 4px 12px; border: 1px solid var(--accent-line); border-radius: var(--radius-sm); background: var(--surface); font-size: 13px; }
.viewer-selection-name { font-weight: 600; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.viewer-selection .icon-btn { width: 28px; height: 28px; }
.viewer-selection .mono { white-space: nowrap; font-size: 12px; }
.viewer-selection-name { flex: 1 1 auto; min-width: 4ch; }
.viewer-pill { position: absolute; z-index: 2; padding: 4px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 12px; font-weight: 600; color: var(--text-2); }
.viewer-pill.tl { top: 12px; left: 12px; }
.viewer-pill.tr { top: 12px; right: 12px; }
.viewer-pill.br { bottom: 12px; right: 12px; }
.viewer-pill.info { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.viewer-hint { position: absolute; z-index: 2; left: 16px; bottom: 12px; color: var(--text-3); font-size: 12px; }
.viewer-overlay { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 8px; color: var(--text-2); background: color-mix(in srgb, var(--surface) 75%, transparent); z-index: 3; }
.viewer-overlay .progress { width: 260px; }
.page-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.page-tabs button { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 999px; padding: 5px 12px; font: 600 12.5px var(--font); cursor: pointer; }
.page-tabs button[aria-pressed=true] { background: var(--text); color: var(--bg); border-color: var(--text); }
.sheet-stage { background: var(--surface-3); background-image: none; }

/* ---------- Side panels ---------- */
.choice { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); text-align: left; font: 14px var(--font); cursor: pointer; }
.choice + .choice { margin-top: 8px; }
.choice strong { display: block; font-weight: 600; }
.choice small { color: var(--text-3); font-family: var(--mono); font-size: 11.5px; }
.choice[aria-pressed=true] { background: var(--accent-soft); border-color: var(--accent-line); }
.choice[aria-pressed=true] strong { color: var(--accent); }
.layer-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 13px; }
.layer-row .name { font-family: var(--mono); font-size: 12.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-row .count { color: var(--text-3); font-family: var(--mono); font-size: 12px; }
.dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.export-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.export-tile { display: grid; justify-items: center; gap: 4px; padding: 14px 6px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text); font-weight: 700; font-size: 13px; }
.export-tile:hover { border-color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.export-tile small { font-weight: 500; color: var(--text-3); font-size: 11px; }
.export-tile.disabled { opacity: .45; pointer-events: none; }
.dropzone { display: grid; place-items: center; gap: 4px; padding: 18px 14px; border: 1.5px dashed var(--border-strong); border-radius: 10px; background: var(--surface-2); cursor: pointer; text-align: center; position: relative; }
.dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; height: 100%; }
.dropzone.busy { cursor: progress; }
.dropzone .progress { width: 100%; margin-top: 8px; }
.cut-input { display: flex; align-items: center; gap: 10px; }
.cut-input input[type=number] { width: 96px; font-family: var(--mono); }
.cut-input input[type=range] { flex: 1; }

/* ---------- Title block preview ---------- */
.tb-preview { border: 2px solid var(--text); border-radius: 2px; font-size: 10.5px; background: #fff; color: #111; }
.tb-preview > div { border-bottom: 1px solid #111; padding: 5px 8px; }
.tb-preview > div:last-child { border-bottom: none; }
.tb-preview .tb-row { display: grid; grid-template-columns: repeat(3, 1fr); padding: 0; }
.tb-preview .tb-row.two { grid-template-columns: 1fr 1fr; }
.tb-preview .tb-row > span { padding: 5px 8px; border-right: 1px solid #111; font-family: var(--mono); font-size: 9.5px; color: #555; }
.tb-preview .tb-row > span:last-child { border-right: none; }

/* ---------- Members ---------- */
.member { display: flex; align-items: center; gap: 12px; min-width: 0; }
.member strong { display: block; }
.member small { display: block; color: var(--text-3); font-family: var(--mono); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; }
.role-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 16px; }
.role-cards h3 { font-size: 12.5px; letter-spacing: .06em; text-transform: uppercase; margin: 0 0 6px; }
.role-cards p { margin: 0; color: var(--text-2); font-size: 13px; }
.menu { position: relative; display: inline-block; }
.menu-pop { position: absolute; right: 0; top: 36px; min-width: 190px; z-index: 20; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; }
.menu-pop button { display: block; width: 100%; text-align: left; border: none; background: none; padding: 8px 10px; border-radius: 6px; font: 13.5px var(--font); color: var(--text); cursor: pointer; }
.menu-pop button:hover { background: var(--surface-2); }
.menu-pop .danger { color: var(--bad); }

/* ---------- Dialog ---------- */
.dialog-backdrop { position: fixed; inset: 0; background: rgb(15 20 25 / .45); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .15s; }
.dialog { width: min(480px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 22px; animation: pop .15s; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.copy-box { display: flex; gap: 8px; margin-top: 8px; }
.copy-box input { font-family: var(--mono); font-size: 12px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }

/* ---------- Auth pages ---------- */
.auth-card { width: min(400px, 100%); }
.auth-card h1 { text-align: center; font-size: 22px; }
.auth-card p.muted { text-align: center; margin: 0 0 8px; }
.auth-foot { text-align: center; margin-top: 16px; font-size: 13.5px; color: var(--text-2); }

/* ---------- Blazor ---------- */
#blazor-error-ui { display: none; position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--bad-soft); color: var(--bad); padding: 10px 16px; border-radius: var(--radius-sm); z-index: 1000; box-shadow: var(--shadow-lg); }
#blazor-error-ui .dismiss { cursor: pointer; margin-left: 12px; }
.valid.modified:not([type=checkbox]) { border-color: var(--good); }
.invalid { border-color: var(--bad); }
.validation-message { color: var(--bad); font-size: 12.5px; margin-top: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .workspace, .workspace.left-panel { grid-template-columns: minmax(0, 1fr); }
  .viewer-stage { height: 62dvh; min-height: 360px; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(84vw, var(--sidebar-w)); transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgb(15 20 25 / .4); z-index: 35; }
  .topbar { padding: 0 16px; }
  .topbar .menu-btn { display: inline-grid; }
  .topbar .search { display: none; }
  .content { padding: 20px 16px 40px; }
  .stats { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .stat { display: flex; align-items: baseline; gap: 10px; padding: 12px 16px; }
  .stat strong { font-size: 22px; }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .hide-sm { display: none !important; }
  .btn-label { display: none; }
  .viewer-stage { height: 56dvh; min-height: 300px; }
  .export-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  td, th { padding: 10px 8px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Shared bits used by auth/engine pages ---------- */
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow-lg); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; }
.badge-good { background: var(--good-soft); color: var(--good); }
.badge-info { background: var(--accent-soft); color: var(--accent); }
.badge-muted { background: var(--surface-3); color: var(--text-2); }
.dot-pulse { width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: .3; } }
.sheet-stage { height: calc(100dvh - var(--topbar-h) - 150px); }
@media (max-width: 1180px) { .sheet-stage { height: 64dvh; } }
@media (max-width: 860px) { .sheet-stage { height: 58dvh; } .topbar-actions .btn { padding: 0 12px; } }
@media (max-width: 860px) {
  .page-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .page-tabs button { flex: none; }
}

/* ---- Billing & license (Fase 3) ------------------------------------------------------------- */
.progress-bar.warn { background: var(--warn); }
.progress-bar.bad { background: var(--bad); }
.license-banner { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; padding: 8px 20px; font-size: 13.5px; border-bottom: 1px solid var(--border); }
.license-banner.warn { background: var(--warn-soft); color: var(--warn); }
.license-banner.bad { background: var(--bad-soft); color: var(--bad); }
.license-banner a { color: inherit; font-weight: 600; text-decoration: underline; }
.billing-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.billing-grid > .card, .plan-grid > .card { margin: 0; }
.billing-plan { font-size: 17px; margin: 0 0 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.feature-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13.5px; }
.feature-list li { display: flex; align-items: center; gap: 8px; }
.feature-list li.on { color: var(--text); }
.feature-list li.on .icon { color: var(--good); }
.feature-list li.off { color: var(--text-3); }
.usage + .usage { margin-top: 14px; }
.usage-head { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; margin-bottom: 6px; flex-wrap: wrap; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.plan-card h3 { margin: 0 0 4px; font-size: 16px; }
.plan-price { font: 700 22px/1.3 var(--display); margin: 0 0 8px; }
.plan-price .muted { font: 500 13px var(--font); }
@media (max-width: 860px) { .billing-grid { grid-template-columns: minmax(0, 1fr); } .license-banner { padding: 8px 16px; } }
.plan-pay { margin-top: 14px; }
.payment-return { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; margin-bottom: 16px; }
.payment-return.ok { border-color: var(--good); background: var(--good-soft); color: var(--good); }
.payment-return.wait { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.payment-return.bad { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.payment-return a { color: inherit; font-weight: 600; }

/* ---- Assisted Classification (models/{id}/classification) ---- */
.stats-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.class-meter { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface-3); gap: 2px; }
.class-meter span { display: block; height: 100%; }
.seg-confirmed, .key-confirmed { background: var(--good); }
.seg-auto, .key-auto { background: var(--accent); }
.seg-review, .key-review { background: var(--warn); }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; margin: 0 2px 0 8px; }
.class-workspace { grid-template-columns: minmax(0, 1fr) 380px; }
.class-table th, .class-table td { padding-left: 8px; padding-right: 8px; }
.class-table td:nth-last-child(2) { white-space: nowrap; }
.segmented button[aria-pressed=true] small { color: inherit; opacity: .85; }
@media (max-width: 1400px) { .class-table th:last-child, .class-table td:last-child { display: none; } }
.class-aside { position: sticky; top: calc(var(--topbar-h) + 16px); }
.class-aside .viewer-stage { height: 56dvh; min-height: 360px; }
.bulkbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.bulkbar .check { display: inline-flex; align-items: center; gap: 6px; margin: 0 8px 0 0; font-weight: 500; font-size: 13px; }
.class-table tbody tr { cursor: pointer; }
.class-table tbody tr:hover { background: var(--surface-2); }
.class-table tr.row-active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.class-table td { vertical-align: top; }
.class-table select { min-width: 150px; }
.el-name { display: flex; align-items: center; gap: 6px; font-weight: 600; min-width: 0; }
.el-name > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.el-reason, .el-layer, .d-block { display: block; }
.el-reason { max-width: 420px; }
.rank-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rank-bars li { display: grid; grid-template-columns: 110px minmax(0, 1fr) 48px; align-items: center; gap: 10px; font-size: 13px; }
.rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-track { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.rank-bar { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.rank-value { text-align: right; color: var(--text-2); }
@media (max-width: 1180px) { .class-workspace { grid-template-columns: minmax(0, 1fr); } .class-aside { position: static; order: -1; } .class-aside .viewer-stage { height: 46dvh; } }
@media (max-width: 860px) { .stats-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .class-table select { min-width: 0; width: 130px; } .el-name > span:first-child { max-width: 180px; } }
