/* Admin control-room theme — loaded ONLY on /admin and /gate/admin pages
   (see the isAdminArea flag in app.js + head.ejs). The resident and gate
   screens never load this file, so they stay as lean as before. Loaded
   after style.css, so these rules intentionally override the base. */

body { padding: 0; background: #eef1f6; color: #1f2733; }

/* ---- Top app bar ---- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  background: #111a2e; color: #fff; padding: .7rem 1.25rem;
  box-shadow: 0 2px 8px rgba(16, 24, 40, .18);
}
.appbar .brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.05rem; letter-spacing: .2px; }
.appbar .brand .appbar-logo { max-height: 30px; max-width: 150px; display: block; }
.appbar .brand .mark {
  display: inline-flex; width: 1.7rem; height: 1.7rem; align-items: center; justify-content: center;
  background: #1a5cff; border-radius: 7px; font-size: 1rem;
}
.appbar .who { display: flex; align-items: center; gap: .8rem; font-size: .85rem; color: #aeb8cc; }
.appbar .who form { display: inline; margin: 0; }
.appbar .who button {
  width: auto; margin: 0; padding: .38rem .85rem; font-size: .8rem;
  background: #26314c; color: #fff; border-radius: 7px;
}
.appbar .who button:hover { background: #35426580; background: #354265; }

/* ---- Subscription banner (warning-only; never blocks anything) ---- */
.subbar {
  padding: .6rem 1.25rem; font-size: .85rem; line-height: 1.4;
  border-bottom: 1px solid rgba(16, 24, 40, .08);
}
.subbar strong { font-weight: 700; }
.subbar.info { background: #eaf1ff; color: #14418a; }
.subbar.warn { background: #fff4e5; color: #8a5a12; }
.subbar.danger { background: #fdeaea; color: #a12a2a; }

/* ---- Shell: sidebar + main ---- */
.shell { display: flex; align-items: flex-start; min-height: calc(100vh - 56px); }
.side {
  flex: 0 0 232px; align-self: stretch; background: #fff;
  border-right: 1px solid #e2e6ef; padding: 1rem .7rem;
  position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto;
}
.main { flex: 1 1 auto; min-width: 0; }

.sidenav { display: flex; flex-direction: column; gap: .15rem; }
.sidenav a {
  display: flex; align-items: center; gap: .65rem;
  padding: .58rem .7rem; border-radius: 9px;
  font-size: .89rem; color: #4d5a72; text-decoration: none;
}
.sidenav a svg {
  width: 18px; height: 18px; flex: 0 0 18px;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.sidenav a:hover { background: #eff3f9; color: #111a2e; }
.sidenav a.active { background: #eaf1ff; color: #1a5cff; font-weight: 600; }

/* Sidebar folds to a horizontal strip on narrow screens */
@media (max-width: 860px) {
  .shell { display: block; }
  .side {
    position: static; height: auto; flex: none; width: auto;
    border-right: 0; border-bottom: 1px solid #e2e6ef; padding: .5rem .75rem;
  }
  .sidenav { flex-direction: row; overflow-x: auto; gap: .25rem; }
  .sidenav a { white-space: nowrap; }
  .sidenav a span { display: none; }
  .sidenav a svg { width: 20px; height: 20px; flex-basis: 20px; }
}

/* ---- Content shell ---- */
.wrap { padding: 0 1.5rem 2.5rem; }
.wrap.wide { max-width: 1180px; margin: 0; }
@media (min-width: 1240px) { .wrap.wide { max-width: 1220px; } }

/* Page header: keep the page title, drop the now-redundant logout (app bar has it) */
.top { margin: 1.5rem 0 1.25rem; }
.top form { display: none; }
.top h1 { font-size: 1.5rem; letter-spacing: -.3px; }

/* ---- Cards ---- */
.card {
  border: 1px solid #e5e8ef; border-radius: 14px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .06); padding: 1.15rem 1.25rem;
}
.card h1 {
  font-size: .78rem !important; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: #6b7688; margin: 0 0 .7rem;
}

/* ---- Stat tiles ----
   Tile contract: label in sentence case, value in the same sans, semibold.
   Values use the font's default proportional figures on purpose — tabular
   digits make a number like 121 look loose at display sizes. */
.kpis { display: grid; gap: 1rem; margin-bottom: 1.35rem; }
@media (min-width: 900px) { .kpis { grid-template-columns: 272px 1fr; align-items: stretch; } }
.kpis .tiles { margin-bottom: 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 1rem; margin-bottom: 1.35rem; }
.tile {
  background: #fff; border: 1px solid #e5e8ef; border-radius: 14px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .06); padding: 1.15rem 1.25rem;
  position: relative; overflow: hidden;
}
.tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: #1a5cff; }
.tile.hi::before { background: #1a7a34; }
.tile .n { font-size: 2rem; font-weight: 700; line-height: 1; color: #111a2e; }
.tile.hi .n { color: #1a7a34; }
.tile .l { color: #6b7688; font-size: .82rem; margin-top: .45rem; line-height: 1.3; }

/* The one hero figure on the view — the number the dashboard leads with. */
.hero-tile { display: flex; flex-direction: column; justify-content: center; }
.hero-tile::before { background: #1a7a34; }
.hero-tile .l { margin: 0 0 .35rem; font-size: .84rem; }
.hero { font-size: 3.25rem; font-weight: 700; line-height: 1; letter-spacing: -1.5px; color: #1a7a34; }
.liverow { display: flex; align-items: center; gap: .45rem; margin-top: .6rem; font-size: .76rem; color: #6b7688; }
.liverow .dot {
  width: 7px; height: 7px; border-radius: 50%; background: #0ca30c;
  box-shadow: 0 0 0 3px rgba(12, 163, 12, .16);
}

/* ---- Column chart (single series; height carries magnitude) ---- */
.chart-card { margin-bottom: 1.35rem; }
.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: #1a5cff; }
.chart .hit { fill: transparent; }
.chart .barg { cursor: default; }
.chart .barg:hover .bar { fill: #0f47cc; }
.chart .barg:hover .hit { fill: rgba(26, 92, 255, .05); }
/* Hairline, solid, recessive — never dashed. */
.chart .grid { stroke: #e8ecf3; stroke-width: 1; }
.chart .axis { stroke: #cbd3e0; stroke-width: 1; }
/* Axis/label text wears text tokens, never the series colour. */
.chart .tick { fill: #8b95a7; font-size: 10px; text-anchor: end; font-variant-numeric: tabular-nums; }
.chart .xlab { fill: #8b95a7; font-size: 11px; text-anchor: middle; }
.chart .xlab.today { fill: #111a2e; font-weight: 700; }
.chart .peak { fill: #4d5a72; font-size: 11px; font-weight: 700; text-anchor: middle; }
.chart-foot { margin-top: .55rem; }

/* Two-column dashboard sections on wide screens */
.dash-cols { display: grid; gap: 1rem; }
@media (min-width: 900px) { .dash-cols { grid-template-columns: 1fr 1fr; align-items: start; } }

/* ---- Rows / activity feed ---- */
.row { padding: .6rem 0; }
.row strong { color: #111a2e; }

/* ---- Tables ---- */
table { font-size: .88rem; }
th {
  color: #6b7688; text-transform: uppercase; font-size: .72rem;
  letter-spacing: .4px; border-bottom: 2px solid #e5e8ef;
}
td { border-bottom: 1px solid #eef1f6; }
tbody tr:hover { background: #f6f8fc; }

/* ---- Buttons / links ---- */
.btn-link, button[type="submit"] { border-radius: 8px; }
.filters input, input, select, textarea { border-radius: 8px; }

/* ============================================================
   Professional refinement layer (light SaaS).
   Visual polish only — no layout/width/display changes, so the
   existing grid never shifts. Loaded after everything above, so
   these win. Admin-only file → the gate/resident pages are untouched.
   ============================================================ */

/* Cheap, tasteful micro-interactions — the biggest "feels premium" win. */
.sidenav a, .card, .tile, button, .btn-link, input, select, textarea, tbody tr, .status, a {
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, color .15s ease, transform .08s ease;
}
::selection { background: rgba(26, 92, 255, .18); }

/* Consistent, visible keyboard focus everywhere (accessible + polished). */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid #1a5cff; outline-offset: 2px;
}

/* ---- Forms ---- */
label { color: #364155; font-size: .82rem; font-weight: 600; margin: .9rem 0 .3rem; }
input, select, textarea {
  border: 1px solid #d5dbe6; background: #fff; color: #1f2733; padding: .6rem .7rem; font-size: .95rem;
}
input::placeholder, textarea::placeholder { color: #9aa4b5; }
input:hover, select:hover, textarea:hover { border-color: #b7c0d1; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: #1a5cff; box-shadow: 0 0 0 3px rgba(26, 92, 255, .15);
}
input:disabled, select:disabled, textarea:disabled { background: #f3f5f9; color: #97a1b2; cursor: not-allowed; }
.hint { color: #7a8496; font-size: .82rem; line-height: 1.45; }
.sub { color: #6b7688; }
.muted { color: #8b95a7; }

/* ---- Buttons ---- */
button, .btn-link { font-weight: 600; letter-spacing: .1px; }
button[type="submit"], .btn-link { background: #1a5cff; box-shadow: 0 1px 2px rgba(16, 24, 40, .10); }
button[type="submit"]:hover, .btn-link:hover { background: #1550e6; }
button:active { transform: translateY(1px); }
button.secondary { background: #eef1f6; color: #26314c; border: 1px solid #dde2ec; box-shadow: none; }
button.secondary:hover { background: #e3e8f1; }
button.danger { background: #dc3030; box-shadow: 0 1px 2px rgba(16, 24, 40, .10); }
button.danger:hover { background: #c52727; }
button:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; transform: none; }
.top button, .filters button { box-shadow: none; }
a { color: #1a5cff; }
a:hover { color: #1550e6; }

/* ---- Cards: soft lift on hover for a tactile, modern feel ---- */
.card { background: #fff; }
.card:hover { box-shadow: 0 6px 20px rgba(16, 24, 40, .09); border-color: #dde3ee; }
.tile:hover { box-shadow: 0 6px 20px rgba(16, 24, 40, .09); }

/* ---- Status badges: crisp hairline border so they read on white ---- */
.status { border: 1px solid transparent; }
.status-valid, .status-active, .status-checked_out { border-color: #b9e3c8; }
.status-used, .status-checked_in { border-color: #c2dbf7; }
.status-expired, .status-revoked, .status-not_found { border-color: #f2c4c4; }
.status-exit_expired, .status-exit_revoked { border-color: #f2ddb3; }

/* ---- Rows / tables: comfortable rhythm, quiet dividers ---- */
.row { border-bottom-color: #eef1f6; }
th, td { padding: .62rem .55rem; }
th { color: #6b7688; }
tbody tr:hover { background: #f6f8fc; }

/* ---- Empty-state hint blocks read as intentional, not leftover ---- */
.card > .hint:only-of-type { padding: .35rem 0; }
