/* ═══════════════════════════════════════════════════════════════════════════
   KleinVet — Design System v4 · THE UTMOST
   ═════════════════════════════════════════════════════════════════════════
   Studied: Linear (dark mode craft), Stripe (mesh gradients, depth),
   Vercel/Geist (snappy easing, border-first), Raycast (glassmorphism),
   Mercury (clinical trust), shadcn/ui (component polish).

   Principles:
   ─ Motion has purpose: enter = ease-out, loop = ease-in-out, exit = ease-in
   ─ Surfaces: border-first, shadow only on elevation change
   ─ Glass effects on overlapping surfaces (header, modals)
   ─ Monospace for all data/numbers/codes (trust signal)
   ─ Gradient accents are earned — used sparingly on primary actions
   ─ 8px grid, 4px for fine tuning
   ─ prefers-reduced-motion respected everywhere
   ═══════════════════════════════════════════════════════════════════════ */

/* ──── DESIGN TOKENS ──── */
:root {
  /* 12-step neutral (cool slate) */
  --gray-25:  #fcfdfe;
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-150: #e8edf4;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --gray-950: #020617;

  /* Accent — teal/cyan family */
  --accent-50:  #ecfeff;
  --accent-100: #cffafe;
  --accent-200: #a5f3fc;
  --accent-300: #67e8f9;
  --accent-400: #22d3ee;
  --accent-500: #06b6d4;
  --accent-600: #0891b2;
  --accent-700: #0e7490;
  --accent-800: #155e75;
  --accent-900: #164e63;

  /* Semantic surfaces */
  --bg:          var(--gray-50);
  --surface:     #ffffff;
  --surface-2:   var(--gray-25);
  --border:      rgba(0, 0, 0, .06);
  --border-2:    rgba(0, 0, 0, .1);
  --border-3:    rgba(0, 0, 0, .14);
  --ink:         var(--gray-900);
  --ink-2:       var(--gray-700);
  --ink-3:       var(--gray-500);
  --muted:       var(--gray-400);

  /* Status — Stripe-style muted but clear */
  --green:       #16a34a;  --green-bg: #f0fdf4;  --green-border: #bbf7d0;
  --amber:       #d97706;  --amber-bg: #fffbeb;  --amber-border: #fde68a;
  --orange:      #ea580c;  --orange-bg: #fff7ed;  --orange-border: #fed7aa;
  --red:         #dc2626;  --red-bg:   #fef2f2;  --red-border:   #fecaca;
  --info:        var(--accent-700);
  --info-bg:     var(--accent-50);
  --info-border: var(--accent-100);

  /* Elevation — Tailwind's exact shadow scale */
  --shadow-xs:  0 1px 2px 0 rgb(0 0 0/.05);
  --shadow-sm:  0 1px 3px 0 rgb(0 0 0/.1), 0 1px 2px -1px rgb(0 0 0/.1);
  --shadow-md:  0 4px 6px -1px rgb(0 0 0/.1), 0 2px 4px -2px rgb(0 0 0/.1);
  --shadow-lg:  0 10px 15px -3px rgb(0 0 0/.1), 0 4px 6px -4px rgb(0 0 0/.1);
  --shadow-xl:  0 20px 25px -5px rgb(0 0 0/.1), 0 8px 10px -6px rgb(0 0 0/.1);
  --shadow-2xl: 0 25px 50px -12px rgb(0 0 0/.25);

  /* Radius */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius:    8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;

  /* Typography */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Noto Sans Arabic", "Segoe UI Arabic", Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", ui-monospace, SFMono-Regular,
               Menlo, Consolas, "Liberation Mono", monospace;

  /* Motion — Vercel's snappy ease-out + custom curves */
  --ease:      cubic-bezier(.16, 1, .3, 1);       /* decel-heavy, Vercel hero */
  --ease-out:  cubic-bezier(.33, 1, .68, 1);       /* standard ease-out */
  --ease-in:   cubic-bezier(.32, 0, .67, 0);
  --ease-spring: cubic-bezier(.175, .885, .32, 1.275); /* subtle overshoot */
  --ease-smooth: cubic-bezier(.4, 0, .2, 1);      /* Material smooth */

  --dur-0: 80ms;    /* micro-feedback: active press */
  --dur-1: 120ms;   /* instant: hover bg shift */
  --dur-2: 180ms;   /* fast: tooltips, dropdowns */
  --dur-3: 250ms;   /* standard: panels, cards */
  --dur-4: 350ms;   /* slow: overlays, page transitions */
  --dur-5: 500ms;   /* dramatic: hero entrances */

  /* Layout */
  --tap: 44px;
  --content-max: 1080px;
  --header-h: 52px;
  --tabbar-h: 48px;
}

/* ──── RESET ──── */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
[dir="rtl"] { text-align: right; }
img { max-width: 100%; display: block; }
a { color: var(--accent-700); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ──── TYPOGRAPHY — Stripe-style tight headings ──── */
h1 { font-size: 1.625rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; }
h2 { font-size: 1.125rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
h3 { font-size: 1rem;     font-weight: 600; letter-spacing: -.015em; line-height: 1.3; }
p  { margin: 0 0 .5em; }

.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.subhead {
  font-size: 11px; font-weight: 600; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 12px;
}
.mono { font-family: var(--font-mono); font-size: 13px; }
.screen { min-height: 100vh; min-height: 100dvh; }

/* ──── FOCUS — 2-layer ring (Vercel Geist pattern) ──── */
:focus-visible {
  outline: 2px solid var(--accent-500);
  outline-offset: 2px;
}
button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) { outline: none; }

/* ──── SELECTION ──── */
::selection { background: var(--accent-200); color: var(--gray-900); }

/* ──── SCROLLBAR — Linear-style minimal ──── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ──── REDUCED MOTION ──── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}


/* ═══════════════════ BUTTONS — Stripe depth + Vercel precision ═══════════ */
.btn {
  font: inherit; font-size: 13px; font-weight: 500; line-height: 1;
  cursor: pointer; position: relative;
  border: 1px solid var(--border-2); border-radius: var(--radius);
  padding: 0 14px; height: 36px; min-height: 36px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: all var(--dur-1) var(--ease-out);
  white-space: nowrap; user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:active:not(:disabled) { transform: scale(.98); transition-duration: var(--dur-0); }
.btn:disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }
.btn-block { width: 100%; height: 40px; }

/* Primary — dark with subtle gradient (Stripe-inspired depth) */
.btn-primary {
  background: linear-gradient(180deg, var(--gray-800) 0%, var(--gray-900) 100%);
  color: #fff; border-color: var(--gray-900);
  box-shadow: 0 1px 2px rgba(0,0,0,.2), inset 0 1px 0 rgba(255,255,255,.06);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--gray-700) 0%, var(--gray-800) 100%);
  box-shadow: 0 2px 4px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.08);
  transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) {
  background: var(--gray-950);
  box-shadow: inset 0 1px 3px rgba(0,0,0,.3);
  transform: translateY(0) scale(.98);
}

/* Secondary */
.btn-secondary {
  background: var(--surface); color: var(--ink-2);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--gray-50); border-color: var(--border-3);
  box-shadow: var(--shadow-sm);
}

/* Ghost */
.btn-ghost { background: transparent; color: var(--ink-3); border-color: transparent; box-shadow: none; }
.btn-ghost:hover:not(:disabled) { background: var(--gray-100); color: var(--ink-2); }

/* Danger ghost */
.btn-danger-ghost { background: var(--surface); color: var(--red); border-color: var(--red-border); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--red-bg); border-color: var(--red); }

.file-btn { position: relative; overflow: hidden; }


/* ═══════════════════ FORM ELEMENTS ═══════════════════ */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.field > span { font-size: 12px; font-weight: 500; color: var(--ink-3); }
.field-inline { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
.field-inline input[type="checkbox"] {
  width: 16px; height: 16px; accent-color: var(--accent-600); flex-shrink: 0;
  cursor: pointer;
}
.field-wide { grid-column: 1 / -1; }

input, select, textarea {
  font: inherit; font-size: 13px; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-2); border-radius: var(--radius);
  padding: 8px 10px; height: 36px; width: 100%;
  transition: border-color var(--dur-1), box-shadow var(--dur-1);
}
textarea { height: auto; min-height: 64px; resize: vertical; line-height: 1.5; }
input:hover, select:hover, textarea:hover { border-color: var(--gray-300); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent-500);
  box-shadow: 0 0 0 3px rgba(6,182,212,.12), var(--shadow-xs);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
.inline-select { width: auto; min-width: 120px; height: 32px; font-size: 12px; cursor: pointer; }

.error-msg {
  color: var(--red); background: var(--red-bg);
  border: 1px solid var(--red-border);
  border-radius: var(--radius); padding: 8px 12px; font-size: 13px;
  margin: 4px 0 8px;
  animation: slideDown var(--dur-3) var(--ease) both;
}
.submit-retry {
  margin-inline-start: 8px; padding: 4px 12px; font-size: 13px; font-weight: 600;
  color: #fff; background: var(--red, #dc2626); border: none;
  border-radius: var(--radius); cursor: pointer; vertical-align: middle;
}
.submit-retry:hover { filter: brightness(0.93); }
.hint { color: var(--ink-3); font-size: 12px; text-align: center; margin-top: 12px; }

.banner {
  border-radius: var(--radius); padding: 10px 14px; font-size: 13px;
  margin: 8px 0 12px; line-height: 1.5;
}
.banner-info {
  background: var(--info-bg); color: var(--info);
  border: 1px solid var(--info-border);
}


/* ═══════════════════ CARDS — border-first, shadow on hover ═══════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 20px;
  transition: box-shadow var(--dur-3) var(--ease-out), border-color var(--dur-3);
}
.card-title { font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }


/* ═══════════════════ ANIMATIONS (shared keyframes) ═══════════ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(.96); }
  to   { opacity: 1; transform: none; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer {
  from { background-position: -200% 0; }
  to   { background-position: 200% 0; }
}
@keyframes barFill {
  from { transform: scaleX(0); transform-origin: left; }
  to   { transform: scaleX(1); transform-origin: left; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-4px); }
  40%      { transform: translateX(4px); }
  60%      { transform: translateX(-3px); }
  80%      { transform: translateX(2px); }
}
@keyframes dropIn {
  from { opacity: 0; transform: translateY(-4px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
@keyframes pulseGlow {
  0%, 100% { opacity: .6; }
  50%      { opacity: 1; }
}

/* ── Stagger entrance classes (set by JS IntersectionObserver) ── */
.animate-in { animation: fadeUp var(--dur-4) var(--ease) both; }
.animate-in.delay-1 { animation-delay: 60ms; }
.animate-in.delay-2 { animation-delay: 120ms; }
.animate-in.delay-3 { animation-delay: 180ms; }
.animate-in.delay-4 { animation-delay: 240ms; }

/* ── Skeleton loading shimmer ── */
.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-150) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
  border-radius: var(--radius-sm);
  color: transparent !important;
  pointer-events: none;
  user-select: none;
}
.skeleton * { visibility: hidden; }

/* ── Ripple effect (added by JS on click) ── */
.ripple {
  position: absolute; border-radius: 50%;
  background: rgba(255,255,255,.25);
  transform: scale(0); animation: rippleOut var(--dur-4) var(--ease-out) forwards;
  pointer-events: none;
}
@keyframes rippleOut {
  to { transform: scale(2.5); opacity: 0; }
}


/* ═══════════════ BRAND ═══════════════ */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-lg { justify-content: center; margin-bottom: 28px; }
.brand-logo-img {
  width: 36px; height: 36px; object-fit: contain; flex: none;
  border-radius: 10px;
}
.brand-title {
  font-size: 15px; font-weight: 700; letter-spacing: -.025em; color: var(--ink);
}
.brand-lg .brand-title { font-size: 18px; }
.brand-sub { font-size: 12px; color: var(--ink-3); display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }


/* ═══════════════ ROLE SELECTION — Linear dark mode craft ═══════════════ */
.role-screen {
  display: grid; place-items: center;
  background: var(--gray-950);
  padding: 24px; position: relative; overflow: hidden;
}
/* Mesh gradient — Stripe-inspired ambient glow */
.role-screen::before {
  content: ''; position: fixed; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 60% 50% at 30% 20%, rgba(6,182,212,.07), transparent 70%),
    radial-gradient(ellipse 40% 40% at 70% 80%, rgba(99,102,241,.05), transparent 60%);
  animation: pulseGlow 8s ease-in-out infinite;
}
/* Subtle grid texture overlay (Linear style) */
.role-screen::after {
  content: ''; position: fixed; inset: 0; pointer-events: none;
  opacity: .03;
  background-image: linear-gradient(rgba(255,255,255,.1) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,.1) 1px, transparent 1px);
  background-size: 48px 48px;
}

