/* AIG Security — Patrol Portal. QR-Patrol design-token match (ROADMAP-PARITY.md "Design tokens").
   Dependency-free; self-hosted Roboto (no Google Fonts CDN — CSP + privacy). All tokens below are
   CSS custom properties so the whole surface (login, Events Monitor, admin console, account) shares
   one theme. */

/* ---- self-hosted brand fonts (no Google Fonts CDN — CSP font-src 'self' + client privacy) ----
   Montserrat is the AIG primary (headings + body) per the brand guidelines, converted from the
   Drive originals. Runda (the display face) is deliberately NOT loaded: the only thing it would
   have set is the SECURITY wordmark, and that is part of the logo ARTWORK — never re-typeset it. Roboto is retained as a
   fallback for anything that hasn't been re-typed yet. */
@font-face {
  font-family: "Montserrat"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/static/fonts/montserrat-400.woff2") format("woff2");
}
@font-face {
  font-family: "Montserrat"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("/static/fonts/montserrat-500.woff2") format("woff2");
}
@font-face {
  font-family: "Montserrat"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/static/fonts/montserrat-600.woff2") format("woff2");
}
@font-face {
  font-family: "Montserrat"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/static/fonts/montserrat-700.woff2") format("woff2");
}
@font-face {
  font-family: "Roboto"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("/static/fonts/roboto-latin.woff2") format("woff2");
}

:root {
  /* ---- AIG Security brand (canonical, per AIG Security - Brand Guidelines Rev 2026.1) ----
     Navy #120658 is canonical by decision (Luke, 2026-07-30): the delivered logo ART samples the
     slightly brighter #19226D, and the business is deliberately transitioning TO #120658 across
     the brand. Do not "correct" navy back to #19226D. Red is an ACCENT ONLY — never body text,
     never a background fill (guidelines: "Eagle accent; sparing emphasis only"). */
  --navy: #120658;                    /* primary: sidebar, headers, primary fills */
  --navy-dk: #0c0440;                 /* pressed / gradient end */
  --navy-lt: #1d0b7d;                 /* hover */
  --red: #C8102E;                     /* ACCENT ONLY */
  --red-dk: #a50d26;
  --ink-brand: #222222;               /* brand "Ink" — body text on light */

  /* semantic aliases kept so the rest of the sheet needs no rewrite */
  --primary: var(--navy);
  --primary-dk: var(--navy-dk);
  --primary-lt: var(--navy-lt);
  --action: var(--navy);              /* Save / primary action */
  --info: #4a4a8f;                    /* secondary action — navy-tinted, not teal */
  --gray: #6C757D;
  --body: #F7F8FB;
  --card: #FFFFFF;
  --grid-head-bg: #F2F3F8;
  --grid-head-ink: rgba(18,6,88,.62);
  --sel-row: #ECEAF6;                 /* pale navy selection (was pale green) */
  --login-btn: var(--red);            /* login CTA = brand red, per the app's login treatment */
  --login-btn-dk: var(--red-dk);

  /* derived neutrals */
  --ink: #222222;            /* brand Ink */
  --muted: #6C757D;
  --border: #e2e8f0;
  --border-dk: #cbd5e1;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(16,29,51,.10), 0 1px 2px rgba(16,29,51,.06);
  --shadow-lg: 0 12px 40px rgba(16,29,51,.20);

  --ok: #1a7f4b;   --ok-bg: #e6f4ec;
  --warn: #b26a00; --warn-bg: #fbf0dc;
  --bad: #c0392b;  --bad-bg: #fbe7e4;

  --rail-w: 64px;
  --rail-w-open: 232px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "Montserrat", "Roboto", Arial, Helvetica, sans-serif;
  background: var(--body); color: var(--ink); line-height: 1.5; font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--action); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; font-weight: 600; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 0 0 .8rem; }
.subtle { color: var(--muted); font-size: .85rem; }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; }

