/* ── Design tokens ──────────────────────────────────────────────────────────── */
:root {
  --bg:        #050b12;
  --sidebar:   #071019;
  --panel:     #09131d;
  --surface:   #0c1824;
  --line:      #1a2a38;
  --cyan:      #00d8c4;
  --cyan2:     #17f0d4;
  --red:       #ff4d48;
  --amber:     #ffb000;
  --blue:      #2fa8ff;
  --text:      #e2e8f0;
  --muted:     #64748b;
  --ok:        #00d8c4;
  --danger:    #ff4d48;
  --radius:    14px;
  --radius-sm: 10px;
  --radius-xs: 7px;
  --header-h:  58px;
  --tab-h:     66px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }
button:active { transform: scale(.96); }
button:disabled { opacity: .4; cursor: not-allowed; }

/* ── ANIMATIONS ─────────────────────────────────────────────────────────────── */

@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

@keyframes scanline {
  0%   { top: 0; opacity: 1; }
  85%  { opacity: .8; }
  100% { top: 100%; opacity: 0; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .25; }
}

@keyframes pulse-ring {
  0%   { transform: scale(1); opacity: .7; }
  100% { transform: scale(2.6); opacity: 0; }
}

@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 18px rgba(0,216,196,.2); }
  50%       { box-shadow: 0 0 32px rgba(0,216,196,.4); }
}

@keyframes grid-scan {
  0%   { transform: translateY(-100%); opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { transform: translateY(100vh); opacity: 0; }
}

/* ── SKELETON ───────────────────────────────────────────────────────────────── */

.skel {
  background: linear-gradient(90deg, var(--panel) 25%, var(--surface) 50%, var(--panel) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite;
  display: block;
}

/* ── LOGIN ──────────────────────────────────────────────────────────────────── */

#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px 20px;
  background:
    radial-gradient(ellipse 80% 60% at 50% 42%, rgba(0,216,196,.07) 0%, transparent 60%),
    radial-gradient(ellipse 40% 30% at 50% 42%, rgba(0,216,196,.05) 0%, transparent 50%),
    var(--bg);
  position: relative;
  overflow: hidden;
}

/* Grid background */
#login-view::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0,216,196,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,216,196,.06) 1px, transparent 1px);
  background-size: 44px 44px;
  pointer-events: none;
  mask-image: radial-gradient(ellipse 85% 85% at 50% 50%, black 0%, transparent 72%);
  -webkit-mask-image: radial-gradient(ellipse 85% 85% at 50% 50%, black 0%, transparent 72%);
}

/* Scan beam */
#login-view::after {
  content: '';
  position: absolute;
  inset-x: 0;
  height: 120px;
  background: linear-gradient(to bottom,
    transparent,
    rgba(0,216,196,.03) 30%,
    rgba(0,216,196,.06) 50%,
    rgba(0,216,196,.03) 70%,
    transparent
  );
  pointer-events: none;
  animation: grid-scan 6s ease-in-out infinite;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 44px 36px;
  max-width: 390px;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow:
    0 32px 80px rgba(0,0,0,.7),
    0 0 0 1px rgba(0,216,196,.07),
    0 0 60px rgba(0,216,196,.04);
  position: relative;
  z-index: 1;
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
  filter: drop-shadow(0 0 12px rgba(0,216,196,.35));
}

.login-form h2 {
  text-align: center;
  color: var(--text);
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: 1.1;
}

.login-sub {
  text-align: center;
  color: var(--muted);
  font-size: .77rem;
  margin-top: -10px;
  letter-spacing: .01em;
}

.login-err {
  color: var(--red);
  text-align: center;
  font-size: .8rem;
  min-height: 1.1em;
  font-weight: 500;
}

/* ── MAIN LAYOUT ────────────────────────────────────────────────────────────── */

#main-view {
  display: none;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  height: var(--header-h);
  background: var(--sidebar);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(0,216,196,.06), 0 4px 24px rgba(0,0,0,.4);
  flex-shrink: 0;
  z-index: 10;
}

.header-left  { display: flex; align-items: center; gap: 10px; }
.header-logo  {
  color: var(--cyan);
  display: flex;
  align-items: center;
  filter: drop-shadow(0 0 6px rgba(0,216,196,.5));
}
.header-title {
  font-size: .92rem;
  font-weight: 700;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -.02em;
}
.header-right { display: flex; align-items: center; gap: 8px; }

