/*
 * eng_tools theme: re-skins Bootstrap to the custom engineering-drawing look and
 * provides the full-screen app shell (left sidebar nav + full-height main).
 * Loaded AFTER bootstrap.min.css so the variable overrides win.
 */

:root {
  --paper: #fafafa;
  --paper-card: #ffffff;
  --ink: #18211d;
  --ink-soft: #5f6b65;
  --line: #dedede;
  --grid-minor: rgba(13, 195, 133, 0.045);
  --grid-major: rgba(13, 195, 133, 0.09);
  --accent: #0dc385;
  --accent-dark: #099666;
  --danger: #d9534f;
  --warn: #c2740b;
  --success: var(--accent-dark);
  --dt-color: #5566b8;
  --stamp-bg: #18211d;

  --display: "Space Grotesk", system-ui, sans-serif;
  --body: "Inter", system-ui, sans-serif;
  --mono: "Space Mono", ui-monospace, "SF Mono", monospace;

  --bs-body-bg: var(--paper);
  --bs-body-color: var(--ink);
  --bs-emphasis-color: var(--ink);
  --bs-secondary-color: var(--ink-soft);
  --bs-tertiary-bg: var(--paper-card);
  --bs-body-font-family: var(--body);
  --bs-border-color: var(--line);
  --bs-border-radius: 0;
  --bs-border-radius-sm: 0;
  --bs-border-radius-lg: 0;
  --bs-border-radius-xl: 0;
  --bs-border-radius-pill: 0;
  --bs-link-color: var(--accent-dark);
  --bs-link-hover-color: var(--accent);
  --bs-link-color-rgb: 9, 150, 102;
  --bs-emphasis-color-rgb: 24, 33, 29;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0e1311;
    --paper-card: #151b18;
    --ink: #e8efea;
    --ink-soft: #94a39b;
    --line: #29322d;
    --grid-minor: rgba(13, 195, 133, 0.03);
    --grid-major: rgba(13, 195, 133, 0.055);
    --accent-dark: #2ad69b;
    --danger: #e5746f;
    --warn: #e0a24a;
    --dt-color: #8b9bef;
    --bs-link-color-rgb: 42, 214, 155;
    --bs-emphasis-color-rgb: 232, 239, 234;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0e1311;
  --paper-card: #151b18;
  --ink: #e8efea;
  --ink-soft: #94a39b;
  --line: #29322d;
  --grid-minor: rgba(13, 195, 133, 0.03);
  --grid-major: rgba(13, 195, 133, 0.055);
  --accent-dark: #2ad69b;
  --danger: #e5746f;
  --warn: #e0a24a;
  --dt-color: #8b9bef;
  --bs-link-color-rgb: 42, 214, 155;
  --bs-emphasis-color-rgb: 232, 239, 234;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

input[type="radio"] {
  accent-color: var(--accent);
}

/* Bare (non-Bootstrap) checkboxes: give them a clearly bordered box so they
 * read against the paper/grid background, with a green check when on. */
input[type="checkbox"]:not(.form-check-input) {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin: 0;
  border: 1.5px solid var(--ink-soft);
  background: var(--paper-card);
  vertical-align: text-bottom;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}
input[type="checkbox"]:not(.form-check-input):hover {
  border-color: var(--accent);
}
input[type="checkbox"]:not(.form-check-input):checked {
  background: var(--accent);
  border-color: var(--accent);
}
input[type="checkbox"]:not(.form-check-input):checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 4px;
  height: 9px;
  border: solid #06241a;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.form-check-input {
  border-color: var(--ink-soft);
}
.form-check-input:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}

/* ---- App shell: left sidebar + full-screen main ------------------------- */

body.app-shell {
  margin: 0;
  min-height: 100vh;
  display: flex;
  color: var(--ink);
  font-family: var(--body);
  -webkit-font-smoothing: auto;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid-minor) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px),
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px);
  background-size:
    24px 24px,
    24px 24px,
    120px 120px,
    120px 120px;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  width: 232px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  border-right: 1.5px solid var(--ink);
  background: var(--paper-card);
  /* Scroll the nav itself when it outgrows the viewport; otherwise the overflow
     spills past the 100vh box and gives the whole page a scrollbar. */
  overflow-y: auto;
}