/* ================= app shell (sidebar + main column) ================= */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--rail-w); flex: 0 0 var(--rail-w);
  background: var(--primary); color: #dbe9f1;
  display: flex; flex-direction: column;
  transition: width .16s ease, flex-basis .16s ease;
  position: sticky; top: 0; height: 100vh; overflow: hidden;
}
.sidebar.open { width: var(--rail-w-open); flex-basis: var(--rail-w-open); }

.side-brand {
  display: flex; flex-direction: column; align-items: flex-start; gap: .3rem;
  padding: .85rem .8rem .8rem; overflow: hidden;   /* never let the label clip mid-word */
}
/* Product name only — "AIG SECURITY" comes from the banner artwork above it, never from type. */
.side-brand .mark { font-weight: 500; letter-spacing: .04em; font-size: .8rem; color: rgba(255,255,255,.72); }
.side-brand .glyph { font-weight: 800; color: #fff; font-size: 1.15rem; }

.side-nav { display: flex; flex-direction: column; padding: .5rem 0; flex: 1; overflow-y: auto; }
.side-link {
  display: flex; align-items: center; gap: .85rem; height: 44px; padding: 0 0 0 20px;
  color: #cfe2ec; font-size: .9rem; white-space: nowrap; border: 0; background: none;
  cursor: pointer; text-decoration: none; width: 100%; text-align: left; font-family: inherit;
  border-left: 3px solid transparent;
}
.side-link:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.side-link.active { background: rgba(255,255,255,.14); color: #fff; border-left-color: #8fd0e6; }
.side-link .ico { flex: 0 0 24px; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; }
.side-link .ico svg { width: 20px; height: 20px; fill: currentColor; }
.side-link .lbl { opacity: 0; transition: opacity .12s ease; }
.sidebar.open .side-link .lbl { opacity: 1; }

.side-foot { border-top: 1px solid rgba(255,255,255,.12); padding: .4rem 0; }
.side-toggle {
  display: flex; align-items: center; gap: .85rem; height: 40px; padding: 0 0 0 22px;
  color: #9fc3d5; background: none; border: 0; cursor: pointer; width: 100%; font-family: inherit;
  font-size: .82rem;
}
.side-toggle:hover { color: #fff; }
.side-toggle .chev { transition: transform .16s ease; display: inline-block; font-size: 1rem; }
.sidebar.open .side-toggle .chev { transform: rotate(180deg); }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ================= topbar ================= */
.topbar {
  background: var(--card); border-bottom: 1px solid var(--border);
  min-height: 60px; display: flex; align-items: center; justify-content: space-between;
  padding: .55rem 1.4rem; gap: 1rem;
}
.page-head { display: flex; flex-direction: column; }
.page-head .title-row { display: flex; align-items: center; gap: .45rem; }
.page-head h1 { color: var(--primary); }
.page-head .info-i {
  width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--gray);
  color: var(--gray); font-size: 11px; font-style: italic; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}
.tz-note { color: var(--muted); font-size: .74rem; margin-top: 1px; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.topbar-right .who { color: var(--muted); font-size: .82rem; }

/* ================= content ================= */
.content { padding: 1.2rem 1.4rem; flex: 1; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.05rem 1.15rem; margin-bottom: 1.1rem;
}
.card > h2 { display: flex; align-items: center; gap: .5rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
.row { display: flex; flex-wrap: wrap; gap: 1.1rem; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ================= controls / buttons ================= */
label { display: block; font-size: .78rem; color: var(--muted); margin: .45rem 0 .2rem; font-weight: 500; }
input, select, textarea {
  width: 100%; padding: .45rem .6rem; border: 1px solid var(--border-dk); border-radius: 6px;
  font: inherit; font-size: .9rem; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--action); outline-offset: -1px; border-color: var(--action); }

button, .btn {
  display: inline-flex; align-items: center; gap: .4rem; justify-content: center;
  padding: .5rem .95rem; border-radius: 6px; border: 1px solid transparent;
  background: var(--action); color: #fff; font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; line-height: 1.2;
}
button:hover, .btn:hover { filter: brightness(1.07); text-decoration: none; }
button:disabled { opacity: .6; cursor: default; }
button.primary { background: var(--primary); }
button.info { background: var(--info); }
button.secondary { background: #fff; color: var(--ink); border-color: var(--border-dk); }
button.gray { background: var(--gray); }
button.danger { background: var(--bad); }
button.small { padding: .3rem .55rem; font-size: 12px; }

/* flat icon toolbar (admin grids) */
.toolbar { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .8rem; align-items: center; }
.filter-select { padding: .35rem .5rem; border: 1px solid #cfd8e0; border-radius: 6px; background: #fff; font: inherit; }
.tbtn {
  display: inline-flex; align-items: center; gap: .35rem; padding: .4rem .7rem; font-size: 13px;
  background: #fff; color: var(--primary); border: 1px solid var(--border-dk); border-radius: 6px;
  cursor: pointer; font-family: inherit; font-weight: 500;
}
.tbtn:hover { background: var(--grid-head-bg); }
.tbtn.danger { color: var(--bad); }
.tbtn .g { font-size: 14px; line-height: 1; }

.inline-form { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; }
.inline-form > div { flex: 1 1 160px; }

/* ================= tables / grid ================= */
.table-scroll { overflow: auto; border: 1px solid var(--border); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th, td { text-align: left; padding: .5rem .65rem; border-bottom: 1px solid var(--border); vertical-align: top; }
thead th {
  background: var(--grid-head-bg); color: var(--grid-head-ink); font-size: 12px; font-weight: 500;
  letter-spacing: .02em; position: sticky; top: 0; z-index: 2;
}
tbody tr:hover { background: #f6f9fc; }
tbody tr.sel { background: var(--sel-row); }
th.col-hidden, td.col-hidden { display: none; }

/* per-column filter row (directly under headers) */
tr.filter-row th { background: var(--grid-head-bg); padding: .25rem .4rem .45rem; top: 30px; position: sticky; z-index: 2; }
tr.filter-row input, tr.filter-row select { padding: .25rem .4rem; font-size: 12px; border-radius: 4px; }
tr.filter-row .date-range { display: flex; gap: .25rem; }
tr.filter-row .date-range input { min-width: 0; }

/* grid footer: total + pager + per-page */
.grid-foot {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .6rem;
  padding: .6rem .2rem 0; font-size: .82rem; color: var(--muted);
}
.pager { display: flex; align-items: center; gap: .35rem; }
.pager button { padding: .25rem .55rem; font-size: 12px; background: #fff; color: var(--primary); border: 1px solid var(--border-dk); }
.pager button:disabled { opacity: .45; }
.per-page { display: flex; align-items: center; gap: .35rem; }
.per-page select { width: auto; padding: .25rem 1.4rem .25rem .4rem; font-size: 12px; }

/* toolbar for the events log (refresh, csv, columns) */
.log-tools { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.log-tools .spacer { flex: 1; }

/* column chooser popover */
.chooser { position: relative; }
.chooser-panel {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; background: #fff;
  border: 1px solid var(--border-dk); border-radius: 6px; box-shadow: var(--shadow-lg);
  padding: .5rem .7rem; min-width: 190px;
}
.chooser-panel label {
  display: flex; align-items: center; gap: .5rem; font-size: .84rem; color: var(--ink);
  font-weight: 400; margin: .25rem 0; cursor: pointer;
}
.chooser-panel input { width: auto; }
.chooser-panel .export-opt {
  display: block; width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  font-size: .84rem; color: var(--ink); padding: .4rem .3rem; border-radius: 4px;
}
.chooser-panel .export-opt:hover { background: var(--grid-head); }

/* circular refresh button */
.icon-btn {
  width: 34px; height: 34px; padding: 0; border-radius: 50%; background: #fff; color: var(--primary);
  border: 1px solid var(--border-dk); display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--grid-head-bg); }
.icon-btn svg { width: 18px; height: 18px; fill: currentColor; }

/* inline copy-to-clipboard button next to a check point's tag UID */
.uid-cell { display: flex; align-items: center; gap: .4rem; }
.copy-btn { width: 22px; height: 22px; font-size: .8rem; line-height: 1; }

/* auto-refresh pill toggle */
.pill-toggle { display: inline-flex; align-items: center; gap: .5rem; font-size: .82rem; color: var(--muted); }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .slider {
  position: absolute; inset: 0; background: var(--border-dk); border-radius: 999px; transition: background .15s;
}
.switch .slider::before {
  content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px; background: #fff;
  border-radius: 50%; transition: transform .15s;
}
.switch input:checked + .slider { background: var(--action); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ================= map strip ================= */
.map-strip .card-head {
  display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .7rem;
}
.map-strip .map-actions { display: flex; align-items: center; gap: .6rem; }
#map { height: 300px; border-radius: 6px; border: 1px solid var(--border); }
#map.fullscreen { position: fixed; inset: 0; height: 100vh; width: 100vw; z-index: 1000; border-radius: 0; }
.collapsible.collapsed .collapsible-body { display: none; }
.chev-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: .8rem; display: inline-flex; align-items: center; gap: .3rem; }
.chev-btn .chev { transition: transform .16s; }
.collapsible.collapsed .chev-btn .chev { transform: rotate(-90deg); }

.legend { display: flex; gap: 1rem; flex-wrap: wrap; margin: .55rem 0 0; font-size: .78rem; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .25rem; vertical-align: middle; }
.dot.fresh { background: var(--ok); } .dot.old { background: var(--warn); }
.dot.stale { background: var(--bad); } .dot.never { background: #b8c1d1; }

/* ================= badges / status ================= */
.badge { display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 600; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.muted { background: var(--grid-head-bg); color: var(--muted); }
.media-ph { color: var(--border-dk); }        /* Media placeholder icon (no media on this event) */
.media-ph svg { width: 18px; height: 18px; fill: currentColor; vertical-align: middle; }
.media-count { display: inline-flex; align-items: center; gap: .25rem; color: var(--action); cursor: pointer; }
.media-count svg { width: 18px; height: 18px; fill: currentColor; vertical-align: middle; }
.media-count .count { font-size: .78rem; font-weight: 700; }

/* ================= event-type tree filter ================= */
.tree-filter { border: 1px solid var(--border); border-radius: 6px; padding: .35rem .5rem; background: #fff; }
.tree-filter .tree-head { font-weight: 600; color: var(--primary); margin: 0 0 .2rem; display: flex;
  align-items: center; gap: .35rem; font-size: .82rem; }
.tree-filter .tree-body { display: flex; flex-direction: column; gap: .12rem; }
.tree-filter label { display: flex; align-items: center; gap: .35rem; font-weight: 400; font-size: .8rem; margin: 0; }
.tree-filter label input { width: auto; }
.tree-filter .tree-group { padding-left: .1rem; }
.tree-filter .tree-child { padding-left: 1.1rem; }
.tree-filter .tree-parent { font-weight: 500; }

/* ================= flash ================= */
.flash { padding: .6rem .8rem; border-radius: 6px; margin: .6rem 0; font-size: .88rem; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--bad-bg); color: var(--bad); }

/* ================= View Details modal ================= */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(11, 21, 38, .55); z-index: 1000;
  display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; overflow-y: auto;
}
.modal-overlay.hidden { display: none; }
.modal-card {
  background: var(--card); border-radius: var(--radius); width: 100%; max-width: 640px;
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--grid-head-bg); padding: .8rem 1rem; border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 1rem; color: var(--primary); }
.modal-body { padding: 1rem 1.1rem 1.3rem; }
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem 1.2rem; }
.kv { display: flex; flex-direction: column; }
.kv .k, .detail-note .k, .media-gallery + .k { font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.kv .v { font-size: .9rem; color: var(--ink); }
.detail-note { margin-top: .9rem; }
.detail-note p { margin: .2rem 0 0; white-space: pre-wrap; word-break: break-word; }
.media-gallery { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .3rem; }
.media-gallery img { width: 140px; height: 140px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

/* ================= admin tabs (kept internally; QR-Patrol vocabulary in the sidebar) ========== */
.admin-tabs { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1rem; }
.admin-tabs button {
  background: #fff; color: var(--primary); border: 1px solid var(--border-dk); font-size: 13px;
}
.admin-tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.token-reveal { background: #fff8e1; border: 1px solid #e6cf7a; padding: .7rem; border-radius: 6px;
                margin: .6rem 0; word-break: break-all; }

/* ================= login page ================= */
.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--primary), var(--primary-dk)); padding: 1.5rem;
}
.login-card {
  background: var(--card); border-radius: var(--radius); width: 100%; max-width: 380px;
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.login-band {
  background: var(--primary); color: #fff; text-align: center; padding: 1.1rem 1rem;
  letter-spacing: .18em; font-weight: 500; font-size: 1.05rem;
}
.login-body { padding: 1.6rem 1.6rem 1.7rem; }
.login-wordmark { text-align: center; }   /* wrapper only — the wordmark is artwork, not type */
.login-sub { text-align: center; color: var(--muted); font-size: .7rem; letter-spacing: .18em;
             text-transform: uppercase; margin: .1rem 0 1.2rem; }
.field-icon { position: relative; }
.field-icon .fi {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px;
  fill: var(--gray); pointer-events: none;
}
.field-icon input { padding-left: 34px; }
.login-row { display: flex; align-items: center; justify-content: space-between; margin: .9rem 0 .2rem; font-size: .82rem; }
.login-row label { margin: 0; display: flex; align-items: center; gap: .4rem; font-weight: 400; color: var(--ink); }
.login-row label input { width: auto; }
.login-body button.login-btn { width: 100%; margin-top: 1rem; padding: .6rem; background: var(--login-btn); font-size: 15px; }
.login-body button.login-btn:hover { background: var(--login-btn-dk); filter: none; }
.login-divider {
  display: flex; align-items: center; gap: .75rem; margin: 1.3rem 0 1rem; color: var(--muted);
  font-size: .7rem; letter-spacing: .1em; text-transform: uppercase;
}
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.gbtn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; background: #fff;
  color: #3c4043; border-radius: 6px; padding: .6rem; font-weight: 500; text-decoration: none;
  border: 1px solid var(--border-dk); font-size: 14px;
}
.gbtn:hover { background: #f5f6f7; text-decoration: none; }
.forgot { color: var(--action); cursor: pointer; }
.login-info { background: var(--grid-head-bg); color: var(--ink); border-radius: 6px; padding: .7rem .8rem;
              font-size: .8rem; margin-top: .9rem; }
.login-foot { text-align: center; color: var(--muted); font-size: .74rem; margin-top: 1.1rem; }

/* ================= responsive ================= */
@media (max-width: 720px) {
  /* Sidebar becomes a fixed overlay. The collapsed icon rail (var(--rail-w))
     stays visible because it holds the nav + the expand toggle, so offset the
     main column by the rail width to keep content from hiding underneath it.
     When expanded (.open) the panel overlays the content as a drawer. */
  .sidebar { position: fixed; z-index: 900; left: 0; top: 0; box-shadow: var(--shadow-lg); }
  .main-col { margin-left: var(--rail-w); }
  .content { padding: 1rem; }
}


/* ---- official logo lockups (Drive: AIG Security Branding/Logos/Logo Formats) --------------
   The word SECURITY is PART of the artwork — never re-typeset it. Colour lockup on light
   backgrounds, white lockup on navy/photos, banner on the interior rail. */
.login-logo { display: block; width: 208px; max-width: 72%; height: auto; margin: 0 auto .55rem; }
/* Sidebar lockup. The rail is 64px collapsed / 232px open, so the wide banner only fits when
   open; collapsed swaps to the stacked mark. Both are the official artwork — the words
   "AIG SECURITY" come from the file, never from type beside it. */
.side-logo { display: block; width: 100%; max-width: 152px; height: auto; }
.side-brand .mark { white-space: nowrap; }
.sidebar:not(.open) .side-brand { align-items: center; padding: .8rem .35rem; }
.sidebar:not(.open) .side-logo { content: url("/static/logo-white.svg"); max-width: 30px; }
.sidebar:not(.open) .side-brand .mark { display: none; }   /* no room — the mark carries it */
