/*
  Snap 51 Tracker — shared design system
  Built on top of stock Bootstrap 5.3 (CDN). Overrides Bootstrap's CSS
  variables so every component (buttons, links, badges, forms, focus
  rings...) automatically inherits the brand palette.
*/

:root {
  --bp-primary: #14477a;
  --bp-primary-dark: #0d2f52;
  --bp-primary-light: #1f6bb3;
  --bp-accent: #c8952a;
  --bp-surface: #ffffff;
  --bp-bg: #f2f5f9;
  --bp-border: #e3e8ef;
  --bp-text: #29323d;
  --bp-text-muted: #6b7686;
  --bp-radius-sm: .5rem;
  --bp-radius: .75rem;
  --bp-radius-lg: 1rem;
  --bp-shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --bp-shadow: 0 4px 16px rgba(16, 24, 40, .08);
  --bp-shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);

  --bs-primary: var(--bp-primary);
  --bs-primary-rgb: 20, 71, 122;
  --bs-link-color: var(--bp-primary);
  --bs-link-color-rgb: 20, 71, 122;
  --bs-link-hover-color: var(--bp-primary-dark);
  --bs-link-hover-color-rgb: 13, 47, 82;
  --bs-body-bg: var(--bp-bg);
  --bs-body-color: var(--bp-text);
  --bs-border-color: var(--bp-border);
  --bs-border-radius: var(--bp-radius-sm);
  --bs-border-radius-lg: var(--bp-radius);
  --bs-border-radius-sm: .375rem;
  --bs-font-sans-serif: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  font-family: var(--bs-font-sans-serif);
  background-color: var(--bp-bg);
  color: var(--bp-text);
}

a {
  text-decoration: none;
}

::selection {
  background: rgba(20, 71, 122, .18);
}

/* ---------- Utility polish ---------- */

.shadow-soft { box-shadow: var(--bp-shadow-sm) !important; }
.shadow-soft-lg { box-shadow: var(--bp-shadow) !important; }

.text-accent { color: var(--bp-accent) !important; }
.bg-accent { background-color: var(--bp-accent) !important; }

.btn {
  font-weight: 500;
  border-radius: var(--bp-radius-sm);
}
.btn-sm { border-radius: .45rem; }

.btn-primary {
  --bs-btn-bg: var(--bp-primary);
  --bs-btn-border-color: var(--bp-primary);
  --bs-btn-hover-bg: var(--bp-primary-dark);
  --bs-btn-hover-border-color: var(--bp-primary-dark);
  --bs-btn-active-bg: var(--bp-primary-dark);
  --bs-btn-active-border-color: var(--bp-primary-dark);
  box-shadow: var(--bp-shadow-sm);
}

.btn-accent {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--bp-accent);
  --bs-btn-border-color: var(--bp-accent);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #a97918;
  --bs-btn-hover-border-color: #a97918;
}

.card {
  border: 1px solid var(--bp-border);
  border-radius: var(--bp-radius);
  box-shadow: var(--bp-shadow);
  transition: box-shadow .15s ease, transform .15s ease;
}

.card-header {
  background-color: var(--bp-surface);
  border-bottom: 1px solid var(--bp-border);
  font-weight: 600;
  color: var(--bp-text);
  padding: 1rem 1.25rem;
}

.card-header .bi { color: var(--bp-primary); }

.form-label {
  font-weight: 500;
  font-size: .875rem;
  color: var(--bp-text);
  margin-bottom: .35rem;
}

.form-control, .form-select {
  border-color: var(--bp-border);
  padding-top: .5rem;
  padding-bottom: .5rem;
}

.form-control:focus, .form-select:focus {
  border-color: var(--bp-primary-light);
  box-shadow: 0 0 0 .2rem rgba(20, 71, 122, .15);
}

.table {
  --bs-table-color: var(--bp-text);
  vertical-align: middle;
}

.table > thead {
  background-color: #eef2f7;
}

.table > thead th, .table > thead td {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--bp-text-muted);
  font-weight: 700;
  border-bottom-width: 1px;
  white-space: nowrap;
}

.table-responsive {
  border-radius: var(--bp-radius);
}

