/* ==========================================================================
   Smart Gas Facility Monitor — design tokens & base styles
   Palette: industrial dark / signal orange, per spec.
   ========================================================================== */

:root {
  --bg: #f4f8fb;
  --bg-elevated: rgba(255, 255, 255, 0.78);
  --card: rgba(255, 255, 255, 0.92);
  --card-hover: rgba(255, 255, 255, 0.98);
  --border: rgba(15, 23, 42, 0.08);
  --accent: #00FFFF;
  --accent-blue: #0076FF;
  --accent-lime: #B1FF00;
  --accent-glow: rgba(0, 255, 255, 0.16);
  --success: #009A00;
  --text: #111827;
  --text-dim: #475569;
  --text-faint: #64748b;

  --blue: #0076FF;
  --purple: #6d28d9;
  --teal: #14b8a6;
  --yellow: #facc15;
  --red: #dc2626;
  --green: #009A00;

  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;

  --shadow-card: 0 24px 60px rgba(15, 23, 42, 0.08);
  --shadow-glow: 0 0 0 1px rgba(0, 255, 255, 0.12), 0 20px 40px rgba(0, 118, 255, 0.1);

  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(circle at 18% 10%, rgba(0, 255, 255, 0.14), transparent 28%),
    radial-gradient(circle at 82% 12%, rgba(0, 118, 255, 0.08), transparent 30%);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
::selection { background: var(--accent-glow); }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #333844; }

/* ==========================================================================
   Layout shells
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  width: 120px;
  height: auto;
  display: block;
  object-fit: contain;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-links {
  display: flex;
  gap: 8px;
  align-items: center;
}

.nav-link {
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 600;
  transition: all .15s ease;
}
.nav-link:hover { color: var(--text); background: rgba(15, 23, 42, 0.04); }
.nav-link.active { color: var(--accent-blue); background: rgba(0, 118, 255, 0.12); }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
}
.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

.page {
  max-width: 1320px;
  margin: 0 auto;
  padding: 44px 32px 84px;
}

/* ==========================================================================
   Hero / upload
   ========================================================================== */

.hero {
  text-align: center;
  padding: 56px 20px 40px;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent-glow);
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 22px;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 16px;
  line-height: 1.08;
}

.hero h1 span { color: var(--accent); }

.hero p {
  font-size: 16.5px;
  color: var(--text-dim);
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.6;
}

.upload-zone {
  margin: 36px auto 0;
  max-width: 760px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
  padding: 52px 32px;
  transition: all .25s ease;
  position: relative;
  box-shadow: var(--shadow-card);
}

.upload-zone.dragover {
  border-color: var(--accent-blue);
  background: rgba(0, 118, 255, 0.05);
  box-shadow: 0 0 0 1px rgba(0, 118, 255, 0.18), 0 24px 45px rgba(0, 118, 255, 0.08);
}

.upload-zone.has-file {
  border-style: solid;
  border-color: rgba(0, 255, 255, 0.3);
}

.upload-icon {
  width: 56px; height: 56px;
  margin: 0 auto 20px;
  border-radius: 16px;
  background: var(--accent-dim);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}

.upload-zone h3 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 600;
}

.upload-zone p {
  margin: 0 0 24px;
  color: var(--text-faint);
  font-size: 13.5px;
}

.upload-formats {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.format-chip {
  font-size: 11.5px;
  font-family: var(--font-mono);
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  padding: 12px 26px;
  border-radius: 12px;
  border: none;
  transition: all .15s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-blue));
  color: #08203c;
  box-shadow: 0 14px 30px rgba(0, 118, 255, 0.18);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 18px 34px rgba(0, 118, 255, 0.22); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: rgba(15, 23, 42, 0.04);
  color: var(--text);
  border: 1px solid rgba(15, 23, 42, 0.1);
}
.btn-secondary:hover { background: rgba(15, 23, 42, 0.08); }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-faint); }

.file-input-hidden { display: none; }

.file-preview {
  display: none;
  align-items: center;
  gap: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-top: 20px;
  text-align: left;
}
.file-preview.visible { display: flex; }
.file-preview-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent-dim); color: var(--accent);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.file-preview-name { font-size: 13.5px; font-weight: 600; }
.file-preview-meta { font-size: 12px; color: var(--text-faint); }
.file-preview-remove {
  margin-left: auto; background: none; border: none; color: var(--text-faint);
  font-size: 18px; padding: 4px 8px;
}
.file-preview-remove:hover { color: var(--red); }

.analyze-btn-row { margin-top: 26px; }

/* ==========================================================================
   Processing screen
   ========================================================================== */

.processing-screen {
  display: none;
  max-width: 640px;
  margin: 60px auto;
  text-align: center;
}
.processing-screen.visible { display: block; }

.processing-ring {
  width: 88px; height: 88px;
  margin: 0 auto 28px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.processing-message {
  font-size: 16px;
  font-weight: 600;
  min-height: 24px;
  transition: opacity .2s ease;
}

.processing-bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  margin-top: 24px;
  overflow: hidden;
}
.processing-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #ff9a4d);
  width: 0%;
  transition: width .3s ease;
  border-radius: 999px;
}
.processing-percent {
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-faint);
}

