/* ---------------------------------------------------------------------------
   Forest Corporation — design tokens
   Deep forest green for chrome, warm neutrals for surfaces. Sizing is tuned for
   gloved hands on mid-range Android phones: 48px minimum touch targets,
   16px base font so mobile browsers never zoom on focus.
--------------------------------------------------------------------------- */
:root {
  --green-900: #064e3b;
  --green-800: #065f46;
  --green-700: #047857;
  --green-600: #059669;
  --green-500: #10b981;
  --green-100: #d1fae5;
  --green-050: #ecfdf5;

  --amber-600: #d97706;
  --amber-100: #fef3c7;
  --red-600: #dc2626;
  --red-100: #fee2e2;
  --blue-600: #2563eb;
  --blue-100: #dbeafe;

  --ink-900: #0f172a;
  --ink-700: #334155;
  --ink-500: #64748b;
  --ink-300: #94a3b8;

  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --bg: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 36px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--ink-900);
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------- App bar ------------------------------- */
.topbar {
  background: #0f172a;
  color: #f8fafc;
  padding: 0 24px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark {
  width: 44px; height: 44px; flex: none;
  background: transparent;
  border: none;
  display: grid; place-items: center;
}
.brand-mark img { height: 42px; width: auto; object-fit: contain; }
.brand-text { min-width: 0; }
.brand-name { font-weight: 700; font-size: 1.05rem; letter-spacing: 0.3px; line-height: 1.2; color: #f8fafc; white-space: nowrap; }
.brand-sub { font-size: 0.78rem; color: #10b981; font-weight: 500; letter-spacing: 0.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.10);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.lang-toggle:hover { background: rgba(255,255,255,0.2); }
.lang-toggle:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--green-600);
  border: 1px solid rgba(255,255,255,0.3);
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.85rem; color: #fff;
  flex: none;
}
.user-meta { line-height: 1.25; text-align: right; }
.user-name { font-size: 0.86rem; font-weight: 600; }
.user-role { font-size: 0.72rem; color: rgba(255,255,255,0.75); }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.24);
  background: rgba(255,255,255,0.08);
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
}
.icon-btn:hover { background: rgba(255,255,255,0.18); }

/* -------------------------------- Nav --------------------------------- */
.nav {
  display: flex;
  gap: 6px;
  padding: 8px 24px;
  background: #0f172a;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  top: 68px;
  z-index: 40;
}
.nav::-webkit-scrollbar { display: none; }
.nav.hidden { display: none; }
.nav a {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  text-decoration: none;
  color: #94a3b8;
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
  border-radius: 8px;
  transition: all 0.15s ease;
}
.nav a:hover { color: #f8fafc; background: rgba(255, 255, 255, 0.06); }
.nav a.active { color: #10b981; background: rgba(16, 185, 129, 0.12); font-weight: 600; }
.nav a svg { flex: none; }

/* ------------------------------- Layout -------------------------------- */
.app { max-width: 1320px; margin: 0 auto; padding: 28px 24px 80px; }

.page-head { margin-bottom: 22px; }
.page-title { font-size: 1.45rem; font-weight: 700; margin: 0 0 6px; letter-spacing: -0.3px; color: var(--ink-900); }
.page-sub { color: var(--ink-500); font-size: 0.92rem; margin: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 26px;
  margin-bottom: 22px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-title { font-size: 1.05rem; font-weight: 700; margin: 0; color: var(--ink-900); }

/* ------------------------------- Forms --------------------------------- */
.field { margin-bottom: 16px; }
.field-label { display: block; font-weight: 600; font-size: 0.88rem; color: var(--ink-700); margin-bottom: 6px; }
.field-hint { font-size: 0.78rem; color: var(--ink-500); margin-top: 5px; }

input, select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--ink-900);
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--ink-300); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(42, 125, 69, 0.15);
}
input::placeholder, textarea::placeholder { color: var(--ink-300); }
textarea { min-height: 84px; resize: vertical; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364717a' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  padding-right: 40px;
}

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 16px; }

/* PIN field with visibility toggle */
.input-affix { position: relative; }
.input-affix input { padding-right: 52px; }
.affix-btn {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  width: 38px; height: 38px;
  border: none; background: transparent;
  color: var(--ink-500);
  display: grid; place-items: center;
  border-radius: 9px; cursor: pointer;
}
.affix-btn:hover { color: var(--green-700); background: var(--green-050); }
.affix-btn:focus-visible { outline: 2px solid var(--green-600); outline-offset: 1px; }

/* ------------------------------- Buttons ------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  padding: 0 22px;
  font-size: 0.98rem;
  font-family: inherit;
  font-weight: 650;
  color: #fff;
  background: var(--green-700);
  border: 1px solid var(--green-800);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn:hover:not(:disabled) { background: var(--green-800); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--green-600); outline-offset: 2px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.secondary { background: var(--surface); color: var(--ink-700); border-color: var(--border-strong); }
.btn.secondary:hover:not(:disabled) { background: var(--surface-alt); color: var(--green-800); }
.btn.ghost-danger {
  background: transparent; color: var(--red-600);
  border-color: transparent; min-height: 40px; padding: 0 10px;
}
.btn.ghost-danger:hover:not(:disabled) { background: var(--red-100); }
.btn.is-loading { cursor: progress; }

.spinner {
  width: 17px; height: 17px; flex: none;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: fc-spin 0.65s linear infinite;
}
.btn.secondary .spinner { border-color: rgba(0,0,0,0.15); border-top-color: var(--green-700); }
@keyframes fc-spin { to { transform: rotate(360deg); } }

/* Top progress bar during any request */
.route-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: linear-gradient(90deg, var(--green-600), #7ed09a);
  z-index: 100;
  transition: width 0.25s ease, opacity 0.3s ease;
  opacity: 0;
}
.route-progress.active { opacity: 1; }