/* Status dot */
.status-dot {
  position: relative;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--cyan);
  display: inline-block;
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(0,216,196,.6);
}

.status-dot::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: var(--cyan);
  opacity: .35;
  animation: pulse-ring 2.2s ease-out infinite;
}

.status-dot.offline {
  background: var(--red);
  box-shadow: 0 0 6px rgba(255,77,72,.5);
}
.status-dot.offline::before {
  background: var(--red);
  animation: none;
  opacity: 0;
}

/* ── TAB BAR ────────────────────────────────────────────────────────────────── */

#tab-bar {
  display: flex;
  height: var(--tab-h);
  background: rgba(7,16,25,.96);
  border-top: 1px solid var(--line);
  box-shadow: 0 -1px 0 rgba(0,216,196,.05), 0 -8px 32px rgba(0,0,0,.3);
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  position: relative;
  transition: color .18s;
  padding: 0;
}

/* Top indicator */
.tab-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 32px;
  height: 2px;
  background: var(--cyan);
  border-radius: 0 0 4px 4px;
  box-shadow: 0 0 12px rgba(0,216,196,.8);
  transition: transform .22s cubic-bezier(.34,1.56,.64,1);
}

.tab-btn.active { color: var(--cyan); }
.tab-btn.active::before { transform: translateX(-50%) scaleX(1); }

.tab-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s, filter .18s;
}

.tab-btn.active .tab-icon {
  transform: scale(1.1);
  filter: drop-shadow(0 0 6px rgba(0,216,196,.55));
}

.tab-label {
  font-size: .6rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.tab-badge {
  position: absolute;
  top: 7px;
  right: calc(50% - 22px);
  background: var(--red);
  color: #fff;
  font-size: .56rem;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  box-shadow: 0 0 8px rgba(255,77,72,.5);
}

/* ── APP MAIN ───────────────────────────────────────────────────────────────── */

#app-main {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tab-panel {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.tab-panel.hidden { display: none; }

/* ── SPLIT LAYOUT (alerts) ──────────────────────────────────────────────────── */

.split-layout {
  display: flex;
  height: 100%;
}

.list-pane {
  width: 320px;
  flex-shrink: 0;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}

.list-pane.full-width { width: 100%; border-right: none; background: var(--bg); }

.detail-pane {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
}

@media (max-width: 767px) {
  .list-pane { width: 100%; border-right: none; background: var(--bg); }
  .detail-pane {
    position: absolute;
    inset: 0;
    z-index: 20;
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
  }
  .detail-pane.visible { transform: translateY(0); }
}

.scroll-pane {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}

/* ── CLIP ROWS ──────────────────────────────────────────────────────────────── */

.clip-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 15px 16px;
  cursor: pointer;
  border-bottom: 1px solid rgba(26,42,56,.7);
  transition: background .14s;
  user-select: none;
  border-left: 3px solid transparent;
  position: relative;
}

.clip-row:hover {
  background: rgba(0,216,196,.025);
  border-left-color: rgba(0,216,196,.2);
}

.clip-row.selected {
  background: rgba(0,216,196,.06);
  border-left-color: var(--cyan);
  box-shadow: inset 4px 0 16px rgba(0,216,196,.05);
}

.clip-row.selected::after {
  content: '';
  position: absolute;
  inset: 0;
  border-right: 1px solid rgba(0,216,196,.1);
  pointer-events: none;
}

.row-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.dot-pending {
  background: var(--amber);
  box-shadow: 0 0 8px rgba(255,176,0,.5);
}
.dot-ok  { background: var(--cyan); box-shadow: 0 0 6px rgba(0,216,196,.4); }
.dot-fp  { background: var(--muted); }

.row-body { flex: 1; min-width: 0; }
.row-top  { display: flex; justify-content: space-between; margin-bottom: 5px; }
.row-cam  {
  font-size: .9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -.01em;
}
.row-time {
  font-size: .72rem;
  color: var(--muted);
  flex-shrink: 0;
  margin-left: 8px;
  font-variant-numeric: tabular-nums;
}
.row-bot { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 5px; }

.conf-badge {
  font-size: .63rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 3px;
}
.conf-high { background: rgba(0,216,196,.15);  color: var(--cyan);  border: 1px solid rgba(0,216,196,.25); }
.conf-med  { background: rgba(255,176,0,.12);  color: var(--amber); border: 1px solid rgba(255,176,0,.2); }
.conf-low  { background: rgba(255,77,72,.12);  color: var(--red);   border: 1px solid rgba(255,77,72,.18); }