/* ==========================================================================
   Cards / stats
   ========================================================================== */

.section-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.section-sub {
  font-size: 13px;
  color: var(--text-faint);
  margin: 0 0 20px;
}

.section-header-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 36px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: var(--radius-md);
  padding: 22px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  transition: transform .15s ease, border-color .15s ease;
}
.stat-card:hover { transform: translateY(-2px); border-color: rgba(0, 118, 255, 0.18); }

.stat-card .stat-icon {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
}
.stat-label {
  font-size: 12.5px;
  color: var(--text-faint);
  margin-top: 8px;
  font-weight: 500;
}
.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.alert .stat-value { color: var(--red); }

.grid-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.panel {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  margin-bottom: 20px;
}

/* ==========================================================================
   Media (image/video result)
   ========================================================================== */

.media-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 720px) { .media-compare { grid-template-columns: 1fr; } }

.media-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.media-box img, .media-box video {
  width: 100%; display: block; background: #000;
}
.media-box-label {
  padding: 10px 14px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border);
}

/* ==========================================================================
   Truck table
   ========================================================================== */

.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.data-table th {
  text-align: left;
  padding: 10px 14px;
  color: var(--text-faint);
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: var(--card-hover); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}
.badge-loading { background: rgba(243,120,32,.15); color: var(--accent); }
.badge-waiting { background: rgba(168,85,247,.15); color: var(--purple); }
.badge-weighing { background: rgba(59,130,246,.15); color: var(--blue); }
.badge-inspection { background: rgba(20,184,166,.15); color: var(--teal); }
.badge-parking { background: rgba(234,179,8,.15); color: var(--yellow); }
.badge-completed { background: rgba(34,197,94,.15); color: var(--green); }
.badge-longstay, .badge-restricted { background: rgba(239,68,68,.15); color: var(--red); }
.badge-entering, .badge-leaving, .badge-unknown { background: rgba(156,163,175,.15); color: var(--text-dim); }

/* ==========================================================================
   Event log / timeline
   ========================================================================== */

.timeline { position: relative; padding-left: 4px; max-height: 520px; overflow-y: auto; }
.timeline-item {
  display: flex;
  gap: 14px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-icon {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}
.timeline-icon.info { color: var(--blue); }
.timeline-icon.success { color: var(--green); }
.timeline-icon.warning { color: var(--yellow); }
.timeline-icon.critical { color: var(--red); }
.timeline-body { flex: 1; }
.timeline-msg { font-size: 13px; line-height: 1.4; }
.timeline-time { font-size: 11px; color: var(--text-faint); font-family: var(--font-mono); margin-top: 3px; }

/* ==========================================================================
   Bar chart (detections per hour)
   ========================================================================== */

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 160px;
  padding-top: 10px;
}
.bar-chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}
.bar-chart-bar {
  width: 100%;
  max-width: 26px;
  background: linear-gradient(180deg, var(--accent), #b85510);
  border-radius: 5px 5px 0 0;
  min-height: 3px;
  transition: height .4s ease;
}
.bar-chart-label {
  font-size: 10px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

/* ==========================================================================
   Empty / misc
   ========================================================================== */

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-faint);
  font-size: 13.5px;
}

.footer-note {
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
  margin-top: 60px;
}

.pulse-live {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--green); font-weight: 600;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fadeIn .35s ease; }

/* ==========================================================================
   Live stream viewer
   ========================================================================== */

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 5px 12px;
  border-radius: 999px;
  text-transform: uppercase;
}
.live-badge.live {
  background: rgba(220, 38, 38, 0.12);
  color: #dc2626;
  border: 1px solid rgba(220, 38, 38, 0.25);
  animation: live-pulse 1.8s ease-in-out infinite;
}
.live-badge.complete {
  background: rgba(0, 154, 0, 0.1);
  color: var(--green);
  border: 1px solid rgba(0, 154, 0, 0.2);
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .65; }
}

.stream-progress-wrap {
  padding: 14px 20px 16px;
  margin-bottom: 20px;
}
.stream-progress-bar-track {
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  margin-top: 8px;
}
.stream-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #ff9a4d);
  width: 0%;
  transition: width .4s ease;
  border-radius: 999px;
}

/* Main 2-column grid: canvas (left) + sidebar (right) */
.live-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
  margin-bottom: 20px;
}
@media (max-width: 1000px) { .live-grid { grid-template-columns: 1fr; } }

.live-canvas-panel {
  padding: 0;
  overflow: hidden;
}
.live-canvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.live-canvas-wrap {
  position: relative;
  background: #000;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#liveCanvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 560px;
  object-fit: contain;
}
.canvas-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: rgba(255,255,255,0.5);
  font-size: 13px;
  background: #0a0f1a;
}
.canvas-placeholder .processing-ring {
  width: 44px; height: 44px; border-width: 3px; margin: 0;
}
.canvas-placeholder.hidden { display: none; }

.live-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.live-sidebar .stat-grid {
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 0;
}
.live-sidebar .stat-card { padding: 16px; }
.live-sidebar .stat-value { font-size: 24px; }

.live-timeline {
  max-height: 300px;
  overflow-y: auto;
}