.role-wrapper {
  width: 100%; max-width: 400px;
  display: flex; flex-direction: column; align-items: center;
  position: relative; z-index: 1;
  animation: fadeUp var(--dur-5) var(--ease) both;
}
.role-brand { text-align: center; color: white; margin-bottom: 48px; }
.role-logo-img {
  width: 80px; height: 80px; margin-bottom: 20px;
  border-radius: 22px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 8px 32px rgba(0,0,0,.4);
}
.role-brand .brand-title {
  font-size: 28px; font-weight: 800; color: white;
  letter-spacing: -.04em;
  background: linear-gradient(180deg, #fff 40%, rgba(255,255,255,.7));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.role-tagline {
  color: var(--gray-400); margin: 8px 0 0;
  font-size: 15px; font-weight: 400; letter-spacing: -.01em;
}

.role-question {
  color: var(--gray-500); font-size: 11px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; margin: 0 0 12px;
}
.role-cards { display: flex; flex-direction: column; gap: 8px; width: 100%; }

.role-card {
  display: flex; align-items: center; gap: 14px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  cursor: pointer; text-align: left; width: 100%;
  transition: all var(--dur-2) var(--ease-out);
  animation: fadeUp var(--dur-5) var(--ease) both;
}
.role-card:nth-child(1) { animation-delay: 120ms; }
.role-card:nth-child(2) { animation-delay: 200ms; }
.role-card:hover, .role-card:focus-visible {
  background: rgba(255,255,255,.07);
  border-color: rgba(255,255,255,.14);
  box-shadow: 0 4px 24px rgba(0,0,0,.2), inset 0 1px 0 rgba(255,255,255,.04);
  transform: translateY(-1px);
  outline: none;
}
.role-card:active {
  background: rgba(255,255,255,.05);
  transform: translateY(0) scale(.99);
  transition-duration: var(--dur-0);
}

.role-shape {
  width: 48px; height: 48px; border-radius: var(--radius-lg); flex-shrink: 0;
  display: grid; place-items: center;
}
.role-shape--vet {
  background: linear-gradient(135deg, var(--accent-600), var(--accent-800));
  box-shadow: 0 2px 8px rgba(8,145,178,.3);
}
.role-shape--owner {
  background: var(--gray-800);
  border: 1px solid rgba(255,255,255,.06);
}
.role-icon { width: 32px; height: 32px; }

.role-label { flex: 1; }
.role-title { display: block; color: white; font-size: 14px; font-weight: 600; }
.role-sub   { display: block; color: var(--gray-400); font-size: 12px; margin-top: 2px; }
.role-arrow {
  color: var(--gray-600); font-size: 20px; font-weight: 300;
  transition: all var(--dur-2) var(--ease-out);
}
.role-card:hover .role-arrow { color: var(--gray-400); transform: translateX(3px); }
[dir="rtl"] .role-card:hover .role-arrow { transform: translateX(-3px); }

.role-footer {
  color: var(--gray-600); font-size: 12px; margin-top: 40px;
  letter-spacing: .01em;
}


/* ═══════════════ PET OWNER INFO ═══════════════ */
.owner-screen {
  display: grid; place-items: center; padding: 24px;
  background: var(--bg);
}
.owner-wrapper {
  width: 100%; max-width: 440px;
  animation: fadeUp var(--dur-4) var(--ease) both;
}
.owner-back {
  background: none; border: none; color: var(--accent-700); font: inherit;
  font-size: 13px; font-weight: 500; cursor: pointer; padding: 0 0 20px;
  display: inline-flex; align-items: center; gap: 4px;
  transition: color var(--dur-1), gap var(--dur-2);
}
.owner-back:hover { color: var(--accent-600); gap: 6px; }
.owner-icon-wrap { display: flex; justify-content: center; margin-bottom: 24px; }
.owner-big-icon { width: 80px; height: 80px; }
.owner-title { text-align: center; font-size: 22px; margin-bottom: 8px; color: var(--ink); }
.owner-body { color: var(--ink-2); line-height: 1.7; margin-bottom: 28px; font-size: 14px; }
.owner-steps { display: flex; flex-direction: column; gap: 8px; }
.owner-step {
  display: flex; align-items: flex-start; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px;
  font-size: 13px; color: var(--ink-2); line-height: 1.5;
  transition: border-color var(--dur-2), box-shadow var(--dur-2);
  animation: fadeUp var(--dur-4) var(--ease) both;
}
.owner-step:nth-child(1) { animation-delay: 80ms; }
.owner-step:nth-child(2) { animation-delay: 140ms; }
.owner-step:nth-child(3) { animation-delay: 200ms; }
.owner-step:hover { border-color: var(--border-2); box-shadow: var(--shadow-xs); }
.owner-step-num {
  width: 28px; height: 28px; border-radius: var(--radius);
  background: var(--gray-900); color: white;
  display: grid; place-items: center;
  font-weight: 700; font-size: 12px; flex-shrink: 0;
  font-family: var(--font-mono);
}


/* ═══════════════ LOGIN ═══════════════ */
.login-screen {
  display: grid; place-items: center; padding: 24px;
  background: var(--bg);
}
.login-card {
  width: 100%; max-width: 380px;
  animation: fadeUp var(--dur-4) var(--ease) both;
  box-shadow: var(--shadow-sm);
}
.login-form h2 { font-size: 16px; margin-bottom: 20px; }
.lang-link {
  display: block; margin: 20px auto 0; background: none; border: none;
  color: var(--accent-700); font: inherit; font-size: 13px;
  font-weight: 500; cursor: pointer; padding: 8px;
  transition: color var(--dur-1);
}
.lang-link:hover { color: var(--accent-600); }
.auth-switch {
  text-align: center; margin: 18px 0 0; font-size: 13px; color: var(--ink-3, #64748b);
  border-top: 1px solid var(--line, #e2e8f0); padding-top: 16px;
}
.auth-switch .lang-link { display: inline; margin: 0 0 0 4px; padding: 0; }


/* ═══════════════ APP SHELL ═══════════════ */
.app-shell { display: flex; flex-direction: column; min-height: 100dvh; }

/* Header — Raycast-style frosted glass */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: rgba(255,255,255,.72);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  padding: 0 20px; height: var(--header-h);
  padding-top: env(safe-area-inset-top, 0);
  transition: box-shadow var(--dur-3) var(--ease-out),
              background var(--dur-3);
}
.app-header.scrolled {
  box-shadow: var(--shadow-sm);
  background: rgba(255,255,255,.88);
}
.header-actions { display: flex; align-items: center; gap: 2px; }
.user-name {
  font-weight: 500; color: var(--ink-3); font-size: 13px;
  max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding-right: 4px;
}

/* ──── Tab bar ──── */
.tabbar {
  position: sticky; top: var(--header-h); z-index: 10;
  display: flex;
  background: rgba(255,255,255,.88);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.tab {
  flex: 1; background: none; border: none; cursor: pointer; font: inherit;
  color: var(--gray-400); font-size: 12px; font-weight: 500;
  padding: 0; height: var(--tabbar-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-bottom: 2px solid transparent;
  transition: color var(--dur-1), border-color var(--dur-2);
  position: relative;
}
.tab .tab-ic { width: 18px; height: 18px; }
.tab span:last-child { font-size: 10px; letter-spacing: .02em; }
.tab:hover { color: var(--gray-600); }
.tab.active {
  color: var(--gray-900); border-bottom-color: var(--gray-900);
  font-weight: 600;
}

/* ──── Main content ──── */
.app-main {
  flex: 1; width: 100%; max-width: var(--content-max); margin: 0 auto;
  padding: 24px 20px 56px;
}
.tab-panel { display: none; }
.tab-panel.active {
  display: block;
  animation: fadeUp var(--dur-3) var(--ease) both;
}

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.panel-head-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }


/* ═══════════════ CAPTURE ═══════════════ */
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }

.capture-stage {
  position: relative; width: 100%; aspect-ratio: 4 / 3;
  background: var(--gray-950); border-radius: var(--radius-lg); overflow: hidden;
  margin: 8px 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.05);
}
.capture-media { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.capture-placeholder {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; color: var(--gray-500);
}
.capture-placeholder svg { width: 40px; height: 40px; opacity: .35; }
.capture-placeholder span { font-size: 12px; }
.capture-controls { display: flex; flex-wrap: wrap; gap: 6px; }
.capture-controls .btn, .capture-controls .file-btn { flex: 1 1 auto; }

.meta-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.meta-form .field-wide, .meta-form .btn-block, .meta-form .error-msg,
.meta-form .capture-more-toggle, .meta-form .capture-more,
.meta-form .capture-completeness { grid-column: 1 / -1; }
.capture-more-toggle {
  background: none; border: 1px dashed var(--border-2, #cbd5e1); color: var(--accent-700, #0f766e);
  border-radius: var(--radius); padding: 8px 12px; font-size: 13px; font-weight: 600;
  cursor: pointer; margin: 6px 0 4px; width: 100%; text-align: center;
}
.capture-more-toggle:hover { background: var(--accent-50, #f0fdfa); }
.capture-count {
  width: 100%; font-size: 13px; font-weight: 600; margin-bottom: 6px;
  padding: 6px 10px; border-radius: var(--radius);
  color: #92400e; background: #fffbeb; border: 1px solid #fde68a;
}
.capture-count.done { color: #166534; background: #f0fdf4; border-color: #bbf7d0; }
@media (prefers-color-scheme: dark) {
  .capture-count { color: #fcd34d; background: rgba(120,53,15,.22); border-color: #78350f; }
  .capture-count.done { color: #86efac; background: rgba(22,101,52,.22); border-color: #166534; }
}
.capture-more { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.capture-more .field-wide { grid-column: 1 / -1; }
@media (max-width: 640px) { .capture-more { grid-template-columns: 1fr; } }

.capture-completeness {
  margin: 0 0 8px; padding: 8px 12px; border-radius: var(--radius);
  font-size: 12px; font-weight: 500; color: var(--ink-3); font-style: italic;
  transition: all var(--dur-3) var(--ease-out);
  border: 1px solid transparent;
}
.capture-completeness.bad {
  background: var(--red-bg); color: var(--red); font-style: normal; font-weight: 600;
  border-color: var(--red-border);
}
.capture-completeness.good {
  background: var(--green-bg); color: var(--green); font-style: normal; font-weight: 500;
  border-color: var(--green-border);
}


/* ═══════════════ RESULT / VERDICT ═══════════════ */
.back-btn { margin-bottom: 8px; padding-left: 4px; }

.verdict-card {
  display: flex; align-items: center; gap: 14px;
  border-radius: var(--radius-xl); padding: 16px 18px;
  margin-bottom: 16px; border: 1px solid transparent;
  animation: scaleIn var(--dur-3) var(--ease) both;
}
.verdict-icon {
  width: 44px; height: 44px; flex: none; border-radius: var(--radius-lg);
  display: grid; place-items: center; font-size: 18px; font-weight: 700; color: #fff;
  box-shadow: var(--shadow-sm);
}
.verdict-headline { font-weight: 600; font-size: 15px; margin: 0; }
.verdict-sub { margin: 2px 0 0; font-size: 12px; color: var(--ink-3); }

.verdict-confident { background: var(--green-bg); border-color: var(--green-border); }
.verdict-confident .verdict-icon { background: linear-gradient(135deg, #16a34a, #15803d); }
.verdict-confident .verdict-headline { color: #14532d; }

.verdict-moderate, .verdict-uncertain { background: var(--amber-bg); border-color: var(--amber-border); }
.verdict-moderate .verdict-icon,
.verdict-uncertain .verdict-icon { background: linear-gradient(135deg, #d97706, #b45309); }
.verdict-moderate .verdict-headline,
.verdict-uncertain .verdict-headline { color: #78350f; }

.verdict-close_call { background: var(--orange-bg); border-color: var(--orange-border); }
.verdict-close_call .verdict-icon { background: linear-gradient(135deg, #ea580c, #c2410c); }
.verdict-close_call .verdict-headline { color: #7c2d12; }

.verdict-ood { background: var(--red-bg); border-color: var(--red-border); }
.verdict-ood .verdict-icon { background: linear-gradient(135deg, #dc2626, #b91c1c); }
.verdict-ood .verdict-headline { color: #7f1d1d; }

.result-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; align-items: start; }
.result-images { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.result-figure { margin: 0; }
.result-figure figcaption {
  font-size: 11px; font-weight: 600; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px;
}
.result-figure img {
  width: 100%; border-radius: var(--radius-lg); background: var(--gray-100);
  aspect-ratio: 1; object-fit: cover; display: block;
  border: 1px solid var(--border);
  transition: transform var(--dur-3) var(--ease-out);
}
.result-figure img:hover { transform: scale(1.02); }

.top-result {
  display: flex; flex-direction: column; gap: 2px; margin-bottom: 16px;
  padding-bottom: 14px; border-bottom: 1px solid var(--border);
}
.top-label {
  font-size: 20px; font-weight: 700; color: var(--ink); letter-spacing: -.025em;
}
.top-confidence {
  font-family: var(--font-mono); font-size: 14px;
  color: var(--accent-700); font-weight: 600;
  letter-spacing: -.01em;
}

/* Probability bars */
.prob-bars { display: flex; flex-direction: column; gap: 8px; }
.prob-row { display: grid; grid-template-columns: 1fr; gap: 3px; }
.prob-row-head { display: flex; justify-content: space-between; font-size: 12px; }
.prob-row-head .name { color: var(--ink-2); transition: color var(--dur-1); }
.prob-row-head .pct {
  font-family: var(--font-mono); font-size: 12px;
  font-variant-numeric: tabular-nums; color: var(--ink-3); font-weight: 500;
}
.prob-track {
  height: 6px; background: var(--gray-100); border-radius: 3px; overflow: hidden;
  position: relative;
}
.prob-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent-400), var(--accent-600));
  transition: width .6s var(--ease-out);
}
.prob-fill.animate { animation: barFill .7s var(--ease) both; }
.prob-row.is-top .prob-fill {
  background: linear-gradient(90deg, var(--gray-700), var(--gray-900));
}
.prob-row.is-top .prob-row-head .name { font-weight: 600; color: var(--ink); }
.prob-row.is-top .prob-row-head .pct { font-weight: 700; color: var(--ink); }


/* ═══════════════ FEEDBACK ═══════════════ */
.feedback-card { margin-top: 16px; }
.quick-confirm { width: 100%; margin: 4px 0 8px; }
.fb-filter { width: 100%; padding: 6px 10px; margin: 4px 0; border: 1px solid var(--border-2); border-radius: var(--radius); font: inherit; font-size: 13px; background: var(--surface); color: var(--ink); }
.fb-filter:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-100); }
.feedback-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 6px 0; max-height: 340px; overflow-y: auto; }
.feedback-buttons .fb-btn {
  text-align: center; padding: 8px 6px;
  border: 1px solid var(--border-2);
  background: var(--surface); border-radius: var(--radius); cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 500; color: var(--ink-2);
  min-height: 38px;
  transition: all var(--dur-1) var(--ease-out);
  position: relative; overflow: hidden;
}
.feedback-buttons .fb-btn:hover {
  background: var(--gray-50); border-color: var(--gray-300);
  transform: translateY(-1px); box-shadow: var(--shadow-xs);
}
.feedback-buttons .fb-btn.selected {
  background: var(--gray-900); color: #fff; border-color: var(--gray-900);
  box-shadow: var(--shadow-sm);
  transform: scale(1.02);
}
.feedback-buttons .fb-btn:active { transform: scale(.97); transition-duration: var(--dur-0); }

.feedback-status {
  border-radius: var(--radius); padding: 10px 14px; font-size: 13px; font-weight: 500;
  animation: scaleIn var(--dur-3) var(--ease) both;
}
.feedback-status.agreed { background: var(--green-bg); color: #14532d; border: 1px solid var(--green-border); }
.feedback-status.corrected { background: var(--amber-bg); color: #78350f; border: 1px solid var(--amber-border); }
.feedback-status.discarded { background: var(--gray-100); color: var(--ink-3); }

.annotation-stage {
  position: relative;
  display: block;
}
.annotation-stage img {
  display: block;
}
.annotation-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}
.lesion-annotation-editor {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.annotation-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.annotation-toolbar .subhead {
  margin-bottom: 2px;
}
.annotation-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.annotation-actions .btn {
  height: 32px;
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}
.annotation-actions .btn.active {
  color: var(--accent-700);
  border-color: var(--accent-500);
  background: var(--accent-50);
}
.raw-lab-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, .65fr);
  gap: 18px;
  align-items: start;
}
.raw-stats-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.raw-project-board {
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.raw-project-board-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.raw-project-board-head strong,
.raw-project-board-head span {
  display: block;
}
.raw-project-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 160px auto;
  gap: 8px;
  align-items: center;
  min-width: min(620px, 100%);
}
.raw-project-controls input,
.raw-project-controls select {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 12px;
}
.raw-project-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(240px, 1fr));
  gap: 12px;
}
.raw-project-card {
  position: relative;
  min-height: 176px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.raw-project-card:hover,
.raw-project-card.active {
  border-color: var(--accent-500);
  box-shadow: 0 10px 24px rgba(15, 23, 42, .08);
}
.raw-project-card.active {
  background: var(--accent-50);
}
.raw-project-menu {
  position: absolute;
  top: 8px;
  right: 10px;
  color: var(--accent-700);
  font-weight: 800;
}
.raw-project-card-head {
  padding-right: 24px;
}
.raw-project-card-head strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}
.raw-project-kind {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}
.raw-project-count {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 800;
}
.raw-project-meter {
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface);
}
.raw-project-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent-500);
}
.raw-project-desc {
  min-height: 34px;
  margin: 0;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.35;
}
.raw-project-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.raw-project-labels span {
  max-width: 100%;
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 11px;
  white-space: nowrap;
}
.raw-project-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  color: var(--muted);
  font-size: 12px;
}
.raw-project-card.body .raw-project-meter i { background: var(--green); }
.raw-project-card.quality .raw-project-meter i { background: var(--amber); }
.raw-project-card.class .raw-project-meter i { background: var(--accent-600); }
.raw-project-card.general .raw-project-meter i { background: var(--gray-500); }
.raw-project-empty {
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}
.raw-project-image-browser {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.raw-project-image-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.raw-project-image-head strong,
.raw-project-image-head span {
  display: block;
}
.raw-project-image-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
}
.raw-image-tile {
  min-height: 150px;
  display: grid;
  grid-template-rows: 90px auto auto;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.raw-image-tile:hover,
.raw-image-tile.active {
  border-color: var(--accent-500);
  background: var(--accent-50);
}
.raw-image-tile.done {
  border-color: rgba(22, 163, 74, .35);
}
.raw-image-tile img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface);
}
.raw-image-tile strong,
.raw-image-tile span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.raw-image-tile strong {
  font-size: 12px;
}
.raw-image-tile span {
  color: var(--muted);
  font-size: 11px;
}
.raw-select-project-state {
  display: grid;
  place-items: center;
  min-height: 220px;
  margin-bottom: 16px;
  padding: 24px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}
.raw-select-project-state strong {
  display: block;
  color: var(--ink);
  font-size: 18px;
}
.raw-select-project-state span {
  display: block;
  margin-top: 6px;
  font-size: 13px;
}
.raw-stat {
  position: relative;
  min-height: 76px;
  padding: 14px 14px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}
.raw-stat::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: var(--accent-500);
  opacity: .75;
}
.raw-stat strong {
  display: block;
  font-size: 24px;
  line-height: 1;
  color: var(--ink);
  font-family: var(--mono);
}
.raw-stat span {
  display: block;
  margin-top: 4px;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 600;
}
.raw-stat-meter {
  height: 5px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}
.raw-stat-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-500), var(--green));
}
.raw-image-card {
  padding: 14px;
  position: sticky;
  top: 14px;
}
.raw-lab-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.raw-toolbar-controls {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.field-compact {
  gap: 4px;
}
.field-compact span {
  font-size: 11px;
}
.raw-toggle {
  min-height: 32px;
}
.raw-queue-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 12px;
}
.raw-taskbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.raw-task-main {
  min-width: 0;
  flex: 1;
}
.raw-task-main strong,
.raw-task-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.raw-task-main strong {
  color: var(--ink);
  font-size: 13px;
}
.raw-task-progress {
  height: 5px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}
.raw-task-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-500), var(--green));
}
.raw-task-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.raw-task-actions .btn {
  height: 32px;
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}
.raw-session-metrics {
  display: grid;
  grid-template-columns: repeat(7, minmax(82px, 1fr));
  gap: 8px;
  margin: 0 0 10px;
}
.raw-session-metric {
  min-height: 52px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.raw-session-metric strong,
.raw-session-metric span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.raw-session-metric strong {
  color: var(--ink);
  font-size: 16px;
  line-height: 1.1;
}
.raw-session-metric span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}
.raw-task-actions .btn.active {
  border-color: var(--accent-500);
  background: var(--accent-50);
  color: var(--accent-800);
}
.raw-thumb {
  position: relative;
  width: 72px;
  height: 58px;
  flex: 0 0 72px;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-2);
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(15, 23, 42, .04);
}
.raw-thumb.active {
  border-color: var(--accent-500);
  box-shadow: 0 0 0 3px var(--accent-100);
}
.raw-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.raw-thumb-done {
  position: absolute;
  right: 3px;
  top: 3px;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--green);
  color: white;
  font-size: 11px;
  font-weight: 800;
}
.raw-workbench {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
}
.raw-queue-panel {
  min-height: 520px;
  max-height: 72vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.raw-queue-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--border);
}
.raw-queue-panel-head strong {
  font-size: 12px;
  color: var(--ink);
}
.raw-queue-panel-head span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
}
.raw-queue-panel-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
}
.raw-queue-panel-controls input,
.raw-queue-panel-controls select {
  min-height: 32px;
  font-size: 12px;
}
.raw-queue-list {
  min-height: 0;
  overflow: auto;
  padding: 6px;
}
.raw-queue-empty {
  padding: 12px;
  color: var(--ink-3);
  font-size: 12px;
}
.raw-queue-item {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.raw-queue-item:hover {
  background: var(--surface-2);
}
.raw-queue-item.active {
  border-color: var(--accent-400);
  background: var(--accent-50);
}
.raw-queue-item-thumb {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-2);
}
.raw-queue-item-main {
  min-width: 0;
}
.raw-queue-item-main strong,
.raw-queue-item-main em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.raw-queue-item-main strong {
  color: var(--ink);
  font-size: 12px;
}
.raw-queue-item-main em {
  margin-top: 2px;
  color: var(--ink-3);
  font-size: 10px;
  font-style: normal;
}
.raw-queue-item-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  color: var(--ink-3);
  background: var(--surface-2);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}