.sidebar-brand {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  padding: 0 10px 4px;
}
.sidebar-brand span {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 400;
  line-height: 1.2em;
  min-height: 4.8em;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent-dark);
  margin-top: 4px;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sidebar > .nav-list {
  margin-top: 14px;
}
.nav-item {
  display: block;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition:
    color 0.12s ease,
    background 0.12s ease;
}
.nav-item:hover {
  color: var(--ink);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}
.nav-item.active {
  color: var(--accent-dark);
  border-left-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, transparent);
}

.app-main {
  flex: 1;
  min-width: 0;
  height: 100vh;
  overflow: auto;
  padding: clamp(20px, 3vw, 40px);
}
/* Full-bleed apps (e.g. the editor) manage their own layout/padding. */
.app-main.flush {
  padding: 0;
  display: flex;
  flex-direction: column;
}

.theme-toggle {
  appearance: none;
  margin-top: auto;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 8px 12px;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    color 0.15s ease;
}
.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.page-title {
  margin: 0 0 24px;
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(22px, 2.4vw, 28px);
  letter-spacing: -0.01em;
  color: var(--accent-dark);
}

/* ---- Home: tool plates -------------------------------------------------- */

.plates {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.plate {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: clamp(20px, 2.6vw, 30px);
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper-card) 68%, transparent);
  text-decoration: none;
  color: inherit;
  transition: background 0.18s ease;
}
.plate::before {
  content: "";
  position: absolute;
  left: 0;
  top: -1px;
  height: 2px;
  width: 0;
  background: var(--accent);
  transition: width 0.2s ease;
}
.plate:hover {
  background: color-mix(in srgb, var(--paper-card) 86%, transparent);
}
.plate:hover::before {
  width: 100%;
}
.plate-name {
  margin: 0 0 10px;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(19px, 1.8vw, 22px);
  letter-spacing: -0.015em;
  color: var(--accent-dark);
}
.plate:hover .plate-name {
  color: var(--accent);
}
.plate-desc {
  margin: 0 0 26px;
  max-width: 38ch;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-soft);
}
.plate-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}
.path {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent-dark);
}
.arrow {
  font-family: var(--mono);
  font-size: 18px;
  color: var(--ink);
  transition: transform 0.18s ease;
}
.plate:hover .arrow {
  transform: translateX(6px);
  color: var(--accent-dark);
}

/* ---- Explore: alphabetical table index --------------------------------- */

/* Data Explorer index: themed sections of tables, laid out as columns so 50+ tables stay
 * compact instead of one long flat list. */