/* ------------------------------- Stepper ------------------------------- */
.stepper { display: flex; align-items: stretch; gap: 8px; }
.stepper button {
  width: 52px; min-height: 48px; flex: none;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--radius);
  font-size: 1.35rem; font-weight: 600; color: var(--green-800);
  cursor: pointer;
}
.stepper button:hover { background: var(--green-050); border-color: var(--green-600); }
.stepper input { text-align: center; font-size: 1.12rem; font-weight: 700; }

/* -------------------------------- Stats -------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 14px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--green-600);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat.amber { border-left-color: var(--amber-600); }
.stat.blue { border-left-color: var(--blue-600); }
.stat .num { font-size: 1.85rem; font-weight: 750; line-height: 1.15; letter-spacing: -0.5px; }
.stat .label { font-size: 0.79rem; color: var(--ink-500); font-weight: 600; margin-top: 2px; }

/* -------------------------------- Table -------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; background: var(--surface); }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th {
  background: var(--surface-alt);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-500);
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--green-050); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty-row td { text-align: center; color: var(--ink-500); padding: 28px; }

/* Matrix entry grid */
.matrix-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.matrix { border-collapse: separate; border-spacing: 0; }
.matrix th, .matrix td { padding: 8px; white-space: nowrap; }
.matrix tbody th {
  position: sticky; left: 0; z-index: 2;
  background: var(--surface-alt);
  text-align: left; text-transform: none;
  font-size: 0.85rem; color: var(--ink-900);
  border-right: 1px solid var(--border);
}
.matrix input {
  width: 72px; min-height: 42px; padding: 8px;
  text-align: center; font-variant-numeric: tabular-nums;
}
.matrix input[data-filled="1"] { border-color: var(--green-600); background: var(--green-050); font-weight: 700; }
.matrix tfoot td { background: var(--green-050); font-weight: 700; }

/* ------------------------------- Badges -------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.2px;
}
.badge.ok { background: var(--green-100); color: var(--green-800); }
.badge.warn { background: var(--amber-100); color: var(--amber-600); }
.badge.bad { background: var(--red-100); color: var(--red-600); }
.badge.info { background: var(--blue-100); color: var(--blue-600); }

/* ------------------------------- Alerts -------------------------------- */
.msg {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 13px 15px;
  border-radius: var(--radius);
  font-size: 0.9rem; font-weight: 500;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.msg.error { background: var(--red-100); color: var(--red-600); border-color: #f3c9c9; }
.msg.success { background: var(--green-100); color: var(--green-800); border-color: #bfe0ca; }
.msg.info { background: var(--blue-100); color: var(--blue-600); border-color: #ccd8fb; }
.msg svg { flex: none; margin-top: 1px; }

/* ------------------------------- Login --------------------------------- */
.login-wrap {
  min-height: calc(100vh - 64px);
  display: grid; place-items: center;
  padding: 24px 16px 60px;
  background:
    radial-gradient(1100px 420px at 50% -8%, rgba(42,125,69,0.13), transparent 70%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 32px 28px;
}
.login-logo {
  width: 58px; height: 58px; margin: 0 auto 14px;
  background: linear-gradient(180deg, var(--green-700), var(--green-900));
  border-radius: 15px;
  display: grid; place-items: center;
  box-shadow: var(--shadow-md);
}
.login-head { text-align: center; margin-bottom: 24px; }
.login-head h1 { font-size: 1.3rem; font-weight: 700; margin: 0 0 4px; }
.login-head p { color: var(--ink-500); font-size: 0.88rem; margin: 0; }

.demo-box {
  margin-top: 22px; padding: 13px 15px;
  background: var(--surface-alt);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  font-size: 0.79rem; color: var(--ink-500);
}
.demo-box strong { color: var(--ink-700); display: block; margin-bottom: 5px; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.5px; }
.demo-row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; font-variant-numeric: tabular-nums; }
.demo-row code { color: var(--green-800); font-weight: 700; }

/* ------------------ Position Receipt: entry flow ----------------------- */
.req { color: var(--red-600); font-weight: 700; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 0.85rem; }

.step-dot {
  display: inline-grid;
  place-items: center;
  width: 24px; height: 24px;
  margin-right: 9px;
  border-radius: 50%;
  background: var(--green-700);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  vertical-align: middle;
}

.section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 0 14px;
  border: none;
  background: none;
  font: inherit;
  color: var(--ink-900);
  cursor: pointer;
  text-align: left;
}
.section-toggle-label { font-size: 1.02rem; font-weight: 700; }
.section-toggle .chevron { color: var(--ink-500); transition: transform 0.18s ease; }
.section-toggle[aria-expanded="false"] .chevron { transform: rotate(-90deg); }

/* Entry list — the phone-first shape of the species x class matrix */
.entry-list { margin-bottom: 14px; }
.empty-hint {
  margin: 0 0 4px;
  padding: 22px 16px;
  text-align: center;
  color: var(--ink-500);
  font-size: 0.9rem;
  background: var(--surface-alt);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

.entry-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--surface);
}
.entry-main { flex: 1; min-width: 0; }
.entry-species { font-weight: 650; font-size: 1rem; }
.entry-class { font-size: 0.82rem; color: var(--ink-500); margin-top: 1px; }
.entry-count { min-width: 56px; text-align: right; line-height: 1.1; }
.entry-count-num {
  display: block;
  font-size: 1.35rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  color: var(--green-800);
}
.entry-count-label { display: block; font-size: 0.7rem; font-weight: 600; color: var(--ink-500); }
.add-entry-btn { border-style: dashed; }

.entry-picker {
  margin-top: 14px;
  padding: 16px;
  background: var(--green-050);
  border: 1.5px solid var(--green-600);
  border-radius: var(--radius-lg);
}
.entry-picker[hidden] { display: none; }
.picker-step { margin-bottom: 16px; }
.picker-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--ink-500);
  margin-bottom: 8px;
}