.raw-queue-item.done .raw-queue-item-badge {
  color: #14532d;
  background: var(--green-bg);
}
.raw-queue-item.open .raw-queue-item-badge {
  color: #92400e;
  background: var(--amber-bg);
}
.raw-tool-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
.raw-tool {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.raw-tool:hover {
  border-color: var(--accent-300);
  color: var(--accent-700);
}
.raw-tool.active {
  border-color: var(--accent-500);
  background: var(--accent-50);
  color: var(--accent-800);
  box-shadow: 0 0 0 3px var(--accent-100);
}
.raw-tool.danger:hover {
  border-color: var(--red-border);
  background: var(--red-bg);
  color: var(--red);
}
.raw-stage {
  position: relative;
  min-height: 520px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #172033;
  border-radius: 8px;
  background:
    radial-gradient(circle at 20px 20px, rgba(255,255,255,.05) 1px, transparent 1px),
    linear-gradient(135deg, #101827, #1f2937);
  background-size: 24px 24px, auto;
}
.raw-stage.grid-on::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.08) 1px, transparent 1px);
  background-size: 64px 64px;
}
.raw-stage img {
  display: block;
  max-width: 100%;
  max-height: 72vh;
  object-fit: contain;
  position: relative;
  z-index: 1;
  transform: translate(var(--raw-pan-x, 0px), var(--raw-pan-y, 0px)) scale(var(--raw-zoom, 1));
  transform-origin: center center;
}
.raw-stage .annotation-canvas {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) translate(var(--raw-pan-x, 0px), var(--raw-pan-y, 0px));
  right: auto;
  bottom: auto;
  z-index: 2;
  cursor: default;
}
.raw-stage.drawing .annotation-canvas {
  cursor: crosshair;
}
.raw-stage.panning .annotation-canvas,
.raw-stage.space-pan .annotation-canvas {
  cursor: grabbing;
}
.raw-stage-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, .78);
  color: white;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid rgba(255,255,255,.18);
  backdrop-filter: blur(8px);
}
.raw-zoom-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 30px;
  padding: 3px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  background: rgba(15, 23, 42, .78);
  color: white;
  backdrop-filter: blur(8px);
}
.raw-zoom-controls button {
  min-width: 26px;
  height: 24px;
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  background: rgba(255,255,255,.1);
  color: white;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.raw-zoom-controls button:hover {
  background: rgba(255,255,255,.2);
}
.raw-zoom-controls span {
  min-width: 42px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
}
.raw-empty-state {
  max-width: 340px;
  padding: 18px;
  text-align: center;
  color: white;
  border: 1px dashed rgba(255,255,255,.24);
  border-radius: 8px;
  background: rgba(15, 23, 42, .58);
}
.raw-empty-state strong {
  display: block;
  font-size: 18px;
}
.raw-empty-state span {
  display: block;
  margin-top: 6px;
  color: rgba(255,255,255,.72);
  font-size: 13px;
}
.raw-actions {
  margin-top: 10px;
  justify-content: center;
}
.raw-actions .btn {
  min-height: 36px;
}
.raw-shortcuts {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.raw-shortcuts span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}
.raw-image-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}
.raw-layer-panel {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}
.raw-layer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}
.raw-layer-head strong {
  color: var(--ink);
  font-size: 12px;
}
.raw-layer-head span {
  min-width: 26px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
}
.raw-object-finder {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 150px;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.raw-object-finder input,
.raw-object-finder select {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
}
.raw-object-filter-chips {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.raw-object-chip {
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
  cursor: pointer;
}
.raw-object-chip:hover,
.raw-object-chip.active {
  border-color: var(--accent-500);
  background: var(--accent-50);
  color: var(--accent-800);
}
.raw-layer-table-wrap {
  max-height: 220px;
  overflow: auto;
}
.raw-layer-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.raw-layer-table th,
.raw-layer-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.raw-layer-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--ink-3);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.raw-layer-table tbody tr {
  cursor: pointer;
}
.raw-layer-table tbody tr:hover,
.raw-layer-table tbody tr.active {
  background: var(--accent-50);
}
.raw-layer-object {
  display: flex;
  align-items: center;
  gap: 8px;
}
.raw-layer-state {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.raw-layer-toggle {
  min-height: 24px;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}
.raw-layer-toggle.off,
.raw-layer-toggle.on {
  border-color: var(--amber-border);
  background: var(--amber-bg);
  color: #92400e;
}
.raw-layer-empty-row td {
  color: var(--ink-3);
  text-align: center;
}
.raw-fact {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.raw-fact b {
  display: block;
  color: var(--ink-3);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.raw-fact em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-style: normal;
  font-size: 12px;
  margin-top: 2px;
}
.raw-form-card .annotation-assist {
  margin: 10px 0;
}
.raw-form-card {
  position: sticky;
  top: 16px;
}
.raw-form-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.raw-form-title .subhead {
  margin-bottom: 2px;
}
.raw-workflow-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin: 10px 0 12px;
}
.raw-workflow-strip span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
}
.raw-focus-hint {
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid var(--accent-200);
  border-radius: 8px;
  background: var(--accent-50);
}
.raw-focus-hint strong,
.raw-focus-hint span {
  display: block;
}
.raw-focus-hint strong {
  color: var(--accent-800);
  font-size: 13px;
}
.raw-focus-hint span {
  margin-top: 3px;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.35;
}
.raw-advanced-details {
  margin: 10px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.raw-advanced-details summary {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.raw-advanced-details .raw-activity-panel,
.raw-advanced-details .raw-history-panel {
  border-width: 1px 0 0;
  border-radius: 0;
  margin: 0;
}
.raw-professional-section {
  margin: 10px 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.raw-professional-section .field {
  margin: 0 0 8px;
}
.raw-body-atlas {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.raw-body-card {
  min-height: 78px;
  display: grid;
  grid-template-rows: 38px auto;
  gap: 5px;
  align-items: center;
  justify-items: center;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink-2);
  cursor: pointer;
}
.raw-body-card:hover,
.raw-body-card.active {
  border-color: var(--accent-500);
  background: var(--accent-50);
  color: var(--accent-800);
}
.raw-body-card-image {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(6,182,212,.18), rgba(22,163,74,.16));
  color: var(--ink);
  font-size: 10px;
  font-weight: 800;
}
.raw-body-card strong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
.raw-feature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.raw-feature-chip {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12px;
  cursor: pointer;
}
.raw-feature-chip input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-600);
}
.raw-feature-chip:has(input:checked) {
  border-color: var(--accent-500);
  background: var(--accent-50);
  color: var(--accent-800);
}
.raw-class-sections {
  display: grid;
  gap: 8px;
  margin: 8px 0 10px;
}
.raw-class-group {
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
.raw-class-group > strong {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}
.raw-class-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.raw-class-chip {
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
  cursor: pointer;
}
.raw-class-chip:hover,
.raw-class-chip.active {
  border-color: var(--accent-500);
  background: var(--accent-50);
  color: var(--accent-800);
}
.raw-context-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 10px 0;
}
.raw-context-pill {
  min-height: 38px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
.raw-context-pill b,
.raw-context-pill em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.raw-context-pill b {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}
.raw-context-pill em {
  margin-top: 3px;
  color: var(--ink);
  font-size: 12px;
  font-style: normal;
}
.raw-form-count {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: var(--accent-700);
  background: var(--accent-50);
  border: 1px solid var(--accent-200);
  font-family: var(--mono);
  font-weight: 800;
}
.raw-label-palette {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin: 8px 0 12px;
  max-height: 236px;
  overflow: auto;
  padding-right: 2px;
}
.raw-label-chip {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-2);
  text-align: left;
  cursor: pointer;
}
.raw-label-chip:hover {
  border-color: var(--accent-300);
}
.raw-label-chip.active {
  border-color: var(--accent-500);
  background: var(--accent-50);
  color: var(--accent-800);
}
.raw-label-key {
  display: grid;
  place-items: center;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
}
.raw-label-chip.active .raw-label-key {
  background: var(--accent-600);
  color: white;
}
.raw-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 12px 0 8px;
}
.raw-section-head strong {
  font-size: 13px;
  color: var(--ink);
}
.raw-status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
}
.raw-status-pill.ok {
  color: #14532d;
  background: var(--green-bg);
  border-color: var(--green-border);
}
.raw-status-pill.todo {
  color: #92400e;
  background: var(--amber-bg);
  border-color: var(--amber-border);
}
.raw-ai-panel {
  margin: 10px 0 12px;
  padding: 12px;
  border: 1px solid var(--accent-200);
  border-radius: 8px;
  background: var(--accent-50);
}
.raw-ai-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
}
.raw-ai-ranks {
  display: grid;
  gap: 7px;
}
.raw-ai-rank {
  position: relative;
  min-height: 28px;
  overflow: hidden;
  padding: 5px 8px;
  border: 1px solid var(--accent-200);
  border-radius: 7px;
  background: var(--surface);
  font-size: 11px;
  font-weight: 600;
}
.raw-ai-rank span {
  position: relative;
  z-index: 1;
}
.raw-ai-rank i {
  position: absolute;
  inset: 0 auto 0 0;
  display: block;
  background: linear-gradient(90deg, rgba(6, 182, 212, .22), rgba(34, 197, 94, .16));
}
.raw-ai-quality {
  margin: 8px 0 0;
  color: var(--ink-3);
  font-size: 12px;
}
.raw-ai-warning {
  margin: 8px 0 0;
  font-size: 12px;
  color: #78350f;
}
.raw-box-ledger {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.raw-box-empty {
  padding: 10px 12px;
  border: 1px dashed var(--border-2);
  border-radius: 8px;
  color: var(--ink-3);
  font-size: 12px;
  background: var(--surface-2);
}
.raw-box-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}
.raw-box-row.active {
  border-color: var(--amber);
  background: var(--amber-bg);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .12);
}
.raw-box-main {
  min-width: 0;
}
.raw-box-main strong,
.raw-box-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.raw-box-main strong {
  font-size: 12px;
}
.raw-box-main span {
  margin-top: 2px;
  color: var(--ink-3);
  font-size: 11px;
}
.raw-box-delete {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-2);
  border-radius: 6px;
  min-height: 28px;
  padding: 0 8px;
  font-size: 11px;
  cursor: pointer;
}
.raw-box-delete:hover {
  border-color: var(--red-border);
  color: var(--red);
  background: var(--red-bg);
}
.raw-object-inspector {
  margin: 10px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  overflow: hidden;
}
.raw-inspector-empty {
  padding: 12px;
}
.raw-inspector-empty strong,
.raw-inspector-empty span {
  display: block;
}
.raw-inspector-empty strong {
  color: var(--ink);
  font-size: 12px;
}
.raw-inspector-empty span {
  margin-top: 3px;
  color: var(--ink-3);
  font-size: 12px;
}
.raw-inspector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.raw-inspector-head strong {
  font-size: 12px;
  color: var(--ink);
}
.raw-object-color {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.45);
}
.raw-inspector-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
}
.raw-inspector-grid .field-wide {
  grid-column: 1 / -1;
}
.raw-inspector-metric {
  min-height: 48px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.raw-inspector-metric span {
  display: block;
  color: var(--ink-3);
  font-size: 10px;
  font-weight: 800;
}
.raw-inspector-metric strong {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
}
.raw-inspector-actions {
  display: flex;
  gap: 6px;
  padding: 0 10px 10px;
}
.raw-inspector-actions .btn {
  flex: 1;
  height: 32px;
  min-height: 32px;
  font-size: 12px;
}
.raw-qa-panel {
  margin: 10px 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
.raw-qa-panel .raw-section-head {
  margin: 0 0 8px;
}
.raw-qa-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.raw-qa-grid label {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
  cursor: pointer;
}
.raw-qa-grid label:has(input:checked) {
  border-color: var(--accent-400);
  background: var(--accent-50);
  color: var(--accent-800);
}
.raw-activity-panel {
  margin: 10px 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.raw-activity-panel .raw-section-head {
  margin: 0 0 8px;
}
.raw-activity-list {
  display: grid;
  gap: 6px;
}
.raw-activity-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12px;
}
.raw-activity-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 999px;
  background: var(--gray-400);
}
.raw-activity-item.ok .raw-activity-dot { background: var(--green); }
.raw-activity-item.warn .raw-activity-dot { background: var(--amber); }
.raw-activity-item.todo .raw-activity-dot { background: var(--gray-400); }
.raw-history-panel {
  margin: 10px 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.raw-history-panel .raw-section-head {
  margin: 0 0 8px;
}
.raw-history-list {
  display: grid;
  gap: 6px;
  max-height: 210px;
  overflow: auto;
}
.raw-history-item,
.raw-history-empty {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 30px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12px;
}
.raw-history-empty {
  display: block;
  color: var(--muted);
}
.raw-history-time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
@media (max-width: 920px) {
  .raw-lab-grid { grid-template-columns: 1fr; }
  .raw-workbench { grid-template-columns: 1fr; }
  .raw-project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .raw-project-controls { grid-template-columns: 1fr; }
  .raw-project-image-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .raw-queue-panel {
    min-height: 220px;
    max-height: 280px;
  }
  .raw-tool-rail {
    flex-direction: row;
    justify-content: flex-start;
  }
  .raw-stats-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .raw-session-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .raw-image-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .raw-workflow-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .raw-form-card { position: static; }
  .raw-stage { min-height: 420px; }
  .raw-workbench { grid-template-columns: 1fr; }
  .raw-tool-rail { flex-direction: row; justify-content: center; }
  .raw-taskbar { align-items: flex-start; flex-direction: column; }
  .raw-task-actions { justify-content: flex-start; }
}
@media (max-width: 560px) {
  .raw-lab-toolbar { align-items: flex-start; flex-direction: column; }
  .raw-toolbar-controls { justify-content: flex-start; width: 100%; }
  .raw-stats-bar,
  .raw-session-metrics,
  .raw-image-facts { grid-template-columns: 1fr; }
  .raw-project-grid { grid-template-columns: 1fr; }
  .raw-project-board-head,
  .raw-project-image-head { flex-direction: column; align-items: stretch; }
  .raw-project-image-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .raw-workflow-strip,
  .raw-body-atlas,
  .raw-feature-grid,
  .raw-context-summary,
  .raw-object-finder { grid-template-columns: 1fr; }
  .raw-qa-grid { grid-template-columns: 1fr; }
}

.second-review-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px 0 0; }
.second-review-actions .btn { height: 32px; min-height: 32px; padding: 0 10px; font-size: 12px; }
.second-review-actions .small { flex: 1 1 140px; }

.field-consent { flex-direction: row; align-items: center; gap: 8px; margin-top: 4px; }
.field-consent input[type="checkbox"] { width: auto; margin: 0; }
.field-consent span { font-weight: normal; }
.case-data-usage { margin-top: 8px; }
.case-data-usage .field-inline { justify-content: flex-start; gap: 8px; flex-wrap: wrap; }
.case-metadata-editor { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.case-metadata-editor .subhead { margin-bottom: 8px; }
.case-metadata-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.case-metadata-actions .btn { height: 32px; min-height: 32px; padding: 0 10px; font-size: 12px; }
.feedback-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.feedback-actions .btn { flex: 1 1 auto; }

.feedback-details { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; margin: 6px 0; }
.feedback-details .field-wide { grid-column: 1 / -1; }
.feedback-details textarea { min-height: 64px; resize: vertical; }

.annotation-assist {
  margin-top: 4px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
.annotation-assist-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.annotation-assist-head strong { font-size: 13px; color: var(--ink); }
.annotation-assist-score {
  min-width: 40px;
  text-align: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-2);
}
.annotation-assist-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}
.annotation-assist-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--ink-2);
}
.annotation-assist-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 4px;
  background: var(--gray-300);
}
.annotation-assist-item.ok .annotation-assist-dot { background: var(--green); }
.annotation-assist-item.warn .annotation-assist-dot { background: var(--amber); }
.annotation-assist-item.todo .annotation-assist-dot { background: var(--accent-500); }
.annotation-assist-item.warn { color: #78350f; }


/* ═══════════════ REVIEW ═══════════════ */
.review-list { padding: 0; overflow: hidden; }
.review-row {
  display: grid; grid-template-columns: 24px 48px 1fr auto; gap: 10px;
  align-items: center; padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--dur-1);
  position: relative;
}
.review-row:last-child { border-bottom: none; }
.review-row:hover { background: var(--gray-50); }
/* Accent bar on hover — Linear list pattern */
.review-row::after {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: transparent; border-radius: 0 2px 2px 0;
  transition: background var(--dur-1);
}
.review-row:hover::after { background: var(--accent-400); }
.review-select { width: 16px; height: 16px; accent-color: var(--accent-600); cursor: pointer; }
.review-thumb {
  width: 48px; height: 48px; border-radius: var(--radius);
  object-fit: cover; background: var(--gray-100);
  border: 1px solid var(--border);
  transition: transform var(--dur-2) var(--ease-out), box-shadow var(--dur-2);
}
.review-row:hover .review-thumb { transform: scale(1.04); box-shadow: var(--shadow-sm); }
.review-main { min-width: 0; }
.review-pred { font-weight: 600; color: var(--ink); font-size: 13px; }
.review-meta {
  font-size: 12px; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.review-block-reason {
  margin-top: 2px; font-size: 11px; font-weight: 600; color: #92400e;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.review-missing-details, .review-quality-issues {
  margin-top: 2px; font-size: 11px; font-weight: 600; color: var(--accent-700);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.review-quality-issues { color: #92400e; }
.review-badges { display: flex; flex-direction: column; gap: 3px; align-items: flex-end; }

.auto-next-control {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap);
  color: var(--ink-2); font-size: 12px; font-weight: 500; white-space: nowrap;
}
.auto-next-control input { width: 16px; height: 16px; accent-color: var(--accent-600); }

/* Badges — shadcn-style bordered pills */
.badge {
  font-size: 11px; font-weight: 600; padding: 2px 7px;
  border-radius: var(--radius-xs); white-space: nowrap;
  letter-spacing: .01em; border: 1px solid transparent;
}
.badge-pending   { background: var(--amber-bg); color: #92400e; border-color: var(--amber-border); }
.badge-confirmed { background: var(--green-bg); color: #14532d; border-color: var(--green-border); }
.badge-discarded { background: var(--gray-100); color: var(--ink-3); }
.badge-agreed    { background: var(--accent-50);  color: var(--accent-900); border-color: var(--accent-100); }
.badge-corrected { background: var(--orange-bg); color: #7c2d12; border-color: var(--orange-border); }
.badge-priority  { background: var(--orange-bg); color: #7c2d12; border-color: var(--orange-border); }
.badge-eligible  { background: var(--green-bg); color: #14532d; border-color: var(--green-border); }
.badge-blocked   { background: var(--amber-bg); color: #92400e; border-color: var(--amber-border); }

.empty-state {
  padding: 56px 20px; text-align: center; color: var(--ink-3); font-size: 13px;
}


/* ═══════════════ DASHBOARD ═══════════════ */
.dash-command {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.dash-command-card {
  position: relative;
  min-height: 116px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  overflow: hidden;
  transition: border-color var(--dur-2), box-shadow var(--dur-2), transform var(--dur-1);
}
.dash-command-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: var(--accent-500);
}
.dash-command-card.warn::before { background: var(--amber); }
.dash-command-card.ok::before { background: var(--green); }
.dash-command-card.todo::before { background: var(--gray-400); }
.dash-command-card:hover {
  transform: translateY(-1px);
  border-color: var(--border-3);
  box-shadow: var(--shadow-md);
}
.dash-command-card strong {
  font-family: var(--font-mono);
  font-size: 28px;
  line-height: 1;
  color: var(--ink);
}
.dash-command-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
}
.dash-command-card em {
  display: block;
  font-style: normal;
  color: var(--ink-3);
  font-size: 11px;
}
.stat-cards {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px;
}
.stat-card {
  padding: 18px 20px; display: flex; flex-direction: column; gap: 4px;
  transition: border-color var(--dur-2), box-shadow var(--dur-2);
}
.stat-card:hover { border-color: var(--border-2); box-shadow: var(--shadow-sm); }
.stat-num {
  font-size: 32px; font-weight: 700; color: var(--ink); line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: -.03em;
  font-family: var(--font-mono);
}
.stat-label { font-size: 11px; color: var(--ink-3); font-weight: 500; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; margin-bottom: 16px; }
.dash-head-actions { display: flex; align-items: center; gap: 8px; }
.dash-species {
  padding: 7px 10px; font-size: 13px; font-family: var(--font);
  color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.dash-species:hover { border-color: var(--border-2); }
.dash-grid-wide { grid-template-columns: minmax(320px, .75fr) minmax(0, 1.25fr); }

.training-pipeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pipeline-row {
  display: grid;
  gap: 5px;
}
.pipeline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--ink-2);
}
.pipeline-head strong {
  font-family: var(--font-mono);
  color: var(--ink);
}
.pipeline-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--gray-100);
}
.pipeline-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent-500);
}
.pipeline-row.ready .pipeline-track i { background: var(--green); }
.pipeline-row.blocked .pipeline-track i { background: var(--amber); }
.pipeline-row.used .pipeline-track i { background: var(--gray-500); }
.pipeline-reasons {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 2px;
}
.pipeline-reasons strong {
  width: 100%;
  color: var(--ink-3);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.pipeline-reasons > span:not(.pipeline-chip) {
  color: var(--ink-3);
  font-size: 12px;
}
.pipeline-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--amber-border);
  border-radius: 999px;
  background: var(--amber-bg);
  color: #92400e;
  font-size: 11px;
  font-weight: 700;
}
.data-asset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.data-asset-item {
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.data-asset-item strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 22px;
  line-height: 1;
  color: var(--ink);
}
.data-asset-item span {
  display: block;
  margin-top: 6px;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 700;
}

/* Per-condition bars */
.per-condition {
  display: flex; flex-direction: column; gap: 10px;
  max-height: 440px; overflow-y: auto; padding-inline-end: 4px;
}
/* Compact mode kicks in when many classes have data (full 41-class taxonomy) */
.per-condition.compact { gap: 6px; }
.per-condition.compact .pc-head { font-size: 11px; }
.per-condition.compact .pc-track { height: 4px; }
.pc-zero-note {
  font-size: 11px; color: var(--ink-3);
  padding-top: 8px; margin-top: 2px; border-top: 1px dashed var(--border);
}
.pc-row { display: grid; grid-template-columns: 1fr; gap: 3px; }
.pc-head { display: flex; justify-content: space-between; font-size: 12px; }
.pc-head .pc-name { color: var(--ink-2); }
.pc-head .pc-count {
  font-family: var(--font-mono); font-weight: 600; font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.pc-track { height: 6px; background: var(--gray-100); border-radius: 3px; overflow: hidden; }
.pc-fill {
  height: 100%; border-radius: 3px; min-width: 2px;
  background: linear-gradient(90deg, var(--accent-400), var(--accent-600));
  transition: width .5s var(--ease);
}

/* Confusion matrix */
.confusion-wrap { overflow-x: auto; max-height: 70vh; overflow-y: auto; }
.confusion { border-collapse: collapse; font-size: 11px; }
.confusion th, .confusion td {
  border: 1px solid var(--border); padding: 4px 6px; text-align: center;
}
.confusion th {
  font-family: var(--font); font-weight: 600; font-size: 10px;
}
.confusion thead th { background: var(--gray-50); color: var(--ink-2); position: sticky; top: 0; z-index: 1; }
.confusion tbody th {
  background: var(--surface); text-align: left; color: var(--ink-2); font-weight: 500;
  position: sticky; left: 0; z-index: 1;
}
.confusion .corner { position: sticky; left: 0; top: 0; z-index: 2; }
.confusion td {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  transition: background var(--dur-1);
}
.confusion td.diag { background: var(--accent-50); font-weight: 700; color: var(--accent-800); }
.confusion td.has  { font-weight: 600; color: var(--accent-700); }
.confusion .corner { background: var(--gray-100); color: var(--ink-3); font-weight: 500; }
.confusion thead th:first-child { left: 0; z-index: 2; }


/* ═══════════════ TRAIN ═══════════════ */
.train-card .train-ready { font-weight: 600; font-size: 14px; color: var(--ink); margin: 8px 0; }
.train-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.train-preflight { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0 0; }
.train-preflight-item {
  border: 1px solid var(--amber-border); background: var(--amber-bg); color: #92400e;
  border-radius: var(--radius); height: 32px; padding: 0 10px;
  font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all var(--dur-1);
}
.train-preflight-item:hover { background: #fef3c7; border-color: #f59e0b; }

.train-readiness {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px; margin-top: 12px;
}
.train-readiness-item {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 14px; background: var(--surface);
  transition: border-color var(--dur-2), box-shadow var(--dur-2);
}
.train-readiness-item:hover { border-color: var(--border-2); box-shadow: var(--shadow-xs); }
.train-readiness-item strong {
  display: block; color: var(--ink); font-size: 18px; line-height: 1.1;
  font-family: var(--font-mono);
}
.train-readiness-item span { display: block; color: var(--ink-3); font-size: 11px; margin-top: 4px; }
.train-readiness-action { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.ready-by-condition { grid-column: 1 / -1; border-top: 1px solid var(--border); padding-top: 12px; }
.ready-by-condition .subhead { margin-bottom: 8px; }
.ready-condition-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px;
  align-items: center; padding: 8px;
  border-top: 1px solid var(--gray-100);
  cursor: pointer; border-radius: var(--radius);
  transition: background var(--dur-1);
}
.ready-condition-row:hover { background: var(--gray-50); }
.ready-condition-row:first-of-type { border-top: 0; }
.ready-condition-name { font-weight: 500; color: var(--ink); font-size: 13px; }
.ready-condition-count, .ready-condition-blocked {
  white-space: nowrap; font-size: 11px; font-weight: 600;
  font-family: var(--font-mono);
}
.ready-condition-count { color: var(--accent-700); }
.ready-condition-row.empty .ready-condition-count { color: var(--amber); }
.ready-condition-blocked { color: var(--ink-3); }

.train-runs { display: flex; flex-direction: column; gap: 8px; }
.run-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px 12px;
  padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  transition: border-color var(--dur-2), box-shadow var(--dur-2);
}
.run-row:hover { border-color: var(--border-2); box-shadow: var(--shadow-xs); }
.run-cell { display: flex; flex-direction: column; gap: 1px; }
.run-cell .k { font-size: 10px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.run-cell .v { font-weight: 500; font-size: 13px; }
.run-status-running { color: var(--amber); }
.run-status-success { color: var(--green); }
.run-status-failed  { color: var(--red); }


/* ═══════════════ OVERLAY / TOAST / SPINNER ═══════════════ */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  animation: fadeIn var(--dur-3) var(--ease-out) both;
}
.overlay-text { color: #fff; font-weight: 500; font-size: 14px; max-width: 80%; text-align: center; }
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.15); border-top-color: #fff;
  animation: spin .65s linear infinite;
}

.toast {
  position: fixed; left: 50%; bottom: 28px;
  transform: translateX(-50%);
  z-index: 60; background: var(--gray-900); color: #fff;
  padding: 10px 20px; border-radius: var(--radius-lg);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-xl); max-width: 90%; text-align: center;
  animation: toastSlide var(--dur-3) var(--ease-spring) both;
}
@keyframes toastSlide {
  from { opacity: 0; transform: translateX(-50%) translateY(12px) scale(.95); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}


/* ═══════════════ FOOTER ═══════════════ */
.app-footer {
  text-align: center; font-size: 11px; line-height: 1.5;
  color: var(--ink-3); padding: 12px 20px;
  border-top: 1px solid var(--border); background: var(--surface);
}


/* ═══════════════ PATIENT LINK ═══════════════ */
.patient-link-row { position: relative; display: flex; align-items: center; gap: 8px; }
.patient-search-wrap { position: relative; flex: 1; }
.search-results {
  position: absolute; top: calc(100% + 4px); inset-inline: 0; z-index: 30;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  max-height: 240px; overflow: auto;
  animation: dropIn var(--dur-2) var(--ease) both;
}
.search-item {
  padding: 10px 14px; cursor: pointer; display: flex; flex-direction: column;
  gap: 2px; border-bottom: 1px solid var(--border);
  transition: background var(--dur-1);
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--gray-50); }
.si-name { font-weight: 500; font-size: 13px; }
.si-meta { font-size: 11px; color: var(--ink-3); }
.search-create { color: var(--accent-700); font-weight: 600; }