.badge {
  font-weight: 600;
  letter-spacing: .01em;
  padding: .4em .65em;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--bp-text-muted);
}
.empty-state .bi { font-size: 2.25rem; color: var(--bp-border); display: block; margin-bottom: .5rem; }

/* ---------- App shell (wl_admin) ---------- */

.app-shell { min-height: 100vh; }

.app-sidebar {
  --bp-sidebar-w: 292px;
  width: var(--bp-sidebar-w);
  background: linear-gradient(190deg, var(--bp-primary-dark), var(--bp-primary) 60%, var(--bp-primary-light) 130%);
  color: #eaf1f8;
  position: relative;
}
.app-sidebar::after {
  /* subtle decorative glow, echoes the auth page treatment so the whole app feels of a piece */
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 15% 0%, rgba(200, 149, 42, .16), transparent 55%);
  pointer-events: none;
}

.app-sidebar .offcanvas-header { border-bottom: 1px solid rgba(255,255,255,.12); }

.sidebar-brand {
  padding: 1.5rem 1.35rem 1.15rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  position: relative;
  z-index: 1;
}
.sidebar-brand img { height: 40px; width: auto; object-fit: contain; background: #fff; border-radius: .5rem; padding: 3px; }
.sidebar-brand .brand-title {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.25;
  color: #fff;
  letter-spacing: -.01em;
}

.sidebar-nav { padding: 1rem .85rem; position: relative; z-index: 1; }
.sidebar-nav-heading {
  padding: .9rem .65rem .4rem;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: rgba(234, 241, 248, .45);
}
.sidebar-nav-heading:first-child { padding-top: .25rem; }
.sidebar-nav .menu-item + .menu-item { margin-top: .2rem; }
.sidebar-nav .nav-link {
  color: rgba(234, 241, 248, .82);
  border-radius: var(--bp-radius-sm);
  padding: .7rem .9rem;
  display: flex;
  align-items: center;
  gap: .85rem;
  font-size: .95rem;
  font-weight: 500;
  transition: background-color .15s ease, color .15s ease, transform .15s ease;
}
.sidebar-nav .nav-link .bi {
  font-size: 1.05rem;
  width: 2rem;
  height: 2rem;
  line-height: 2rem;
  flex-shrink: 0;
  text-align: center;
  border-radius: .55rem;
  background: rgba(255, 255, 255, .08);
  transition: background-color .15s ease, color .15s ease;
}
.sidebar-nav .nav-link:hover { background: rgba(255, 255, 255, .09); color: #fff; transform: translateX(2px); }
.sidebar-nav .nav-link:hover .bi { background: rgba(255, 255, 255, .16); }
.sidebar-nav .menu-item.open .nav-link {
  background: rgba(255, 255, 255, .16);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--bp-accent);
}
.sidebar-nav .menu-item.open .nav-link .bi {
  background: var(--bp-accent);
  color: #fff;
}

.sidebar-footer {
  padding: 1rem 1.35rem;
  color: rgba(234, 241, 248, .55);
  font-size: .75rem;
  border-top: 1px solid rgba(255, 255, 255, .12);
  position: relative;
  z-index: 1;
}

.app-main { min-width: 0; }

.app-topbar {
  background: var(--bp-surface);
  border-bottom: 1px solid var(--bp-border);
  padding: .65rem 1.25rem;
}

.app-topbar #header-title {
  font-weight: 600;
  color: var(--bp-text);
}

.app-topbar .avatar-btn img {
  width: 34px;
  height: 34px;
  object-fit: cover;
  border: 2px solid var(--bp-border);
}

.app-content {
  padding: 1.75rem;
  background:
    radial-gradient(circle at 100% 0%, rgba(20, 71, 122, .05), transparent 45%),
    radial-gradient(circle at 0% 100%, rgba(200, 149, 42, .05), transparent 40%);
}

.app-footer {
  padding: 1rem 1.25rem;
  color: var(--bp-text-muted);
  font-size: .825rem;
  border-top: 1px solid var(--bp-border);
  background: var(--bp-surface);
}

@media (max-width: 991.98px) {
  .app-content { padding: 1rem; }
}