/* Big tap targets instead of a dropdown — faster with gloves, no keyboard */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 46px;
  padding: 0 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-700);
  cursor: pointer;
}
.chip:hover { border-color: var(--green-600); color: var(--green-800); }
.chip.selected {
  background: var(--green-700);
  border-color: var(--green-800);
  color: #fff;
}

.stepper.big button { width: 64px; min-height: 56px; font-size: 1.6rem; }
.stepper.big input { min-height: 56px; font-size: 1.5rem; font-weight: 750; }

.picker-actions { display: flex; gap: 10px; }
.picker-actions .btn { flex: 1; }

/* Sticky totals + submit, always reachable with a thumb */
.submit-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  margin: 0 -16px -16px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(16, 32, 22, 0.07);
  z-index: 30;
}
.submit-total {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 0.95rem;
  color: var(--ink-700);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}
.submit-total strong { font-size: 1.3rem; font-weight: 750; color: var(--green-800); }
.submit-sub { display: block; font-size: 0.78rem; color: var(--ink-500); }
.submit-bar .btn { flex: none; }


/* ------------------------- Add-entry wizard ---------------------------- */
/* One question per screen. A field officer seeing this for the first time
   should be able to be taught it in one sentence: tap the species, tap the
   class, set the number, press Add. */
.wizard {
  margin-top: 14px;
  padding: 18px 16px 16px;
  background: var(--surface);
  border: 2px solid var(--green-600);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.wizard[hidden] { display: none; }

.wizard-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 16px;
}
.wiz-dot {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  flex: none;
  border-radius: 50%;
  background: var(--surface-alt);
  border: 2px solid var(--border-strong);
  color: var(--ink-300);
  font-size: 0.85rem;
  font-weight: 700;
}
.wiz-dot.current { background: var(--green-700); border-color: var(--green-800); color: #fff; }
.wiz-dot.done { background: var(--green-100); border-color: var(--green-600); color: var(--green-800); }
.wiz-line { width: 34px; height: 2.5px; background: var(--border-strong); flex: none; }
.wiz-line.done { background: var(--green-600); }

.wizard-chosen { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.wizard-chosen:empty { display: none; }
.chosen-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: var(--green-050);
  border: 1.5px solid var(--green-600);
  border-radius: var(--radius);
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.chosen-label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--ink-500); }
.chosen-value { flex: 1; font-size: 1rem; font-weight: 700; color: var(--green-800); }
.chosen-edit { font-size: 0.8rem; font-weight: 700; color: var(--green-700); text-decoration: underline; }

.wiz-question {
  margin: 0 0 14px;
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
  color: var(--ink-900);
}

/* Equal-width buttons that tile the row — no ragged wrapping, and every
   target is the same size regardless of how long the species name is. */
.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 62px;
  padding: 10px 8px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  font: inherit;
  font-size: 1rem;
  font-weight: 650;
  color: var(--ink-900);
  cursor: pointer;
  text-align: center;
  line-height: 1.25;
}
.option:hover { border-color: var(--green-600); background: var(--green-050); }
.option:active { transform: scale(0.98); }
.option.selected { background: var(--green-700); border-color: var(--green-800); color: #fff; }
.option-sub { font-size: 0.72rem; font-weight: 600; color: var(--ink-500); }
.option.selected .option-sub { color: rgba(255,255,255,0.8); }

.wiz-calc {
  margin: 12px 0 0;
  text-align: center;
  font-size: 1rem;
  color: var(--ink-500);
  font-variant-numeric: tabular-nums;
}
.wiz-calc strong { color: var(--green-800); font-size: 1.15rem; }

.wiz-actions { display: flex; gap: 10px; margin-top: 18px; }
.wiz-actions .btn { flex: 1; }

@media (max-width: 420px) {
  .option-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .option { min-height: 58px; font-size: 0.95rem; }
  .wiz-question { font-size: 1.05rem; }
}

/* ------------------- Field / Depot simplified home --------------------- */
.section-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--ink-500);
  margin: 26px 0 12px;
}

.field-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.fstat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.fstat.danger { border-color: #f0c4c4; background: var(--red-100); }
.fnum { display: block; font-size: 1.7rem; font-weight: 750; line-height: 1.1; letter-spacing: -0.5px; }
.fstat.danger .fnum { color: var(--red-600); }
.flabel { display: block; font-size: 0.74rem; font-weight: 600; color: var(--ink-500); margin-top: 3px; }

/* Big, unmistakable action tiles — the main field-officer interaction */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.tile {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 84px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--ink-900);
  transition: border-color 0.15s ease, transform 0.08s ease, box-shadow 0.15s ease;
}
.tile:hover { border-color: var(--green-600); box-shadow: var(--shadow-md); }
.tile:active { transform: translateY(1px); }
.tile-icon {
  width: 52px; height: 52px; flex: none;
  display: grid; place-items: center;
  background: var(--green-100);
  color: var(--green-800);
  border-radius: 14px;
}
.tile-icon svg { width: 26px; height: 26px; }
.tile-label { flex: 1; font-size: 1.05rem; font-weight: 650; line-height: 1.3; }
.tile-go { font-size: 1.3rem; color: var(--ink-300); }

.simple-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.simple-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  min-height: 68px;
}
.simple-row:last-child { border-bottom: none; }
.simple-row.link { text-decoration: none; color: inherit; }
.simple-row.link:hover { background: var(--green-050); }
.simple-title { font-weight: 650; font-size: 1rem; }
.simple-sub { font-size: 0.82rem; color: var(--ink-500); margin-top: 2px; }
.simple-value { text-align: right; font-size: 1.3rem; font-weight: 750; line-height: 1.1; }
.simple-value span { display: block; font-size: 0.7rem; font-weight: 600; color: var(--ink-500); }