.patient-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-50); border: 1px solid var(--accent-100);
  color: var(--accent-900); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; font-weight: 500; min-height: 32px;
}
.chip-ic { width: 14px; height: 14px; flex: none; }
.chip-x {
  background: none; border: none; color: var(--accent-700); font-size: 14px;
  line-height: 1; cursor: pointer; padding: 0 2px; min-height: auto; width: auto;
  transition: transform var(--dur-1);
}
.chip-x:hover { transform: scale(1.15); }


/* ═══════════════ PATIENTS ═══════════════ */
.panel-head-sub { margin-bottom: 12px; }
.search-input { width: 100%; }
.patient-form { margin-bottom: 16px; }
.patient-form .btn { margin-top: 4px; }
.patient-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.patient-id { min-width: 0; }
.patient-id .card-title { margin-bottom: 2px; }
.patient-avatar {
  width: 44px; height: 44px; border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--gray-100), var(--gray-200));
  color: var(--ink-3);
  display: grid; place-items: center; flex: none;
}
.patient-avatar svg { width: 20px; height: 20px; }

.record-list { display: flex; flex-direction: column; }
.record-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.record-row:last-child { border-bottom: none; }
.record-row.link {
  cursor: pointer; border-radius: var(--radius); padding: 8px;
  margin: 0 -8px; transition: background var(--dur-1);
}
.record-row.link:hover { background: var(--gray-50); }
.rr-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.rr-title { font-weight: 500; color: var(--ink); font-size: 13px; }
.rr-sub { font-size: 11px; color: var(--ink-3); }