.index-list {
  margin: 0;
  padding: 0;
  list-style: none;
  max-width: 420px;
  border-top: 1px solid var(--line);
}
.index-list li {
  border-bottom: 1px solid var(--line);
}
.index-list-columns {
  max-width: none;
  border-top: none;
  columns: 2;
  column-gap: 32px;
}
.index-list-columns li {
  break-inside: avoid;
  border-top: 1px solid var(--line);
  border-bottom: none;
}
.index-list a {
  display: block;
  padding: 10px 8px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition:
    color 0.12s ease,
    background 0.12s ease;
}
.index-list a:hover {
  color: var(--accent-dark);
  border-left-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

/* ---- Home: section headers --------------------------------------------- */

.section-title {
  margin: 40px 0 16px;
  padding-bottom: 8px;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
}
.section-title:first-of-type {
  margin-top: 4px;
}
.plates + .section-title {
  margin-top: 44px;
}

/* ---- Investigator: recent reservations --------------------------------- */

.recent h2,
.investigation h2 {
  margin: 4px 0 14px;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(17px, 1.7vw, 20px);
  letter-spacing: -0.01em;
}
.recent-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}
.recent-list li {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.recent-list a {
  flex: 0 0 auto;
  min-width: 78px;
  font-family: var(--mono);
  font-weight: 600;
  text-decoration: none;
  color: var(--accent-dark);
}
.recent-list a:hover {
  color: var(--accent);
}
.recent-list .status {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}
.recent-list .created {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
}

/* ---- Sidebar: grouped sections ----------------------------------------- */

.nav-group {
  margin-top: 16px;
}
.nav-heading {
  display: block;
  padding: 0 0 6px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
  opacity: 0.7;
}

/* ---- Cohort detectors: filter chips ------------------------------------ */

.cohort-filter {
  margin: 0 0 16px;
}
.cohort-filter .form-control {
  width: 280px;
}
.cohort-filter .days-field {
  width: 6rem;
}

.detector-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 22px;
}
.detector-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
  text-decoration: none;
  color: var(--ink);
  transition:
    border-color 0.12s ease,
    color 0.12s ease;
}
.detector-chip:hover {
  border-color: var(--accent);
  color: var(--ink);
}
.detector-chip.active {
  border-color: var(--accent);
  color: var(--accent-dark);
}
.detector-chip .count {
  font-weight: 700;
  color: var(--ink);
}
.recent-list .codes {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* Shared listing table: a real table so columns line up across rows and status pills
 * size to content instead of stretching to fill a grid track. Use for any multi-column
 * listing (gremlins, detail-page sublists, landing lists). */
.list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.list-table th {
  text-align: left;
  padding: 0 16px 8px 0;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.list-table td {
  padding: 7px 16px 7px 0;
  vertical-align: middle;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
}
.list-table tbody tr:hover td,
.list-table tr:hover td {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}
.gremlin-codes .tag {
  margin: 0 4px 4px 0;
}

/* Cohort rows align as a fixed grid so the columns line up across rows. */
.cohort-list li {
  display: grid;
  grid-template-columns: 92px 84px 232px minmax(0, 1fr) auto;
  align-items: baseline;
}
.cohort-list .created {
  justify-self: end;
}

.cost-breakdown .amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cost-breakdown tr.informational td {
  color: var(--ink-soft);
}
.cost-breakdown tr.total-row td {
  border-top: 2px solid var(--line);
  font-weight: 600;
}

/* ---- Investigator: search form + loaded investigation ------------------ */

.investigate-form {
  margin: 0 0 28px;
}
.error {
  margin: 0 0 18px;
  padding: 10px 14px;
  border-left: 3px solid var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  font-size: 14px;
}

/* A non-fatal degraded-state notice, e.g. a data source that could not be loaded while
 * the rest of the page still renders. Amber, softer than .error. */
.notice {
  margin: 0 0 12px;
  padding: 8px 12px;
  border-left: 3px solid var(--warn);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  font-size: 13px;
  color: var(--ink-soft);
}

.inv-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 8px 0 18px;
}
.inv-header h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(19px, 2vw, 22px);
  letter-spacing: -0.01em;
}
.inv-header .sim-link {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 12px;
}
.status-badge {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border: 1px solid var(--line);
  color: var(--ink-soft);
}
.status-badge.status-active {
  border-color: var(--accent);
  color: var(--accent-dark);
}
.status-badge.status-canceled,
.status-badge.status-expired {
  border-color: var(--danger);
  color: var(--danger);
}

/* Enum / status pills (see the tag / status_tag macros). */
.tag {
  display: inline-block;
  padding: 2px 8px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid var(--line);
  color: var(--ink-soft);
}
.tag-ok {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  color: var(--accent-dark);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.tag-bad {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--line));
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}
.tag-warn {
  border-color: color-mix(in srgb, var(--warn) 55%, var(--line));
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 14%, transparent);
}
.tag-neutral {
  color: var(--ink-soft);
  background: color-mix(in srgb, var(--ink-soft) 8%, transparent);
}

/* Placeholder pills for non-values in data views, kept visually distinct from real
 * content and from each other: NULL (absent column), BLANK (present empty string), and
 * HIDDEN (redacted column). Dashed border signals "no value here". */
.nullish {
  display: inline-block;
  padding: 0 6px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px dashed color-mix(in srgb, var(--ink-soft) 35%, transparent);
  border-radius: 2px;
  color: var(--ink-soft);
  opacity: 0.8;
}
.nullish-null {
  color: var(--ink-soft);
}
.nullish-blank {
  font-style: italic;
  border-style: dotted;
  color: color-mix(in srgb, var(--accent-dark) 70%, var(--ink-soft));
}
.nullish-hidden {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 45%, var(--line));
}
.nullish-empty {
  color: var(--ink-soft);
}

/* Boolean values rendered as a small boxed token: a desaturated green box for true, a muted
 * grey one for false, so they read at a glance without the saturation of the accent green. */
.boolpill {
  display: inline-block;
  padding: 0 6px;
  font-family: var(--mono);
  font-size: 11px;
  border: 1px solid;
  border-radius: 2px;
}
.boolpill-true {
  color: color-mix(in srgb, var(--accent-dark) 65%, var(--ink-soft));
  border-color: color-mix(in srgb, var(--accent-dark) 30%, var(--line));
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}
.boolpill-false {
  color: var(--ink-soft);
  border-color: var(--line);
  background: color-mix(in srgb, var(--ink-soft) 6%, transparent);
}