/* ── TAGS + CHIPS ───────────────────────────────────────────────────────────── */

.gesture-tag {
  font-size: .64rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  background: rgba(255,77,72,.1);
  color: var(--red);
  white-space: nowrap;
  border: 1px solid rgba(255,77,72,.2);
}

.gesture-tag.lg { font-size: .76rem; padding: 4px 11px; }

.store-tag {
  font-size: .64rem;
  padding: 3px 7px;
  border-radius: var(--radius-xs);
  background: rgba(47,168,255,.08);
  color: var(--blue);
  white-space: nowrap;
  border: 1px solid rgba(47,168,255,.18);
}

.meta-chip {
  font-size: .72rem;
  color: var(--muted);
}

/* ── DETAIL PANEL ───────────────────────────────────────────────────────────── */

.detail-inner { padding: 18px; }

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  margin-bottom: 14px;
}

.detail-video-wrap {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  box-shadow:
    0 0 0 1px rgba(0,216,196,.08),
    0 12px 40px rgba(0,0,0,.6);
}

.detail-video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Scan line animation */
.scan-line {
  position: absolute;
  inset-x: 0;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  box-shadow: 0 0 14px rgba(0,216,196,.8);
  animation: scanline 3s linear infinite;
  pointer-events: none;
  z-index: 5;
}

/* Camera badge top-left */
.video-badge-tl {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(5,11,18,.75);
  border: 1px solid rgba(0,216,196,.2);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: .64rem;
  font-weight: 600;
  color: #94a3b8;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.dot-xs {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--cyan);
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(0,216,196,.7);
}

.bbox-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  width: 100% !important;
  height: 100% !important;
  z-index: 4;
}

.video-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: .85rem;
}

.detail-actions {
  display: flex;
  gap: 10px;
}

.detail-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 260px;
  gap: 12px;
  color: var(--muted);
  font-size: .82rem;
  text-align: center;
}

.detail-empty-icon {
  width: 58px; height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,216,196,.06);
  border: 1px solid rgba(0,216,196,.12);
  border-radius: 16px;
  color: var(--muted);
  margin-bottom: 4px;
}

.btn-back {
  position: fixed;
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + 14px);
  left: 16px;
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 22px;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  z-index: 30;
  box-shadow: 0 4px 20px rgba(0,0,0,.55);
  font-family: inherit;
}

/* ── BUTTONS ────────────────────────────────────────────────────────────────── */

.btn-primary {
  background: linear-gradient(135deg, rgba(0,216,196,.22), rgba(0,216,196,.12));
  color: var(--cyan);
  border: 1px solid rgba(0,216,196,.3);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: .92rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  font-family: inherit;
  letter-spacing: -.01em;
  transition: background .15s, box-shadow .15s, border-color .15s;
  box-shadow: 0 0 20px rgba(0,216,196,.08);
}

.btn-primary:hover {
  background: linear-gradient(135deg, rgba(0,216,196,.32), rgba(0,216,196,.20));
  border-color: rgba(0,216,196,.5);
  box-shadow: 0 0 28px rgba(0,216,196,.18);
}

.btn-primary.compact { width: auto; padding: 9px 22px; font-size: .82rem; }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  cursor: pointer;
  font-family: inherit;
  transition: border-color .15s, background .15s;
}

.btn-secondary:hover { border-color: rgba(255,255,255,.18); background: rgba(255,255,255,.03); }
.btn-secondary.sm { padding: 6px 12px; font-size: .78rem; }

.btn-icon-sm {
  background: none;
  border: none;
  cursor: pointer;
  padding: 7px;
  border-radius: var(--radius-xs);
  color: var(--muted);
  line-height: 1;
  display: flex;
  align-items: center;
  transition: color .15s, background .15s;
}

.btn-icon-sm:hover { color: var(--text); background: rgba(255,255,255,.06); }
.btn-icon-sm:disabled { opacity: .35; cursor: not-allowed; }

.btn-clear {
  flex: 1;
  background: rgba(255,255,255,.04);
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 13px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background .12s, color .12s;
}

.btn-clear:hover { background: rgba(255,255,255,.07); color: var(--text); }

.btn-theft {
  flex: 2;
  background: linear-gradient(135deg, rgba(255,77,72,.25), rgba(255,77,72,.15));
  color: var(--red);
  border: 1px solid rgba(255,77,72,.3);
  padding: 13px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background .15s, box-shadow .15s;
}