.inline-form { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; align-items: center; }
.inline-form input { flex: 1 1 120px; width: auto; }
.inline-form .inline-select { flex: 1 1 140px; }
.inline-form .btn { flex: 0 0 auto; }


/* ═══════════════ PRODUCTIVITY / BATCH / CONDITION FILTER ═══════════════ */
.productivity-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px; margin: 8px 0 12px;
}
.productivity-pill {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); padding: 14px 16px; cursor: pointer;
  transition: all var(--dur-2) var(--ease-out);
}
.productivity-pill:hover {
  border-color: var(--accent-200); background: var(--accent-50);
  box-shadow: var(--shadow-xs);
  transform: translateY(-1px);
}
.productivity-pill strong {
  display: block; color: var(--ink); font-size: 18px;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
}
.productivity-pill span {
  display: block; color: var(--ink-3); font-size: 11px; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 700px) { .productivity-strip { grid-template-columns: 1fr 1fr; } }

.review-batch {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 10px 14px; margin: 0 0 10px;
  border: 1px solid var(--accent-100); border-radius: var(--radius-lg);
  background: var(--accent-50);
}
.review-batch strong { color: var(--ink); margin-inline-end: 2px; font-size: 13px; }
.review-batch .btn { height: 28px; min-height: 28px; padding: 0 8px; font-size: 11px; }

.review-list-tools {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 0 0 8px; color: var(--ink-3); font-size: 12px; font-weight: 500;
}
.review-list-tools .btn { height: 28px; min-height: 28px; padding: 0 8px; font-size: 11px; }

.review-condition-filter {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin: 6px 0 10px; color: var(--ink-2); font-size: 13px; font-weight: 500;
}
.review-condition-filter .btn { height: 28px; min-height: 28px; padding: 0 8px; font-size: 11px; }


/* ═══════════════ NOTES / ALERTS ═══════════════ */
.quality-note {
  font-size: 12px; color: #92400e; background: var(--amber-bg);
  border: 1px solid var(--amber-border); border-radius: var(--radius);
  padding: 8px 12px; margin: 6px 0 0; font-weight: 500;
}
.eligibility-note {
  font-size: 13px; font-weight: 600; border-radius: var(--radius);
  padding: 10px 14px; margin: 8px 0 0;
  animation: scaleIn var(--dur-3) var(--ease) both;
}
.eligibility-note.eligible {
  background: var(--green-bg); color: #14532d; border: 1px solid var(--green-border);
}
.eligibility-note.blocked {
  background: var(--amber-bg); color: #78350f; border: 1px solid var(--amber-border);
}

