/* AST-Smart v3: clean, premium lab UI */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #f5f6fb;
  --ink: #0f172a;
  --muted: #64748b;
  --line: rgba(15, 23, 42, 0.08);
  --card: rgba(255, 255, 255, 0.78);
  --card-solid: #ffffff;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-3: #06b6d4;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 45%, #06b6d4 100%);
  --S: #10b981;  --S-bg: #ecfdf5;  --S-ink: #047857;
  --I: #f59e0b;  --I-bg: #fffbeb;  --I-ink: #b45309;
  --R: #f43f5e;  --R-bg: #fff1f2;  --R-ink: #be123c;
  --U: #94a3b8;  --U-bg: #f1f5f9;  --U-ink: #475569;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -10px rgba(30, 41, 99, .18);
  --shadow-lg: 0 2px 6px rgba(16, 24, 40, .05), 0 24px 60px -20px rgba(30, 41, 99, .35);
  --radius: 18px;
}

html, body { height: 100%; }
body.app-body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-feature-settings: 'cv11', 'ss01';
  overflow: hidden;
}

/* Ambient aurora */
.aurora { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.aurora span { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .55; }
.aurora span:nth-child(1) { width: 46vw; height: 46vw; left: -12vw; top: -18vw; background: radial-gradient(circle, #c7d2fe, transparent 65%); }
.aurora span:nth-child(2) { width: 40vw; height: 40vw; right: -10vw; top: -8vw; background: radial-gradient(circle, #a5f3fc, transparent 65%); opacity: .45; }
.aurora span:nth-child(3) { width: 50vw; height: 50vw; right: 10vw; bottom: -30vw; background: radial-gradient(circle, #ddd6fe, transparent 65%); opacity: .5; }
header, main, .modal, .drawer, .toasts { position: relative; z-index: 1; }

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(100, 116, 139, .28); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- Top bar ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 18px; z-index: 30;
  background: rgba(255, 255, 255, .7);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; color: #fff;
  background: var(--grad); box-shadow: 0 6px 16px -6px rgba(99, 102, 241, .7), inset 0 1px 0 rgba(255,255,255,.35);
}
.brand-mark svg { width: 20px; height: 20px; }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: rgba(15, 23, 42, .05); border: 1px solid var(--line); }
.seg-btn { padding: 6px 12px; border-radius: 9px; font-size: 13px; font-weight: 500; color: #475569; transition: all .15s ease; white-space: nowrap; }
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-active { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); font-weight: 600; }
.seg-sm .seg-btn { padding: 5px 10px; font-size: 12px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px;
  border-radius: 10px; font-size: 12.5px; font-weight: 500; color: #334155;
  background: rgba(255, 255, 255, .85); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  transition: all .15s ease;
}
.chip:hover { background: #fff; border-color: rgba(99, 102, 241, .35); }
.chip-organism { color: #4338ca; background: linear-gradient(180deg, #eef2ff, #e0e7ff); border-color: #c7d2fe; }
.chip.is-private { color: #047857; background: linear-gradient(180deg, #ecfdf5, #d1fae5); border-color: #a7f3d0; }
.live-dot { width: 7px; height: 7px; border-radius: 99px; background: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, .2); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); } }

.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 10px; color: #475569; background: rgba(255,255,255,.85); border: 1px solid var(--line); transition: all .15s; }
.icon-btn:hover { color: var(--ink); background: #fff; }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn-sm { width: 30px; height: 30px; font-size: 12px; }
.icon-btn-sm svg { width: 15px; height: 15px; }

/* ---------------- Buttons & inputs ---------------- */
.btn { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 15px; border-radius: 11px; font-size: 13px; font-weight: 600; transition: all .15s ease; white-space: nowrap; }
.btn-sm { height: 30px; padding: 0 11px; font-size: 12px; border-radius: 9px; }
.btn-primary { color: #fff; background: linear-gradient(180deg, #6d70f5, #5457e8); box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 8px 18px -8px rgba(79, 70, 229, .8), 0 0 0 1px rgba(67, 56, 202, .6); }
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .5; transform: none; cursor: not-allowed; }
.btn-ghost { color: #334155; background: rgba(255,255,255,.9); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.btn-ghost:hover { background: #fff; border-color: rgba(99,102,241,.35); }
.btn-success { color: #fff; background: linear-gradient(180deg, #19c08a, #0ea371); box-shadow: 0 6px 14px -8px rgba(5, 150, 105, .9), 0 0 0 1px rgba(4, 120, 87, .5); }
.link-btn { font-size: 12px; font-weight: 600; color: #4f46e5; }
.link-btn:hover { text-decoration: underline; }

.input, .field-select {
  height: 38px; padding: 0 12px; border-radius: 11px; font-size: 13px; color: var(--ink);
  background: #fff; border: 1px solid rgba(15, 23, 42, .12); box-shadow: var(--shadow-sm); outline: none; transition: all .15s;
}
.input:focus, .field-select:focus { border-color: #818cf8; box-shadow: 0 0 0 4px rgba(99, 102, 241, .15); }
.field-select { padding-right: 30px; appearance: none; min-width: 0; flex: 1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 14px; }

.glass { background: var(--card); backdrop-filter: blur(18px) saturate(150%); -webkit-backdrop-filter: blur(18px) saturate(150%); border: 1px solid rgba(255,255,255,.7); box-shadow: var(--shadow), 0 0 0 1px var(--line); border-radius: var(--radius); }

/* ---------------- Home ---------------- */
.home-inner { max-width: 1180px; margin: 0 auto; padding: 36px 24px 64px; }
.hero { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, .88fr); gap: 36px; align-items: center; }
@media (max-width: 1023px) { .hero { grid-template-columns: 1fr; } .hero-visual { display: none; } }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; color: #4338ca; background: rgba(238, 242, 255, .9); border: 1px solid #e0e7ff; }
.eyebrow-dot { width: 18px; height: 18px; border-radius: 99px; background: var(--grad); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.hero-title { margin-top: 16px; font-size: clamp(30px, 4.2vw, 50px); line-height: 1.05; font-weight: 800; letter-spacing: -0.035em; color: #0b1120; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { margin-top: 14px; max-width: 560px; font-size: 15.5px; line-height: 1.6; color: #475569; }

.setup { margin-top: 24px; padding: 14px; }
.setup-row { display: flex; flex-wrap: wrap; gap: 12px; padding: 2px 2px 14px; }
.setup-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.setup-field.grow { flex: 1 1 220px; }
.field-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #64748b; }
.field-btn { height: 38px; display: inline-flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 150px; padding: 0 12px; border-radius: 11px; font-size: 13px; font-weight: 600; color: #3730a3; background: #fff; border: 1px solid rgba(15,23,42,.12); box-shadow: var(--shadow-sm); }
.field-btn:hover { border-color: #a5b4fc; }

.dropzone {
  position: relative; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 18px; border-radius: 14px; cursor: pointer; transition: all .2s ease;
  background: linear-gradient(180deg, rgba(248, 250, 252, .9), rgba(241, 245, 249, .8));
  border: 1.5px dashed rgba(99, 102, 241, .35);
}
.dropzone:hover, .dropzone.dragover { border-color: #6366f1; background: linear-gradient(180deg, #eef2ff, #f5f3ff); box-shadow: 0 0 0 5px rgba(99,102,241,.1); }
.dz-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; color: #fff; background: var(--grad); box-shadow: 0 10px 20px -10px rgba(99,102,241,.9); flex-shrink: 0; }
.dz-icon svg { width: 22px; height: 22px; }
.dz-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.trust { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 12.5px; color: #475569; }
.trust li { display: flex; align-items: center; gap: 7px; }
.trust-ic { width: 20px; height: 20px; border-radius: 7px; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #4f46e5; background: #eef2ff; border: 1px solid #e0e7ff; }

.hero-visual { position: relative; aspect-ratio: 1; max-width: 520px; width: 100%; justify-self: center; }
.orb { position: absolute; inset: 6%; border-radius: 50%; background: radial-gradient(circle at 35% 30%, rgba(129, 140, 248, .55), rgba(6, 182, 212, .25) 45%, transparent 70%); filter: blur(30px); }
.hero-plate { position: absolute; inset: 9%; width: 82%; height: 82%; border-radius: 50%; object-fit: cover;
  box-shadow: 0 40px 80px -30px rgba(15, 23, 42, .55), 0 0 0 10px rgba(255,255,255,.55), 0 0 0 11px rgba(15,23,42,.06);
  -webkit-mask-image: radial-gradient(circle, #000 70%, rgba(0,0,0,.85) 100%); mask-image: radial-gradient(circle, #000 70%, rgba(0,0,0,.85) 100%);
  animation: floaty 9s ease-in-out infinite; }
.hero-plate-sm { position: absolute; width: 30%; border-radius: 50%; opacity: .9; box-shadow: 0 24px 40px -20px rgba(15,23,42,.6), 0 0 0 6px rgba(255,255,255,.6); }
.hero-plate-sm.a { right: -4%; top: 2%; animation: floaty 11s ease-in-out infinite reverse; }
.hero-plate-sm.b { left: -6%; bottom: 0; width: 26%; animation: floaty 13s ease-in-out infinite; }
.hero-rings { position: absolute; inset: 3%; width: 94%; height: 94%; }
.hero-rings circle { fill: none; stroke: rgba(99,102,241,.35); stroke-width: .3; stroke-dasharray: 1.2 1.6; animation: spin 60s linear infinite; transform-origin: 50% 50%; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes floaty { 50% { transform: translateY(-8px); } }
.float-card { position: absolute; display: flex; align-items: center; gap: 10px; padding: 9px 13px 9px 9px; border-radius: 14px;
  background: rgba(255,255,255,.82); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,.8); box-shadow: var(--shadow-lg); font-size: 12px; line-height: 1.2; animation: floaty 7s ease-in-out infinite; }
.float-card b { display: block; font-weight: 700; color: #0f172a; }
.float-card small { color: #64748b; font-size: 11px; }
.fc-1 { left: -4%; top: 22%; }
.fc-2 { right: -2%; top: 54%; animation-delay: -2s; }
.fc-3 { left: 14%; bottom: 3%; animation-delay: -4s; }
.sir { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; }
.sir-S { background: linear-gradient(180deg, #34d399, #059669); }
.sir-warn { background: linear-gradient(180deg, #fbbf24, #d97706); }
.sir-ok { background: var(--grad); }

.steps { margin-top: 40px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 767px) { .steps { grid-template-columns: 1fr; } }
.step { display: flex; gap: 12px; padding: 16px; }
.step b { font-size: 14px; }
.step p { margin-top: 3px; font-size: 12.5px; line-height: 1.5; color: #64748b; }
.step-n { flex-shrink: 0; width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #4f46e5; background: #eef2ff; border: 1px solid #e0e7ff; }

.recent { margin-top: 40px; }
.section-title { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.recent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.plate-card { position: relative; border-radius: 16px; overflow: hidden; text-align: left; background: #0b1120; box-shadow: var(--shadow); transition: transform .2s ease, box-shadow .2s ease; aspect-ratio: 1; }
.plate-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.plate-card img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.04); transition: transform .4s ease; }
.plate-card:hover img { transform: scale(1.09); }
.plate-card .pc-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(2,6,23,0) 35%, rgba(2,6,23,.85)); }
.plate-card .pc-body { position: absolute; left: 12px; right: 12px; bottom: 10px; color: #fff; }
.plate-card .pc-title { font-size: 13px; font-weight: 600; font-style: italic; }
.plate-card .pc-meta { font-size: 11px; opacity: .75; margin-top: 1px; }
.plate-card .pc-tags { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 99px; backdrop-filter: blur(8px); }
.tag-S { background: rgba(16,185,129,.85); color: #fff; }
.tag-I { background: rgba(245,158,11,.9); color: #fff; }
.tag-R { background: rgba(244,63,94,.9); color: #fff; }
.tag-ok { background: rgba(255,255,255,.88); color: #047857; }
.tag-warn { background: rgba(255,255,255,.88); color: #b45309; }
.recent-empty { grid-column: 1 / -1; padding: 28px; text-align: center; font-size: 13px; color: #64748b; border-radius: 16px; border: 1.5px dashed rgba(100,116,139,.25); background: rgba(255,255,255,.5); }
.skeleton { aspect-ratio: 1; border-radius: 16px; background: linear-gradient(90deg, rgba(226,232,240,.7), rgba(241,245,249,.9), rgba(226,232,240,.7)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------------- Analysis layout ---------------- */
.analysis { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 14px; padding: 14px; }
@media (max-width: 1023px) { .analysis { grid-template-columns: 1fr; grid-template-rows: minmax(360px, 55vh) auto; overflow-y: auto; } }

.stage {
  position: relative; display: flex; flex-direction: column; min-height: 0; border-radius: 22px; overflow: hidden;
  background: radial-gradient(120% 90% at 50% 0%, #1b2547 0%, #0b1120 55%, #070b16 100%);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(15,23,42,.6);
}
.stage::before { content: ''; position: absolute; inset: 0; pointer-events: none; background-image: radial-gradient(rgba(148,163,184,.12) 1px, transparent 1px); background-size: 22px 22px; mask-image: radial-gradient(circle at 50% 50%, #000, transparent 75%); }
.stage-bar { position: relative; z-index: 3; display: flex; align-items: center; gap: 8px; padding: 12px; }
.glass-dark-pill { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 13px; border-radius: 11px; font-size: 12.5px; color: #e2e8f0; background: rgba(15, 23, 42, .6); border: 1px solid rgba(148,163,184,.18); backdrop-filter: blur(12px); }
.glass-dark-btn { height: 34px; min-width: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 11px; color: #e2e8f0; background: rgba(15, 23, 42, .6); border: 1px solid rgba(148,163,184,.18); backdrop-filter: blur(12px); transition: all .15s; }
.glass-dark-btn:hover { background: rgba(30, 41, 59, .8); color: #fff; }
.glass-dark-btn.is-on { background: rgba(99,102,241,.35); border-color: rgba(129,140,248,.6); }
.glass-light-btn { height: 34px; display: inline-flex; align-items: center; gap: 6px; padding: 0 13px; border-radius: 11px; font-size: 12.5px; font-weight: 600; color: #1e1b4b; background: rgba(255,255,255,.92); box-shadow: 0 8px 20px -10px rgba(0,0,0,.6); transition: all .15s; }
.glass-light-btn:hover { background: #fff; transform: translateY(-1px); }
.cal-badge { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 11px; font-size: 12px; font-weight: 600; border: 1px solid; backdrop-filter: blur(12px); cursor: help; }
.cal-good { color: #a7f3d0; background: rgba(6, 78, 59, .45); border-color: rgba(52, 211, 153, .35); }
.cal-ok { color: #bae6fd; background: rgba(12, 74, 110, .45); border-color: rgba(56, 189, 248, .35); }
.cal-warn { color: #fde68a; background: rgba(120, 53, 15, .45); border-color: rgba(251, 191, 36, .35); }
.cal-bad { color: #fecdd3; background: rgba(136, 19, 55, .5); border-color: rgba(251, 113, 133, .4); }

.stage-canvas { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 6px 18px 10px; }
.plate-wrap { position: relative; display: inline-flex; max-width: 100%; max-height: 100%; line-height: 0; }
#plate-image-viewer { max-width: 100%; max-height: calc(100vh - 210px); width: auto; height: auto; object-fit: contain; border-radius: 50%; user-select: none;
  box-shadow: 0 30px 70px -25px rgba(0,0,0,.9), 0 0 0 1px rgba(148,163,184,.15), 0 0 80px -20px rgba(99,102,241,.35); }
#plate-image-viewer.show-original { border-radius: 14px; }
.zone-overlay-svg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.stage-foot { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px 14px; color: #94a3b8; font-size: 11.5px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 9px; height: 9px; border-radius: 99px; display: inline-block; }
.lg-S { background: var(--S); box-shadow: 0 0 10px var(--S); }
.lg-I { background: var(--I); box-shadow: 0 0 10px var(--I); }
.lg-R { background: var(--R); box-shadow: 0 0 10px var(--R); }
.lg-U { background: var(--U); }
.hint { opacity: .8; }

/* SVG overlay elements */
.zone-ring { pointer-events: stroke; cursor: pointer; transition: stroke-width .15s ease, opacity .15s; }
.zone-fill { pointer-events: none; transition: fill-opacity .2s ease; }
.zone-group.dim { opacity: .35; }
.zone-group.is-active .zone-ring { stroke-width: 4px; }
.zone-group.is-active .zone-fill { fill-opacity: .22; }
.disk-hit { pointer-events: all; cursor: pointer; }
.pin { cursor: pointer; pointer-events: all; }
.pin text { font-family: Inter, system-ui, sans-serif; }
.drag-handle { cursor: grab; pointer-events: all; filter: drop-shadow(0 2px 4px rgba(0,0,0,.6)); }
.drag-handle:active { cursor: grabbing; }

.plate-tooltip { position: absolute; z-index: 50; pointer-events: none; transform: translate(-50%, -115%); padding: 9px 12px; border-radius: 12px; color: #f8fafc; font-size: 12px; background: rgba(15, 23, 42, .92); border: 1px solid rgba(148,163,184,.2); box-shadow: 0 20px 40px -15px rgba(0,0,0,.8); backdrop-filter: blur(10px); white-space: nowrap; }

/* ---------------- Review panel ---------------- */
.review { display: flex; flex-direction: column; min-height: 0; border-radius: 22px; overflow: hidden; background: rgba(255,255,255,.82); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); box-shadow: var(--shadow-lg), 0 0 0 1px var(--line); }
.review-head { padding: 16px 16px 12px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, rgba(255,255,255,.95), rgba(248,250,252,.8)); }
.sir-summary { display: flex; gap: 4px; flex-shrink: 0; }
.sum { font-size: 11.5px; font-weight: 700; padding: 4px 8px; border-radius: 8px; }
.sum-S { background: var(--S-bg); color: var(--S-ink); }
.sum-I { background: var(--I-bg); color: var(--I-ink); }
.sum-R { background: var(--R-bg); color: var(--R-ink); }
.progress-wrap { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.progress { flex: 1; height: 7px; border-radius: 99px; background: rgba(15,23,42,.07); overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #34d399, #10b981); transition: width .35s ease; }
.tab-btn { height: 28px; padding: 0 10px; border-radius: 8px; font-size: 12px; font-weight: 600; color: #64748b; display: inline-flex; align-items: center; gap: 5px; }
.tab-btn:hover { color: var(--ink); background: rgba(15,23,42,.04); }
.tab-btn.is-active { color: #3730a3; background: #eef2ff; }
.tab-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; font-size: 10.5px; display: inline-grid; place-items: center; color: #fff; background: #f59e0b; }
.tab-count.zero { background: #cbd5e1; }
.warn-banner { margin: 10px 12px 0; padding: 9px 11px; border-radius: 12px; font-size: 11.5px; line-height: 1.45; color: #92400e; background: linear-gradient(180deg, #fffbeb, #fef3c7); border: 1px solid #fde68a; }
.review-list { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.empty-note { padding: 40px 12px; text-align: center; font-size: 13px; color: #94a3b8; }
.review-foot { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: rgba(248,250,252,.85); }

.disk-card { position: relative; border-radius: 16px; background: #fff; border: 1px solid rgba(15,23,42,.08); box-shadow: var(--shadow-sm); padding: 11px; transition: border-color .15s, box-shadow .15s, transform .15s; cursor: pointer; }
.disk-card:hover { border-color: rgba(99,102,241,.35); }
.disk-card.is-active { border-color: #818cf8; box-shadow: 0 0 0 4px rgba(99,102,241,.12), var(--shadow); }
.disk-card.st-check { background: linear-gradient(180deg, #fffdf6, #fff); border-color: #fde68a; }
.disk-card.st-done { background: linear-gradient(180deg, #f6fefb, #fff); }
.disk-card::before { content: ''; position: absolute; left: -1px; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--U); }
.disk-card.sir-S::before { background: var(--S); }
.disk-card.sir-I::before { background: var(--I); }
.disk-card.sir-R::before { background: var(--R); }
.dc-top { display: flex; gap: 11px; align-items: center; }
.patch { width: 54px; height: 54px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: #e2e8f0; box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--ring, #cbd5e1), 0 6px 14px -6px rgba(15,23,42,.5); transition: transform .2s; }
.patch:hover { transform: scale(1.06); }
.patch-lg { width: 64px; height: 64px; }
.patch-zoom { position: fixed; z-index: 70; width: 260px; height: 260px; border-radius: 50%; pointer-events: none; box-shadow: 0 30px 60px -20px rgba(0,0,0,.6), 0 0 0 6px #fff; object-fit: cover; }
.dc-num { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; font-weight: 600; color: #94a3b8; }
.dc-name { font-size: 14px; font-weight: 650; font-weight: 600; color: #0f172a; line-height: 1.2; }
.code { font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 6px; color: #3730a3; background: #eef2ff; border: 1px solid #e0e7ff; }
.conf { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; color: #64748b; }
.conf-bar { width: 38px; height: 4px; border-radius: 99px; background: #e2e8f0; overflow: hidden; }
.conf-bar i { display: block; height: 100%; border-radius: 99px; }
.dc-right { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.stepper { display: inline-flex; align-items: center; height: 32px; border-radius: 10px; background: #f8fafc; border: 1px solid rgba(15,23,42,.1); }
.stepper button { width: 26px; height: 100%; font-weight: 700; color: #64748b; font-size: 15px; }
.stepper button:hover { color: #0f172a; }
.stepper input { width: 46px; text-align: center; font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 600; background: transparent; outline: none; color: #0f172a; }
.stepper .unit { font-size: 10px; color: #94a3b8; padding-right: 6px; margin-left: -4px; }
.sir-pills { display: flex; gap: 4px; }
.pill { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 7px; border-radius: 7px; font-size: 10.5px; font-weight: 700; }
.pill small { font-weight: 600; opacity: .7; font-size: 9.5px; letter-spacing: .02em; }
.pill-S { background: var(--S-bg); color: var(--S-ink); box-shadow: inset 0 0 0 1px #a7f3d0; }
.pill-I { background: var(--I-bg); color: var(--I-ink); box-shadow: inset 0 0 0 1px #fde68a; }
.pill-R { background: var(--R-bg); color: var(--R-ink); box-shadow: inset 0 0 0 1px #fecdd3; }
.pill-U { background: var(--U-bg); color: var(--U-ink); box-shadow: inset 0 0 0 1px #e2e8f0; }
.dc-flags { margin-top: 9px; display: flex; flex-direction: column; gap: 4px; }
.flag { display: flex; align-items: flex-start; gap: 6px; font-size: 11.5px; line-height: 1.35; color: #92400e; }
.flag::before { content: ''; flex-shrink: 0; margin-top: 5px; width: 5px; height: 5px; border-radius: 99px; background: #f59e0b; }
.dc-actions { margin-top: 9px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.mini { height: 28px; padding: 0 10px; border-radius: 8px; font-size: 11.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; color: #334155; background: #f8fafc; border: 1px solid rgba(15,23,42,.1); transition: all .12s; }
.mini:hover { background: #fff; border-color: #a5b4fc; color: #3730a3; }
.mini-confirm { color: #047857; background: #ecfdf5; border-color: #a7f3d0; }
.mini-confirm:hover { color: #065f46; background: #d1fae5; border-color: #6ee7b7; }
.mini-danger:hover { color: #be123c; border-color: #fecdd3; background: #fff1f2; }
.sugg { height: 26px; padding: 0 9px; border-radius: 99px; font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 600; color: #3730a3; background: #fff; border: 1px dashed #a5b4fc; display: inline-flex; align-items: center; gap: 5px; }
.sugg:hover { background: #eef2ff; border-style: solid; }
.sugg small { font-family: Inter, sans-serif; color: #94a3b8; font-weight: 500; }
.done-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; color: #047857; }

/* Full-screen plate viewer */
.viewer { position: fixed; inset: 0; z-index: 58; display: flex; flex-direction: column; background: radial-gradient(120% 80% at 50% 20%, #18213f, #070b16 70%); color: #e2e8f0; animation: fade .15s ease; }
.viewer.hidden { display: none; }
.viewer-top { display: flex; align-items: center; gap: 10px; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); }
.viewer-zoom { display: inline-flex; align-items: center; height: 34px; border-radius: 11px; background: rgba(15,23,42,.6); border: 1px solid rgba(148,163,184,.18); }
.viewer-zoom button { min-width: 32px; height: 100%; font-size: 16px; font-weight: 600; color: #e2e8f0; }
.viewer-zoom span { min-width: 44px; text-align: center; font-family: 'JetBrains Mono', monospace; font-size: 11px; color: #94a3b8; }
.viewer-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: none; cursor: grab; }
.viewer-stage:active { cursor: grabbing; }
.viewer-canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.viewer-canvas img { display: block; border-radius: 50%; user-select: none; -webkit-user-drag: none; box-shadow: 0 30px 80px -20px rgba(0,0,0,.9); }
.viewer-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.viewer-sheet { flex-shrink: 0; margin: 0 10px 10px; margin-bottom: max(10px, env(safe-area-inset-bottom)); padding: 12px; border-radius: 20px; color: #0f172a; background: rgba(255,255,255,.96); box-shadow: 0 -10px 40px -10px rgba(0,0,0,.5); max-width: 640px; width: calc(100% - 20px); align-self: center; }
.vs-row { display: flex; align-items: center; gap: 11px; }
.vs-actions { margin-top: 10px; display: flex; align-items: center; gap: 6px; }
.vs-nav { width: 40px; height: 40px; flex-shrink: 0; border-radius: 12px; font-size: 22px; line-height: 1; color: #334155; background: #f1f5f9; border: 1px solid rgba(15,23,42,.08); }
.vs-nav:active { background: #e2e8f0; }
.vs-hint { margin-top: 8px; text-align: center; font-size: 10.5px; color: #94a3b8; }
.vs-empty { padding: 8px 4px; text-align: center; font-size: 13px; color: #475569; }
.stepper-lg { height: 40px; }
.stepper-lg button { width: 34px; font-size: 18px; }
.stepper-lg input { width: 52px; font-size: 15px; }
body.viewer-open { overflow: hidden !important; }
#plate-image-viewer { cursor: zoom-in; }
.hint-mobile { display: none; }

/* Menus */
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; bottom: calc(100% + 6px); min-width: 200px; padding: 6px; border-radius: 14px; background: #fff; box-shadow: var(--shadow-lg), 0 0 0 1px var(--line); z-index: 20; }
.menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 9px; font-size: 13px; color: #334155; }
.menu button:hover { background: #f1f5f9; color: #0f172a; }

/* Scanning overlay */
.analysis-spinner { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(7, 11, 22, .55); backdrop-filter: blur(6px); }
.scan-card { text-align: center; padding: 28px 32px; border-radius: 22px; background: rgba(15, 23, 42, .85); border: 1px solid rgba(148,163,184,.18); box-shadow: 0 30px 80px -20px rgba(0,0,0,.8); }
.scan-ring { position: relative; width: 74px; height: 74px; margin: 0 auto 16px; border-radius: 50%; background: conic-gradient(from 0deg, transparent, #818cf8, #22d3ee, transparent 70%); animation: spin 1.1s linear infinite; }
.scan-ring span { position: absolute; inset: 5px; border-radius: 50%; background: #0f172a; }
.scan-ring::after { content: ''; position: absolute; inset: 26px; border-radius: 50%; background: #fff; box-shadow: 0 0 20px #818cf8; }

/* Modals & drawer */
.modal { position: fixed; inset: 0; z-index: 55; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(15, 23, 42, .42); backdrop-filter: blur(6px); animation: fade .15s ease; }
.modal.hidden { display: none; }
.modal-card { width: 100%; border-radius: 22px; background: #fff; box-shadow: 0 40px 100px -30px rgba(15,23,42,.6), 0 0 0 1px var(--line); animation: pop .18s cubic-bezier(.2,.9,.3,1.2); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 12px; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px 18px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 380px; max-width: 100%; z-index: 56; display: flex; flex-direction: column; background: rgba(255,255,255,.95); backdrop-filter: blur(18px); box-shadow: -30px 0 60px -30px rgba(15,23,42,.4); border-left: 1px solid var(--line); transition: transform .3s cubic-bezier(.2,.8,.2,1); }
.drawer-scrim { position: fixed; inset: 0; z-index: 55; background: rgba(15,23,42,.25); backdrop-filter: blur(2px); }
.hist-item { display: flex; gap: 10px; align-items: center; width: 100%; padding: 8px; border-radius: 14px; text-align: left; background: #fff; border: 1px solid var(--line); transition: all .15s; }
.hist-item:hover { border-color: #a5b4fc; box-shadow: var(--shadow); }
.hist-item img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: #0b1120; flex-shrink: 0; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 11px; text-align: left; font-size: 13px; color: #1e293b; }
.list-row:hover { background: #f1f5f9; }
.list-row .sub { font-size: 11.5px; color: #94a3b8; }
.howto { display: flex; gap: 11px; align-items: flex-start; }
.howto > span { flex-shrink: 0; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #4f46e5; background: #eef2ff; }
.panel-chip { height: 30px; padding: 0 10px; border-radius: 9px; font-family: 'JetBrains Mono', monospace; font-size: 11.5px; font-weight: 600; color: #475569; background: #f8fafc; border: 1px solid rgba(15,23,42,.1); transition: all .12s; }
.panel-chip:hover { border-color: #a5b4fc; }
.panel-chip.on { color: #fff; background: linear-gradient(180deg, #6d70f5, #5457e8); border-color: #4f46e5; }

/* Toasts */
.toasts { position: fixed; z-index: 80; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; max-width: min(380px, calc(100vw - 36px)); }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 9px; padding: 11px 13px; border-radius: 14px; font-size: 12.5px; line-height: 1.4; color: #0f172a; background: rgba(255,255,255,.96); backdrop-filter: blur(12px); box-shadow: var(--shadow-lg), 0 0 0 1px var(--line); transform: translateY(8px); opacity: 0; transition: all .25s ease; }
.toast.show { transform: none; opacity: 1; }
.toast .t-ic { flex-shrink: 0; width: 20px; height: 20px; border-radius: 7px; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff; }
.t-success .t-ic { background: #10b981; } .t-error .t-ic { background: #f43f5e; } .t-warning .t-ic { background: #f59e0b; } .t-info .t-ic { background: #6366f1; }

/* Camera reticle & shutter (scanner views) */
.reticle-overlay { position: absolute; inset: 0; pointer-events: none; display: flex; align-items: center; justify-content: center; }
.reticle-circle { width: min(78vw, 380px); height: min(78vw, 380px); border-radius: 50%; border: 2px solid rgba(255,255,255,.75); box-shadow: 0 0 0 9999px rgba(2, 6, 23, .45), 0 0 30px rgba(129,140,248,.5) inset; position: relative; }
.reticle-crosshair { position: absolute; inset: 50%; transform: translate(-50%, -50%); width: 22px; height: 22px; }
.reticle-crosshair::before, .reticle-crosshair::after { content: ''; position: absolute; background: rgba(255,255,255,.85); }
.reticle-crosshair::before { top: 10px; left: 0; width: 22px; height: 2px; }
.reticle-crosshair::after { top: 0; left: 10px; width: 2px; height: 22px; }
.shutter-btn { width: 80px; height: 80px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.18); border: 4px solid #fff; backdrop-filter: blur(8px); box-shadow: 0 20px 40px -10px rgba(0,0,0,.7); transition: transform .12s ease; }
.shutter-btn span { width: 60px; height: 60px; border-radius: 50%; background: var(--grad); box-shadow: inset 0 2px 0 rgba(255,255,255,.4); }
.shutter-btn:active { transform: scale(.92); }

.glass-dark-pill, .glass-dark-btn, .glass-light-btn, .cal-badge { white-space: nowrap; }
/* ---------- Phones & tablets: one naturally scrolling page ---------- */
@media (max-width: 1023px) {
  html, body.app-body { height: auto; min-height: 100%; }
  body.app-body { display: block; overflow-x: hidden; overflow-y: auto; }
  .topbar { position: sticky; top: 0; }
  main.flex-1 { min-height: calc(100vh - 56px); }
  #view-workbench, #empty-dropzone-view, #analysis-view { height: auto !important; overflow: visible !important; }
  .analysis { display: flex; flex-direction: column; gap: 12px; padding: 10px 10px 0; }
  .stage { border-radius: 20px; }
  .stage-canvas { padding: 2px 8px 6px; }
  .plate-wrap { width: 100%; max-width: 560px; }
  #plate-image-viewer { width: 100%; max-height: none; }
  .stage-foot { padding: 8px 12px 12px; flex-wrap: wrap; }
  .legend { gap: 10px; font-size: 11px; }
  .hint-mobile { display: inline-flex; margin-left: auto; font-size: 11.5px; font-weight: 600; color: #c7d2fe; }
  .review { overflow: visible; border-radius: 20px; }
  .review-head { border-radius: 20px 20px 0 0; }
  .review-list { overflow: visible; flex: none; padding: 10px; }
  .review-foot { position: sticky; bottom: 0; z-index: 6; border-radius: 0 0 20px 20px; padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: rgba(248,250,252,.94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
  .menu { bottom: calc(100% + 6px); }
  .toasts { bottom: 86px; }
}
@media (max-width: 640px) {
  .stage-bar { gap: 6px; padding: 10px; }
  .cal-badge .cal-text, .glass-light-btn .btn-text, #result-disc-count, .stage-bar .opacity-40 { display: none; }
  .cal-badge { padding: 0 10px; }
  .topbar { padding: 8px 12px; }
  .home-inner { padding: 22px 16px 48px; }
  .dz-actions { margin-left: 0; width: 100%; }
  .dz-actions .btn { flex: 1; justify-content: center; }
  .chip { padding: 0 9px; }
  .disk-card { padding: 12px; }
  .patch { width: 58px; height: 58px; }
  .stepper { height: 38px; }
  .stepper button { width: 32px; font-size: 17px; }
  .stepper input { width: 46px; font-size: 14px; }
  .mini { height: 34px; padding: 0 12px; font-size: 12px; }
  .sugg { height: 32px; }
  .tab-btn { height: 32px; }
  .review-head .flex.items-center.gap-1\.5 { flex-wrap: wrap; }
  .viewer-zoom span { display: none; }
  .dc-actions > .flex-1 { display: none; }
  .dc-actions .mini-confirm { margin-left: auto; }
}

@media print {
  .aurora, .topbar, .stage-bar, .stage-foot, .review-foot, .dc-actions, .tab-btn, .no-print, .toasts { display: none !important; }
  body.app-body { overflow: visible; background: #fff; }
  .analysis { display: block; }
  .stage { background: #fff; box-shadow: none; }
  #plate-image-viewer { max-height: 9cm; box-shadow: none; }
  .review { box-shadow: none; }
  .review-list { overflow: visible; }
}
.analysis.hidden, .home.hidden { display: none !important; }
