/* ── КТ-эксперт design system ─────────────────────────────────────────── */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-2: #06b6d4;
  --grad: linear-gradient(135deg, #2563eb 0%, #06b6d4 100%);
  --grad-soft: linear-gradient(135deg, rgba(37,99,235,.08), rgba(6,182,212,.08));
  --ok: #10b981;
  --warn: #f59e0b;
  --info: #3b82f6;
  --bad: #ef4444;
  --violet: #8b5cf6;
  --cyan: #0ea5e9;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 34px rgba(15, 23, 42, .07);
  --shadow-sm: 0 4px 14px rgba(15, 23, 42, .05);
  --font: "Manrope", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
img { max-width: 100%; }

/* ── Brand ────────────────────────────────────────────────────────────── */
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); }
.brand-mark {
  width: 38px; height: 38px; flex: none;
  background: url("tooth.png") center/contain no-repeat;
  filter: drop-shadow(0 4px 10px rgba(37, 99, 235, .30));
}
.brand-name { font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.brand-lg .brand-mark { width: 56px; height: 56px; }
.brand-lg .brand-name { font-size: 28px; }

/* ── Login ────────────────────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; position: relative; overflow: hidden;
  background:
    radial-gradient(1100px 600px at 15% -10%, rgba(37,99,235,.14), transparent 60%),
    radial-gradient(900px 600px at 110% 110%, rgba(6,182,212,.16), transparent 60%),
    var(--bg);
}
.blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; animation: float 14s ease-in-out infinite; }
.blob-a { width: 420px; height: 420px; background: rgba(37,99,235,.25); top: -120px; left: -80px; }
.blob-b { width: 360px; height: 360px; background: rgba(6,182,212,.25); bottom: -120px; right: -60px; animation-delay: -5s; }
.blob-c { width: 240px; height: 240px; background: rgba(139,92,246,.18); top: 55%; left: 12%; animation-delay: -9s; }
@keyframes float { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-34px) } }

.login-card {
  position: relative; width: 100%; max-width: 420px;
  background: rgba(255,255,255,.82); backdrop-filter: blur(18px);
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 26px; padding: 44px 40px 32px;
  box-shadow: 0 24px 70px rgba(15,23,42,.13);
  animation: rise .5s cubic-bezier(.2,.9,.3,1);
}
@keyframes rise { from { opacity: 0; transform: translateY(18px) } to { opacity: 1; transform: none } }
.login-sub { color: var(--muted); margin: 14px 0 26px; font-size: 14.5px; }
.login-foot { color: var(--muted); font-size: 12.5px; text-align: center; margin: 22px 0 0; }
.login-error {
  background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca;
  padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 14px;
}

.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; letter-spacing: .02em; }
.field input {
  width: 100%; padding: 12px 15px; font: inherit; font-size: 15px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(37,99,235,.12); }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; font-size: 14px;
  border: none; border-radius: 12px; padding: 10px 18px; cursor: pointer;
  transition: transform .12s, box-shadow .15s, background .15s, opacity .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 8px 20px rgba(37,99,235,.30); }
.btn-primary:hover { box-shadow: 0 10px 26px rgba(37,99,235,.40); }
.btn-block { width: 100%; padding: 13px; font-size: 15px; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: rgba(15,23,42,.06); }
.btn-outline { background: #fff; color: var(--ink-2); border: 1.5px solid var(--line); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger-ghost { background: transparent; color: var(--bad); }
.btn-danger-ghost:hover { background: #fef2f2; }
.btn-sm { padding: 7px 13px; font-size: 13px; }

/* ── App shell ────────────────────────────────────────────────────────── */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 48px;
  background: rgba(255,255,255,.72); backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(15,27,45,.06);
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 16px 5px 6px; box-shadow: var(--shadow-sm);
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--grad); color: #fff; font-weight: 800; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.user-name { font-weight: 700; font-size: 13.5px; }

.view { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 30px 32px 60px; }
.footer {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 18px 32px; color: var(--muted); font-size: 12.5px;
  border-top: 1px solid var(--line);
}

