:root {
  --bg: #f3f4f6; --panel: #ffffff; --line: #dde1e7; --ink: #1f2937; --muted: #6b7280;
  --accent: #3b5b8c; --accent-2: #2f4a73; --danger: #c62828; --ok: #2e7d5b;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body { min-height: 100%; background: var(--bg); color: var(--ink); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
h1, h2, h3 { line-height: 1.2; }

/* ---------- the app behind the modals ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; padding-bottom: 44px; }
.app { transition: filter .8s ease; }
.app.locked { filter: blur(3px) saturate(.8); user-select: none; pointer-events: none; }
.overlay { transition: opacity .5s ease; }
.overlay.fade-out { opacity: 0; pointer-events: none; }
.topbar { display: flex; align-items: center; gap: 18px; height: 56px; padding: 0 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; background: var(--accent); }
.logo svg { fill: #fff; }
.brand-name { font-weight: 600; letter-spacing: .01em; }
.ver { font-size: 11px; color: var(--muted); border: 1px solid var(--line); padding: 1px 8px; border-radius: 999px; }
.search { flex: 1; max-width: 460px; margin-left: auto; }
.search input { width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; background: #f9fafb; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #cbd5e1; display: grid; place-items: center; font-size: 12px; font-weight: 600; }
.layout { flex: 1; display: grid; grid-template-columns: 220px 1fr; }
.sidebar { background: #eceef1; border-right: 1px solid var(--line); padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item { padding: 9px 12px; border-radius: 6px; color: #9aa1ad; }
.nav-item.active { background: #dfe4ea; color: #5b6472; font-weight: 600; }
.content { padding: 24px; }
.content h1 { font-size: 22px; margin-bottom: 18px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.kpi span { color: var(--muted); font-size: 12px; display: block; }
.kpi b { font-size: 24px; display: block; margin: 2px 0; }
.kpi i { font-style: normal; font-size: 12px; color: var(--ok); }
.panel-row { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.box h3 { font-size: 15px; margin-bottom: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
th { color: var(--muted); font-weight: 500; }
.pbar { display: grid; grid-template-columns: 110px 1fr; gap: 10px; align-items: center; margin: 10px 0; font-size: 13px; color: var(--muted); }
.pbar i { display: block; height: 8px; background: var(--accent); border-radius: 4px; opacity: .7; }

/* ---------- modals ---------- */
.overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px 16px 60px; background: rgba(243,244,246,.55); }
.modal { position: relative; width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 22px 24px 20px; box-shadow: 0 20px 60px rgba(31,41,55,.25); }
.modal h2 { font-size: 20px; margin: 6px 0 16px; }
.modal label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }
.modal input[type=text] { width: 100%; padding: 10px 12px; border: 1px solid #c3cad4; border-radius: 6px; font: inherit; background: #fff; }
.modal input:focus { outline: 2px solid rgba(59,91,140,.35); border-color: var(--accent); }
.primary, .secondary { display: block; width: 100%; padding: 11px 14px; border-radius: 6px; border: 1px solid var(--accent); font-weight: 600; }
.primary { background: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-2); }
.secondary { background: #fff; color: var(--accent); }
.secondary:hover { background: #f0f4fa; }
.modal form .primary { margin-top: 18px; }
.link { display: block; margin: 12px auto 0; background: none; border: 0; color: var(--accent); text-decoration: underline; font-size: 13px; }
.fine { margin-top: 14px; font-size: 11px; color: var(--muted); text-align: center; }
.notice { margin-top: 14px; padding: 9px 12px; border-radius: 6px; background: #fdecea; color: var(--danger); font-size: 13px; text-align: center; }

/* password field shows only ducks; the real characters are never in the DOM */
.pw-wrap { position: relative; }
.pw-wrap input { letter-spacing: 2px; font-size: 15px; }

/* session timer */
.timer { margin: -6px -8px 12px; }
.timer-label { color: var(--danger); font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; margin-bottom: 6px; }
.timer-track { height: 4px; background: #f3d0cd; border-radius: 2px; overflow: hidden; }
.timer-track i { display: block; height: 100%; width: 100%; background: var(--danger); }
.timer.warn .timer-label { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* goose check */
.modal.check { text-align: center; }
.shield { display: grid; place-items: center; margin-bottom: 4px; }
.modal.check p { color: var(--muted); margin-bottom: 18px; }
.modal.check .fine { margin-top: 16px; margin-bottom: 0; }
.choices { display: grid; gap: 10px; }
#no { transition: transform .22s cubic-bezier(.3,1.4,.5,1); }

/* ---------- scan ---------- */
.scan { position: fixed; inset: 0; z-index: 25; background: #0f1722; color: #cfe3f1; padding: 20px 20px 60px; overflow: auto; }
.scan-grid { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 28px; min-height: calc(100vh - 80px); align-items: center; }
.radar-col h2 { font-size: 20px; font-weight: 600; margin-bottom: 14px; color: #e6f2fa; }
.radar { width: 100%; max-width: 520px; height: auto; display: block; margin: 0 auto; }
.sweep { transform-origin: 200px 200px; animation: sweep 4s linear infinite; }
@keyframes sweep { to { transform: rotate(360deg); } }
.ripple { fill: none; stroke: #7dd3fc; stroke-width: 1.5; opacity: 0; animation: ripple 2.6s ease-out forwards; transform-origin: center; transform-box: fill-box; }
@keyframes ripple { 0% { transform: scale(.2); opacity: .8; } 100% { transform: scale(4.5); opacity: 0; } }
.blip { fill: #5eead4; opacity: 0; animation: blip 2.4s ease-out forwards; }
@keyframes blip { 0% { opacity: 0; } 12% { opacity: 1; } 100% { opacity: 0; } }
.progress { max-width: 520px; margin: 14px auto 0; display: flex; align-items: center; gap: 12px; }
.p-track { flex: 1; height: 8px; background: #1f3140; border-radius: 4px; overflow: hidden; }
.p-track i { display: block; height: 100%; width: 0; background: #5eead4; }
#scan-pct { min-width: 46px; text-align: right; font-variant-numeric: tabular-nums; }
.console-col { background: #0a121a; border: 1px solid #1f3140; border-radius: 10px; padding: 14px 16px; height: min(520px, 70vh); display: flex; flex-direction: column; }
.console-head { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: #6fa3bd; margin-bottom: 10px; }
.console { list-style: none; flex: 1; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.console li { animation: logline .4s ease-out; word-break: break-word; }
.console li time { color: #4f7a91; margin-right: 8px; }
.console li.glitch { transform: translateX(4px); text-shadow: 2px 0 rgba(255,60,80,.8), -2px 0 rgba(0,200,255,.8); }
.console li.warn { color: #f5c26b; }
@keyframes logline { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.scan.frozen *, .scan.frozen { animation-play-state: paused !important; }

/* ---------- verdict ---------- */
.detect { position: fixed; inset: 0; z-index: 60; background: #b71c1c; color: #fff; display: grid; place-content: center; text-align: center; padding: 20px; transition: opacity .4s ease; }
.detect.out { opacity: 0; }
.detect-title { font-size: clamp(40px, 11vw, 150px); font-weight: 800; letter-spacing: .04em; line-height: 1; }
.detect-sub { margin-top: 18px; font-size: clamp(18px, 3vw, 30px); letter-spacing: .12em; }

/* escalation panel (card used by scene.js) */
.ms-card { position: fixed; z-index: 15; inset: 0; margin: auto; height: fit-content; width: min(640px, calc(100% - 32px)); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 22px 26px; box-shadow: 0 20px 60px rgba(31,41,55,.25); }

/* ---------- footer and toasts ---------- */
.crm-foot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 18px; padding: 10px 20px; background: #e9ebee; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.crm-foot a { color: var(--accent); }
#toasts { position: fixed; right: 16px; bottom: 60px; z-index: 50; display: grid; gap: 8px; max-width: min(360px, calc(100% - 32px)); }
.toast { background: #1f2937; color: #fff; padding: 11px 14px; border-radius: 8px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.25); animation: toastin .25s ease-out; }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- mobile ---------- */
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; overflow: hidden; padding: 8px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .panel-row { grid-template-columns: 1fr; }
  .search { display: none; }
  .ver { display: none; }
  .scan-grid { grid-template-columns: 1fr; gap: 16px; min-height: 0; }
  .console-col { height: 38vh; }
  .ms-steps { height: 240px; }
}
@media (max-width: 480px) {
  .modal { padding: 18px 16px; }
  .content { padding: 16px; }
  .crm-foot { font-size: 10.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .sweep, .ripple, .blip, .console li, .toast { animation: none; }
  .timer.warn .timer-label { animation: none; }
  .detect { transition: none; }
  #no { transition: none; }
}