/* A spot's marker, rendered as a little Parkade sign placard: paper card, dark text, with a thin
 * Parkade-green top edge as the brand accent. Compact: ~1px taller than plain text. */
.marker-sign {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  padding: 1px 7px;
  white-space: nowrap;
  color: var(--ink);
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-top: 2px solid var(--accent);
  border-radius: 2px;
}

/* A compact license plate. The mounting holes are empty pseudo-elements, leaving
 * one plain text node as the complete selectable/copyable content. */
.license-plate {
  position: relative;
  display: inline-block;
  min-width: 7.5ch;
  padding: 2px 11px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.07em;
  text-align: center;
  white-space: nowrap;
  user-select: text;
  color: var(--ink);
  background: linear-gradient(
    color-mix(in srgb, var(--paper-card) 86%, var(--ink-soft)),
    color-mix(in srgb, var(--paper-card) 94%, var(--paper))
  );
  border: 1px solid color-mix(in srgb, var(--ink-soft) 55%, var(--line));
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--paper) 65%, transparent), 0 1px 1px rgb(0 0 0 / 10%);
}
.license-plate::before,
.license-plate::after {
  position: absolute;
  top: 50%;
  width: 3px;
  height: 3px;
  content: "";
  background: color-mix(in srgb, var(--ink-soft) 75%, var(--line));
  border-radius: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  user-select: none;
}
.license-plate::before {
  left: 4px;
}
.license-plate::after {
  right: 4px;
}

.divergences {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 24px;
}
.divergence {
  padding: 10px 14px;
  border-left: 3px solid var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  font-size: 14px;
}

.inv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.panel {
  padding: 18px 20px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper-card) 60%, transparent);
}
.panel h3 {
  margin: 0 0 14px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
}
/* Sub-labels inside a panel (e.g. "Long-term rules") - a caption that sits clearly
 * above the 11px column headers beneath it, so the two label tiers don't merge. */
.panel h4 {
  margin: 16px 0 6px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
}

/* A rule-set panel nests title > section label > column header > data. Its title is a
 * named entity, so it leads in full ink at a heading size instead of the faint 12px
 * label the flat data panels use; otherwise the title reads as smaller than its rows. */
.rule-set h3 {
  font-size: 15px;
  letter-spacing: 0.06em;
  color: var(--ink);
}
/* "Long/Short-term rules" must out-rank the rows beneath it, so the section label sits
 * a step above the rule data (which we pull down to 13px) rather than matching it. */
.rule-set h4 {
  font-size: 14px;
  color: var(--ink);
}
.rule-set .rule-table td {
  font-size: 13px;
}

/* Rule tables hold a few narrow columns; let them hug their content instead of stretching the
 * full page width, with generous column gaps so the data stays scannable. */
.rule-table {
  width: auto;
}
.rule-table th,
.rule-table td {
  padding-right: 32px;
}

