:root {
  --bg: #07111f;
  --panel: rgba(14, 27, 47, 0.88);
  --panel-strong: #0e1b2f;
  --line: rgba(119, 214, 255, 0.18);
  --text: #edf8ff;
  --muted: #9bb6c9;
  --accent: #39c6ff;
  --accent-2: #74f7c9;
  --warning: #ffd166;
  --danger: #ff6b6b;
  --ok: #4de5a1;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.32);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body {
  background:
    radial-gradient(circle at 16% -10%, rgba(57, 198, 255, 0.28), transparent 34rem),
    radial-gradient(circle at 92% 4%, rgba(116, 247, 201, 0.16), transparent 26rem),
    linear-gradient(135deg, #07111f 0%, #0a1322 54%, #06101d 100%);
}

a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }

.app-shell { width: min(1440px, 100%); margin: 0 auto; padding: 20px; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px 0 22px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 46px; height: 46px; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: #03111c; font-weight: 900; letter-spacing: -0.08em;
  box-shadow: 0 0 32px rgba(57, 198, 255, 0.25);
}
.brand h1 { margin: 0; font-size: clamp(1.15rem, 2vw, 1.6rem); letter-spacing: -0.03em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 0.92rem; }
.nav { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end; }
.nav a, .pill {
  border: 1px solid var(--line); color: var(--text); text-decoration: none;
  padding: 9px 12px; border-radius: 999px; background: rgba(255,255,255,0.04);
  font-size: 0.9rem;
}
.nav a:hover, .pill:hover { border-color: rgba(57, 198, 255, 0.55); }

.hero {
  display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(360px, 1.35fr); gap: 18px;
  align-items: stretch;
}
.panel, .card {
  border: 1px solid var(--line); background: var(--panel); border-radius: 24px;
  box-shadow: var(--shadow); backdrop-filter: blur(18px);
}
.panel { padding: 20px; }
.card { padding: 16px; }
.card.compact { padding: 12px; }
.section-title { margin: 0 0 12px; font-size: 1.02rem; letter-spacing: -0.02em; }
.kicker { color: var(--accent-2); text-transform: uppercase; letter-spacing: 0.13em; font-size: 0.75rem; font-weight: 800; }
.big-title { font-size: clamp(2rem, 5vw, 4.2rem); line-height: 0.96; letter-spacing: -0.07em; margin: 12px 0; }
.subtitle { color: var(--muted); font-size: 1.02rem; line-height: 1.65; margin: 0 0 18px; }

.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn {
  border: 1px solid rgba(57, 198, 255, 0.34); background: rgba(57, 198, 255, 0.12);
  color: var(--text); border-radius: 14px; padding: 11px 14px; font-weight: 750;
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
}
.btn:hover { background: rgba(57, 198, 255, 0.2); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #03111c; border: 0; }
.btn.ghost { background: rgba(255,255,255,0.045); border-color: var(--line); color: var(--text); }
.btn.danger { border-color: rgba(255,107,107,0.45); background: rgba(255,107,107,0.11); }

.field { display: grid; gap: 7px; margin-bottom: 12px; }
.field label { color: var(--muted); font-size: 0.86rem; font-weight: 700; }
.input, select, textarea {
  width: 100%; border: 1px solid var(--line); background: rgba(1, 8, 18, 0.55); color: var(--text);
  border-radius: 14px; padding: 11px 12px; outline: none;
}
.input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(57,198,255,0.12); }
textarea { min-height: 86px; resize: vertical; }

.viewer-wrap { min-height: 530px; position: relative; overflow: hidden; }
.viewer { width: 100%; height: 100%; min-height: 530px; border-radius: 24px; overflow: hidden; }
.viewer-toolbar {
  position: absolute; left: 14px; top: 14px; right: 14px; z-index: 2; display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; pointer-events: none;
}
.viewer-toolbar > * { pointer-events: auto; }
.badge-row { display: flex; flex-wrap: wrap; gap: 8px; }
.badge {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(2, 12, 24, 0.68); color: var(--text); font-size: 0.78rem; font-weight: 750;
}
.badge.ok { border-color: rgba(77,229,161,0.42); color: #bfffe6; }
.badge.warn { border-color: rgba(255,209,102,0.5); color: #ffe7a8; }
.badge.danger { border-color: rgba(255,107,107,0.42); color: #ffc1c1; }

.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.stat { padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,0.045); }
.stat small { color: var(--muted); display: block; margin-bottom: 4px; }
.stat strong { font-size: 1.1rem; }

.camera-box { position: relative; min-height: 220px; border-radius: 20px; overflow: hidden; background: #020914; border: 1px solid var(--line); }
.camera-box video { width: 100%; height: 100%; min-height: 220px; object-fit: cover; display: block; }
.camera-overlay {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(rgba(57,198,255,0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(57,198,255,0.18) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, transparent, black 14%, black 86%, transparent);
}
.camera-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); padding: 24px; text-align: center; }

.scan-list { display: grid; gap: 10px; max-height: 620px; overflow: auto; padding-right: 4px; }
.scan-item {
  display: grid; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 16px;
  background: rgba(255,255,255,0.04); text-align: left;
}
.scan-item:hover, .scan-item.active { border-color: rgba(57,198,255,0.68); background: rgba(57,198,255,0.11); }
.scan-item strong { display: block; font-size: 0.98rem; }
.scan-item span { color: var(--muted); font-size: 0.8rem; }

.table { width: 100%; border-collapse: collapse; overflow: hidden; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { color: var(--muted); font-size: 0.8rem; }
.table td { font-size: 0.9rem; }

.toast {
  position: fixed; z-index: 50; right: 18px; bottom: 18px; max-width: min(420px, calc(100vw - 36px));
  background: rgba(5, 15, 27, 0.96); border: 1px solid rgba(57,198,255,0.45); color: var(--text);
  padding: 13px 14px; border-radius: 16px; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px);
  transition: 0.2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

.notice { border-left: 4px solid var(--warning); padding: 12px 14px; background: rgba(255,209,102,0.1); border-radius: 14px; color: #fff1c4; line-height: 1.55; }
.notice.ok { border-color: var(--ok); background: rgba(77,229,161,0.1); color: #d9fff0; }
.notice.info { border-color: var(--accent); background: rgba(57,198,255,0.09); color: #dff7ff; }

.workflow { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.workflow .step { border: 1px solid var(--line); border-radius: 18px; padding: 12px; background: rgba(255,255,255,0.04); }
.workflow .step strong { display:block; margin-bottom:5px; }
.workflow .step span { color: var(--muted); font-size:0.85rem; line-height:1.45; }

.footer { color: var(--muted); padding: 24px 0 10px; font-size: 0.88rem; }

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; }
  .grid.two, .grid.three, .grid.four, .stats, .workflow { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .nav { justify-content: flex-start; }
  .viewer, .viewer-wrap { min-height: 420px; }
}

@media (max-width: 560px) {
  .app-shell { padding: 14px; }
  .panel { padding: 15px; border-radius: 20px; }
  .viewer, .viewer-wrap { min-height: 360px; }
  .big-title { font-size: 2.2rem; }
}