.btn-theft:hover { background: linear-gradient(135deg, rgba(255,77,72,.35), rgba(255,77,72,.22)); box-shadow: 0 0 18px rgba(255,77,72,.2); }

.btn-sm {
  font-size: .75rem;
  padding: 6px 12px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background .12s, border-color .12s;
}

.btn-sm:hover { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.1); }

/* ── BOTTOM SHEET ───────────────────────────────────────────────────────────── */

.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.sheet-overlay.hidden { display: none; }

.sheet-content {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 1px solid rgba(0,216,196,.15);
  border-bottom: none;
  border-radius: 22px 22px 0 0;
  padding: 12px 22px calc(30px + env(safe-area-inset-bottom, 0px));
  width: 100%;
  max-width: 480px;
  transform: translateY(100%);
  transition: transform .32s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
}

.sheet-overlay.open .sheet-content { transform: translateY(0); }

.sheet-handle {
  width: 38px; height: 4px;
  background: var(--line);
  border-radius: 2px;
  align-self: center;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.sheet-title {
  font-size: .98rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.optional { font-size: .78rem; font-weight: 400; color: var(--muted); }

.outcome-btn {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--oc, var(--line)) 35%, transparent);
  background: color-mix(in srgb, var(--oc, var(--line)) 10%, transparent);
  color: color-mix(in srgb, var(--oc, var(--text)) 90%, white);
  font-size: .88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background .14s;
}

.outcome-btn:hover { background: color-mix(in srgb, var(--oc, var(--line)) 20%, transparent); }
.outcome-cancel { --oc: #334155; color: var(--muted); }

.sheet-btns { display: flex; gap: 10px; }
.sheet-btns .btn-primary { flex: 1; width: auto; }
.sheet-btns .btn-secondary { flex: 1; }

/* ── FORMS ──────────────────────────────────────────────────────────────────── */

.form-label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: .78rem;
  color: var(--muted);
  font-weight: 500;
}

.form-label input,
.form-label select,
input[type="text"],
input[type="password"],
input[type="number"] {
  background: rgba(5,11,18,.8);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-family: inherit;
  width: 100%;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0,216,196,.12);
}

select option { background: var(--panel); }

/* ── THEFT CARDS ────────────────────────────────────────────────────────────── */

.theft-card {
  padding: 16px 18px;
  border-bottom: 1px solid rgba(26,42,56,.7);
  display: flex;
  flex-direction: column;
  gap: 9px;
  transition: background .12s;
  border-left: 3px solid transparent;
}

.theft-card:hover {
  background: rgba(255,255,255,.025);
  border-left-color: rgba(255,255,255,.08);
}

.theft-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.theft-time   { font-size: .7rem; color: var(--muted); flex-shrink: 0; font-variant-numeric: tabular-nums; }

.outcome-badge {
  font-size: .67rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-xs);
  border: 1px solid;
  letter-spacing: .01em;
}

.theft-meta   { display: flex; gap: 6px; flex-wrap: wrap; }
.theft-values { display: flex; gap: 8px; flex-wrap: wrap; }
.theft-actions { display: flex; gap: 8px; align-items: center; }

.value-chip {
  font-size: .72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-xs);
}

.value-chip.loss { background: rgba(255,77,72,.12); color: var(--red); border: 1px solid rgba(255,77,72,.22); }
.value-chip.rec  { background: rgba(0,216,196,.1);  color: var(--cyan); border: 1px solid rgba(0,216,196,.22); }

.saved-label { font-size: .75rem; color: var(--cyan); font-weight: 600; }

/* ── STATISTICS ─────────────────────────────────────────────────────────────── */

.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.stats-header h2 { font-size: 1.05rem; font-weight: 700; letter-spacing: -.03em; }

.period-selector { display: flex; gap: 5px; }

.period-btn {
  padding: 5px 13px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line);
  background: none;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .14s, color .14s, border-color .14s;
}

.period-btn.active {
  background: var(--cyan);
  color: #031a18;
  border-color: var(--cyan);
  box-shadow: 0 2px 10px rgba(0,216,196,.3);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.kpi-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 10px;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: border-color .15s;
}

/* Top color accent */
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--line);
}

