:root {
  --primary: #0e7490;
  --primary-dark: #155e75;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--primary);
  color: #fff;
  padding: 0.75rem 1.25rem;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { font-weight: 700; font-size: 1.15rem; }
.nav-toggle { display: none; background: none; border: none; color: #fff; font-size: 1.4rem; cursor: pointer; }
.nav-links { display: flex; align-items: center; gap: 0.9rem; margin-left: auto; flex-wrap: wrap; }
.nav-links a { color: #e0f2fe; font-size: 0.95rem; }
.nav-links a:hover { color: #fff; }
.user-chip { background: rgba(255,255,255,.2); padding: 0.25rem 0.7rem; border-radius: 999px; font-size: 0.85rem; }
.btn-logout { background: rgba(0,0,0,.2); padding: 0.3rem 0.8rem; border-radius: 8px; color: #fff; }

/* Container */
.container { max-width: 1080px; margin: 1.5rem auto; padding: 0 1rem; }
.container-auth { max-width: 420px; margin: 8vh auto; }

/* Alerts */
.alert { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.card h2 { margin: 0 0 0.75rem; font-size: 1.1rem; }

/* Grid */
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid-main { grid-template-columns: 1.4fr 1fr; }
.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 1.25rem; }
@media (max-width: 720px) {
  .grid-2, .grid-3, .grid-main { grid-template-columns: 1fr; }
  .nav-toggle { display: block; }
  .nav-links { display: none; width: 100%; }
  .nav-links.open { display: flex; }
}

.stat { text-align: center; }
.stat-num { font-size: 1.7rem; font-weight: 700; color: var(--primary); }
.stat-label { color: var(--muted); font-size: 0.85rem; }

/* Buttons */
.btn {
  display: inline-block;
  background: #e2e8f0;
  color: var(--text);
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(0.95); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--border); }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.82rem; }
.btn-lg { padding: 0.8rem 1.6rem; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; }
.kv { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.kv th, .kv td { text-align: left; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.kv th { color: var(--muted); width: 120px; font-weight: 600; }

/* Forms */
label { display: block; margin: 0.9rem 0 0.3rem; font-weight: 500; font-size: 0.9rem; }
input, select, textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
}
input[type="checkbox"] { width: auto; }
.form-actions { margin-top: 1.2rem; display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* Badges */
.badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem; background: #e2e8f0; }
.badge-pending { background: #fef9c3; color: #854d0e; }
.badge-processing, .badge-uploading { background: #dbeafe; color: #1e40af; }
.badge-success, .badge-ready { background: #dcfce7; color: #166534; }
.badge-failed { background: #fee2e2; color: #991b1b; }

/* Page head */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; flex-wrap: wrap; gap: 0.5rem; }
.page-title { margin: 0 0 0.25rem; font-size: 1.5rem; }

/* Camera */
.camera-wrap {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 10;
  max-height: 420px;
}
.camera-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.rec-controls { display: flex; gap: 0.6rem; margin-top: 0.9rem; flex-wrap: wrap; }
.rec-status { margin-top: 0.5rem; }
.rec-timer { font-size: 1.3rem; font-weight: 700; text-align: center; margin-top: 0.4rem; color: var(--primary); }

/* Progress */
.progress { height: 12px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin-top: 0.75rem; }
.progress-bar { height: 100%; width: 0; background: var(--primary); transition: width 0.2s; }

/* Checkbox list */
.checkbox-list { border: 1px solid var(--border); border-radius: 8px; padding: 0.4rem 0.6rem; max-height: 220px; overflow: auto; }
.checkbox-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0; margin: 0; cursor: pointer; }
.checkbox-item input { margin: 0; }
.plat-icon { font-size: 0.8rem; text-transform: uppercase; background: #f1f5f9; padding: 0.1rem 0.45rem; border-radius: 6px; }

/* Video box */
.video-box { background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16/9; margin-bottom: 1rem; }
.video-box iframe, .video-box img { width: 100%; height: 100%; border: 0; object-fit: cover; }
.placeholder { display: flex; align-items: center; justify-content: center; height: 100%; color: #94a3b8; }

/* List item */
.list-item { display: flex; align-items: center; justify-content: space-between; padding: 0.6rem 0; border-bottom: 1px solid var(--border); }

/* Quick actions */
.quick-actions { text-align: center; margin: 1.5rem 0; }

/* Login */
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 2rem; box-shadow: 0 8px 30px rgba(0,0,0,.06); }
.login-logo { font-size: 3rem; text-align: center; }
.login-card h1 { text-align: center; margin: 0.3rem 0; }

/* Footer */
.footer { text-align: center; color: var(--muted); font-size: 0.82rem; padding: 1.5rem 1rem 2rem; }