.referral-note {
  background: var(--amber-bg); color: #78350f;
  border: 1px solid var(--amber-border);
  border-radius: var(--radius-lg); padding: 12px 16px;
  font-size: 13px; font-weight: 600; margin: -4px 0 16px;
  line-height: 1.5;
}
.healthy-disclaimer {
  background: var(--blue-bg, #eff6ff); color: #1e40af;
  border: 1px solid var(--blue-border, #bfdbfe);
  border-radius: var(--radius-lg); padding: 12px 16px;
  font-size: 13px; margin: -4px 0 16px; line-height: 1.5;
}
.capture-thumb {
  position: relative; width: 70px; height: 54px;
  border: 1px solid var(--border-2, #cbd5e1); border-radius: var(--radius);
  overflow: hidden; background: var(--bg-2, #f8fafc); flex-shrink: 0;
}
.capture-thumb-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.capture-thumb-label {
  position: absolute; left: 4px; top: 3px;
  background: rgba(15,23,42,.75); color: #fff;
  border-radius: 10px; padding: 1px 6px; font-size: 10px;
}
.qc-badge {
  position: absolute; right: 3px; top: 3px;
  width: 16px; height: 16px; line-height: 16px; text-align: center;
  border-radius: 50%; font-size: 11px; font-weight: 700; color: #fff;
}
.qc-badge.qc-good { background: #16a34a; }
.qc-badge.qc-bad { background: #dc2626; }
.qc-badge.qc-pending { background: #64748b; }
.qc-warn {
  width: 100%; margin-top: 8px; font-size: 12px;
  color: #b91c1c; background: #fef2f2;
  border: 1px solid #fecaca; border-radius: var(--radius); padding: 8px 10px;
}
.qc-warn ul { margin: 4px 0 0; padding-inline-start: 18px; }
.qc-warn li { margin: 2px 0; }
@media (prefers-color-scheme: dark) {
  .qc-warn { color: #fca5a5; background: rgba(127,29,29,.25); border-color: #7f1d1d; }
}
.roi-note {
  font-size: 12px; color: var(--accent-700); background: var(--accent-50);
  border: 1px solid var(--accent-100); border-radius: var(--radius);
  padding: 8px 12px; margin: 6px 0 0; font-weight: 500;
}


/* ═══════════════ MODEL REGISTRY ═══════════════ */
.subhead2 { font-size: 12px; color: var(--ink-3); font-weight: 600; margin: 16px 0 8px; }
.model-version { display: flex; align-items: baseline; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.mv-tag {
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  color: var(--ink); background: var(--gray-100);
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  padding: 3px 8px;
}
.metric-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.metric-tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 10px; text-align: center;
  transition: border-color var(--dur-2), box-shadow var(--dur-2);
}
.metric-tile:hover { border-color: var(--border-2); box-shadow: var(--shadow-xs); }
.metric-val {
  font-size: 22px; font-weight: 700; color: var(--ink);
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.metric-label {
  font-size: 10px; color: var(--ink-3); margin-top: 4px;
  text-transform: uppercase; letter-spacing: .04em; font-weight: 600;
}
.metric-sub { font-size: 10px; color: var(--ink-3); margin-top: 2px; font-family: var(--font-mono); }
.model-history { display: flex; flex-direction: column; gap: 10px; }
.model-versions { display: flex; flex-direction: column; }
.model-versions .record-row { align-items: center; }
@media (max-width: 560px) { .metric-tiles { grid-template-columns: 1fr 1fr; } }
[dir="rtl"] .mv-tag { direction: ltr; }


/* ═══════════════ TRAINING LOG ═══════════════ */
.train-log {
  max-height: 360px; overflow: auto; margin: 0;
  padding: 14px 16px; border-radius: var(--radius-lg);
  background: var(--gray-950); color: var(--gray-400);
  font-family: var(--font-mono); font-size: 12px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.3);
}
[dir="rtl"] .train-log { direction: ltr; text-align: left; }


/* ═══════════════ RESPONSIVE ═══════════════ */
@media (max-width: 820px) {
  .panel-grid, .result-grid, .dash-grid { grid-template-columns: 1fr; }
  .dash-command { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .train-readiness { grid-template-columns: 1fr; }
  .run-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  :root {
    --header-h: 56px;
    --tabbar-h: 70px;
    --tap: 48px;
  }
  body {
    font-size: 15px;
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  }
  .app-shell { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); }
  .app-header {
    height: var(--header-h);
    padding: 6px 12px;
    gap: 8px;
  }
  .brand { min-width: 0; gap: 8px; }
  .brand-logo-img { width: 34px; height: 34px; border-radius: 9px; }
  .brand-text { min-width: 0; }
  .brand-title {
    max-width: 34vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .brand-sub { display: none; }
  .header-actions {
    margin-left: auto;
    gap: 4px;
    min-width: 0;
  }
  .user-name {
    display: none;
  }
  .header-actions .btn {
    min-height: 38px;
    height: 38px;
    padding: 0 10px;
    font-size: 12px;
    border-radius: 9px;
  }
  #theme-toggle {
    display: none;
  }
  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    z-index: 40;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border);
    border-bottom: 0;
    box-shadow: 0 -10px 30px rgba(15, 23, 42, .10);
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }
  .tab {
    flex: 0 0 72px;
    height: 58px;
    min-width: 72px;
    border-bottom: 0;
    border-radius: 14px;
    gap: 4px;
    color: var(--gray-500);
  }
  .tab .tab-ic { width: 22px; height: 22px; }
  .tab span:last-child {
    font-size: 11px;
    line-height: 1;
    max-width: 66px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .tab.active {
    color: var(--gray-950);
    background: var(--accent-50);
    box-shadow: inset 0 0 0 1px var(--accent-200);
  }
  .app-main {
    padding: 14px 12px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom, 0px));
  }
  .card {
    padding: 14px;
    border-radius: 12px;
  }
  .panel-head {
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
  }
  .panel-head h2 { font-size: 18px; }
  .panel-head-actions,
  .capture-controls,
  .feedback-actions,
  .case-metadata-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .btn,
  .btn-block,
  .capture-controls .btn,
  .capture-controls .file-btn,
  .feedback-actions .btn,
  .case-metadata-actions .btn {
    min-height: var(--tap);
    height: var(--tap);
    font-size: 14px;
    border-radius: 10px;
  }
  input, select, textarea {
    min-height: var(--tap);
    height: var(--tap);
    font-size: 16px;
    border-radius: 10px;
    padding: 10px 12px;
  }
  textarea {
    min-height: 92px;
  }
  .field { margin-bottom: 14px; }
  .field > span { font-size: 13px; }
  .capture-stage {
    aspect-ratio: 3 / 4;
    max-height: 58vh;
    border-radius: 14px;
  }
  .meta-form { grid-template-columns: 1fr; }
  .result-images { grid-template-columns: 1fr 1fr; }
  .feedback-buttons { grid-template-columns: 1fr 1fr; }
  .feedback-details { grid-template-columns: 1fr; }
  .dash-command { grid-template-columns: 1fr; }
  .data-asset-grid { grid-template-columns: 1fr; }
  .stat-cards,
  .metric-tiles,
  .productivity-strip {
    grid-template-columns: 1fr 1fr;
  }
  .stat-num { font-size: 24px; }
  h1 { font-size: 1.375rem; }

  /* Mobile annotation workbench */
  .raw-project-board {
    padding: 10px;
    margin-bottom: 12px;
  }
  .raw-project-controls {
    grid-template-columns: 1fr;
    min-width: 0;
  }
  .raw-project-controls input,
  .raw-project-controls select {
    min-height: var(--tap);
    font-size: 16px;
  }
  .raw-lab-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .raw-image-card {
    position: static;
    padding: 10px;
  }
  .raw-lab-toolbar,
  .raw-taskbar {
    gap: 8px;
  }
  .raw-taskbar {
    position: sticky;
    top: var(--header-h);
    z-index: 12;
    padding: 8px;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
  }
  .raw-task-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    gap: 6px;
  }
  .raw-task-actions .btn {
    min-height: 42px;
    height: 42px;
    padding: 0 8px;
    font-size: 12px;
  }
  .raw-session-metrics,
  .raw-image-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .raw-workbench {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .raw-tool-rail {
    position: sticky;
    top: calc(var(--header-h) + 58px);
    z-index: 11;
    flex-direction: row;
    justify-content: flex-start;
    gap: 8px;
    padding: 8px;
    overflow-x: auto;
    border-radius: 12px;
    box-shadow: var(--shadow-xs);
  }
  .raw-tool {
    width: 46px;
    height: 46px;
    min-width: 46px;
    border-radius: 12px;
    font-size: 13px;
  }
  .raw-stage {
    min-height: min(72vh, 620px);
    height: min(72vh, 620px);
    border-radius: 14px;
    touch-action: none;
  }
  .raw-stage img {
    max-height: calc(72vh - 12px);
  }
  .raw-stage-badge {
    top: 8px;
    left: 8px;
    max-width: 58%;
    min-height: 30px;
    font-size: 11px;
  }
  .raw-zoom-controls {
    top: 8px;
    right: 8px;
    min-height: 38px;
  }
  .raw-zoom-controls button {
    min-width: 36px;
    height: 32px;
    font-size: 14px;
  }
  .raw-zoom-controls span {
    min-width: 46px;
    font-size: 12px;
  }
  .raw-layer-panel {
    display: none;
  }
  .raw-form-card {
    position: static;
    padding-bottom: calc(var(--tabbar-h) + 78px + env(safe-area-inset-bottom, 0px));
  }
  .raw-workflow-strip {
    grid-template-columns: repeat(5, minmax(88px, 1fr));
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .raw-workflow-strip span {
    min-height: 38px;
    font-size: 10px;
  }
  .raw-body-atlas,
  .raw-feature-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .raw-body-card,
  .raw-feature-chip {
    min-height: 54px;
  }
  .raw-class-chip-row,
  .raw-label-palette {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 6px;
  }
  .raw-class-chip,
  .raw-label-chip {
    flex: 0 0 auto;
    min-height: 42px;
    padding: 8px 12px;
    font-size: 13px;
  }
  .raw-box-row {
    min-height: 56px;
    grid-template-columns: minmax(0, 1fr) 44px;
  }
  .raw-box-delete {
    width: 40px;
    height: 40px;
  }
  .raw-inspector-grid,
  .raw-qa-grid,
  .raw-context-summary {
    grid-template-columns: 1fr;
  }
  .raw-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .raw-actions .btn {
    min-height: 44px;
  }
  .raw-form-card > .feedback-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    z-index: 38;
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, .8fr);
    gap: 8px;
    padding: 10px 12px;
    background: rgba(255,255,255,.94);
    border-top: 1px solid var(--border);
    box-shadow: 0 -8px 26px rgba(15, 23, 42, .10);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }
  .raw-form-card > .feedback-actions .btn {
    min-height: 50px;
    height: 50px;
    font-size: 14px;
  }
}


/* ═══════════════ RTL — comprehensive mirroring ═══════════════ */
[dir="rtl"] .back-btn span[aria-hidden] { transform: scaleX(-1); display: inline-block; }
[dir="rtl"] .review-badges { align-items: flex-start; }
[dir="rtl"] .confusion tbody th { text-align: right; }
[dir="rtl"] .review-row::after { left: auto; right: 0; border-radius: 2px 0 0 2px; }
[dir="rtl"] .role-arrow { transform: scaleX(-1); }
[dir="rtl"] .role-card:hover .role-arrow { transform: scaleX(-1) translateX(-3px); }
[dir="rtl"] .brand { flex-direction: row-reverse; }
[dir="rtl"] .header-actions { flex-direction: row-reverse; }
[dir="rtl"] .tab-ic { margin-inline-end: 0; }
[dir="rtl"] .app-header { direction: rtl; }
[dir="rtl"] .patient-chip { flex-direction: row-reverse; }
[dir="rtl"] .chip-x { margin-inline-start: 0; margin-inline-end: 6px; }
[dir="rtl"] .owner-step { flex-direction: row-reverse; text-align: right; }
[dir="rtl"] .owner-step-num { margin-inline-start: 12px; margin-inline-end: 0; }
[dir="rtl"] .prob-bar-label { direction: ltr; unicode-bidi: plaintext; }
[dir="rtl"] .stat-card { text-align: center; }
[dir="rtl"] .verdict-card { flex-direction: row-reverse; }
[dir="rtl"] .feedback-actions { direction: rtl; }
[dir="rtl"] .inline-form { direction: rtl; }
[dir="rtl"] .panel-head { flex-direction: row-reverse; }
[dir="rtl"] .panel-head-actions { flex-direction: row-reverse; }
[dir="rtl"] .capture-controls { direction: rtl; }
[dir="rtl"] .top-result { text-align: right; }
[dir="rtl"] .referral-note { direction: rtl; }
[dir="rtl"] .case-metadata-actions { flex-direction: row-reverse; }
[dir="rtl"] .second-review-actions { flex-direction: row-reverse; }
[dir="rtl"] .auto-next-control { flex-direction: row-reverse; }
[dir="rtl"] .field-inline { flex-direction: row-reverse; }
[dir="rtl"] .search-results { text-align: right; }
[dir="rtl"] .toast { direction: rtl; }

/* ═══════════════ DARK MODE (auto via prefers-color-scheme) ═══════════════ */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:          var(--gray-950);
    --surface:     var(--gray-900);
    --surface-2:   var(--gray-800);
    --border:      rgba(255, 255, 255, .06);
    --border-2:    rgba(255, 255, 255, .1);
    --border-3:    rgba(255, 255, 255, .14);
    --ink:         var(--gray-50);
    --ink-2:       var(--gray-300);
    --ink-3:       var(--gray-400);
    --muted:       var(--gray-500);
    --green-bg:    #052e16; --green-border: #166534;
    --amber-bg:    #451a03; --amber-border: #92400e;
    --red-bg:      #450a0a; --red-border:   #991b1b;
    --info-bg:     #083344; --info-border:  #155e75;
  }
  body { -webkit-font-smoothing: auto; }
  .btn-primary {
    background: linear-gradient(180deg, var(--accent-700) 0%, var(--accent-800) 100%);
    border-color: var(--accent-800);
  }
  .btn-primary:hover:not(:disabled) {
    background: linear-gradient(180deg, var(--accent-600) 0%, var(--accent-700) 100%);
  }
  .btn-secondary { background: var(--gray-800); color: var(--gray-200); }
  .btn-secondary:hover:not(:disabled) { background: var(--gray-700); }
  .btn-ghost:hover:not(:disabled) { background: var(--gray-800); color: var(--gray-200); }
  .card { background: var(--gray-900); border-color: rgba(255,255,255,.06); }
  input, select, textarea { background: var(--gray-800); border-color: rgba(255,255,255,.1); color: var(--gray-100); }
  input:focus, select:focus, textarea:focus {
    border-color: var(--accent-500);
    box-shadow: 0 0 0 3px rgba(6,182,212,.15);
  }
  .skeleton {
    background: linear-gradient(90deg, var(--gray-800) 25%, var(--gray-700) 50%, var(--gray-800) 75%);
  }
  ::-webkit-scrollbar-thumb { background: var(--gray-600); }
  ::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }
  .capture-placeholder { background: var(--gray-800); }
  .login-screen { background: var(--gray-950); }
  .login-card { background: var(--gray-900); border-color: rgba(255,255,255,.06); }
  .prob-bar-bg { background: var(--gray-800); }
  .overlay { background: rgba(2,6,23,.85); }
  .toast { background: var(--gray-800); color: var(--gray-100); border-color: rgba(255,255,255,.1); }
  .owner-screen { background: var(--gray-950); }
  .owner-wrapper { color: var(--gray-200); }
  .review-row:hover { background: var(--gray-800); }
  ::selection { background: var(--accent-800); color: white; }

  /* Review system dark mode */
  .rv-stats-pill { background: var(--gray-800); border-color: rgba(255,255,255,.06); }
  .rv-chip { background: var(--gray-800); border-color: rgba(255,255,255,.08); color: var(--gray-300); }
  .rv-chip.active { background: var(--accent-900); border-color: var(--accent-600); color: var(--accent-200); }
  .rv-queue-card { background: var(--gray-900); border-color: rgba(255,255,255,.06); }
  .rv-queue-card:hover { background: var(--gray-800); border-color: rgba(255,255,255,.1); }
  .rv-scoring { background: var(--gray-900); }
  .rv-star { color: var(--gray-600); }
  .rv-star.filled { color: var(--amber); }
  .rv-panel-left .card, .rv-panel-right .card { background: var(--gray-900); border-color: rgba(255,255,255,.06); }
  .rv-similar-thumb { border-color: rgba(255,255,255,.1); }
  .rv-prev-review-card { background: var(--gray-800); border-color: rgba(255,255,255,.06); }
  .rv-dashboard .rv-dash-card { background: var(--gray-900); border-color: rgba(255,255,255,.06); }
  .rv-sub-tab { color: var(--gray-400); }
  .rv-sub-tab.active { color: var(--accent-400); border-color: var(--accent-400); }
  .rv-urgency-escalated { background: rgba(239,68,68,.15); }
  .rv-urgency-critical { background: rgba(249,115,22,.1); }
  .rv-urgency-high { background: rgba(234,179,8,.08); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   STRUCTURED REVIEW SYSTEM
   ═══════════════════════════════════════════════════════════════════════ */

/* Sub-navigation */
.rv-sub-nav {
  display: flex; gap: var(--space-2); border-bottom: 1px solid var(--border-2);
  margin-bottom: var(--space-4);
  align-items: flex-end;
  overflow-x: auto;
}
.rv-sub-tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: var(--space-3) var(--space-4); font: inherit; font-weight: 600;
  color: var(--ink-3); cursor: pointer; transition: color .15s, border-color .15s;
  min-height: 44px; white-space: nowrap; flex: 0 0 auto;
}
.rv-sub-tab.active { color: var(--accent-600); border-bottom-color: var(--accent-600); }
.rv-sub-tab:hover { color: var(--ink-2); }

/* Stats bar */
.rv-stats-bar {
  display: flex; gap: var(--space-2); flex-wrap: wrap;
  margin-bottom: var(--space-3);
}

/* In-app theme control. Light is the default, regardless of OS theme. */
:root[data-theme="dark"] {
  --bg:          var(--gray-950);
  --surface:     var(--gray-900);
  --surface-2:   var(--gray-800);
  --border:      rgba(255, 255, 255, .06);
  --border-2:    rgba(255, 255, 255, .1);
  --border-3:    rgba(255, 255, 255, .14);
  --ink:         var(--gray-50);
  --ink-2:       var(--gray-300);
  --ink-3:       var(--gray-400);
  --muted:       var(--gray-500);
  --green-bg:    #052e16; --green-border: #166534;
  --amber-bg:    #451a03; --amber-border: #92400e;
  --red-bg:      #450a0a; --red-border:   #991b1b;
  --info-bg:     #083344; --info-border:  #155e75;
}
:root[data-theme="dark"] body { -webkit-font-smoothing: auto; }
:root[data-theme="dark"] .btn-primary {
  background: linear-gradient(180deg, var(--accent-700) 0%, var(--accent-800) 100%);
  border-color: var(--accent-800);
}
:root[data-theme="dark"] .btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--accent-600) 0%, var(--accent-700) 100%);
}
:root[data-theme="dark"] .btn-secondary { background: var(--gray-800); color: var(--gray-200); }
:root[data-theme="dark"] .btn-secondary:hover:not(:disabled) { background: var(--gray-700); }
:root[data-theme="dark"] .btn-ghost:hover:not(:disabled) { background: var(--gray-800); color: var(--gray-200); }
:root[data-theme="dark"] .card { background: var(--gray-900); border-color: rgba(255,255,255,.06); }
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea { background: var(--gray-800); border-color: rgba(255,255,255,.1); color: var(--gray-100); }
:root[data-theme="dark"] .login-screen,
:root[data-theme="dark"] .owner-screen { background: var(--gray-950); }
:root[data-theme="dark"] .login-card { background: var(--gray-900); border-color: rgba(255,255,255,.06); }
:root[data-theme="dark"] .toast { background: var(--gray-800); color: var(--gray-100); border-color: rgba(255,255,255,.1); }