.kpi-card:has(.kpi-red)   { border-color: rgba(255,77,72,.15); }
.kpi-card:has(.kpi-red)   ::before { background: linear-gradient(90deg, transparent, var(--red), transparent); }
.kpi-card:has(.kpi-cyan)  { border-color: rgba(0,216,196,.15); }
.kpi-card:has(.kpi-cyan)  ::before { background: linear-gradient(90deg, transparent, var(--cyan), transparent); }
.kpi-card:has(.kpi-amber) { border-color: rgba(255,176,0,.15); }
.kpi-card:has(.kpi-amber) ::before { background: linear-gradient(90deg, transparent, var(--amber), transparent); }
.kpi-card:has(.kpi-blue)  { border-color: rgba(47,168,255,.15); }
.kpi-card:has(.kpi-blue)  ::before { background: linear-gradient(90deg, transparent, var(--blue), transparent); }

.kpi-val {
  font-size: 1.9rem;
  font-weight: 800;
  margin-bottom: 5px;
  line-height: 1;
  letter-spacing: -.04em;
}

.kpi-val.kpi-cyan  { color: var(--cyan);  text-shadow: 0 0 20px rgba(0,216,196,.4); }
.kpi-val.kpi-amber { color: var(--amber); text-shadow: 0 0 20px rgba(255,176,0,.4); }
.kpi-val.kpi-blue  { color: var(--blue);  text-shadow: 0 0 20px rgba(47,168,255,.4); }
.kpi-val.kpi-red   { color: var(--red);   text-shadow: 0 0 20px rgba(255,77,72,.4); }

.kpi-label {
  font-size: .57rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .09em;
  font-weight: 600;
}

.value-summary {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.value-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: .85rem;
}

.value-num.loss { color: var(--red);  font-weight: 700; }
.value-num.rec  { color: var(--cyan); font-weight: 700; }

.chart-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px 14px;
  margin-bottom: 12px;
}

.section-heading {
  font-size: .6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
  margin-bottom: 14px;
}

.section-heading.sm { font-size: .58rem; }

.canvas-wrap {
  position: relative;
  width: 100%;
  height: 160px;
}

#timeline-canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
}

.bar-label  { font-size: .72rem; flex: 0 0 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track  { flex: 1; height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar-fill   { height: 100%; background: linear-gradient(90deg, var(--cyan), var(--cyan2)); border-radius: 3px; transition: width .4s ease; }
.bar-count  { font-size: .72rem; color: var(--muted); flex: 0 0 24px; text-align: right; font-variant-numeric: tabular-nums; }

.roi-result {
  font-size: .85rem;
  padding: 11px 14px;
  background: rgba(0,216,196,.07);
  border: 1px solid rgba(0,216,196,.18);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  color: var(--cyan);
}

.roi-result strong { font-weight: 700; }

/* ── ACCOUNT ────────────────────────────────────────────────────────────────── */

.account-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-bottom: 10px;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile-avatar {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, rgba(0,216,196,.2), rgba(0,216,196,.08));
  border: 1px solid rgba(0,216,196,.25);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--cyan);
  flex-shrink: 0;
  box-shadow: 0 0 16px rgba(0,216,196,.1);
}

.profile-name { font-size: .95rem; font-weight: 700; letter-spacing: -.02em; }
.profile-role { font-size: .75rem; color: var(--muted); margin-top: 3px; font-weight: 500; }

.current-store { font-size: .92rem; font-weight: 700; margin-bottom: 9px; letter-spacing: -.01em; }

.section-hint { font-size: .75rem; color: var(--muted); margin-bottom: 9px; font-weight: 500; }

.store-list { display: flex; flex-direction: column; gap: 6px; }

.store-btn {
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: none;
  color: var(--text);
  font-size: .85rem;
  font-family: inherit;
  cursor: pointer;
  transition: background .12s, border-color .14s;
  font-weight: 500;
}

.store-btn:hover { background: rgba(0,216,196,.04); border-color: rgba(0,216,196,.2); }

/* Gesture toggles */
.gesture-list { display: flex; flex-direction: column; gap: 14px; }

.gesture-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.gesture-info { flex: 1; min-width: 0; }
.gesture-name { font-size: .85rem; font-weight: 600; }
.gesture-desc { font-size: .72rem; color: var(--muted); margin-top: 2px; }

.toggle { position: relative; width: 44px; height: 26px; flex-shrink: 0; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--line);
  border-radius: 13px;
  cursor: pointer;
  transition: background .2s;
  border: 1px solid rgba(255,255,255,.05);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  left: 2px; top: 2px;
  background: var(--muted);
  border-radius: 50%;
  transition: transform .2s, background .2s;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
}