@media (max-width: 420px) {
  .fnum { font-size: 1.4rem; }
  .flabel { font-size: 0.68rem; }
  .tile { min-height: 76px; padding: 14px; }
  .tile-icon { width: 46px; height: 46px; }
  .tile-label { font-size: 0.98rem; }
}


/* ----------------------- Phone bottom tab bar -------------------------- */
/* Fixed, thumb-reachable, one button per permitted screen. Hidden on
   desktop, where the tab strip under the app bar is the better shape. */
.tabbar { display: none; }

@media (max-width: 760px) {
  /* The scrolling top tab strip is replaced entirely on phones. */
  .nav { display: none !important; }

  .tabbar {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 60;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 14px rgba(16, 32, 22, 0.10);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 9px 2px 8px;
    min-height: 60px;
    text-decoration: none;
    color: var(--ink-500);
    font-size: 0.68rem;
    font-weight: 650;
    border-top: 2.5px solid transparent;
  }
  .tabbar a span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .tabbar a svg { width: 21px; height: 21px; }
  .tabbar a.active { color: var(--green-800); border-top-color: var(--green-600); background: var(--green-050); }
  .tabbar a:active { background: var(--green-100); }

  /* Keep content and the sticky submit bar clear of the tab bar. */
  body.has-tabbar .app { padding-bottom: 88px; }
  body.has-tabbar .footer { padding-bottom: 80px; }
  body.has-tabbar .submit-bar { bottom: calc(60px + env(safe-area-inset-bottom)); }
}


/* App bar had no flex floor, so a long brand name pushed the language toggle
   and avatar off the right edge on a 375px screen. */
.brand { min-width: 0; flex: 1 1 auto; overflow: hidden; }
.brand-name { overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { flex: 0 0 auto; }

@media (max-width: 620px) {
  .lang-toggle { padding: 0 10px; }
  .lang-toggle span { display: none; }   /* icon alone is enough beside a globe */
  .brand-mark { width: 34px; height: 34px; }
  .brand-mark svg { width: 19px; height: 19px; }
  .brand-name { font-size: 0.95rem; }
}

@media (max-width: 380px) {
  .brand-name { font-size: 0.88rem; }
  .topbar { gap: 8px; }
}

/* Badges stay on one line in tables, but in list rows a long status
   ("Discrepancy Damaged") must be allowed to wrap on a 320px phone instead of
   pushing past the screen edge. */
.badge { white-space: nowrap; }
.simple-row > div:first-child { min-width: 0; flex: 1 1 auto; }
.simple-row .simple-title, .simple-row .simple-sub { overflow-wrap: anywhere; }
.simple-row .badge { flex: 0 1 auto; white-space: normal; text-align: center; max-width: 48%; }


/* ------------------------ Filters, search, staff ----------------------- */
.filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0 14px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.search-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search-box { position: relative; flex: 1 1 220px; min-width: 0; }
.search-box svg {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--ink-500); pointer-events: none;
}
.search-box input { padding-left: 42px; }
.search-row .btn { flex: none; }

.user-row.inactive { opacity: 0.6; background: var(--surface-alt); }
.user-row .btn-sm { flex: none; }

.check-row {
  display: flex; align-items: center; gap: 10px;
  margin: 4px 0 0; font-weight: 600; font-size: 0.92rem; cursor: pointer;
}
.check-row input { width: 22px; height: 22px; min-height: 0; flex: none; accent-color: var(--green-700); }

@media (max-width: 620px) {
  .filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-bar .field { min-width: 0; }
  .search-row .btn { flex: 1 1 auto; }
  .user-row { flex-wrap: wrap; }
}


