:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #162033;
  --border: #2d3c54;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --green: #22c55e;
  --orange: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  background: #0b1220;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.7);
}
.brand-title { font-size: 16px; font-weight: 700; letter-spacing: 0.3px; }
.brand-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: 0.15s;
}
.tab:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.tab.active { color: #fff; background: var(--primary); }

.top-actions { display: flex; align-items: center; gap: 10px; }
.date-input, .select, input[type="text"], input[type="number"], input[type="password"] {
  background: #0f172a;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
}
.date-input:focus, .select:focus, input:focus { border-color: var(--primary); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #273449;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: 0.15s;
}
.btn:hover { background: #334155; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: rgba(239,68,68,0.16); border-color: rgba(239,68,68,0.5); color: #fca5a5; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border); }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.container { max-width: 1480px; margin: 0 auto; padding: 18px 22px 40px; }
.container.full-bleed { max-width: none; padding: 0; }
.panel { display: none; }
.panel.active { display: block; }
.panel-analytics { width: 100%; }
.analytics-iframe {
  width: 100%;
  height: calc(100vh - 64px);
  border: none;
  display: block;
  background: #eef3f8;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.kpi-grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.kpi-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.kpi-highlight {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e3a8a 100%);
  border-color: #3b82f6;
}
.kpi-warn { border-color: rgba(245, 158, 11, 0.45); }
.kpi-muted { border-color: rgba(148, 163, 184, 0.35); }
.kpi-label { font-size: 12px; color: #cbd5e1; }
.kpi-value { font-size: 32px; font-weight: 800; margin: 6px 0 4px; line-height: 1.1; }
.kpi-value small { font-size: 18px; color: var(--muted); font-weight: 600; }
.kpi-desc { font-size: 12px; color: var(--muted); }
.kpi-highlight .kpi-desc { color: #dbeafe; }

.dash-main {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.dash-main .card { margin-bottom: 0; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.card-header h3 { margin: 0; font-size: 15px; }
.muted { color: var(--muted); font-size: 12px; }

.video-wrap {
  position: relative;
  width: 100%;
  background: #090e1a;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--border);
}
.video-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
#lineCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#lineCanvas.drawing { pointer-events: auto; cursor: crosshair; }

.legend-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 10px;
  font-size: 12px;
  color: #cbd5e1;
  flex-wrap: wrap;
}
.legend-bar .right { margin-left: auto; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; }
.dot-green { background: var(--green); }
.dot-orange { background: var(--orange); }
.dot-gray { background: #94a3b8; }

.chart-area {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 290px;
  padding: 16px 8px 6px;
  background: var(--panel-2);
  border-radius: 10px;
  border: 1px solid var(--border);
}
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}
.bar-pair {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 220px;
  width: 100%;
  justify-content: center;
}
.bar {
  width: 42%;
  min-height: 2px;
  border-radius: 4px 4px 0 0;
  transition: height 0.25s;
}
.bar-total { background: rgba(96, 165, 250, 0.45); }
.bar-unique { background: #3b82f6; }
.bar-num { font-size: 11px; color: #334155; font-weight: 600; margin-bottom: 3px; min-height: 14px; }
.bar-label { font-size: 11px; color: #475569; margin-top: 6px; }
.snapshot-note {
  margin-top: 10px;
  font-size: 12px;
  color: #475569;
  word-break: break-all;
}
.snapshot-note code {
  color: #1d4ed8;
  background: #edf4ff;
  padding: 2px 6px;
  border-radius: 5px;
  font-weight: 600;
}

.recent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.event-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.event-imgs {
  display: flex;
  gap: 6px;
  height: 170px;
}
.event-imgs img {
  flex: 1;
  width: 50%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  border-radius: 8px;
  background: #eee9e5;
  border: 1px solid var(--border);
  cursor: zoom-in;
  transition: transform 0.15s, border-color 0.15s;
}
.event-imgs img:hover {
  border-color: var(--primary);
  filter: brightness(1.06);
}
.event-imgs.single img { width: 100%; }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(5, 10, 22, 0.86);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  z-index: 999;
  padding: 24px;
  cursor: zoom-out;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 90vw;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 12px;
  border: 2px solid var(--border);
  box-shadow: 0 20px 60px rgba(0,0,0,0.65);
  background: #0b1220;
  cursor: default;
}
.lightbox-caption {
  color: #e2e8f0;
  font-size: 14px;
  background: rgba(15, 23, 42, 0.9);
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(5, 10, 22, 0.78);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 998;
  padding: 20px;
}
.modal-mask.open { display: flex; }
.modal-card {
  width: 100%;
  max-width: 480px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.55);
}
.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}
.emp-chip {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: 0.15s;
}
.emp-chip:hover {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.22);
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.badge-new { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.badge-dup { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge-emp { background: #e2e8f0; color: #334155; border: 1px solid #cbd5e1; }
.event-meta { font-size: 12px; color: #334155; line-height: 1.55; }
.event-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }

.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.event-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.emp-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
}
.form-stack { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.form-stack label, .form-grid label, .full-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
}
.emp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.emp-card {
  background: #f8fbff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 14px;
  color: #0f172a;
}
.emp-photos {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.emp-photo-item { position: relative; width: 64px; height: 64px; }
.emp-photo-item img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 6px;
  border: 1px solid #cbd5e1;
}
.emp-photo-del {
  position: absolute; top: -5px; right: -5px;
  width: 18px; height: 18px; border-radius: 50%;
  border: none; background: var(--danger); color: #fff;
  font-size: 11px; cursor: pointer; line-height: 18px; padding: 0;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 500;
  color: #1e293b;
  cursor: pointer;
}
.msg-box {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 500;
  color: #1d4ed8;
  min-height: 18px;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  border: 1px solid var(--primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
  z-index: 100;
}
.toast.show { opacity: 1; }

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.chain-dark-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 680px;
}
.chain-dark-table th {
  padding: 11px 12px;
  background: #f2f6fc;
  border-bottom: 1px solid #cbd5e1;
  color: #334155;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}
.chain-dark-table th:first-child { border-radius: 8px 0 0 8px; }
.chain-dark-table th:last-child { border-radius: 0 8px 8px 0; }
.chain-dark-table td {
  padding: 11px 12px;
  color: #0f172a;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}
.chain-dark-table tbody tr:hover {
  background: #f7faff;
}

/* ==================== 桌面大屏优化 ==================== */
.topbar {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: rgba(11, 18, 32, 0.92);
}
.kpi-card {
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.kpi-card:hover {
  transform: translateY(-2px);
  border-color: rgba(59, 130, 246, 0.55);
}
.event-card {
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.event-card:hover {
  border-color: rgba(59, 130, 246, 0.45);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
}

/* ==================== iPad / 平板适配 (<= 1180px) ==================== */
@media (max-width: 1180px) {
  .topbar {
    padding: 10px 16px;
    gap: 10px;
  }


  .tab {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 9px 14px;
    min-height: 38px;
  }
  .container {
    padding: 14px 16px calc(32px + env(safe-area-inset-bottom));
  }
  .analytics-iframe {
    height: calc(100dvh - 108px);
  }
  .kpi-grid, .kpi-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .dash-main, .emp-layout, .settings-grid {
    grid-template-columns: 1fr;
  }
  .recent-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .event-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .emp-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ==================== 手机端深度适配 (<= 767px) ==================== */
@media (max-width: 767px) {
  body { font-size: 13px; }
  .topbar {
    padding: 10px 12px 8px;
    gap: 8px;
  }
  .brand { gap: 8px; min-width: 0; flex: 1; }
  .brand-title {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .brand-sub {
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 210px;
  }
  .top-actions {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }
  .top-actions .date-input {
    flex: 1;
    min-width: 0;
  }
  .top-actions .btn {
    min-height: 38px;
    padding: 7px 14px;
    white-space: nowrap;
  }
  .date-input, .select, input[type="text"], input[type="number"], input[type="password"] {
    font-size: 16px; /* 防止 iOS Safari 聚焦输入框自动放大页面 */
    min-height: 40px;
  }
  .btn { min-height: 38px; }
  .btn-sm { min-height: 34px; padding: 6px 10px; }
  .container {
    padding: 12px 12px calc(28px + env(safe-area-inset-bottom));
  }
  .analytics-iframe {
    height: calc(100dvh - 148px);
  }
  .card {
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 12px;
  }
  .kpi-grid, .kpi-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
  }
  .kpi-card { padding: 12px 12px; }
  .kpi-value { font-size: 26px; }
  .kpi-desc { font-size: 11px; }
  .chart-area {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    height: 230px;
    padding: 12px 6px 4px;
  }
  .bar-col { min-width: 24px; }
  .bar-pair { height: 165px; }
  .recent-grid, .event-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .event-imgs { height: 148px; }
  .event-actions { flex-wrap: wrap; }
  .event-actions .btn { flex: 1; min-width: 64px; }
  .form-grid { grid-template-columns: 1fr; }
  .emp-grid { grid-template-columns: 1fr; }
  .legend-bar { gap: 8px; font-size: 11px; }
  .legend-bar .right { margin-left: 0; width: 100%; }
  .modal-card {
    padding: 14px;
    max-height: 86dvh;
    overflow-y: auto;
  }
  .toast {
    left: 12px;
    right: 12px;
    bottom: calc(14px + env(safe-area-inset-bottom));
    text-align: center;
  }
}

/* 超窄小屏手机 (<= 400px) */
@media (max-width: 400px) {
  .recent-grid, .event-list {
    grid-template-columns: 1fr;
  }
  .event-imgs { height: 190px; }
}

/* Retail monitoring dashboard — 3333 业绩看板蓝白主题 */
:root {
  --rail-width: 224px;
  --bg: #eef3f8;
  --panel: #ffffff;
  --panel-2: #f8fbff;
  --border: #cbd5e1;
  --text: #0f172a;
  --muted: #475569;
  --primary: #1677ff;
  --primary-hover: #1d4ed8;
  --green: #0f8f69;
  --orange: #d97706;
  --danger: #b42318;
  --radius: 14px;
  --warm-button: linear-gradient(135deg, #2386ff, #1677ff);
}
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(circle at top left, rgba(29, 78, 216, 0.10), transparent 36%), var(--bg);
  min-height: 100vh;
}
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.ui-icon { width: 1em; height: 1em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.side-rail {
  position: fixed; z-index: 25; inset: 0 auto 0 0; width: var(--rail-width);
  border-right: 1px solid #d8e0eb; border-radius: 0;
  background: linear-gradient(180deg, #ffffff 0%, #f4f8ff 100%);
  box-shadow: 2px 0 18px rgba(15, 23, 42, 0.05);
  color: #0f172a; display: flex; flex-direction: column; overflow: auto;
}
.side-brand { position: relative; z-index: 1; padding: 34px 22px 0; white-space: nowrap; }
.side-brand strong { display: block; font-size: 21px; font-weight: 800; color: #07111f; letter-spacing: -0.01em; }
.side-brand span { display: block; color: #64748b; font-size: 12px; margin-top: 6px; }
.side-nav { display: grid; gap: 10px; margin: 34px 12px 0; z-index: 1; }
.side-nav .tab {
  color: #475569; display: flex; align-items: center; gap: 14px;
  width: 100%; min-height: 46px; text-align: left; padding: 10px 16px; border-radius: 10px; font-size: 15px; font-weight: 600;
}
.side-nav .ui-icon { font-size: 21px; }
.side-nav .tab.active {
  background: linear-gradient(135deg, #2386ff 0%, #1677ff 100%);
  border-color: transparent; color: #ffffff;
  box-shadow: 0 8px 20px rgba(22, 119, 255, 0.24);
}
.side-nav .tab:hover:not(.active) { background: #edf4ff; color: #1d4ed8; }
.side-wave { position: absolute; bottom: 84px; left: 0; width: 100%; height: 148px; pointer-events: none; }
.side-footer { margin-top: auto; padding: 24px 22px 32px; font-size: 13px; font-weight: 600; color: #71859f; z-index: 1; }
.topbar, .container { margin-left: var(--rail-width); max-width: none; }
.topbar {
  min-height: 70px; padding: 12px 18px 12px 26px; gap: clamp(8px,1.2vw,20px);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-color: #d8e0eb; flex-wrap: nowrap;
}
.brand { flex: 0 1 auto; }
.brand-title { margin: 0; font-size: clamp(17px,1.42vw,23px); font-weight: 800; color: #07111f; white-space: nowrap; letter-spacing: -0.01em; }


#btnStart, #btnDrawLine { color: #fff; background: var(--warm-button); border-color: transparent; box-shadow: 0 6px 16px rgba(22, 119, 255, 0.20); }
#btnStop { color: #b42318; background: #fef2f2; border-color: #fecaca; box-shadow: 0 2px 6px rgba(180, 35, 24, 0.08); }

.btn:hover { background: #f7faff; border-color: #b7cef5; color: #1d4ed8; }
#btnStart:hover, #btnDrawLine:hover { background: #1d4ed8; color: #fff; }
#btnStop:hover { background: #dc2626; border-color: #dc2626; color: #fff; }
.top-actions { flex: none; gap: 10px; }
.top-actions .date-input, .top-actions .btn { min-height: 36px; border-radius: 8px; }
.top-actions .date-input { min-width: 145px; }
.date-input, .select, input[type="text"], input[type="number"], input[type="password"] {
  background: #f8fafc; border: 1px solid #cbd5e1; color: #0f172a;
  min-height: 38px; padding: 7px 11px;
}
input::placeholder { color: #94a3b8; }
input[type="file"] { color: #334155; font-size: 13px; }
.card h3, .card-header h3 { color: #07111f; font-weight: 700; }
.muted { color: #475569; font-size: 12.5px; }
.date-input:focus, .select:focus, input:focus {
  background: #ffffff; border-color: #1d4ed8; box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.16);
}
.btn { color: #1e40af; background: #ffffff; border-color: #d8e0eb; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04); }
.btn-primary { color: #fff; background: #1677ff; border-color: #1677ff; }
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.btn-danger { color: #b42318; background: #fef2f2; border-color: #fecaca; }
.btn-danger:hover { background: #dc2626; border-color: #dc2626; color: #fff; }
:focus-visible { outline: 2px solid #1677ff; outline-offset: 2px; }
.container { padding: 20px 22px 36px; }
.container.full-bleed { padding: 0; }
.analytics-iframe { height: calc(100dvh - 70px); }
.kpi-grid-4 { grid-template-columns: 1.05fr 1.01fr 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.kpi-card {
  display: grid; grid-template-columns: 38px minmax(0, 1fr); column-gap: 16px;
  align-content: center; min-height: 120px; padding: 14px 20px; border-radius: 12px;
  background: #ffffff;
  border-color: rgba(148, 163, 184, 0.30);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 14px 34px rgba(15, 23, 42, 0.07);
}
.kpi-card > .ui-icon { grid-row: 1 / 4; align-self: start; margin-top: 2px; font-size: 27px; color: #1677ff; }
.kpi-card > div { grid-column: 2; }
.kpi-highlight {
  color: #fff; border-color: transparent;
  background: linear-gradient(135deg, #2386ff 0%, #1677ff 52%, #4aa3ff 100%);
  box-shadow: 0 12px 28px rgba(22, 119, 255, 0.24);
}
.kpi-highlight > .ui-icon, .kpi-highlight .kpi-label, .kpi-highlight .kpi-desc { color: #fff; }
.kpi-label { font-size: 13px; color: #64748b; font-weight: 600; }
.kpi-desc { font-size: 12px; color: #71859f; }
.kpi-value { font-size: 36px; font-variant-numeric: tabular-nums; margin: 6px 0 3px; color: #07111f; }
.kpi-highlight .kpi-value { color: #ffffff; }
.dash-main { grid-template-columns: minmax(0, 1.405fr) minmax(0,1fr); gap: 16px; margin-bottom: 20px; }
.card {
  border-radius: var(--radius);
  border-color: rgba(148, 163, 184, 0.30);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 14px 34px rgba(15, 23, 42, 0.07);
}
.dash-main .card, .recent-card { background: #ffffff; }
.dash-main .card { padding: 16px 20px 14px; min-width: 0; }
.dash-main .card-header h3, .recent-card .card-header h3 { font-size: 17px; line-height: 1.35; font-weight: 750; color: #07111f; }
.dash-main .card-header .muted { display:block; margin-top: 4px; font-size: 12px; }
.video-card .card-header { margin-bottom: 18px; gap: 8px; }
.video-card .card-header > div:first-child { padding-left: 24px; position: relative; }
.stream-indicator { position:absolute; left: 3px; top: 7px; width: 11px; height: 11px; border-radius: 50%; background: #94a3b8; }
.stream-indicator.online { background: var(--green); }
.video-card .btn-group { gap: 7px; }
.video-card .btn-sm { white-space: nowrap; min-height: 34px; }
.video-wrap {
  width: min(100%, 640px);
  max-height: min(330px, 38vh);
  aspect-ratio: 16 / 9;
  margin-inline: auto;
  border-color: #d8e0eb;
  background: #0f172a;
}
.video-wrap img { object-fit: contain; }
.video-wrap img[hidden] { display: none; }
.stream-status { position: absolute; top: 8px; left: 11px; z-index: 1; max-width: calc(100% - 22px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 6px; padding: 3px 8px; color: #fff; background: rgba(15, 23, 42, 0.78); font-size: 12px; pointer-events: none; }
#lineCanvas.drawing { z-index: 2; }
.legend-bar { color: #64748b; gap: 8px 14px; font-size: 12px; }
.legend-bar .right { text-align: right; flex-basis: 100%; }
.dot-gray { background: #94a3b8; }
.chart-card .card-header { margin-bottom: 18px; }
.chart-card .card-header .btn { min-height: 34px; border-radius: 8px; font-size: 13px; }
.chart-legend { display: flex; justify-content: flex-end; gap: 24px; margin: 0 4px 22px; font-size: 12px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.chart-legend i { width: 14px; height: 9px; border-radius: 2px; }
.chart-area { position: relative; display: block; height: 240px; padding: 0 2px 0 34px; border: 0; border-radius: 0; background: transparent; overflow: visible; }
.chart-plot { height: 100%; position: relative; display: flex; padding: 0 5px; }
.chart-gridline { position: absolute; left: 0; right: 0; height: 1px; background: #edf1f6; pointer-events: none; }
.chart-gridline span { position:absolute; top: 0; right: calc(100% + 15px); transform: translateY(-50%); font-size: 12px; color: #7890ab; white-space: nowrap; }
.bar-col { position: relative; min-width: 0; }
.bar-pair { height: 100%; gap: 3px; padding: 0 3px; }
.bar { z-index: 1; min-height: 0; width: 45%; max-width: 15px; border-radius: 3px 3px 0 0; }
.bar-total { background: #bfdbfe; }
.bar-unique { background: #1677ff; }
.bar-label { position: absolute; top: 100%; margin-top: 10px; color: #64748b; }
.snapshot-note { margin: 72px 4px 12px; font-size: 13px; line-height: 1.55; }
.recent-card { padding: 16px 20px; }
.recent-card .card-header { margin-bottom: 18px; }
.recent-card h3 small { font-size: 14px; font-weight: 500; }
.recent-card .card-header .btn { background: transparent; border-color: transparent; box-shadow: none; font-size: 13px; }
.recent-grid {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.recent-grid .event-card,
.event-list .event-card {
  padding: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.recent-grid .event-card:hover,
.event-list .event-card:hover {
  border-color: #1677ff;
  box-shadow: 0 8px 20px rgba(22, 119, 255, 0.12);
}
.recent-grid .event-meta,
.event-list .event-meta {
  font-size: 12px;
  color: #334155;
  line-height: 1.55;
}
.recent-grid .event-actions { flex-wrap: wrap; }
.modal-card, .msg-box { background: transparent; }
.modal-card { background: var(--panel); }
@media (max-width: 1480px) {
  .topbar { flex-wrap: wrap; }
  .topbar .brand { flex: 1; }

  .video-card .card-header { flex-wrap: wrap; }
}
@media (max-width: 1180px) {
  :root { --rail-width: 184px; }
  .side-brand { padding-inline: 15px; }
  .side-brand strong { font-size: 19px; }
  .side-brand span { font-size: 11px; }
  .side-nav .tab { padding-inline: 11px; gap: 11px; }
  .container { padding-inline: 16px; }
  .dash-main { grid-template-columns: minmax(0,1fr); }
  .kpi-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-card { padding-inline: 16px; }
}
@media (max-width: 767px) {
  .side-rail {
    inset: auto 0 0;
    width: auto;
    border-radius: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .side-brand, .side-wave, .side-footer { display: none; }
  .side-nav {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 2px;
    margin: 4px;
  }
  .side-nav .tab {
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 4px 1px;
    white-space: nowrap;
    border-radius: 9px;
    font-size: 10px;
  }
  .side-nav .ui-icon { font-size: 18px; }
  .topbar, .container { margin-left: 0; }
  .topbar { padding: 10px 12px; }
  .topbar .brand { flex-basis: 100%; }
  .brand-title { white-space: normal; }

  .top-actions { width: auto; }
  .top-actions .date-input { min-width: 132px; font-size: 13px; }
  .container { padding: 14px 10px calc(72px + env(safe-area-inset-bottom)); }
  .analytics-iframe { height: calc(100dvh - 157px - env(safe-area-inset-bottom)); }
  .toast { bottom: calc(68px + env(safe-area-inset-bottom)); }
  .kpi-grid-4 { gap: 9px; margin-bottom: 12px; }
  .kpi-card { grid-template-columns: 25px minmax(0,1fr); column-gap: 7px; padding: 10px; min-height: 97px; }
  .kpi-card > .ui-icon { font-size: 21px; }
  .kpi-value { font-size: 30px; }
  .kpi-label, .kpi-desc { font-size: 11px; }
  .dash-main { gap: 12px; margin-bottom: 12px; }
  .dash-main .card, .recent-card { padding: 13px 11px; }
  .dash-main .card-header h3, .recent-card .card-header h3 { font-size: 15px; }
  .video-card .btn-group { flex-wrap: wrap; }
  .video-card .btn-sm { font-size: 11px; padding-inline: 7px; }
  .chart-area { height: 200px; }
  .bar-pair { padding-inline: 1px; gap: 1px; }
  .bar-label { font-size: 9px; }
  .snapshot-note { margin-top: 42px; }
}



.event-details { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.event-heading { display: flex; justify-content: space-between; align-items: center; gap: 6px; flex-wrap: wrap; }
:is(.event-list, .recent-grid) .event-imgs {
  height: 185px;
  min-width: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 5px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
:is(.event-list, .recent-grid) .event-imgs img {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  max-width: calc(50% - 3px);
  height: 100%;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
}
:is(.event-list, .recent-grid) .event-imgs.single img { max-width: 100%; }
:is(.event-list, .recent-grid) .event-details { align-self: stretch; padding-block: 2px; }
:is(.event-list, .recent-grid) .event-actions { flex-wrap: wrap; }
@media (max-width: 620px) {
  :is(.event-list, .recent-grid) { grid-template-columns: minmax(0, 1fr); }
  :is(.event-list, .recent-grid) .event-imgs { height: 190px; }
  :is(.event-list, .recent-grid) .event-actions .btn { flex: 0 1 auto; }
}