table.kv {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.kv th {
  width: 1%;
  white-space: nowrap;
  padding: 5px 16px 5px 0;
  text-align: left;
  font-weight: 500;
  vertical-align: top;
  color: var(--ink-soft);
}
table.kv td {
  padding: 5px 0;
  word-break: break-word;
}
table.kv .filter-row th {
  padding-top: 0;
  padding-bottom: 4px;
}
table.kv .col-head th {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  padding-top: 8px;
  padding-bottom: 4px;
}

/* Every explorer-list data column shrink-wraps to its content, and a single empty trailing
 * spacer column (`.spacer`) soaks up all leftover page width. So a value column -- a date, an
 * enum, an id -- is never stretched past its content to fill the row, no matter how few columns
 * the table has. These rules sit after the generic table.kv th/td above so their padding wins. */
table.explore-table th,
table.explore-table td {
  padding-right: 2em;
}
table.explore-table td {
  width: 1px;
  white-space: nowrap;
  word-break: normal;
}
table.explore-table .spacer {
  width: auto;
  min-width: 0;
  padding-right: 0;
  white-space: normal;
}
.col-filter {
  width: 100%;
  min-width: 48px;
  box-sizing: border-box;
  padding: 2px 6px;
  font-family: var(--bs-font-monospace, monospace);
  font-size: 12px;
  color: var(--ink);
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.col-filter:focus {
  outline: none;
  border-color: var(--accent);
}
.col-filter-invalid {
  border-color: var(--danger);
}

/* Raw-fields panel. Two things give the eye an anchor here:
 * 1. Phone-book flow: CSS multicol (not a row-major grid), so the alphabetical field
 *    order runs DOWN each column and a lookup scans one column top to bottom instead
 *    of ricocheting across the page. A hairline column rule fences the columns.
 * 2. Texture contrast: labels are small muted mono, values full-ink body face, so the
 *    label column and the value column read as two distinct vertical bands. */
.kv-grid {
  columns: 340px;
  column-gap: 48px;
  column-rule: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  margin: 0;
  font-size: 14px;
}
.kv-pair {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 0 16px;
  padding: 5px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent);
  break-inside: avoid;
}
.kv-pair dt {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  word-break: break-word;
  /* optical baseline alignment: the label face is ~2.5px shorter than the value face */
  padding-top: 3px;
}
.kv-pair dd {
  margin: 0;
  color: var(--ink);
  word-break: break-word;
}

.invoice {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
}
.invoice:last-child {
  margin-bottom: 0;
}
.invoice.is-canceled {
  border-left-color: var(--danger);
}

.invoice-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}
.invoice.is-canceled .invoice-head {
  background: color-mix(in srgb, var(--danger) 7%, transparent);
}
.invoice-refs {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ref {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.ref-label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.ref-id {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.ref-sep {
  font-family: var(--mono);
  color: var(--ink-soft);
}
.invoice-total {
  display: flex;
  align-items: center;
  gap: 10px;
}
.invoice-total .amount {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.invoice-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 26px;
  margin: 0;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
}
.invoice-meta .meta-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.invoice-meta dt {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.invoice-meta dd {
  margin: 0;
  font-size: 12px;
}
.meta-arrow {
  color: var(--ink-soft);
}

.ledger {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content max-content max-content;
  align-items: baseline;
  column-gap: 14px;
  row-gap: 4px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--ink-soft) 4%, transparent);
}
.ledger-row,
.ledger-refund {
  display: contents;
}
.ledger-kind {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 1px 6px;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  justify-self: start;
}
.kind-pi {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  color: var(--accent-dark);
}
.kind-charge {
  border-color: var(--line);
  color: var(--ink);
}
.kind-refund {
  border-style: dashed;
}
.ledger-id {
  min-width: 0;
  font-family: var(--mono);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.ledger-note {
  margin-left: 8px;
  font-size: 12px;
  color: var(--ink-soft);
}
.ledger-flag {
  margin-left: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--danger);
}
.ledger-amount {
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.ledger-refund .ledger-amount {
  color: var(--danger);
}
.ledger-time {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
  text-align: right;
  white-space: nowrap;
}
.ledger-refund .ledger-id {
  padding-left: 4px;
}
.ledger .tag {
  justify-self: start;
}
.ledger-refund .ledger-amount {
  grid-column: 4;
}
.ledger-refund .ledger-time {
  grid-column: 5;
}

.timeline {
  margin: 0;
  padding: 0;
  list-style: none;
}
.timeline .entry {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.timeline .entry:last-child {
  border-bottom: 0;
}
.timeline .ts {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
}
.timeline .kind {
  flex: 0 0 auto;
  padding: 1px 6px;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}
.timeline .summary {
  flex: 1 1 auto;
}
.timeline .actor {
  color: var(--ink-soft);
}
.empty {
  color: var(--ink-soft);
  font-size: 14px;
}

/* ---- Parking simulator: gate access matrix + per-gate timelines -------- */

.sim-matrix {
  margin: 0;
}
.sim-matrix td {
  vertical-align: middle;
}
.sim-matrix td.gate {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--ink);
}
/* The verdict column is the page's answer: give it a hairline separator and
 * let its pill carry the weight while the input columns stay quiet. */
.sim-matrix th:last-child,
.sim-matrix td:last-child {
  border-left: 1px solid var(--line);
}

.sim-gate + .sim-gate {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.sim-gate h4 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}

/* ---- Bootstrap component nudges ---------------------------------------- */

.form-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.form-control,
.form-select {
  background-color: var(--paper-card);
  border-color: var(--line);
  color: var(--ink);
}
.form-control:focus,
.form-select:focus {
  background-color: var(--paper-card);
  border-color: var(--accent);
  box-shadow: 0 0 0 0.15rem color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--ink);
}

.btn {
  --bs-btn-border-radius: 0;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.btn-primary {
  --bs-btn-bg: var(--accent);
  --bs-btn-border-color: var(--accent);
  --bs-btn-hover-bg: var(--accent-dark);
  --bs-btn-hover-border-color: var(--accent-dark);
  --bs-btn-active-bg: var(--accent-dark);
  --bs-btn-active-border-color: var(--accent-dark);
  --bs-btn-color: #06241a;
  --bs-btn-hover-color: #06241a;
  --bs-btn-active-color: #06241a;
}
.btn-outline-primary {
  --bs-btn-color: var(--accent-dark);
  --bs-btn-border-color: var(--accent);
  --bs-btn-hover-bg: var(--accent);
  --bs-btn-hover-border-color: var(--accent);
  --bs-btn-hover-color: #06241a;
}

.card {
  --bs-card-bg: var(--paper-card);
  --bs-card-border-color: var(--line);
  --bs-card-border-radius: 0;
  box-shadow: none;
}
.card-title {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--ink);
  --bs-table-border-color: var(--line);
  --bs-table-striped-bg: color-mix(in srgb, var(--accent) 5%, transparent);
  --bs-table-striped-color: var(--ink);
  --bs-table-hover-bg: color-mix(in srgb, var(--accent) 9%, transparent);
  --bs-table-hover-color: var(--ink);
  font-size: 13px;
}
.table > thead th {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent-dark);
}

h1, h2, h3, h4, h5, h6 {
  color: var(--ink);
}
.text-body-secondary {
  color: var(--ink-soft) !important;
}

.mono {
  font-family: var(--mono);
}
/* Numeric scalars in data cells: mono + tabular digits so magnitudes line up and
 * numbers read as a distinct texture from prose strings. Slightly shrunk because
 * the mono face runs visually larger than the body face at equal size. */
.num {
  font-family: var(--mono);
  font-size: 0.93em;
  font-variant-numeric: tabular-nums;
}
.muted {
  color: var(--ink-soft);
}
.dt {
  cursor: help;
  color: var(--dt-color);
  font-size: 0.8em;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.dt-dim {
  opacity: 0.75;
}

/* Datetime cells hold a fixed-width value, so shrink the column to that content and never
 * let the table's auto layout stretch or wrap it. */
td:has(> .dt) {
  width: 1px;
  white-space: nowrap;
}

/* Cross-reference link: a dashed-underlined accent link used wherever an id
 * points at another detail view. */
a.xlink {
  color: var(--accent-dark);
  text-decoration: none;
  border-bottom: 1px dashed color-mix(in srgb, var(--accent-dark) 45%, transparent);
  cursor: pointer;
}
a.xlink:hover {
  border-bottom-style: solid;
}
/* A cross-reference link whose target list is empty (e.g. a zero-count "referenced by"
 * entry): keep it clickable but visually recede so populated links stand out. */
a.xlink.xlink-dim {
  opacity: 0.45;
}
.nowrap {
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* htmx loading overlay: a translucent cover with a centered spinner that sits
 * over the data region while a request is in flight. The overlay element also
 * carries .htmx-indicator, so htmx fades it in via the htmx-request class. */
.loading-host {
  position: relative;
}
.loading-host:has(.htmx-request) {
  min-height: 140px;
}
.skeleton {
  display: inline-block;
  width: 60%;
  min-width: 36px;
  height: 1em;
  vertical-align: middle;
  border-radius: 3px;
  background: linear-gradient(
    90deg,
    var(--paper-card),
    color-mix(in srgb, var(--ink-soft) 28%, var(--paper-card)),
    var(--paper-card)
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
  }
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 10px;
  padding-top: 28px;
  background: color-mix(in srgb, var(--paper) 70%, transparent);
  color: var(--ink-soft);
  z-index: 5;
  pointer-events: none;
}

.login-card {
  max-width: 420px;
}

.search-field .dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 10;
  max-height: 320px;
  overflow-y: auto;
}
/* CSS-only dismissal: suggestions show only while the field (input or a
   suggestion button) holds focus, and reappear on refocus. */
.search-field:not(:focus-within) .dropdown-menu.show {
  display: none;
}
