:root {
  --bg: #f8f6f1;
  --surface: #ffffff;
  --surface-2: #fbf9f5;
  --border: #e8e2d5;
  --border-strong: #d9d0bd;

  --text-900: #241f19;
  --text-700: #4a4438;
  --text-500: #7a7263;
  --text-400: #a49c8b;

  --accent-1: #1f6f54;   /* deep emerald */
  --accent-2: #b8860b;   /* warm bronze/gold */
  --accent-grad: linear-gradient(135deg, var(--accent-1), #2f9c74);

  --danger: #a13d3d;
  --danger-bg: #f8ece9;
  --success: #1f6f54;
  --success-bg: #e8f3ec;
  --slate-bg: #f0ede5;

  --shadow-sm: 0 1px 3px rgba(60, 45, 20, 0.05), 0 1px 2px rgba(60, 45, 20, 0.04);
  --shadow-md: 0 10px 30px rgba(60, 45, 20, 0.08), 0 2px 8px rgba(60, 45, 20, 0.05);
  --shadow-lg: 0 30px 70px rgba(30, 22, 10, 0.28);
  --glow-1: 0 0 0 1px rgba(31, 111, 84, 0.18), 0 10px 28px rgba(31, 111, 84, 0.12);

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text-900);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(31, 111, 84, 0.18); color: var(--text-900); }

/* ---- Shell / sidebar ---- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 234px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  color: var(--text-900);
  display: flex;
  flex-direction: column;
  padding: 26px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px 26px;
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: .01em;
}
.brand-mark {
  color: var(--accent-1);
  display: inline-flex;
}
.brand-name { color: var(--text-900); }
.brand-name b, .brand-name .accent { color: var(--accent-2); }

.nav { display: flex; flex-direction: column; gap: 3px; padding: 0 14px; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-500);
  text-decoration: none;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
.nav-icon { flex-shrink: 0; opacity: .8; }
.nav-link:hover { background: var(--surface-2); color: var(--text-900); }
.nav-link.active {
  background: var(--success-bg);
  color: var(--accent-1);
  font-weight: 700;
  box-shadow: inset 2px 0 0 var(--accent-1);
}

.sidebar-footer { padding: 18px 22px 0; border-top: 1px solid var(--border); margin-top: 14px; }
.admin-tag { color: var(--text-500); font-size: 12.5px; margin-bottom: 8px; }
.logout-link { color: var(--danger); text-decoration: none; font-size: 13px; font-weight: 600; opacity: .85; }
.logout-link:hover { opacity: 1; }

.main { flex: 1; padding: 36px 44px; max-width: 1240px; }

/* ---- Headers ---- */
.page-header { margin-bottom: 26px; }
.page-header h1 { margin: 0 0 4px; font-size: 25px; font-weight: 800; letter-spacing: -.01em; color: var(--text-900); }
.page-sub { color: var(--text-500); margin: 0; font-size: 14px; }

/* ---- Stat cards ---- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 30px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px 22px; box-shadow: var(--shadow-sm);
  transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease;
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent-grad);
}
.stat-card:hover { box-shadow: var(--glow-1); transform: translateY(-2px); border-color: var(--border-strong); }
.stat-icon { display: inline-flex; color: var(--accent-1); margin-bottom: 10px; }
.stat-value { font-size: 29px; font-weight: 800; letter-spacing: -.02em; color: var(--text-900); }
.stat-label { color: var(--text-500); font-size: 12.5px; margin-top: 4px; font-weight: 500; }
.stat-card-red .stat-value { color: var(--danger); }
.stat-card-red .stat-icon { color: var(--danger); }
.stat-card-teal .stat-value { color: var(--accent-2); }
.stat-card-teal .stat-icon { color: var(--accent-2); }

/* ---- Panels ---- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 24px 26px; margin-bottom: 26px; box-shadow: var(--shadow-sm);
}
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.panel-header h2 { margin: 0; font-size: 16px; font-weight: 700; color: var(--text-900); }
.link { color: var(--accent-1); font-size: 13.5px; text-decoration: none; font-weight: 700; }
.link:hover { color: var(--accent-2); }

.empty-state { color: var(--text-500); font-size: 14px; padding: 20px 0; text-align: center; }
.hint { color: var(--text-500); font-size: 12.5px; margin-top: 10px; }

/* ---- Forms ---- */
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--text-500); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.field input[type=text], .field input[type=file], .field input[type=date], .field input[type=time], .field select {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 11px; font-size: 13.5px; min-width: 200px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
  background: var(--surface); color: var(--text-900);
}
.field input::placeholder { color: var(--text-400); }
.field input:focus, .field select:focus {
  outline: none; border-color: var(--accent-1); box-shadow: 0 0 0 3px rgba(31, 111, 84, 0.14);
}
.field-checkbox { flex-direction: row; align-items: center; }
.field-checkbox label { display: flex; align-items: center; gap: 6px; font-weight: 500; color: var(--text-700); text-transform: none; }