:root[data-theme="light"] {
  --bg:          var(--gray-50);
  --surface:     #ffffff;
  --surface-2:   var(--gray-25);
  --border:      rgba(0, 0, 0, .06);
  --border-2:    rgba(0, 0, 0, .1);
  --border-3:    rgba(0, 0, 0, .14);
  --ink:         var(--gray-900);
  --ink-2:       var(--gray-700);
  --ink-3:       var(--gray-500);
  --muted:       var(--gray-400);
  --green-bg:    #f0fdf4; --green-border: #bbf7d0;
  --amber-bg:    #fffbeb; --amber-border: #fde68a;
  --red-bg:      #fef2f2; --red-border:   #fecaca;
  --info-bg:     var(--accent-50); --info-border: var(--accent-100);
}
:root[data-theme="light"] body { -webkit-font-smoothing: antialiased; }
:root[data-theme="light"] .btn-primary {
  background: linear-gradient(180deg, var(--accent-600) 0%, var(--accent-700) 100%);
  border-color: var(--accent-700);
}
:root[data-theme="light"] .btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--accent-500) 0%, var(--accent-600) 100%);
}
:root[data-theme="light"] .btn-secondary { background: white; color: var(--gray-700); }
:root[data-theme="light"] .btn-secondary:hover:not(:disabled) { background: var(--gray-50); }
:root[data-theme="light"] .btn-ghost:hover:not(:disabled) { background: var(--gray-100); color: var(--gray-800); }
:root[data-theme="light"] .card { background: white; border-color: rgba(0,0,0,.06); }
:root[data-theme="light"] input,
:root[data-theme="light"] select,
:root[data-theme="light"] textarea { background: white; border-color: rgba(0,0,0,.1); color: var(--gray-900); }
:root[data-theme="light"] .login-screen,
:root[data-theme="light"] .owner-screen { background: var(--gray-50); }
:root[data-theme="light"] .login-card { background: white; border-color: rgba(0,0,0,.06); }
:root[data-theme="light"] .capture-placeholder,
:root[data-theme="light"] .prob-bar-bg { background: var(--gray-100); }
:root[data-theme="light"] .overlay { background: rgba(248,250,252,.86); }
:root[data-theme="light"] .toast { background: white; color: var(--gray-900); border-color: rgba(0,0,0,.1); }
.rv-stats-pill {
  display: flex; flex-direction: column; align-items: center;
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-lg);
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; transition: border-color .15s, box-shadow .15s;
  min-width: 72px; min-height: 44px;
}
.rv-stats-pill:hover { border-color: var(--accent-400); box-shadow: var(--shadow-sm); }
.rv-stats-pill strong { font-size: 1.25rem; font-family: var(--mono); }
.rv-stats-pill span { font-size: .75rem; color: var(--ink-3); }
.rv-stats-pill.pill-critical strong { color: var(--red); }
.rv-stats-pill.pill-high strong { color: var(--amber); }
.rv-stats-pill.pill-escalated strong { color: var(--red); }

/* Filter chips */
.rv-filters {
  display: flex; align-items: center; gap: var(--space-2);
  flex-wrap: wrap; margin-bottom: var(--space-3);
}
.rv-filter-chips { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.rv-chip {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border-2);
  background: var(--surface); font: inherit; font-size: .8125rem; font-weight: 500;
  color: var(--ink-3); cursor: pointer; transition: all .15s;
  min-height: 36px; white-space: nowrap;
}
.rv-chip.active {
  background: var(--accent-50); border-color: var(--accent-400);
  color: var(--accent-700); font-weight: 600;
}
.rv-chip:hover { border-color: var(--accent-300); }
.rv-divider { width: 1px; height: 24px; background: var(--border-2); margin: 0 4px; }

/* Queue list */
.rv-queue-list { display: flex; flex-direction: column; gap: var(--space-2); }

.rv-queue-card {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3); border-radius: var(--radius-lg);
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.rv-queue-card:hover { border-color: var(--accent-300); box-shadow: var(--shadow-sm); }

.rv-queue-thumb {
  width: 56px; height: 56px; border-radius: var(--radius-md);
  object-fit: cover; flex-shrink: 0;
}
.rv-queue-main { flex: 1; min-width: 0; }
.rv-queue-pred { font-weight: 600; font-size: .9rem; }
.rv-queue-meta { font-size: .75rem; color: var(--ink-3); margin-top: 2px; }
.rv-queue-badges { display: flex; gap: var(--space-1); flex-wrap: wrap; flex-shrink: 0; }

/* Urgency badges */
.rv-urgency-badge {
  display: inline-flex; align-items: center; padding: 2px 10px;
  border-radius: 999px; font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em;
}
.rv-urgency-escalated {
  background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border);
  animation: rv-pulse 2s ease-in-out infinite;
}
.rv-urgency-critical {
  background: rgba(249,115,22,.1); color: #ea580c; border: 1px solid rgba(249,115,22,.25);
}
.rv-urgency-high {
  background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-border);
}
.rv-urgency-normal {
  background: var(--gray-100); color: var(--gray-500); border: 1px solid var(--gray-200);
}
.rv-badge-dual {
  background: rgba(139,92,246,.1); color: #7c3aed; border: 1px solid rgba(139,92,246,.25);
  font-size: .65rem; padding: 1px 8px; border-radius: 999px; font-weight: 600;
}
.rv-badge-species {
  background: var(--accent-50); color: var(--accent-700);
  border: 1px solid var(--accent-200); font-size: .65rem;
  padding: 1px 8px; border-radius: 999px;
}
.rv-meta-complete { color: var(--green); font-size: .7rem; }
.rv-meta-incomplete { color: var(--amber); font-size: .7rem; }
.rv-badge-phase {
  font-size: .65rem; padding: 1px 8px; border-radius: 999px; font-weight: 700;
}
.rv-badge-phase.rv-phase-screening { background: rgba(56,189,248,.12); color: #0369a1; border: 1px solid rgba(56,189,248,.3); }
.rv-badge-phase.rv-phase-expert { background: rgba(168,85,247,.12); color: #7e22ce; border: 1px solid rgba(168,85,247,.3); }
.rv-phase-banner {
  margin: 8px 0 4px; padding: 10px 14px; border-radius: 10px; font-size: 13px; line-height: 1.5;
}
.rv-phase-banner.rv-phase-screening { background: #f0f9ff; color: #0c4a6e; border: 1px solid #bae6fd; }
.rv-phase-banner.rv-phase-expert { background: #faf5ff; color: #6b21a8; border: 1px solid #e9d5ff; }

@keyframes rv-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .6; }
}

/* Review panel */
.rv-panel-grid {
  display: grid; grid-template-columns: 1fr; gap: var(--space-4);
}
@media (min-width: 768px) {
  .rv-panel-grid { grid-template-columns: 1fr 380px; }
}

/* Images in review panel */
.rv-images {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.rv-figure { margin: 0; }
.rv-figure figcaption { font-size: .75rem; color: var(--ink-3); margin-bottom: 4px; }
.rv-case-img {
  width: 100%; border-radius: var(--radius-md); cursor: zoom-in;
  border: 1px solid var(--border);
}

/* Label comparison */
.rv-label-compare { margin-bottom: var(--space-3); }
.rv-label-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3);
}
.rv-label-col { text-align: center; }
.rv-label-col strong { display: block; font-size: .95rem; margin-top: 4px; }
.rv-conf-bar {
  height: 6px; background: var(--gray-200); border-radius: 3px;
  margin-top: 6px; overflow: hidden;
}
.rv-conf-fill {
  height: 100%; background: var(--accent-500); border-radius: 3px;
  transition: width .3s ease-out;
}

.rv-dual-badge {
  text-align: center; margin-top: var(--space-2);
  padding: 6px 12px; border-radius: var(--radius-md);
  background: rgba(139,92,246,.1); color: #7c3aed;
  border: 1px solid rgba(139,92,246,.25);
  font-weight: 700; font-size: .75rem; letter-spacing: .04em;
}

/* Case meta grid */
.rv-meta-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px var(--space-3);
  font-size: .8125rem;
}
.rv-meta-grid .rv-mk { color: var(--ink-3); }
.rv-meta-grid .rv-mv { font-weight: 500; }

/* Scoring */
.rv-scoring { padding: var(--space-3); }
.rv-score-dim { margin-bottom: var(--space-3); }
.rv-dim-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px; font-size: .8125rem; font-weight: 500;
}
.rv-dim-weight { color: var(--ink-3); font-size: .7rem; }