/* ------------------------- Dashboard & reports ------------------------- */
.page-head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  padding: 18px 20px;
}
.kpi-icon { width: 44px; height: 44px; flex: none; border-radius: 12px; display: grid; place-items: center; }
.kpi-icon svg { width: 22px; height: 22px; }
.kpi-icon.green { background: var(--green-100); color: var(--green-800); }
.kpi-icon.amber { background: var(--amber-100); color: var(--amber-600); }
.kpi-icon.blue { background: var(--blue-100); color: var(--blue-600); }
.kpi-icon.purple { background: #f1e9fb; color: #6d28d9; }
.kpi-body { min-width: 0; flex: 1; }
.kpi-label { font-size: 0.8rem; font-weight: 650; color: var(--ink-500); }
.kpi-num { font-size: 1.75rem; font-weight: 760; letter-spacing: -0.5px; line-height: 1.2; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 0.78rem; color: var(--ink-500); margin-top: 4px; }
.kpi-bar { height: 6px; background: var(--surface-alt); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.kpi-bar span { display: block; height: 100%; background: var(--amber-600); border-radius: 99px; }

.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.dash-grid > .card { margin-bottom: 0; min-width: 0; }
.dash-wide { grid-column: 1 / -1; }

.card-link { font-size: 0.85rem; font-weight: 650; color: var(--green-700); text-decoration: none; white-space: nowrap; }
.card-link:hover { text-decoration: underline; }

.progress-col { width: 30%; min-width: 150px; }
.progress-cell { display: flex; align-items: center; gap: 10px; }
.bar { flex: 1; height: 8px; background: var(--surface-alt); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--green-600), #5cb97a); border-radius: 99px; }
.bar-pct { font-size: 0.8rem; font-weight: 700; color: var(--ink-700); min-width: 38px; text-align: right; font-variant-numeric: tabular-nums; }
.no-activity { font-size: 0.8rem; color: var(--ink-300); font-style: italic; }
.muted-row td { color: var(--ink-500); }
.muted-row strong { color: var(--ink-500); font-weight: 600; }
.total-row td { background: var(--green-050); font-weight: 750; border-top: 2px solid var(--border-strong); }
.cell-sub { font-size: 0.75rem; color: var(--ink-500); margin-top: 2px; font-weight: 500; }

.alert-list { display: flex; flex-direction: column; gap: 10px; }
.alert-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border); }
.alert-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex: none; }
.alert-item.bad { background: var(--red-100); border-color: #f3c9c9; }
.alert-item.bad .alert-dot { background: var(--red-600); }
.alert-item.warn { background: var(--amber-100); border-color: #f5d7ab; }
.alert-item.warn .alert-dot { background: var(--amber-600); }
.alert-item.ok { background: var(--green-050); border-color: #bfe0ca; }
.alert-item.ok .alert-dot { background: var(--green-600); }
.alert-title { font-weight: 700; font-size: 0.92rem; }
.alert-body { font-size: 0.82rem; color: var(--ink-700); margin-top: 2px; }

.hbar-list { display: flex; flex-direction: column; gap: 12px; }
.hbar-row { display: grid; grid-template-columns: minmax(90px, 140px) 1fr 48px; align-items: center; gap: 12px; }
.hbar-label { font-size: 0.88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 12px; background: var(--surface-alt); border-radius: 99px; overflow: hidden; }
.hbar-track span { display: block; height: 100%; background: var(--green-600); border-radius: 99px; }
.hbar-val { font-size: 0.88rem; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 620px) {
  .app { padding: 16px 12px 60px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-num { overflow-wrap: anywhere; }
  .kpi { padding: 14px; flex-direction: column; gap: 8px; }
  .kpi-icon { width: 36px; height: 36px; }
  .kpi-num { font-size: 1.35rem; }
  .progress-col { min-width: 120px; }
}


/* Mobile page padding is 12px, so the full-bleed submit bar must pull back by
   exactly that much or it overhangs the screen edge. */
@media (max-width: 620px) {
  .submit-bar { margin: 0 -12px -12px; }
}
.kpi-grid > .kpi, .search-row > *, .filter-bar > * { min-width: 0; }

/* ------------------------------- Footer -------------------------------- */
.footer { text-align: center; color: var(--ink-300); font-size: 0.76rem; padding: 26px 16px; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-alt) 25%, #eceeed 50%, var(--surface-alt) 75%);
  background-size: 200% 100%;
  animation: fc-shimmer 1.3s infinite;
  border-radius: 8px; height: 18px; margin-bottom: 10px;
}
@keyframes fc-shimmer { to { background-position: -200% 0; } }

@media (max-width: 620px) {
  .topbar { height: 58px; padding: 0 12px; }
  .nav { top: 58px; }
  .brand-sub, .user-meta { display: none; }
  .app { padding: 16px 12px 60px; }
  .card { padding: 16px; border-radius: var(--radius); }
  .page-title { font-size: 1.2rem; }
  .stat .num { font-size: 1.55rem; }
}

.sync-pill{position:fixed;top:10px;left:50%;transform:translateX(-50%);z-index:60;border:0;border-radius:999px;padding:6px 14px;font:600 13px/1.2 inherit;background:#b45309;color:#fff;box-shadow:0 2px 8px rgba(0,0,0,.2);cursor:pointer;max-width:calc(100vw - 32px)}
.sync-pill.is-failed{background:#b91c1c}
.sync-pill[hidden]{display:none}
.pending-row{display:flex;flex-wrap:wrap;gap:10px;align-items:center;justify-content:space-between;padding:12px 0;border-top:1px solid var(--border)}
.pending-row:first-child{border-top:0}
.pending-main{flex:1 1 220px;min-width:0}
.pending-date{margin-left:8px;color:var(--ink-500,#64748b);font-size:13px}
.pending-reason{margin-top:4px;font-size:13px;color:var(--ink-500,#64748b);overflow-wrap:anywhere}
.pending-reason.is-failed{color:var(--red-600)}
.pending-actions{display:flex;gap:8px}

/* ===== Possession receipt (rc_) and volume charts (vc_) ===== */
.rc-chart-notice .msg { margin: 8px 0 0; }
.rc-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.rc-grid .rc-lbl { font-size: 0.78rem; color: var(--ink-500); text-align: right; padding-right: 6px; }
.rc-grid .rc-vol-row td { background: var(--surface-alt); color: var(--ink-700); font-variant-numeric: tabular-nums; }
.rc-grid .rc-vol-row .row-vol, .rc-grid tfoot .num { font-weight: 700; }

/* Receipt sheet: the same block is shown on screen and printed on A4. */
.rc-sheet { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.rc-title { text-align: center; font-size: 1.15rem; margin: 0 0 12px; }
.rc-head-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 18px; margin-bottom: 12px; font-size: 0.92rem; }
.rc-meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 4px 18px; margin-bottom: 14px; }
.rc-meta { display: flex; gap: 8px; font-size: 0.85rem; border-bottom: 1px dotted var(--border-strong); padding: 3px 0; }
.rc-meta-k { color: var(--ink-500); flex: none; }
.rc-meta-v { margin-left: auto; text-align: right; font-weight: 600; overflow-wrap: anywhere; }
.rc-print-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.rc-print-table th, .rc-print-table td { border: 1px solid var(--border-strong); padding: 4px 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rc-print-table thead th, .rc-print-table tfoot th, .rc-print-table tfoot td { background: var(--surface-alt); font-weight: 700; }
.rc-print-table tbody th { text-align: left; }
.rc-print-table .num { text-align: right; }
.rc-sign { display: flex; justify-content: space-between; gap: 24px; margin-top: 56px; }
.rc-sign-box { flex: 1; text-align: center; font-size: 0.88rem; }
.rc-sign-line { border-top: 1px solid var(--ink-900); margin-bottom: 6px; }
.rc-sign-cap { font-weight: 700; }
.rc-sign-name { color: var(--ink-500); min-height: 1.2em; }

/* Volume charts admin */
.vc-banner { display: flex; gap: 10px; align-items: flex-start; background: var(--amber-100); color: var(--amber-600); border: 1px solid #f3d9a8; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; font-weight: 600; }
.vc-banner svg { flex: none; margin-top: 2px; }
.vc-scroll { overflow: auto; max-height: 65vh; border: 1px solid var(--border); border-radius: var(--radius); }
.vc-table { border-collapse: separate; border-spacing: 0; }
.vc-table th, .vc-table td { padding: 6px; white-space: nowrap; border-bottom: 1px solid var(--border); }
.vc-table thead th { position: sticky; top: 0; background: var(--surface-alt); z-index: 2; }
.vc-table tbody th { position: sticky; left: 0; background: var(--surface); text-align: left; z-index: 1; border-right: 1px solid var(--border); font-size: 0.85rem; }
.vc-table td { position: relative; }
.vc-in { width: 76px; min-height: 40px; padding: 6px; text-align: right; font-variant-numeric: tabular-nums; }
.vc-flagged .vc-in { border-color: var(--amber-600); background: var(--amber-100); }
.vc-mark { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: var(--amber-600); color: #fff; font-weight: 800; font-size: 0.8rem; line-height: 20px; cursor: pointer; }
.vc-note { margin-top: 12px; padding: 12px 14px; border: 1px solid #f3d9a8; background: var(--amber-100); border-radius: var(--radius); }
.vc-note p { margin: 6px 0 10px; overflow-wrap: anywhere; }
.vc-add-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-bottom: 14px; }
.vc-add-cell { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; color: var(--ink-700); }
.vc-add-cell input { width: 100%; min-width: 0; }
.vc-unit-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.vc-unit-row:first-child { border-top: 0; }
.vc-unit-name { flex: 1 1 140px; min-width: 0; }
.vc-unit-row select { flex: 1 1 180px; min-width: 0; }
@media (max-width: 620px) {
  .rc-sheet { padding: 12px; }
  .rc-print-wrap { overflow-x: auto; }
  .rc-sign { margin-top: 36px; gap: 12px; }
}
@media print {
  @page { size: A4 portrait; margin: 12mm; }
  .topbar, .nav, .tabbar, .footer, .no-print, .sync-pill, .route-progress { display: none !important; }
  body, body.has-tabbar { background: #fff; padding: 0 !important; }
  .app { padding: 0; max-width: none; }
  .rc-sheet { border: 0; padding: 0; margin: 0; }
  .rc-print-wrap { overflow: visible; border: 0; }
  .rc-print-table { font-size: 8.5pt; }
  .rc-print-table th, .rc-print-table td { padding: 2px 3px; }
  .rc-title { font-size: 14pt; }
}

/* ==========================================================================
   OFFICER & USER DIRECTORY (TABULAR MANAGEMENT)
   ========================================================================== */
.users-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.users-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.users-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  flex: 1 1 500px;
}
.users-filters .search-box {
  flex: 1 1 220px;
  min-width: 200px;
}
.users-filters select {
  height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.88rem;
  color: var(--ink-700);
}
.users-actions-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.btn-emerald {
  background: #047857 !important;
  color: #fff !important;
}
.btn-emerald:hover {
  background: #065f46 !important;
}
.btn-amber {
  background: #d97706 !important;
  color: #fff !important;
}
.btn-amber:hover {
  background: #b45309 !important;
}
.btn-danger {
  background: #dc2626 !important;
  color: #fff !important;
}
.btn-danger:hover {
  background: #b91c1c !important;
}
.btn-outline {
  background: transparent !important;
  border: 1px solid var(--border-strong) !important;
  color: var(--ink-700) !important;
}
.btn-outline:hover {
  background: var(--surface-alt) !important;
  color: var(--ink-900) !important;
}

.table-users {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}
.table-users th {
  position: sticky;
  top: 0;
  background: #0f172a;
  color: #f8fafc;
  font-size: 0.76rem;
  letter-spacing: 0.5px;
  font-weight: 700;
  padding: 12px 14px;
  z-index: 10;
  border-bottom: 2px solid #10b981;
}
.table-users td {
  padding: 12px 14px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.table-users tr:hover td {
  background: #f1fdf7;
}

.user-name-cell {
  display: flex;
  flex-direction: column;
}
.user-name-title {
  font-weight: 700;
  color: var(--ink-900);
}
.user-contact-sub {
  font-size: 0.78rem;
  color: var(--ink-500);
}

.pw-cell-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 6px;
}
.pw-val {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.86rem;
  font-weight: 600;
  color: #047857;
  letter-spacing: 0.5px;
  user-select: all;
  min-width: 100px;
}
.pw-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  color: var(--ink-500);
  border-radius: 4px;
}
.pw-btn:hover {
  color: var(--ink-900);
  background: var(--border);
}

.role-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.role-pill-hq {
  background: #ede9fe;
  color: #5b21b6;
  border: 1px solid #ddd6fe;
}
.role-pill-dm {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}
.role-pill-fo {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 600;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-dot.active { background: #10b981; box-shadow: 0 0 6px #10b981; }
.status-dot.inactive { background: #dc2626; }

.tbl-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* Modals */
.user-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.user-modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-strong);
  max-width: 580px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.user-modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-alt);
}
.user-modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink-900);
  margin: 0;
}
.user-modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.user-modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: var(--surface-alt);
}

/* ==========================================================================
   EXECUTIVE DASHBOARD & CHART.JS ENHANCEMENTS
   ========================================================================== */
.dash-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.dash-filter-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.dash-filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dash-filter-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--ink-500);
}

.dash-select {
  height: 40px;
  padding: 0 34px 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background-color: var(--surface);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-900);
  cursor: pointer;
  min-width: 170px;
}

.dash-select:focus {
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.dash-grid-2col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.dash-grid-full {
  margin-bottom: 20px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s ease;
}

.chart-card:hover {
  box-shadow: var(--shadow-md);
}

.chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.chart-title-wrap {
  min-width: 0;
}

.chart-title {
  font-size: 1.05rem;
  font-weight: 750;
  color: var(--ink-900);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-subtitle {
  font-size: 0.8rem;
  color: var(--ink-500);
  margin: 3px 0 0 0;
}

.chart-canvas-wrap {
  position: relative;
  width: 100%;
  height: 290px;
  max-height: 320px;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card-v2 {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kpi-card-v2:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-card-v2::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
}

.kpi-card-v2.green::before { background: linear-gradient(90deg, #059669, #10b981); }
.kpi-card-v2.amber::before { background: linear-gradient(90deg, #d97706, #fbbf24); }
.kpi-card-v2.blue::before { background: linear-gradient(90deg, #2563eb, #38bdf8); }
.kpi-card-v2.purple::before { background: linear-gradient(90deg, #7c3aed, #a855f7); }

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.kpi-label-v2 {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-500);
}

.kpi-icon-pill {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
}

.kpi-card-v2.green .kpi-icon-pill { background: #ecfdf5; color: #047857; }
.kpi-card-v2.amber .kpi-icon-pill { background: #fffbeb; color: #b45309; }
.kpi-card-v2.blue .kpi-icon-pill { background: #eff6ff; color: #1d4ed8; }
.kpi-card-v2.purple .kpi-icon-pill { background: #faf5ff; color: #6d28d9; }

.kpi-metric-v2 {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--ink-900);
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.kpi-sub-v2 {
  font-size: 0.82rem;
  color: var(--ink-500);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kpi-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  background: var(--surface-alt);
  color: var(--ink-700);
  border: 1px solid var(--border);
}

.kpi-badge-pill.green { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.kpi-badge-pill.amber { background: #fef3c7; color: #92400e; border-color: #fde68a; }

.lot-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}

@media (max-width: 768px) {
  .dash-grid-2col {
    grid-template-columns: 1fr;
  }
  .chart-canvas-wrap {
    height: 250px;
  }
  .dash-filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .dash-filter-group {
    flex-direction: column;
    align-items: stretch;
  }
  .dash-select {
    width: 100%;
  }
}

/* ==========================================================================
   FORMAL VOLUME CHART & SEARCH BAR ENHANCEMENTS
   ========================================================================== */
.vc-controls-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.vc-toolbar-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.vc-pick-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 320px;
  min-width: 280px;
}

.vc-pick-group label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-500);
  white-space: nowrap;
}

.vc-chart-select {
  height: 44px;
  padding: 0 36px 0 14px;
  border-radius: 9px;
  border: 1.5px solid var(--border-strong);
  background-color: var(--surface);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink-900);
  cursor: pointer;
  flex: 1;
  min-width: 240px;
}

.vc-chart-select:focus {
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}

.vc-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 340px;
  min-width: 260px;
}

.vc-search-icon {
  position: absolute;
  left: 14px;
  color: var(--ink-500);
  pointer-events: none;
  display: flex;
  align-items: center;
}

.vc-search-input {
  width: 100%;
  height: 44px;
  padding: 0 40px 0 42px;
  border-radius: 9px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface-alt);
  font-size: 0.92rem;
  color: var(--ink-900);
  transition: all 0.15s ease;
}

.vc-search-input:focus {
  background: var(--surface);
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}

.vc-search-clear {
  position: absolute;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--ink-300);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.vc-search-clear:hover {
  color: var(--ink-900);
  background: var(--border);
}

.vc-meta-ribbon {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 0.84rem;
  color: var(--ink-700);
}

.vc-meta-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.vc-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 650;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--ink-700);
}

.vc-chip.active {
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}

.vc-chip.units {
  background: #eff6ff;
  color: #1e40af;
  border-color: #bfdbfe;
}

.vc-chip.flags {
  background: #fffbeb;
  color: #92400e;
  border-color: #fde68a;
  cursor: pointer;
}

.vc-formal-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}

.vc-formal-table thead th {
  position: sticky;
  top: 0;
  background: #0f172a;
  color: #f8fafc;
  padding: 12px 14px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  z-index: 10;
  border-bottom: 2px solid #10b981;
  text-align: right;
}

.vc-formal-table thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 20;
  text-align: left;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
}

.vc-formal-table tbody th {
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 5;
  text-align: left;
  padding: 10px 14px;
  border-right: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.vc-formal-table tbody tr:hover th {
  background: #f1fdf7;
}

.vc-formal-table tbody tr:hover td {
  background: #f8fafc;
}

.vc-formal-table td {
  padding: 10px 14px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.vc-val-display {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.94rem;
  font-weight: 650;
  color: #047857;
  letter-spacing: 0.3px;
  padding: 4px 8px;
  border-radius: 6px;
  display: inline-block;
  min-width: 60px;
  text-align: right;
}

.vc-val-display.is-zero {
  color: var(--ink-300);
}

.vc-val-display.is-null {
  color: var(--ink-300);
  font-style: italic;
}

.vc-in-edit {
  width: 78px;
  height: 36px;
  padding: 4px 8px;
  text-align: right;
  font-family: 'Consolas', monospace;
  font-weight: 700;
  font-size: 0.92rem;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
}

.vc-in-edit:focus {
  border-color: var(--green-600);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.vc-species-title {
  font-weight: 750;
  color: var(--ink-900);
  display: flex;
  align-items: center;
  gap: 8px;
}

.vc-species-sub {
  font-size: 0.76rem;
  color: var(--ink-500);
  font-weight: 500;
  margin-top: 1px;
}

.species-code-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 800;
  background: #e2e8f0;
  color: #334155;
  letter-spacing: 0.5px;
}

.vc-audit-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
  font-size: 0.72rem;
  font-weight: 800;
  margin-left: 4px;
  cursor: pointer;
  vertical-align: middle;
}

.search-highlight {
  background: #fef08a;
  border-radius: 2px;
  padding: 0 2px;
}

@media (max-width: 768px) {
  .vc-toolbar-top {
    flex-direction: column;
    align-items: stretch;
  }
  .vc-pick-group {
    flex-direction: column;
    align-items: stretch;
  }
  .vc-chart-select {
    width: 100%;
  }
  .vc-search-wrap {
    width: 100%;
  }
}

/* ==========================================================================
   DYNAMIC INTERACTIVE DASHBOARD & POPUP ANALYTICS
   ========================================================================== */
.kpi-card-v2.interactive {
  cursor: pointer;
  position: relative;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.kpi-card-v2.interactive:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px -4px rgba(15, 23, 42, 0.12), 0 4px 6px -2px rgba(15, 23, 42, 0.05);
  border-color: var(--green-600);
}
.kpi-card-v2.interactive:active {
  transform: translateY(-1px);
}
.kpi-tap-hint {
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--ink-400);
  transition: color 0.15s ease;
}
.kpi-card-v2.interactive:hover .kpi-tap-hint {
  color: var(--green-700);
}

.chart-toggle-group {
  display: inline-flex;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}
.chart-toggle-btn {
  padding: 4px 10px;
  font-size: 0.76rem;
  font-weight: 700;
  border: none;
  background: transparent;
  color: var(--ink-600);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.chart-toggle-btn:hover {
  color: var(--ink-900);
}
.chart-toggle-btn.active {
  background: var(--surface);
  color: var(--green-800);
  box-shadow: var(--shadow-sm);
}

.species-split-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1.1fr) minmax(260px, 1.2fr);
  gap: 16px;
  align-items: center;
  min-height: 290px;
}
@media (max-width: 900px) {
  .species-split-layout {
    grid-template-columns: 1fr;
  }
}

.species-list-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 4px;
}
.species-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s ease;
}
.species-item-row:hover {
  background: #f8fafc;
  border-color: var(--green-600);
  transform: translateX(3px);
  box-shadow: var(--shadow-sm);
}
.species-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.species-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  flex-shrink: 0;
}
.species-item-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.species-item-sub {
  font-size: 0.74rem;
  color: var(--ink-500);
}
.species-item-right {
  text-align: right;
  flex-shrink: 0;
}
.species-item-vol {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--ink-900);
}
.species-item-pct {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--green-700);
}
.species-mini-bar {
  height: 4px;
  border-radius: 999px;
  background: #e2e8f0;
  margin-top: 4px;
  overflow: hidden;
}
.species-mini-bar-fill {
  height: 100%;
  border-radius: 999px;
}

/* Modal Analysis Cards */
.analysis-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.analysis-stat-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  text-align: left;
}
.analysis-stat-label {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--ink-500);
  margin-bottom: 4px;
}
.analysis-stat-val {
  font-size: 1.35rem;
  font-weight: 850;
  color: var(--ink-900);
  line-height: 1.1;
}
.analysis-stat-sub {
  font-size: 0.74rem;
  color: var(--ink-600);
  margin-top: 4px;
}

.analysis-section-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--ink-800);
  margin: 14px 0 8px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.analysis-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.analysis-data-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 0.74rem;
  font-weight: 750;
  text-transform: uppercase;
  color: var(--ink-500);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