.btn {
  border: none; border-radius: var(--radius-sm); padding: 10px 18px; font-size: 13.5px; font-weight: 700;
  cursor: pointer; background: var(--surface-2); color: var(--text-900);
  border: 1px solid var(--border);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease;
}
.btn:hover { transform: translateY(-1px); background: var(--surface); border-color: var(--border-strong); }
.btn-primary {
  background: var(--accent-grad);
  color: #fff; border: none;
  box-shadow: 0 4px 16px rgba(31, 111, 84, 0.28);
}
.btn-primary:hover { box-shadow: 0 6px 22px rgba(31, 111, 84, 0.38); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #efd9d4; }
.btn-small { padding: 6px 12px; font-size: 12.5px; }
.btn-full { width: 100%; }

.row-actions { display: flex; gap: 8px; }
.row-actions form { display: inline; }

/* ---- Captures grid (dashboard) ---- */
.capture-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.capture-card {
  border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm); transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease;
}
.capture-card:hover { box-shadow: var(--glow-1); transform: translateY(-3px); border-color: var(--border-strong); }
.capture-thumb { position: relative; aspect-ratio: 4/3; background: var(--text-900); }
.capture-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.capture-meta { padding: 11px 13px; }
.capture-camera { font-weight: 700; font-size: 13px; color: var(--text-900); }
.capture-time { color: var(--text-500); font-size: 12px; margin-top: 2px; }
.capture-verdict { font-size: 11.5px; color: var(--danger); margin-top: 4px; font-weight: 600; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.badge-red { background: var(--danger-bg); color: var(--danger); }
.badge-teal { background: var(--success-bg); color: var(--accent-1); }
.badge-slate { background: var(--slate-bg); color: var(--text-500); }
.capture-thumb .badge { position: absolute; top: 8px; right: 8px; box-shadow: 0 2px 6px rgba(0,0,0,0.25); }

/* ---- Data table ---- */
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th, .data-table td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--border); color: var(--text-700); }
.data-table th {
  color: var(--text-500); font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border-strong);
}
.data-table tbody tr { transition: background .12s ease; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr:nth-child(even) { background: rgba(31, 111, 84, 0.02); }
.data-table tbody tr:nth-child(even):hover { background: var(--surface-2); }
.row-thumb { width: 60px; height: 44px; object-fit: cover; border-radius: 7px; cursor: zoom-in; transition: outline-color .15s ease; }
.row-thumb:hover { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.mono { font-family: ui-monospace, monospace; font-size: 12.5px; color: var(--text-500); }

/* ---- Filter form ---- */
.filter-form { margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.filter-form input[type=time] { min-width: 130px; }

/* ---- Dropdown (details/summary based, used for the Person filter) ---- */
.dropdown { position: relative; }
.dropdown-summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 11px; font-size: 13.5px; min-width: 170px;
  background: var(--surface); color: var(--text-900);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.dropdown-summary::-webkit-details-marker { display: none; }
.dropdown-summary svg { color: var(--text-500); flex-shrink: 0; transition: transform .15s ease; }
.dropdown[open] .dropdown-summary { border-color: var(--accent-1); box-shadow: 0 0 0 3px rgba(31, 111, 84, 0.14); }
.dropdown[open] .dropdown-summary svg { transform: rotate(180deg); }
.dropdown-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 20;
  min-width: 200px; max-height: 240px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); padding: 6px;
}
.dropdown-option {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: 6px; font-size: 13.5px; color: var(--text-700);
  cursor: pointer; font-weight: 500;
}
.dropdown-option:hover { background: var(--surface-2); }
.dropdown-option input { accent-color: var(--accent-1); }
.dropdown-empty { color: var(--text-400); font-size: 13px; padding: 8px; }

/* ---- Lightbox ---- */
.lightbox {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: rgba(30, 25, 15, 0.75);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  align-items: center; justify-content: center; flex-direction: column;
  cursor: zoom-out;
}
.lightbox.open { display: flex; }
.lightbox img, .lightbox video {
  max-width: 90vw; max-height: 82vh; border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); cursor: default;
  border: 3px solid #fff;
}
.lightbox-caption { color: #fff; margin-top: 16px; font-size: 14px; }
.lightbox-close {
  position: absolute; top: 22px; right: 34px; color: #fff;
  font-size: 34px; line-height: 1; cursor: pointer; font-weight: 300;
  transition: color .15s ease;
}
.lightbox-close:hover { color: var(--accent-2); }

/* ---- Live cameras ---- */
.live-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.live-card {
  border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.live-card img { width: 100%; display: block; background: #000; aspect-ratio: 16/9; object-fit: cover; }
.live-card-label { padding: 9px 13px; font-size: 12.5px; font-weight: 700; color: var(--text-700); }

/* ---- Auth ---- */
.auth-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 18% 18%, rgba(31, 111, 84, 0.08), transparent 42%),
    radial-gradient(circle at 82% 82%, rgba(184, 134, 11, 0.07), transparent 45%),
    var(--bg);
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 40px 36px; width: 360px;
  box-shadow: var(--shadow-lg);
  position: relative; overflow: hidden;
}
.auth-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent-grad);
}
.auth-brand { margin-bottom: 4px; }
.auth-brand .brand-logo { height: 64px !important; }
.auth-brand .brand-name { font-size: 26px; font-weight: 800; }
.auth-sub { color: var(--text-500); font-size: 13px; margin: 0 0 22px; }
.auth-form { display: flex; flex-direction: column; gap: 6px; }
.auth-form label { font-size: 12px; color: var(--text-500); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; margin-top: 10px; }
.auth-form input {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 13px; font-size: 14px;
  background: var(--surface); color: var(--text-900);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.auth-form input:focus { outline: none; border-color: var(--accent-1); box-shadow: 0 0 0 3px rgba(31, 111, 84, 0.14); }
.auth-form button { margin-top: 20px; }
.form-error { background: var(--danger-bg); color: var(--danger); padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px; border: 1px solid #efd9d4; }