.rv-stars {
  display: flex; gap: 2px;
}
.rv-star {
  width: 32px; height: 32px; min-width: 44px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.5rem; color: var(--gray-300); cursor: pointer;
  transition: color .1s, transform .1s; user-select: none;
  border: none; background: none; padding: 0;
}
.rv-star:hover { transform: scale(1.15); }
.rv-star.filled { color: #f59e0b; }
.rv-star.filled:hover { color: #d97706; }

.rv-overall {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--space-2) 0; border-top: 1px solid var(--border);
  margin-top: var(--space-2); font-weight: 600;
}
.rv-overall strong { font-family: var(--mono); font-size: 1.1rem; color: var(--accent-600); }

/* Reject options */
.rv-reject-opts { margin-bottom: var(--space-3); }

/* Action buttons */
.rv-actions {
  display: flex; gap: var(--space-2); flex-wrap: wrap;
}
.rv-btn-approve {
  flex: 1; min-height: 48px; font-weight: 700; font-size: .9rem;
  background: var(--green); color: white; border: none; border-radius: var(--radius-md);
  cursor: pointer; transition: background .15s;
}
.rv-btn-approve:hover { background: #15803d; }
.rv-btn-approve:disabled { opacity: .5; cursor: not-allowed; }
.rv-btn-reject {
  flex: 1; min-height: 48px; font-weight: 700; font-size: .9rem;
  background: var(--red); color: white; border: none; border-radius: var(--radius-md);
  cursor: pointer; transition: background .15s;
}
.rv-btn-reject:hover { background: #b91c1c; }
.rv-btn-flag {
  min-height: 48px; font-weight: 600; font-size: .8rem;
  background: none; color: var(--amber); border: 1px solid var(--amber);
  border-radius: var(--radius-md); cursor: pointer; padding: 0 var(--space-3);
  transition: background .15s;
}
.rv-btn-flag:hover { background: var(--amber-bg); }

/* Similar cases strip */
.rv-similar-strip {
  display: flex; gap: var(--space-2); overflow-x: auto;
  padding-bottom: var(--space-2); -webkit-overflow-scrolling: touch;
}
.rv-similar-card {
  flex-shrink: 0; text-align: center; width: 100px;
}
.rv-similar-thumb {
  width: 88px; height: 88px; border-radius: var(--radius-md);
  object-fit: cover; border: 2px solid var(--border);
}
.rv-similar-label { font-size: .7rem; color: var(--ink-3); margin-top: 4px; }

/* Previous reviews */
.rv-prev-review-card {
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
  border: 1px solid var(--border); margin-bottom: var(--space-2);
  font-size: .8125rem;
}
.rv-prev-head { display: flex; justify-content: space-between; margin-bottom: 4px; }
.rv-prev-name { font-weight: 600; }
.rv-prev-date { color: var(--ink-3); font-size: .75rem; }
.rv-prev-scores { display: flex; gap: var(--space-2); flex-wrap: wrap; font-size: .75rem; color: var(--ink-3); }
.rv-prev-verdict { font-weight: 600; margin-top: 4px; }
.rv-prev-verdict.approve { color: var(--green); }
.rv-prev-verdict.reject { color: var(--red); }
.rv-prev-verdict.flag_bad { color: var(--amber); }

/* Dashboard */
.rv-dashboard { display: flex; flex-direction: column; gap: var(--space-3); }
.rv-dash-card {
  padding: var(--space-4); border-radius: var(--radius-lg);
  border: 1px solid var(--border); background: var(--surface);
}
.rv-dash-card h3 { margin: 0 0 var(--space-3); font-size: 1rem; }
.rv-dash-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--space-3);
}
.rv-dash-stat { text-align: center; }
.rv-dash-stat .rv-dash-num {
  display: block; font-size: 1.5rem; font-family: var(--mono); font-weight: 700;
}
.rv-dash-stat .rv-dash-label { font-size: .75rem; color: var(--ink-3); }

/* Access denied */
.rv-access-denied {
  text-align: center; padding: var(--space-8) var(--space-4);
  color: var(--ink-3); font-size: 1rem;
}

/* Mobile adjustments */
@media (max-width: 767px) {
  .rv-images { grid-template-columns: 1fr; }
  .rv-case-img { max-height: 300px; object-fit: contain; }
  .rv-star { min-width: 48px; min-height: 48px; font-size: 1.75rem; }
  .rv-actions { flex-direction: column; }
  .rv-btn-approve, .rv-btn-reject { min-height: 52px; }
  .rv-label-row { grid-template-columns: 1fr; gap: var(--space-2); }
  .rv-stats-bar { gap: var(--space-1); }
  .rv-stats-pill { min-width: 60px; padding: var(--space-1) var(--space-2); }
  .rv-stats-pill strong { font-size: 1rem; }
  .rv-queue-thumb { width: 48px; height: 48px; }
}

/* ============================ Annotation competition (leaderboard / admin console / student status) ============================ */

.comp-lb-title { margin: 8px 0 14px; font-weight: 700; }
.comp-lb-hint { font-weight: 400; color: #64748b; }

.comp-table-wrap { overflow: auto; border: 1px solid #e2e8f0; border-radius: 10px; margin-bottom: 14px; }
.comp-table { border-collapse: collapse; width: 100%; font-size: 12px; }
.comp-table th, .comp-table td { padding: 7px 10px; text-align: left; }
.comp-table thead tr { background: #f8fafc; }
.comp-lb-scroll .comp-table thead tr { background: #fff; }
.comp-table tbody tr { border-top: 1px solid #eef2f7; }
.comp-c { text-align: center !important; }
.comp-rank { font-weight: 700; }
.comp-credited { font-weight: 700; color: #0f766e; }
.comp-muted { color: #64748b; }
.comp-good { color: #15803d; }
.comp-bad { color: #b91c1c; }
.comp-mono { font-family: ui-monospace, monospace; }

.comp-panel { margin-bottom: 14px; border: 1px solid #e2e8f0; border-radius: 10px; overflow: hidden; }
.comp-statbar { display: flex; gap: 18px; flex-wrap: wrap; background: #f8fafc; padding: 10px 12px; border-bottom: 1px solid #e2e8f0; }
.comp-stat-num { font-size: 18px; color: #0f172a; }
.comp-stat-num.comp-good { color: #15803d; }
.comp-stat-num.comp-bad { color: #b91c1c; }
.comp-toggle { border: 0; color: #fff; border-radius: 7px; padding: 6px 10px; font-weight: 600; cursor: pointer; }
.comp-btn-close { background: #b91c1c; }
.comp-btn-open { background: #15803d; }
.comp-export { margin-left: auto; border: 0; background: #0f766e; color: #fff; border-radius: 7px; padding: 6px 10px; text-decoration: none; font-weight: 600; }
.comp-integrity { display: flex; gap: 12px; flex-wrap: wrap; padding: 10px 12px; border-bottom: 1px solid #e2e8f0; background: #fff; }
.comp-integrity b { color: #0f172a; }
.comp-coverage { margin: 14px 0; padding: 12px 14px; background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; }
.comp-coverage-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; flex-wrap: wrap; gap: 6px; }
.cov-summary { font-size: 12px; color: #64748b; }
.cov-row { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
.cov-name { flex: 0 0 40%; font-size: 12px; color: #334155; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cov-track { flex: 1; height: 10px; background: #f1f5f9; border-radius: 999px; overflow: hidden; }
.cov-fill { display: block; height: 100%; border-radius: 999px; }
.cov-fill.cov-full { background: #16a34a; }
.cov-fill.cov-mid { background: #f59e0b; }
.cov-fill.cov-low { background: #dc2626; }
.cov-fill.cov-site { background: #0ea5e9; }
.cov-subhead { margin: 12px 0 6px; font-size: 12px; font-weight: 700; color: #64748b; }
.cov-num { flex: 0 0 auto; font-size: 11px; color: #64748b; min-width: 44px; text-align: right; }
@media (prefers-color-scheme: dark) {
  .comp-coverage { background: #0f172a; border-color: #1e293b; }
  .cov-name { color: #cbd5e1; } .cov-track { background: #1e293b; }
}
.comp-integrity b.comp-good { color: #15803d; }
.comp-integrity b.comp-bad { color: #b91c1c; }
.comp-warnbar { padding: 10px 12px; border-bottom: 1px solid #e2e8f0; font-size: 12px; color: #334155; }
.comp-warnbar.warn { background: #fff7ed; }
.comp-warnbar.ok { background: #f0fdf4; }
.comp-warn-label { color: #9f1239; }
.comp-ok-label { color: #15803d; }
.comp-backup-cmd { margin-top: 5px; color: #64748b; }
.comp-lb-scroll { max-height: 300px; overflow: auto; }
.comp-lb-scroll .comp-table th, .comp-lb-scroll .comp-table td { padding: 7px 9px; }
.comp-flag-count { color: #64748b; font-weight: 700; }
.comp-flag-count.flagged { color: #b91c1c; }

.comp-suspicious { margin-bottom: 14px; border: 1px solid #fecaca; background: #fff7ed; border-radius: 10px; padding: 10px 12px; }
.comp-suspicious summary { cursor: pointer; font-weight: 700; color: #9f1239; }
.comp-suspicious-scroll { max-height: 220px; overflow: auto; margin-top: 8px; }
.comp-sus-table { border-collapse: collapse; width: 100%; font-size: 12px; background: #fff; }
.comp-sus-table th, .comp-sus-table td { padding: 6px 8px; text-align: left; }
.comp-suspicious-scroll .comp-sus-table tbody tr { border-top: 1px solid #fee2e2; }
.comp-flags-cell { color: #b91c1c; }
.comp-judge-load { margin-bottom: 14px; font-size: 12px; color: #475569; }

.comp-my-status { border: 1px solid #bae6fd; background: #f0f9ff; border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; }
.comp-my-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.comp-my-title { color: #0f172a; }
.comp-rank-pill {
  background: linear-gradient(135deg, #0f766e, #14b8a6);
  color: #fff; padding: 2px 10px; border-radius: 999px; font-size: 13px;
  white-space: nowrap;
}
.comp-rank-pill b { font-size: 15px; }
.comp-my-scroll { overflow: auto; margin-top: 8px; }
.comp-my-tr { border-top: 1px solid #e0f2fe; }
.comp-notes-bad { color: #9f1239; }
.comp-notes-ok { color: #64748b; }
.comp-boost { margin-top: 10px; padding: 10px 12px; border: 1px solid #fde68a; background: #fffbeb; border-radius: 10px; }
.comp-boost-title { color: #92400e; display: block; margin-bottom: 6px; }
.comp-boost-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }
.comp-boost-line { margin: 6px 0; font-size: 13px; line-height: 1.9; }
.comp-boost-lbl { color: #78350f; font-weight: 600; }
.comp-boost-tip { margin-top: 8px; font-size: 12px; color: #92400e; }
.comp-chip { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #e2e8f0; color: #334155; font-size: 12px; }
.comp-chip-rare { background: #fecaca; color: #991b1b; font-weight: 600; }
.comp-cohort-needs {
  margin: 4px 0 10px; padding: 8px 10px; font-size: 13px;
  background: linear-gradient(135deg, #ecfeff, #cffafe);
  border: 1px solid #a5f3fc; border-radius: var(--radius, 8px);
}
.comp-cohort-lbl { font-weight: 700; color: #0e7490; margin-inline-end: 4px; }
.comp-chip-cohort { background: #0e7490; color: #fff; font-weight: 600; margin: 2px; }
@media (prefers-color-scheme: dark) {
  .comp-cohort-needs { background: rgba(14,116,144,.18); border-color: #155e75; }
  .comp-cohort-lbl { color: #67e8f9; }
}
.comp-rules-link { margin-top: 10px; background: none; border: none; color: #92400e; font-weight: 600; font-size: 13px; cursor: pointer; padding: 0; text-decoration: underline; }
.comp-rules-link:hover { color: #78350f; }

/* Competition onboarding modal */
.comp-onb-overlay { position: fixed; inset: 0; z-index: 10000; display: flex; align-items: center; justify-content: center;
  background: rgba(15,23,42,.6); padding: 20px; overflow-y: auto; }
.comp-onb-card { background: #fff; color: #0f172a; width: 100%; max-width: 560px; border-radius: 18px;
  padding: 26px 28px; box-shadow: 0 24px 70px rgba(0,0,0,.4); font: 14px/1.55 system-ui, sans-serif; margin: auto; }
.comp-onb-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.comp-onb-trophy { font-size: 30px; }
.comp-onb-head h2 { font-size: 20px; margin: 0; color: #0f172a; }
.comp-onb-mission { color: #475569; margin: 0 0 18px; }
.comp-onb-step { display: flex; gap: 14px; padding: 12px 0; border-top: 1px solid #f1f5f9; }
.comp-onb-step-icon { font-size: 24px; flex-shrink: 0; width: 34px; text-align: center; }
.comp-onb-step b { color: #0f172a; }
.comp-onb-step p { margin: 3px 0 0; color: #64748b; font-size: 13px; }
.comp-onb-scoring { margin: 16px 0 0; padding: 14px 16px; background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: 12px; }
.comp-onb-scoring b { color: #065f46; }
.comp-onb-scoring ul { margin: 8px 0 0; padding-inline-start: 20px; color: #047857; font-size: 13px; }
.comp-onb-scoring li { margin: 3px 0; }
.comp-onb-fair { margin: 14px 0 0; padding: 14px 16px; background: #fef2f2; border: 1px solid #fecaca; border-radius: 12px; }
.comp-onb-fair b { color: #991b1b; }
.comp-onb-fair p { margin: 4px 0 0; color: #b91c1c; font-size: 13px; }
.comp-onb-note { margin: 14px 0 0; padding: 12px 16px; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 12px; color: #1e40af; font-size: 13px; white-space: pre-wrap; }
.comp-onb-cta { margin-top: 22px; width: 100%; padding: 13px; border: none; border-radius: 12px;
  background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; font-weight: 700; font-size: 15px; cursor: pointer; }
.comp-onb-cta:hover { filter: brightness(1.05); }
.comp-onb-overlay[dir="rtl"] .comp-onb-step { flex-direction: row; }

/* Competition review-pipeline monitor */
.mon-panel { margin: 14px 0; padding: 14px 16px; border: 1px solid #cbd5e1; border-radius: 12px; background: #f8fafc; }
.mon-title { font-weight: 700; color: #0f172a; margin-bottom: 10px; }
.mon-alerts { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.mon-alert { padding: 8px 12px; border-radius: 8px; font-size: 13px; font-weight: 500; }
.mon-critical { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.mon-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.mon-ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.mon-flow { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.mon-phase { flex: 1; min-width: 120px; padding: 12px; border: 1px solid #e2e8f0; border-radius: 10px; background: #fff; text-align: center; }
.mon-phase-done { background: #f0fdf4; border-color: #bbf7d0; }
.mon-bottleneck { border-color: #f59e0b; box-shadow: 0 0 0 2px #fde68a; }
.mon-phase-head { font-size: 12px; font-weight: 600; color: #475569; }
.mon-bottleneck-tag { color: #b45309; font-weight: 700; text-transform: uppercase; font-size: 10px; }
.mon-phase-num { font-size: 30px; font-weight: 800; color: #0f172a; line-height: 1.1; margin: 4px 0; }
.mon-phase-sub { font-size: 11px; color: #94a3b8; }
.mon-phase-meta { font-size: 11px; color: #64748b; margin-top: 6px; }
.mon-phase-breach { font-size: 11px; color: #dc2626; font-weight: 600; margin-top: 3px; }
.mon-arrow { display: flex; align-items: center; color: #cbd5e1; font-size: 22px; font-weight: 700; }
.mon-stats { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: #334155; margin-bottom: 10px; }
.mon-stats b { color: #0f172a; }
.mon-spark { display: flex; gap: 6px; align-items: flex-end; margin-bottom: 10px; }
.mon-spark-col { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.mon-spark-bar { width: 22px; background: linear-gradient(180deg, #38bdf8, #0284c7); border-radius: 3px 3px 0 0; }
.mon-spark-col span { font-size: 9px; color: #94a3b8; }
.mon-idle { font-size: 12px; color: #92400e; background: #fffbeb; border-radius: 8px; padding: 6px 10px; }

/* Billing & usage card (admin console) */
.billing-card { margin-bottom: 14px; padding: 14px 16px; border: 1px solid #bae6fd; background: #f0f9ff; border-radius: 12px; }
.billing-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.billing-head b { color: #0c4a6e; }
.billing-plan { font-size: 13px; font-weight: 600; color: #0369a1; background: #e0f2fe; border-radius: 999px; padding: 2px 10px; }
.billing-usage { font-size: 13px; color: #334155; margin: 8px 0 6px; }
.billing-bar { height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.billing-bar-fill { height: 100%; border-radius: 999px; transition: width .3s; }
.billing-plans { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 6px; }
.billing-plan-btn { flex: 1; min-width: 90px; display: flex; flex-direction: column; gap: 2px; align-items: center;
  padding: 8px 10px; border: 1px solid #7dd3fc; background: #fff; color: #0369a1; border-radius: 10px; cursor: pointer; font-weight: 600; }
.billing-plan-btn span { font-size: 11px; font-weight: 400; color: #64748b; }
.billing-plan-btn:hover:not(.current) { background: #e0f2fe; }
.billing-plan-btn.current { border-color: #0f766e; background: #ecfdf5; color: #065f46; cursor: default; }
.billing-note { font-size: 11px; color: #64748b; }
.billing-msg { margin-top: 8px; font-size: 12px; color: #9f1239; }

/* North-Star progress card */
.ns-card { margin: 12px 0; padding: 14px 16px; border: 1px solid #fde68a; background: linear-gradient(135deg,#fffbeb,#fef9c3); border-radius: 12px; }
.ns-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.ns-head b { color: #92400e; } .ns-head span { font-weight: 700; color: #b45309; }
.ns-bar { height: 10px; background: #fde68a; border-radius: 999px; overflow: hidden; margin: 8px 0 6px; }
.ns-bar-fill { height: 100%; background: linear-gradient(90deg,#f59e0b,#d97706); border-radius: 999px; transition: width .4s; }
.ns-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: #78350f; }
.ns-meta b { color: #92400e; }

/* Prevalence insights card */
.ins-card { margin: 12px 0; padding: 14px 16px; border: 1px solid #ddd6fe; background: #faf5ff; border-radius: 12px; }
.ins-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.ins-head b { color: #6b21a8; } .ins-head span { font-size: 12px; color: #7e22ce; }
.ins-row { display: grid; grid-template-columns: 1fr 100px auto; gap: 10px; align-items: center; padding: 3px 0; font-size: 13px; }
.ins-label { color: #334155; } .ins-zoo { font-size: 10px; color: #b91c1c; background: #fee2e2; border-radius: 999px; padding: 1px 6px; }
.ins-track { height: 7px; background: #ede9fe; border-radius: 999px; overflow: hidden; }
.ins-fill { display: block; height: 100%; background: #8b5cf6; border-radius: 999px; }
.ins-count { color: #64748b; font-size: 12px; text-align: right; white-space: nowrap; }
.ins-note { margin-top: 8px; font-size: 11px; color: #7e22ce; }