.toggle input:checked + .toggle-slider {
  background: rgba(0,216,196,.2);
  border-color: rgba(0,216,196,.35);
}
.toggle input:checked + .toggle-slider::before {
  transform: translateX(18px);
  background: var(--cyan);
  box-shadow: 0 0 8px rgba(0,216,196,.5);
}

/* Notification row */
.notif-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .85rem;
  font-weight: 500;
}

/* Support */
.support-info { display: flex; flex-direction: column; gap: 9px; }
.support-row  { font-size: .8rem; color: var(--muted); }
.support-row strong { font-weight: 600; color: var(--text); }

.support-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--cyan);
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
}

.btn-logout-full {
  width: 100%;
  padding: 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: none;
  color: var(--muted);
  font-size: .88rem;
  font-family: inherit;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background .12s, color .12s, border-color .12s;
}

.btn-logout-full:hover {
  background: rgba(255,77,72,.07);
  color: var(--red);
  border-color: rgba(255,77,72,.25);
}

/* ── CAMERA MANAGEMENT ───────────────────────────────────────────────────────── */

.camera-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }

.camera-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cam-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--muted);
}
.cam-dot-on  { background: var(--cyan);  box-shadow: 0 0 6px rgba(0,216,196,.5); }
.cam-dot-off { background: var(--red);   box-shadow: 0 0 6px rgba(255,77,72,.4); }

.camera-info { flex: 1; min-width: 0; }
.camera-label-text { font-size: .85rem; font-weight: 600; }
.camera-id-text    { font-size: .72rem; color: var(--muted); margin-top: 2px; font-family: 'SF Mono', 'Fira Code', monospace; }

.camera-add-btn {
  width: 100%;
  text-align: center;
  padding: 10px 14px;
  border-radius: var(--radius-xs);
  border: 1px dashed var(--line);
  background: none;
  color: var(--muted);
  font-size: .82rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .14s, color .14s, background .12s;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.camera-add-btn:hover {
  border-color: rgba(0,216,196,.35);
  color: var(--cyan);
  background: rgba(0,216,196,.04);
}

.btn-sm-danger {
  border-color: rgba(255,77,72,.18);
  color: var(--red);
  opacity: .65;
  padding: 6px 8px;
}
.btn-sm-danger:hover { opacity: 1; background: rgba(255,77,72,.08); border-color: rgba(255,77,72,.35); }

/* ── BLOCKED NOTIFICATION MESSAGE ───────────────────────────────────────────── */

.notif-blocked-msg {
  background: rgba(255,176,0,.07);
  border-bottom: 1px solid rgba(255,176,0,.18);
  padding: 10px 18px;
  font-size: .75rem;
  color: var(--amber);
  font-weight: 500;
}

/* ── EMPTY / LOADING / ERROR STATES ─────────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  gap: 10px;
  text-align: center;
}

.empty-icon-wrap {
  width: 62px; height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,216,196,.07);
  border: 1px solid rgba(0,216,196,.14);
  border-radius: 18px;
  color: var(--cyan);
  margin-bottom: 6px;
  box-shadow: 0 0 20px rgba(0,216,196,.07);
}

.empty-title { font-size: .92rem; font-weight: 600; color: var(--text); }
.empty-sub   { font-size: .78rem; color: var(--muted); margin-top: 2px; }

.monitor-active {
  margin-top: 10px;
  display: flex;
  align-items: center;
  font-size: .72rem;
  color: var(--muted);
  font-weight: 500;
  gap: 7px;
}

.pulse-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  animation: pulse 2s infinite;
  display: inline-block;
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(0,216,196,.5);
}

.loading {
  padding: 48px;
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 500;
}

.error-state {
  padding: 48px;
  text-align: center;
  color: var(--red);
  font-size: .85rem;
  font-weight: 500;
}

/* ── TOAST ──────────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--panel);
  border: 1px solid rgba(0,216,196,.35);
  color: var(--text);
  padding: 11px 22px;
  border-radius: 26px;
  font-size: .8rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity .2s, transform .22s;
  pointer-events: none;
  z-index: 200;
  white-space: nowrap;
  box-shadow: 0 4px 24px rgba(0,0,0,.55), 0 0 0 1px rgba(0,216,196,.08);
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: rgba(255,77,72,.4); }

/* ── MISC ───────────────────────────────────────────────────────────────────── */

.mt-8 { margin-top: 8px; }