/* ── Dashboard ────────────────────────────────────────────────────────── */
.page-head {
  display: flex; align-items: flex-start; gap: 24px; flex-wrap: wrap;
  margin: 14px 0 34px;
}
.page-head .ph-text { margin-right: auto; }
.page-head h1 { font-size: 34px; font-weight: 800; letter-spacing: -.03em; margin: 0 0 8px; }
.page-head p { color: #5a6a7e; margin: 0; font-size: 17px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 999px; background: #fff;
  border: 1px solid rgba(15,27,45,.07); font-size: 14px; font-weight: 700;
  color: #12924a; box-shadow: 0 2px 8px -3px rgba(15,27,45,.1);
}
.status-pill .dot {
  width: 8px; height: 8px; border-radius: 999px; background: #16a34a;
  box-shadow: 0 0 0 3px rgba(22,163,74,.18);
}

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 22px; }
@media (max-width: 800px) { .stats { grid-template-columns: 1fr; } }
.stat-card {
  padding: 24px; background: #fff; border: 1px solid rgba(15,27,45,.055);
  border-radius: 20px;
  box-shadow: 0 1px 2px rgba(15,27,45,.04), 0 16px 36px -28px rgba(15,27,45,.24);
}
.stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.stat-icon {
  width: 46px; height: 46px; border-radius: 14px; flex: none;
  display: flex; align-items: center; justify-content: center;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-badge { font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 999px; }
.stat-val { font-size: 36px; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.stat-lbl { margin-top: 8px; font-size: 14px; color: #5a6a7e; font-weight: 500; }

/* upload banner (dark gradient) */
.upload-banner {
  position: relative; overflow: hidden; border-radius: 24px; padding: 40px;
  margin-bottom: 48px; color: #fff; cursor: pointer;
  background: linear-gradient(135deg, #0d1830 0%, #163a76 55%, #1170a8 100%);
  box-shadow: 0 30px 60px -34px rgba(13,24,48,.7);
}
.upload-banner::before {
  content: ""; position: absolute; right: -60px; top: -60px;
  width: 280px; height: 280px; border-radius: 999px; pointer-events: none;
  background: radial-gradient(circle, rgba(18,182,216,.35), transparent 68%);
}
.upload-banner.dragover { outline: 2px dashed rgba(255,255,255,.55); outline-offset: -10px; }
.ub-inner { position: relative; display: flex; align-items: center; gap: 32px; flex-wrap: wrap; }
.ub-icon {
  width: 78px; height: 78px; border-radius: 22px; flex: none;
  background: linear-gradient(150deg, #2f7bf6, #12b6d8);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 20px 40px -14px rgba(18,182,216,.7), inset 0 1px 0 rgba(255,255,255,.35);
}
.ub-icon svg { width: 34px; height: 34px; }
.ub-text { flex: 1; min-width: 260px; }
.ub-title { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 8px; }
.ub-sub { font-size: 16px; color: rgba(255,255,255,.72); line-height: 1.5; }
.ub-actions { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.ub-hint { text-align: center; font-size: 13px; color: rgba(255,255,255,.55); }
.btn-white {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 14px 26px; border-radius: 13px; background: #fff; color: #0f1b2d;
  font-size: 15px; font-weight: 800; border: none; cursor: pointer;
  box-shadow: 0 12px 28px -10px rgba(0,0,0,.4);
  transition: background .15s;
}
.btn-white:hover { background: #eaf1ff; }
/* banner states (confirm / progress reuse the same ids) */
.upload-banner .dz-title { color: #fff; }
.upload-banner .dz-sub { color: rgba(255,255,255,.65); }
.upload-banner .dz-confirm { cursor: default; }
.upload-banner .dz-confirm .field span { color: rgba(255,255,255,.85); }
.upload-banner .dz-actions .btn-outline {
  background: transparent; color: #fff; border-color: rgba(255,255,255,.4);
}
.upload-banner .dz-actions .btn-outline:hover { border-color: #fff; }
/* dropzone states inside the banner (ids kept for app.js) */
.dz-title { font-weight: 800; font-size: 16.5px; }
.dz-sub { color: rgba(255,255,255,.65); font-size: 13.5px; margin-top: 4px; }
.dz-confirm { position: relative; max-width: 440px; margin: 0 auto; text-align: left; }
.dz-confirm .dz-title { text-align: center; margin-bottom: 14px; word-break: break-all; }
.dz-field { margin: 0 0 14px; }
.dz-actions { display: flex; gap: 10px; justify-content: center; }
.dz-progress { position: relative; margin-top: 4px; }
.progress-track { height: 8px; background: rgba(255,255,255,.18); border-radius: 99px; overflow: hidden; max-width: 460px; margin: 0 auto; }
.progress-fill { height: 100%; width: 0; background: #fff; border-radius: 99px; transition: width .2s; }
.dz-progress .dz-sub { margin-top: 8px; }

/* studies list */
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin: 0 0 18px;
}
.section-title h2 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.section-title .count { color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; }
.list-tools { display: flex; align-items: center; gap: 12px; flex: 1; justify-content: flex-end; min-width: 0; }
.search-box {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1px solid rgba(15,27,45,.09); border-radius: 13px;
  padding: 11px 16px; color: var(--muted);
  width: min(340px, 100%);
  box-shadow: 0 1px 2px rgba(15,27,45,.04);
  transition: border-color .15s, box-shadow .15s;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(37,99,235,.10); color: var(--accent); }
.search-box svg { flex: none; }
.search-box input {
  border: none; outline: none; background: none; font: inherit; font-size: 15px;
  color: var(--ink); width: 100%; padding: 0;
}
.search-box input::placeholder { color: #8494a6; }

.study-table {
  background: #fff; border: 1px solid rgba(15,27,45,.055); border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15,27,45,.04), 0 20px 44px -34px rgba(15,27,45,.28);
}
.study-thead {
  display: grid; grid-template-columns: 1fr 160px 120px; gap: 16px;
  padding: 15px 24px; background: #f8fafd; border-bottom: 1px solid rgba(15,27,45,.06);
  font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: #8494a6;
}
.study-pager {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 12px 24px; border-top: 1px solid rgba(15,27,45,.06);
}
.study-pager:empty { display: none; }
.pager-btn {
  min-width: 34px; height: 32px; padding: 0 8px;
  border: 1px solid rgba(15,27,45,.12); border-radius: 8px;
  background: #fff; color: #33465c; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .12s, color .12s, border-color .12s;
}
.pager-btn:hover { border-color: #1f6edc; color: #1f6edc; }
.pager-btn.active { background: #1f6edc; border-color: #1f6edc; color: #fff; }
.pager-btn.disabled { opacity: .35; pointer-events: none; }
.pager-gap { color: #8494a6; padding: 0 2px; }
.pager-info { margin-left: auto; font-size: 12px; color: #8494a6; }
.study-thead span:last-child { text-align: right; }
.study-row {
  display: grid; grid-template-columns: 1fr 160px 120px; gap: 16px; align-items: center;
  padding: 16px 24px; border-bottom: 1px solid rgba(15,27,45,.045);
  cursor: pointer; transition: background .15s;
}
.study-row:last-child { border-bottom: none; }
.study-row:hover { background: #f8fafd; }
.study-row .s-main { display: flex; align-items: center; gap: 15px; min-width: 0; }
.study-ic {
  width: 44px; height: 44px; border-radius: 13px; flex: none;
  background: linear-gradient(160deg, #eef3fb, #e3ebf7); color: #4a6a9e;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(15,27,45,.05);
}
.study-name { font-weight: 700; font-size: 15px; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.study-meta { color: #7a8798; font-size: 13px; margin-top: 3px; font-weight: 500; }
.study-actions { text-align: right; }
.study-list .empty { border: none; background: none; box-shadow: none; }
.btn-dark {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: 11px; background: #0f1b2d; color: #fff;
  font-size: 13px; font-weight: 700;
  box-shadow: 0 8px 18px -8px rgba(15,27,45,.5);
  transition: background .15s;
}
.btn-dark:hover { background: #1d63d1; color: #fff; }
.empty {
  text-align: center; color: var(--muted); padding: 46px 20px;
  background: var(--surface); border-radius: var(--radius); border: 1px dashed var(--line);
}

/* status badges */
.badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 800; letter-spacing: .01em;
  border-radius: 999px; padding: 5px 13px;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-uploaded { background: #fef3c7; color: #b45309; }
.badge-processing { background: #dbeafe; color: #1d4ed8; }
.badge-processing .dot { animation: pulse 1.1s ease-in-out infinite; }
.badge-done { background: #d1fae5; color: #047857; }
.badge-failed { background: #fee2e2; color: #b91c1c; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .25 } }

/* ── Study detail ─────────────────────────────────────────────────────── */
.back-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13.5px; margin-bottom: 16px; }
.detail-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; flex-wrap: wrap;
  margin-bottom: 22px;
}
.detail-head h1 { font-size: 25px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 8px; }
.study-h1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: rgba(15,23,42,.07); color: var(--accent); }
.name-input {
  font: inherit; font-size: 21px; font-weight: 800; letter-spacing: -.02em;
  color: var(--ink); background: #fff;
  border: 1.5px solid var(--accent); border-radius: 10px;
  padding: 4px 12px; outline: none; min-width: 320px; max-width: 100%;
  box-shadow: 0 0 0 4px rgba(37,99,235,.12);
}
.meta-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2); padding: 4px 12px;
}
.chip b { font-weight: 800; }
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid rgba(226,232,240,.6); box-shadow: var(--shadow-sm);
  padding: 24px; margin-bottom: 18px;
}
.card h3 { margin: 0 0 16px; font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.card h3 .hint { color: var(--muted); font-weight: 600; font-size: 12.5px; margin-left: 8px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* processing state */
.state-card { text-align: center; padding: 56px 24px; }
.spinner {
  width: 52px; height: 52px; margin: 0 auto 18px; border-radius: 50%;
  border: 4px solid rgba(37,99,235,.15); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }
.state-title { font-weight: 800; font-size: 18px; }
.state-sub { color: var(--muted); font-size: 14px; margin-top: 6px; }
.error-box {
  background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c;
  border-radius: var(--radius-sm); padding: 14px 16px; font-size: 13.5px;
  text-align: left; white-space: pre-wrap; word-break: break-word;
  max-height: 220px; overflow: auto; margin: 16px auto 0; max-width: 720px;
}

/* summary chips */
.summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.summary-item {
  display: flex; align-items: center; gap: 12px;
  border-radius: var(--radius-sm); padding: 13px 15px; background: var(--surface-2);
  border: 1px solid var(--line);
}
.summary-dot { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.summary-name { font-size: 13px; font-weight: 700; color: var(--ink-2); line-height: 1.3; }
.summary-count { margin-left: auto; font-size: 19px; font-weight: 800; }

/* panoramic */
.pano-wrap { border-radius: var(--radius-sm); overflow: hidden; background: #0b1220; cursor: zoom-in; }
.pano-wrap img { display: block; width: 100%; max-height: calc(100vh - 220px); object-fit: contain; }

/* odontogram */
.odontogram { overflow-x: auto; padding: 4px 0 8px; }
.arch { display: flex; gap: 4px; width: max-content; margin: 0 auto; }
.arch + .arch { margin-top: 10px; }
.arch-gap { width: 12px; flex: none; }
.tooth {
  width: 30px; height: 44px; flex: none; position: relative;
  border: 1.5px solid var(--line); background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 800; color: var(--ink-2);
  cursor: default; transition: transform .12s, box-shadow .12s;
}
.arch-upper .tooth { border-radius: 14px 14px 7px 7px; }
.arch-lower .tooth { border-radius: 7px 7px 14px 14px; }
.tooth.has-findings, .tooth.mark { cursor: pointer; color: #fff; border-color: transparent; }
.tooth.has-findings:hover, .tooth.mark:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.tooth .tbadge {
  position: absolute; top: -5px; right: -4px;
  width: 15px; height: 15px; border-radius: 50%;
  background: #fff; color: #1f2937; font-size: 9.5px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .28);
}
.tooth.missing {
  background:
    linear-gradient(135deg, transparent 45%, #cbd5e1 45%, #cbd5e1 55%, transparent 55%),
    var(--surface-2);
  color: #b6c2d4; border-style: dashed;
}
.odo-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 16px; justify-content: center; }
.odo-legend span { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.odo-legend i { width: 11px; height: 11px; border-radius: 4px; display: inline-block; }

/* per-tooth cards (all 32 teeth, crop + slice views + findings) */
.jaw-title {
  font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin: 22px 0 12px;
}
.jaw-title:first-of-type { margin-top: 4px; }
.teeth-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); gap: 14px; }
.tooth-card {
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-top: 3px solid transparent;
  border-radius: var(--radius-sm);
  padding: 14px; background: #fff; box-shadow: var(--shadow-sm);
  scroll-margin-top: 90px;
  transition: box-shadow .15s, transform .12s;
}
.tooth-card:hover { box-shadow: var(--shadow); }
.tooth-card.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 4px rgba(37,99,235,.45) } 100% { box-shadow: 0 0 0 4px transparent } }
.tooth-card-head { display: flex; align-items: center; gap: 11px; margin-bottom: 12px; }
.tc-name { min-width: 0; }
.tc-title { font-weight: 800; font-size: 14.5px; }
.fdi-num {
  width: 40px; height: 40px; border-radius: 12px; background: var(--grad); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px;
  flex: none;
}
.tooth-card-head .q { color: var(--muted); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.tc-status {
  margin-left: auto; flex: none;
  font-size: 11px; font-weight: 800; letter-spacing: .02em;
  border-radius: 999px; padding: 4px 10px;
}
/* status theming: top accent + FDI badge + pill */
.st-problem { border-top-color: #E5484D; }
.st-problem .fdi-num { background: #E5484D; }
.st-problem .tc-status { background: #fbeaea; color: #b91c1c; }
.st-crown { border-top-color: #E0A32E; }
.st-crown .fdi-num { background: #E0A32E; }
.st-crown .tc-status { background: #fbf1de; color: #9a6b12; }
.st-implant { border-top-color: #2E90C4; }
.st-implant .fdi-num { background: #2E90C4; }
.st-implant .tc-status { background: #e4f1f8; color: #1f6d97; }
.st-healthy { border-top-color: #3FA87A; }
.st-healthy .fdi-num { background: #3FA87A; }
.st-healthy .tc-status { background: #e9f5ef; color: #2b7d58; }
.st-missing, .st-unknown { border-style: dashed; border-top-style: solid; background: var(--surface-2); box-shadow: none; }
.st-missing .fdi-num, .st-unknown .fdi-num { background: #cbd5e1; }
.st-missing .tc-status, .st-unknown .tc-status { background: #eef2f7; color: #64748b; }
.tooth-card.compact { padding: 12px 14px; }
.tooth-card.compact .tooth-card-head { margin-bottom: 6px; }
.tc-note { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.tc-note.ok { color: #047857; padding-top: 4px; }

/* main crop */
.crop-main {
  background: #0b1220; border-radius: 10px; overflow: hidden;
  min-height: 150px; flex: 1;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
}
.crop-main img {
  max-height: 100%; max-width: 100%; object-fit: contain;
  cursor: zoom-in; transition: transform .15s;
}
.crop-main img:hover { transform: scale(1.04); }

/* 6 slice views: two labelled groups of 3 */
.views-row { display: flex; gap: 10px; margin-bottom: 10px; }
.views-group { flex: 1; min-width: 0; }
.vg-thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.vg-thumbs img {
  width: 100%; height: 104px; object-fit: contain;
  border-radius: 8px; background: #0b1220;
  cursor: zoom-in; transition: transform .12s, box-shadow .12s;
}
.vg-thumbs img:hover { transform: scale(1.07); box-shadow: var(--shadow-sm); }
.vg-label {
  text-align: center; margin-top: 4px;
  font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted);
}
.finding { padding: 9px 0; border-top: 1px solid var(--line); }
.finding:first-of-type { border-top: none; }
.finding-row { display: flex; align-items: center; gap: 8px; }
.finding-name { font-weight: 700; font-size: 13.5px; flex: 1; }
.finding-conf { font-size: 12.5px; font-weight: 800; color: var(--ink-2); }
.conf-track { height: 5px; border-radius: 99px; background: rgba(15,23,42,.08); margin-top: 7px; overflow: hidden; }
.conf-fill { height: 100%; border-radius: 99px; }

/* bone resorption / misc */
.prob-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.prob-lbl { width: 120px; font-size: 13px; font-weight: 700; color: var(--ink-2); flex: none; }
.prob-track { flex: 1; height: 9px; border-radius: 99px; background: rgba(15,23,42,.08); overflow: hidden; }
.prob-fill { height: 100%; border-radius: 99px; background: var(--grad); }
.prob-val { width: 46px; text-align: right; font-size: 12.5px; font-weight: 800; }
.grade-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px;
  font-weight: 800; font-size: 14px;
}
.grade-1 { background: #d1fae5; color: #047857; }
.grade-2 { background: #fef3c7; color: #b45309; }
.grade-3 { background: #fee2e2; color: #b91c1c; }

.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  font-weight: 800; font-size: 13px; color: var(--ink-2); padding: 6px 12px;
}

/* table */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); font-weight: 800; padding: 8px 12px; border-bottom: 1.5px solid var(--line);
}
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tbl tr:last-child td { border-bottom: none; }

/* raw json */
.json-view {
  background: #0b1220; color: #d7e3f4; border-radius: var(--radius-sm);
  padding: 18px; font: 12.5px/1.6 ui-monospace, "Cascadia Code", Consolas, monospace;
  overflow: auto; max-height: 480px; white-space: pre;
}

.disclaimer { color: var(--muted); font-size: 12.5px; text-align: center; margin: 6px 0 0; }

/* toast + lightbox */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff; font-weight: 700; font-size: 14px;
  padding: 12px 22px; border-radius: 999px; box-shadow: 0 14px 40px rgba(15,23,42,.35);
  z-index: 200; animation: rise .25s ease-out;
}
.toast.err { background: #b91c1c; }
.lightbox {
  position: fixed; inset: 0; z-index: 150; background: rgba(8,12,22,.88);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 30px; cursor: zoom-out;
}
.lightbox img { max-width: 100%; max-height: calc(100% - 40px); border-radius: 8px; }
.lightbox-cap { color: #cbd5e1; font-weight: 700; font-size: 14px; text-align: center; }

@media (max-width: 720px) {
  .topbar { padding: 12px 16px; }
  .view { padding: 20px 16px 48px; }
  .upload-banner { padding: 26px 20px; }
  .study-thead { display: none; }
  .study-row { grid-template-columns: 1fr auto; }
  .study-row .badge { grid-column: 2; justify-self: end; grid-row: 1; }
  .study-actions { grid-column: 1 / -1; text-align: left; }
  .user-name { display: none; }
}

/* ── top nav (studies / accounts / settings) ─────────────────────────── */
.topnav { display: flex; align-items: center; gap: 4px; margin-right: 6px; }
.topnav-link {
  padding: 9px 18px; border-radius: 11px; font-size: 15px; font-weight: 600;
  color: #566579; white-space: nowrap; transition: background .15s, color .15s;
}
.topnav-link:hover { background: rgba(15,27,45,.045); color: #0f1b2d; }
.topnav-link.active {
  font-weight: 700; color: #1550b8;
  background: linear-gradient(180deg, #e4edff, #d7e5ff);
  box-shadow: inset 0 0 0 1px rgba(47,123,246,.14);
}

/* ── settings: key-value + API key field ─────────────────────────────── */
.card-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; }
.card-sub code, .api-hint code { background: rgba(15,23,42,.06); border-radius: 6px; padding: 1px 6px; font-size: 12.5px; }
.kv { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: none; }
.kv-k { width: 150px; flex: none; color: var(--muted); font-weight: 700; font-size: 13px; }
.kv-v { color: var(--ink); font-weight: 600; }

.key-field { display: flex; gap: 8px; align-items: center; min-width: 0; }
.key-input {
  flex: 1; min-width: 0; font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 13px; padding: 9px 12px; border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); background: #fff; color: var(--ink);
}
.key-field.compact { gap: 6px; }
.key-field.compact .key-input { font-size: 12px; padding: 7px 10px; border-radius: 10px; }
.key-btn {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 33px; height: 33px; border: 1.5px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--muted); cursor: pointer; transition: border-color .15s, color .15s;
}
.key-btn:hover { border-color: var(--accent); color: var(--accent); }
.key-none { color: var(--muted); font-size: 13px; }
.api-hint { margin-top: 14px; color: var(--muted); font-size: 12.5px; line-height: 1.7; word-break: break-all; }

/* ── accounts table ──────────────────────────────────────────────────── */
.field select {
  width: 100%; padding: 10px 12px; font: inherit; font-size: 14px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink); outline: none; cursor: pointer;
}
.field select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(37,99,235,.12); }

.acc-form { display: grid; grid-template-columns: 1fr 1.2fr 1fr .9fr auto; gap: 12px; align-items: end; }
.acc-form .field { margin: 0; }
.acc-form button { height: 44px; padding-top: 0; padding-bottom: 0; }
@media (max-width: 820px) { .acc-form { grid-template-columns: 1fr 1fr; } }

.acc-table { display: flex; flex-direction: column; }
.acc-item { border-bottom: 1px solid var(--line); }
.acc-item:last-child { border-bottom: none; }
.acc-row, .acc-head {
  display: grid; grid-template-columns: minmax(110px,.9fr) minmax(120px,1fr) 130px minmax(220px,1.6fr) auto;
  gap: 14px; align-items: center; padding: 13px 0;
}
.acc-head {
  font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); border-bottom: 1px solid var(--line); padding: 6px 0 10px;
}
.acc-login { font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-name { color: var(--ink-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-login em { font-style: normal; color: var(--muted); font-weight: 600; font-size: 12px; }
.acc-key { min-width: 0; }
.acc-actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }
.acc-actions .btn[disabled] { opacity: .45; cursor: not-allowed; }
.role-pill { display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.role-admin { background: rgba(37,99,235,.12); color: var(--accent); }
.role-client { background: rgba(100,116,139,.14); color: var(--muted); }

/* inline edit panel under a row */
.acc-edit { padding: 2px 0 16px; }
.acc-edit-form {
  display: grid; grid-template-columns: 1.2fr 1.2fr .9fr auto; gap: 12px; align-items: end;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.acc-edit-form .field { margin: 0; }
.acc-edit-form .field span em { font-style: normal; font-weight: 500; color: var(--muted); }
.acc-edit-actions { display: flex; gap: 8px; }
.acc-edit-actions .btn { height: 40px; }

@media (max-width: 900px) {
  .acc-head { display: none; }
  .acc-row { grid-template-columns: 1fr; gap: 8px; padding: 15px 0; }
  .acc-actions { justify-content: flex-start; }
  .acc-edit-form { grid-template-columns: 1fr 1fr; }
}

/* ── Annotation screen ──────────────────────────────────────────────────── */
#view:has(.anno-root) { max-width: 1560px; }
.anno-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 14px;
}
.anno-head h1 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.anno-counters { display: flex; gap: 8px; flex-wrap: wrap; }
.anno-layout { display: flex; gap: 18px; align-items: stretch; }
.anno-stage { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.anno-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.anno-tools {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 4px 8px;
}
.anno-tools-lbl { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.anno-tool { background: transparent; color: var(--ink-2); border: none; box-shadow: none; }
.anno-tool:hover { background: rgba(15,23,42,.06); }
.anno-tool.active { background: var(--grad); color: #fff; }
.anno-zoom { font-size: 12.5px; font-weight: 700; color: var(--muted); min-width: 46px; }
.anno-save-status { margin-left: auto; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.anno-save-status.err { color: var(--bad); }

.anno-canvas-wrap {
  position: relative; flex: 1; height: calc(100vh - 300px); min-height: 520px;
  background: #0b1220; border-radius: 16px; overflow: hidden;
  box-shadow: var(--shadow-sm);
}
#anno-canvas { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; }
.anno-hint {
  position: absolute; left: 12px; bottom: 10px; pointer-events: none;
  font-size: 11.5px; color: rgba(255,255,255,.55);
}

.anno-panel {
  width: 320px; flex: none; align-self: flex-start;
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  padding: 18px; box-shadow: var(--shadow-sm);
  max-height: calc(100vh - 200px); overflow-y: auto;
}
.anno-panel-empty { color: var(--muted); font-size: 13.5px; }
.anno-panel-empty b { color: var(--ink-2); }
.anno-panel-empty p { margin: 8px 0 0; }
.anno-kind { display: flex; gap: 8px; margin-bottom: 16px; }
.anno-kind-btn {
  flex: 1; padding: 8px; font: inherit; font-size: 13px; font-weight: 700;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
  color: var(--ink-2); cursor: pointer; transition: border-color .15s, color .15s, background .15s;
}
.anno-kind-btn:hover { border-color: var(--accent); color: var(--accent); }
.anno-kind-btn.active { background: var(--grad-soft); border-color: var(--accent); color: var(--accent); }
.anno-select {
  width: 100%; padding: 11px 13px; font: inherit; font-size: 14px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.anno-select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(37,99,235,.12); }
.anno-checks {
  display: flex; flex-direction: column; gap: 7px;
  max-height: 260px; overflow-y: auto; padding-right: 4px;
}
.anno-check {
  display: flex; align-items: center; gap: 9px;
  font-size: 13.5px; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.anno-check input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.anno-textarea {
  width: 100%; padding: 11px 13px; font: inherit; font-size: 14px; resize: vertical;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.anno-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(37,99,235,.12); }
.anno-field-hint { display: block; margin-top: 5px; font-style: normal; font-size: 11.5px; color: var(--muted); }
.anno-del { width: 100%; margin-top: 4px; }

/* annotation status badges in the dashboard list */
.s-status { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.badge-anno-done { background: #d1fae5; color: #047857; }
.badge-anno-progress { background: #dbeafe; color: #1d4ed8; }

@media (max-width: 980px) {
  .anno-layout { flex-direction: column; }
  .anno-panel { width: 100%; max-height: none; }
}

/* ── Annotation queue (dashboard) ───────────────────────────────────────── */
.filter-chip {
  padding: 10px 16px; border-radius: 999px; border: 1.5px solid var(--line);
  background: #fff; font: inherit; font-size: 13.5px; font-weight: 700;
  color: var(--ink-2); cursor: pointer; white-space: nowrap; flex: none;
  transition: border-color .15s, color .15s, background .15s;
}
.filter-chip:hover { border-color: var(--accent); color: var(--accent); }
.filter-chip.active { background: var(--grad-soft); border-color: var(--accent); color: var(--accent); }
.queue-stats { margin: -8px 0 14px; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.queue-stats b { color: var(--ink-2); }
.study-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }

/* active state for toolbar toggles (hide-boxes) */
.anno-toolbar .btn-outline.active {
  background: var(--grad-soft); border-color: var(--accent); color: var(--accent);
}

/* dictation card (annotation screen) */
.anno-side { width: 320px; flex: none; align-self: flex-start; display: flex; flex-direction: column; gap: 12px; }
.anno-side .anno-panel { width: 100%; }
.anno-dict {
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  padding: 14px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 10px;
}
.anno-dict-head { display: flex; align-items: center; gap: 10px; }
.anno-dict-rec { flex: none; }
.anno-dict-rec.recording { background: var(--bad); animation: anno-dict-pulse 1.2s ease-in-out infinite; }
.anno-dict-rec:disabled { opacity: .5; cursor: not-allowed; }
.anno-dict .busy { opacity: .6; pointer-events: none; }
@keyframes anno-dict-pulse { 50% { box-shadow: 0 0 0 6px rgba(239,68,68,.25); } }
.anno-dict-status { font-size: 12.5px; font-weight: 600; color: var(--muted); line-height: 1.3; }
.anno-dict-status.err { color: var(--bad); }
.anno-dict .anno-textarea { margin: 0; }
.anno-dict-actions { display: flex; gap: 8px; }
.anno-dict-preview { display: flex; flex-direction: column; gap: 8px; }
.anno-dict-preview:empty { display: none; }
.anno-dict-list { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; }
.anno-dict-item span { font-size: 13px; }
.anno-dict-item em { display: block; font-style: normal; font-size: 11.5px; color: var(--warn); }
.anno-dict-item.off span { color: var(--muted); }
.anno-dict-note { font-size: 12px; color: var(--muted); }
.anno-dict-note.warn { color: var(--warn); }
@media (max-width: 980px) { .anno-side { width: 100%; } }
.anno-dict-level {
  width: 6px; height: 22px; border-radius: 3px; background: var(--line);
  display: inline-flex; align-items: flex-end; overflow: hidden; flex: none;
}
.anno-dict-level[hidden] { display: none; }
.anno-dict-level i { display: block; width: 100%; height: 100%; background: var(--ok); transform-origin: bottom; transform: scaleY(0); transition: transform .06s linear; }
.anno-batch-chip { background: #fef3c7; color: #92400e; font-weight: 700; }
.batch-tag { display: inline-block; margin-right: 8px; padding: 1px 8px; border-radius: 999px; background: #fef3c7; color: #92400e; font-weight: 700; font-size: 11.5px; }
.queue-batch { color: #92400e; }
.anno-excluded-chip { background: #fee2e2; color: #991b1b; font-weight: 700; }
.anno-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.anno-icon-btn { padding: 7px 9px; color: var(--muted); position: relative; }
.anno-icon-btn:hover { color: var(--bad); border-color: var(--bad); }
/* instant hover hint (native title shows only after a delay) */
[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; top: calc(100% + 6px); left: 50%;
  transform: translateX(-50%); z-index: 20; white-space: nowrap; pointer-events: none;
  background: var(--ink); color: #fff; font-size: 12px; font-weight: 600;
  padding: 6px 10px; border-radius: 8px; box-shadow: var(--shadow-sm);
}