.analysis-data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--ink-800);
}
.analysis-data-table tr:hover td {
  background: #f1f5f9;
}

/* ==========================================================================
   MOBILE-FIRST CARDS & TOUCH-FRIENDLY RESPONSIVENESS
   ========================================================================== */
.mobile-recent-lots {
  display: none;
  flex-direction: column;
  gap: 10px;
}
.lot-mobile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}
.lot-mobile-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.lot-mobile-title {
  font-weight: 800;
  color: var(--green-900);
  text-decoration: none;
  font-size: 0.95rem;
}
.lot-mobile-meta {
  font-size: 0.8rem;
  color: var(--ink-600);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lot-mobile-meta strong {
  color: var(--ink-900);
}

.mobile-user-cards {
  display: none;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}
.officer-mobile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.officer-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.officer-card-name {
  font-size: 1rem;
  font-weight: 800;
  color: var(--ink-900);
}
.officer-card-phone {
  font-size: 0.8rem;
  color: var(--ink-500);
}
.officer-card-scope {
  font-size: 0.82rem;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}
.officer-card-creds {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  background: #f8fafc;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.officer-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.officer-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.officer-card-actions button {
  flex: 1;
}

@media (max-width: 768px) {
  .table-desktop-wrap {
    display: none !important;
  }
  .mobile-user-cards {
    display: flex !important;
  }
  .table-lots-desktop {
    display: none !important;
  }
  .mobile-recent-lots {
    display: flex !important;
  }
  .users-toolbar {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .users-filters {
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
  }
  .users-filters select {
    width: 100% !important;
  }
  .users-actions-bar {
    width: 100% !important;
  }
  .users-actions-bar button {
    width: 100% !important;
    justify-content: center !important;
  }
  .dash-filter-bar {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .dash-filter-group {
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
  }
  .dash-filter-item {
    width: 100% !important;
    justify-content: space-between !important;
  }
  .dash-select {
    width: 100% !important;
  }
  .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }
  .kpi-card-v2 {
    padding: 12px 14px !important;
  }
  .kpi-metric-v2 {
    font-size: 1.45rem !important;
  }
  .card-head {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }
  .rc-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    width: 100% !important;
    gap: 6px !important;
  }
  .rc-actions button, .rc-actions a {
    flex: 1 1 calc(50% - 6px) !important;
    text-align: center !important;
    justify-content: center !important;
  }
}