/* Preloader / progress overlay (kept from legacy behaviour, restyled) */
#preloader, #pre_progress_bar {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(242, 245, 249, .85);
  backdrop-filter: blur(2px);
  z-index: 1080;
}
#loader { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
#progress_bar { position: absolute; top: 50%; left: 5%; width: 90%; transform: translateY(-50%); }
#progress_bar .title { text-align: center; margin-bottom: .75rem; }

/* ---------- Auth pages (login / 404) ---------- */

.auth-wrapper {
  min-height: 100vh;
  display: flex;
}

.auth-aside {
  background: radial-gradient(circle at 20% 20%, var(--bp-primary-light), var(--bp-primary-dark) 65%);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.auth-aside::after {
  content: "";
  position: absolute;
  inset: -20%;
  background: radial-gradient(circle, rgba(200,149,42,.25), transparent 60%);
}
.auth-aside .content { position: relative; z-index: 1; }
.auth-aside img.brand-logo { height: 46px; background: #fff; padding: 6px; border-radius: .5rem; }

.auth-card {
  border: none;
  border-radius: var(--bp-radius-lg);
  box-shadow: var(--bp-shadow-lg);
}

.auth-card .form-control { background: #fbfcfe; }

#captchaCanvas {
  border: 1px solid var(--bp-border);
  border-radius: var(--bp-radius-sm);
  background: #fbfcfe;
}

.error-code {
  font-size: 6rem;
  font-weight: 800;
  color: var(--bp-primary);
  line-height: 1;
}

@media (max-width: 991.98px) {
  .auth-aside { display: none !important; }
}

/* ---------- Dashboard ---------- */

.dashboard-hero {
  background: linear-gradient(120deg, var(--bp-primary-dark), var(--bp-primary) 55%, var(--bp-primary-light) 130%);
  color: #fff;
  border: none;
  position: relative;
  overflow: hidden;
}
.dashboard-hero::after {
  content: "";
  position: absolute;
  inset: -30% -10% auto auto;
  width: 60%;
  height: 220%;
  background: radial-gradient(circle, rgba(200, 149, 42, .28), transparent 62%);
  pointer-events: none;
}
.dashboard-hero .card-body { position: relative; z-index: 1; }
.dashboard-hero p { color: rgba(255, 255, 255, .8) !important; }

.stat-card { border: none; position: relative; overflow: hidden; }
.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: var(--stat-color, var(--bp-primary));
}
.stat-card .stat-icon {
  width: 3rem;
  height: 3rem;
  border-radius: var(--bp-radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  background: color-mix(in srgb, var(--stat-color, var(--bp-primary)) 14%, transparent);
  color: var(--stat-color, var(--bp-primary));
  margin-bottom: .75rem;
}
.stat-card .stat-value { font-size: 1.85rem; font-weight: 800; line-height: 1.15; color: var(--bp-text); }
.stat-card .stat-label { color: var(--bp-text); font-size: .82rem; font-weight: 600; margin-top: .15rem; }
.stat-card .stat-caption { color: var(--bp-text-muted); font-size: .76rem; margin-top: .15rem; }

.stat-card-primary { --stat-color: var(--bp-primary); }
.stat-card-info { --stat-color: #0f8b8d; }
.stat-card-accent { --stat-color: var(--bp-accent); }
.stat-card-purple { --stat-color: #6b46c1; }
.stat-card-warning { --stat-color: #c77b12; }
.stat-card-success { --stat-color: #1a8f4c; }
.stat-card-danger { --stat-color: #b23c3c; }

/* ---------- Dashboard: review timeliness action panel ----------
   Three wide tiles reporting queue health -- how stale the pending backlog is, and how much
   activity happened today -- rather than individual stat cards, since these three numbers are
   read together as one story, not compared independently. */
.action-panel-row { border-radius: var(--bp-radius); overflow: hidden; }
.action-panel-tile {
  padding: 1.25rem 1.5rem;
  text-align: center;
}
.action-panel-value { font-size: 2.5rem; font-weight: 800; line-height: 1; }
.action-panel-label { font-weight: 700; margin-top: .35rem; color: var(--bp-text); }
.action-panel-caption { font-size: .8rem; color: var(--bp-text-muted); margin-top: .2rem; }

.action-panel-tile-critical { background: color-mix(in srgb, #b23c3c 10%, transparent); }
.action-panel-tile-critical .action-panel-value { color: #b23c3c; }
.action-panel-tile-good { background: color-mix(in srgb, #1a8f4c 10%, transparent); }
.action-panel-tile-good .action-panel-value { color: #1a8f4c; }
.action-panel-tile-info { background: var(--bp-bg); }
.action-panel-tile-info .action-panel-value { color: var(--bp-primary); }

@media (max-width: 767.98px) {
  .action-panel-tile { border-radius: var(--bp-radius-sm); margin-bottom: .5rem; }
  .action-panel-row { border-radius: 0; overflow: visible; }
}

/* ---------- Dashboard: AC verification gauge ----------
   A half-circle instrument dial, deliberately echoing the measurement gauges (density/alcohol
   meters) this whole portal exists to report on -- not a generic donut. Threshold-colored like a
   real gauge redline: red/amber/green zones, not the brand accent. */
.gauge-card { display: flex; flex-direction: column; align-items: center; }
.gauge-svg { width: 100%; max-width: 220px; height: auto; }
.gauge-track { fill: none; stroke: var(--bp-border); stroke-width: 14; stroke-linecap: round; }
.gauge-fill {
  fill: none;
  stroke-width: 14;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s cubic-bezier(.4, 0, .2, 1), stroke .3s ease;
}
.gauge-fill.gauge-critical { stroke: #b23c3c; }
.gauge-fill.gauge-warning { stroke: #c77b12; }
.gauge-fill.gauge-good { stroke: #1a8f4c; }
.gauge-readout {
  margin-top: -3.1rem;
  text-align: center;
  position: relative;
  z-index: 1;
}
.gauge-readout .gauge-value { font-size: 2rem; font-weight: 800; line-height: 1; color: var(--bp-text); }
.gauge-readout .gauge-value .unit { font-size: 1.1rem; font-weight: 700; color: var(--bp-text-muted); }
.gauge-caption {
  font-size: .82rem;
  color: var(--bp-text-muted);
  text-align: center;
  margin-top: .35rem;
}

/* ---------- Dashboard: recent activity ---------- */
.activity-row .entity-cell .name { font-weight: 600; color: var(--bp-text); }
.activity-row .entity-cell .meta { font-size: .78rem; color: var(--bp-text-muted); }

@media (max-width: 767.98px) {
  .gauge-card { margin-top: .5rem; }
}

/* ---------- API documentation code blocks ---------- */
.docs-code-block {
  background: #14202e;
  color: #e6edf3;
  border-radius: var(--bp-radius-sm);
  padding: .9rem 1.1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .85rem;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  margin: 0;
}

/* ---------- Mobile-friendly stacked tables ----------
   Applied via `.table-stack-mobile` to wide data tables. Below the breakpoint each row becomes
   a bordered card and every cell's `data-label` attribute is shown as a left-aligned label,
   instead of relying on horizontal scroll alone. */
@media (max-width: 767.98px) {
  table.table-stack-mobile thead {
    display: none;
  }
  table.table-stack-mobile,
  table.table-stack-mobile tbody,
  table.table-stack-mobile tr,
  table.table-stack-mobile td {
    display: block;
    width: 100%;
  }
  table.table-stack-mobile tr {
    margin-bottom: 1rem;
    border: 1px solid var(--bp-border);
    border-radius: var(--bp-radius-sm);
    padding: .5rem 0;
  }
  table.table-stack-mobile td {
    text-align: right !important;
    padding: .5rem .75rem .5rem 45% !important;
    position: relative;
    border: none;
    border-bottom: 1px dashed var(--bp-border);
    min-height: 2.25rem;
  }
  table.table-stack-mobile tr td:last-child {
    border-bottom: none;
  }
  table.table-stack-mobile td[data-label]::before {
    content: attr(data-label);
    position: absolute;
    left: .75rem;
    width: 40%;
    text-align: left;
    font-weight: 600;
    color: var(--bp-text-muted);
    white-space: normal;
  }
  table.table-stack-mobile td:not([data-label]) {
    text-align: center !important;
    padding-left: .75rem !important;
  }
}
