/* theme.css — remaps Bootstrap 5.3 to Trazadera tokens and styles base elements.
   Loaded AFTER bootstrap.css and tokens.css. Component-level restyles are added
   per-screen in later phases. */

:root,
[data-bs-theme="light"] {
  --bs-primary: var(--tz-primary);
  --bs-primary-rgb: var(--tz-primary-rgb);

  --bs-body-bg: var(--tz-n50);
  --bs-body-color: var(--tz-n600);
  --bs-emphasis-color: var(--tz-primary-dark);
  --bs-secondary-color: var(--tz-n500);
  --bs-secondary-bg: var(--tz-n100);
  --bs-tertiary-bg: var(--tz-n50);
  --bs-border-color: var(--tz-n200);

  --bs-link-color: var(--tz-accent-blue);
  --bs-link-color-rgb: 0, 128, 170;
  --bs-link-hover-color: var(--tz-accent-blue-dark);

  --bs-font-sans-serif: var(--tz-font-sans);
  --bs-font-monospace: var(--tz-font-mono);

  --bs-border-radius: var(--tz-r-md);
  --bs-border-radius-sm: var(--tz-r-sm);
  --bs-border-radius-lg: var(--tz-r-lg);
  --bs-border-radius-xl: var(--tz-r-xl);

  --bs-box-shadow-sm: var(--tz-shadow-sm);
  --bs-box-shadow: var(--tz-shadow-md);
  --bs-box-shadow-lg: var(--tz-shadow-lg);

  /* teal-tinted gray ramp */
  --bs-gray-100: var(--tz-n100); --bs-gray-200: var(--tz-n200);
  --bs-gray-300: var(--tz-n300); --bs-gray-400: var(--tz-n400);
  --bs-gray-500: var(--tz-n500); --bs-gray-600: var(--tz-n600);
  --bs-gray-700: var(--tz-n700); --bs-gray-800: var(--tz-n800);
  --bs-gray-900: var(--tz-n900);
}

body {
  background-color: var(--bs-body-bg);
  color: var(--bs-body-color);
  font-family: var(--bs-font-sans-serif);
  font-size: var(--tz-text);
  /* Inter renders harsh with macOS subpixel AA — smooth it. */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Base UI controls share the 14px base for a consistent rhythm. */
.btn, .form-control, .form-select, .form-label, .input-group-text,
.table, .dropdown-item, .nav-link, .badge {
  font-size: var(--tz-text);
}
small, .small, .text-muted, .form-text { font-size: var(--tz-text-sm); }

/* Buttons never wrap — icon + label + shortcut badge stay on a single line. */
.btn { white-space: nowrap; }

/* Montserrat is reserved for the few large titles; everything else is Inter. */
h1, h2, .h1, .h2 {
  font-family: var(--tz-font-display);
  color: var(--tz-primary-dark);
  font-weight: 700;
  letter-spacing: -0.01em;
}
h3, h4, h5, h6, .h3, .h4, .h5, .h6 {
  font-family: var(--bs-font-sans-serif);
  color: var(--tz-primary-dark);
  font-weight: 600;
  letter-spacing: -0.005em;
}
h1, .h1 { font-size: var(--tz-text-h1); }
h2, .h2 { font-size: var(--tz-text-h2); }
h3, .h3 { font-size: var(--tz-text-h3); }
h4, .h4 { font-size: var(--tz-text-h4); }
h5, .h5 { font-size: var(--tz-text-lg); }
h6, .h6 { font-size: var(--tz-text); }

/* Fixed-width: standardized on JetBrains Mono everywhere code appears. */
code, pre, kbd, samp, .font-monospace {
  font-family: var(--tz-font-mono);
}
.ace_editor, .ace_editor .ace_text-layer, .ace_editor .ace_line {
  font-family: var(--tz-font-mono) !important;
}

/* ============================================================================
   BUTTON ROLES — normalized to 4. Every button maps to exactly one:
     Primary         .btn-primary          solid teal    — the one main action/view
     Brand-secondary .btn-outline-primary  subtle border, teal on hover — important non-primary actions
     Neutral         .btn-secondary        filled gray   — cancel / toolbar / utility
     Danger          .btn-danger/-outline  red           — destructive only
   Retired (do not reintroduce): btn-light + btn-default (→ btn-secondary),
   btn-outline-secondary (→ btn-secondary), btn-dark, btn-warning/-outline-warning
   (→ btn-danger by intent). .btn-link is a separate no-chrome inline-action
   utility (icon edit/delete/cancel), not an emphasis role — left to Bootstrap.
   ============================================================================ */

/* Primary → solid teal */
.btn-primary {
  --bs-btn-bg: var(--tz-primary);
  --bs-btn-border-color: var(--tz-primary);
  --bs-btn-hover-bg: var(--tz-primary-dark);
  --bs-btn-hover-border-color: var(--tz-primary-dark);
  --bs-btn-active-bg: var(--tz-primary-dark);
  --bs-btn-active-border-color: var(--tz-primary-dark);
  --bs-btn-disabled-bg: var(--tz-primary);
  --bs-btn-disabled-border-color: var(--tz-primary);
}

/* Brand-secondary → subtle hairline border at rest, teal on hover */
.btn-outline-primary {
  --bs-btn-color: var(--tz-primary);
  --bs-btn-border-color: var(--tz-n200);
  --bs-btn-hover-bg: var(--tz-primary);
  --bs-btn-hover-border-color: var(--tz-primary);
  --bs-btn-active-bg: var(--tz-primary-dark);
}

/* Neutral → filled gray */
.btn-secondary {
  --bs-btn-bg: var(--tz-n100); --bs-btn-border-color: var(--tz-n200); --bs-btn-color: var(--tz-n700);
  --bs-btn-hover-bg: var(--tz-n200); --bs-btn-hover-border-color: var(--tz-n300); --bs-btn-hover-color: var(--tz-n800);
  --bs-btn-active-bg: var(--tz-n200); --bs-btn-active-border-color: var(--tz-n300); --bs-btn-active-color: var(--tz-n800);
}

/* Danger → solid / outline red (destructive only) */
.btn-danger {
  --bs-btn-bg: var(--tz-error); --bs-btn-border-color: var(--tz-error);
  --bs-btn-hover-bg: var(--tz-error-fg); --bs-btn-hover-border-color: var(--tz-error-fg);
  --bs-btn-active-bg: var(--tz-error-fg); --bs-btn-active-border-color: var(--tz-error-fg);
}
.btn-outline-danger {
  --bs-btn-color: var(--tz-error); --bs-btn-border-color: var(--tz-error);
  --bs-btn-hover-bg: var(--tz-error); --bs-btn-hover-border-color: var(--tz-error); --bs-btn-hover-color: var(--tz-white);
  --bs-btn-active-bg: var(--tz-error); --bs-btn-active-border-color: var(--tz-error); --bs-btn-active-color: var(--tz-white);
}

/* focus = visible ring, not glow (scoped to interactive elements) */
.btn:focus-visible,
.form-control:focus,
.form-select:focus,
a:focus-visible,
.nav-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--tz-primary);
  border-color: var(--tz-primary);
}

a { color: var(--bs-link-color); }

/* Heroicons via sprite + fragment inherit text color */
.tz-icon { display: inline-block; vertical-align: -0.125em; color: currentColor; }

/* Compact padding for data tables (tz-table). */
.tz-table > :where(thead, tbody) > tr > :where(th, td) { padding: 6px 10px; }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ---- App shell: dark-teal top bar (L1 domain nav) + light underline sub-nav (L2) ---- */
.tz-topbar {
  position: sticky; top: 0; z-index: 1030;
  display: flex; align-items: center; gap: 20px;
  height: 56px; padding: 0 24px;
  background: var(--tz-primary-dark);
}
.tz-brand { display: inline-flex; align-items: center; height: 56px; }
.tz-brand img { height: 22px; width: auto; }
.tz-topbar-spacer { flex: 1 1 auto; }
.tz-user { display: inline-flex; align-items: center; color: var(--tz-white); }
.tz-user-name { color: var(--tz-n300); font-size: var(--tz-text-sm); }
.tz-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: var(--tz-r-full);
  background: rgba(var(--tz-white-rgb), .12); color: var(--tz-white);
}

/* First-level domain nav — pill buttons in the dark bar (modernaize-style). */
.tz-topnav { display: flex; align-items: center; gap: 4px; }
.tz-topnav > a {
  display: inline-flex; align-items: center; height: 34px;
  padding: 0 16px; border-radius: var(--tz-r-md);
  color: var(--tz-n400); font-size: var(--tz-text); font-weight: 500;
  text-decoration: none; white-space: nowrap;
  transition: background-color .15s ease, color .15s ease;
}
.tz-topnav > a:hover { color: var(--tz-white); background: rgba(var(--tz-white-rgb), .07); }
.tz-topnav > a.active { color: var(--tz-white); background: var(--tz-primary); font-weight: 600; }

/* Second-level item nav — underline tabs in the white bar. */
.tz-subnav {
  position: sticky; top: 56px; z-index: 1029;
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px; background: var(--tz-white);
  border-bottom: 1px solid var(--tz-n200);
  overflow-x: auto;
}
.tz-subnav > a {
  display: inline-flex; align-items: center; height: 46px;
  padding: 0 4px; white-space: nowrap;
  color: var(--tz-n500); font-size: var(--tz-text); font-weight: 500;
  text-decoration: none; border-bottom: 2px solid transparent;
}
.tz-subnav > a:hover { color: var(--tz-n700); }
.tz-subnav > a.active { color: var(--tz-primary); border-bottom-color: var(--tz-primary); font-weight: 600; }
.tz-subnav-sep { width: 1px; height: 20px; background: var(--tz-n200); margin: 0 6px; flex: 0 0 auto; }
.tz-subnav-chip { margin-left: 8px; flex: 0 0 auto; }
.tz-main { max-width: 1280px; margin: 0 auto; padding: 22px 24px; }
/* Wider container for data-dense pages (opt-in per page). */
.tz-main--wide { max-width: 1600px; }

/* card polish — hairline border, no glow */
.card { border: 1px solid var(--tz-n200); border-radius: var(--tz-r-lg); box-shadow: none; }

/* footer — drop the old NiceAdmin sidebar offset */
.footer { margin-left: 0 !important; text-align: center; padding: 16px; color: var(--tz-n500); font-size: var(--tz-text-sm); background: transparent; }
.footer .copyright { color: var(--tz-n500); }

/* The section sub-nav replaces per-page title + breadcrumb — hide them. */
.pagetitle { display: none; }

/* Status pills — low-chroma dot + label (never color-only). */
.tz-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--tz-text-sm); font-weight: 600; line-height: 1.3;
  padding: 2px 9px; border-radius: var(--tz-r-full);
  background: var(--tz-n100); color: var(--tz-n600); white-space: nowrap;
}
.tz-pill::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex: 0 0 auto;
}
.tz-pill--success { background: var(--tz-success-bg); color: var(--tz-success-fg); }
.tz-pill--warning { background: var(--tz-warning-bg); color: var(--tz-warning-fg); }
.tz-pill--error   { background: var(--tz-error-bg);   color: var(--tz-error-fg); }
.tz-pill--info    { background: var(--tz-info-bg);    color: var(--tz-info-fg); }
.tz-pill--neutral { background: var(--tz-n100);       color: var(--tz-n600); }

/* Tag chip — neutral, no dot. */
.tz-tag {
  display: inline-flex; align-items: center;
  font-size: var(--tz-text-sm); font-weight: 500;
  padding: 2px 8px; border-radius: var(--tz-r-sm);
  background: var(--tz-n100); color: var(--tz-n600);
}

/* Card chrome — align Bootstrap .card to the tz-card look so legacy pages
   (management screens, install/audit) match the agents/locations cards. */
.card { border: 1px solid var(--tz-n200); border-radius: var(--tz-r-lg); box-shadow: none; }
.card-header, .card-footer { background: transparent; }
.card-header { border-bottom: 1px solid var(--tz-n100); }
.card-footer { border-top: 1px solid var(--tz-n100); }
.card > .card-header, .card > .card-body, .card > .card-footer { padding: 12px 16px; }
.card-title {
  font-family: var(--tz-font-sans); font-size: var(--tz-text-lg); font-weight: 600;
  line-height: 1.3; color: var(--tz-primary-dark); margin: 0;
}
.card-title a { color: inherit; text-decoration: none; }
.card-title a:hover { color: var(--tz-primary); }
.card-subtitle { color: var(--tz-n500); font-weight: 400; }

/* Tables — consistent quiet header + tokenized rows on every page. */
.table { --bs-table-hover-bg: var(--tz-n50); }
.table > thead > tr > th {
  font-size: var(--tz-text-sm); font-weight: 600; color: var(--tz-n600);
  border-bottom: 1px solid var(--tz-n200); white-space: nowrap;
}
.table > :where(thead, tbody) > tr > :where(th, td) { padding: 8px 12px; vertical-align: middle; }

/* Badges — pill shape + subtle, tokenized colours so Bootstrap badges read like
   tz-pill/tz-tag (status semantics preserved). */
.badge {
  border-radius: var(--tz-r-full); font-size: var(--tz-text-sm); font-weight: 600;
  padding: 3px 9px;
}
.badge.text-bg-light   { background-color: var(--tz-n100) !important;       color: var(--tz-n600) !important; }
.badge.text-bg-success { background-color: var(--tz-success-bg) !important; color: var(--tz-success-fg) !important; }
.badge.text-bg-danger  { background-color: var(--tz-error-bg) !important;   color: var(--tz-error-fg) !important; }
.badge.text-bg-warning { background-color: var(--tz-warning-bg) !important; color: var(--tz-warning-fg) !important; }
.badge.text-bg-info    { background-color: var(--tz-info-bg) !important;    color: var(--tz-info-fg) !important; }

/* tz-card — our own card component (decoupled from the NiceAdmin .card* styles). */
.tz-card {
  background: var(--tz-white);
  border: 1px solid var(--tz-n200);
  border-radius: var(--tz-r-lg);
  box-shadow: none;
  display: flex;
  flex-direction: column;
}
.tz-card__head { padding: 12px 16px; border-bottom: 1px solid var(--tz-n100); }
.tz-card__title {
  margin: 0; font-family: var(--tz-font-sans);
  font-size: var(--tz-text-lg); font-weight: 600; line-height: 1.3;
  color: var(--tz-primary-dark);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tz-card__title a { color: inherit; text-decoration: none; }
.tz-card__title a:hover { color: var(--tz-primary); }
.tz-card__sub { color: var(--tz-n500); font-weight: 400; }
.tz-card__body { padding: 12px 16px; flex: 1 1 auto; }
.tz-card__foot { padding: 12px 16px; border-top: 1px solid var(--tz-n100); }

/* Contextual page header (title left, actions right) — detail / form / table pages. */
.tz-page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 16px; flex-wrap: wrap;
}
.tz-page-head__title {
  margin: 0; font-family: var(--tz-font-sans);
  font-size: var(--tz-text-h3); font-weight: 600; color: var(--tz-primary-dark);
}
.tz-page-head__sub { color: var(--tz-n500); font-weight: 400; }
.tz-page-head__actions { display: flex; align-items: center; gap: 8px; }

/* JSONEditor flattening: hide its own object header (our contextual header replaces it) and
   strip the nested Bootstrap card chrome so fields sit directly in our panel. Scoped via the
   tz-jsoneditor--flat class — only applied where the schema is a single (flat) object. */
.tz-jsoneditor--flat .je-object__title,
.tz-jsoneditor--flat .je-object__controls { display: none; }
.tz-jsoneditor--flat .card { border: 0; box-shadow: none; background: transparent; }
.tz-jsoneditor--flat .card-body { padding: 0; }

/* Agent install page: OS context header + numbered installation steps. */
.install-os {
    display: flex;
    align-items: center;
    gap: var(--tz-sp-4);
    padding-bottom: var(--tz-sp-4);
    margin-bottom: var(--tz-sp-6);
    border-bottom: 1px solid var(--tz-n200);
}
.install-os__icon { font-size: 2.75rem; line-height: 1; color: var(--tz-primary-dark); }
.install-os__title { margin: 0; font-size: var(--tz-text-h4); font-weight: 600; color: var(--tz-primary-dark); }
.install-os__sub { color: var(--tz-n600); font-size: var(--tz-text-sm); }

.install-steps { list-style: none; margin: 0; padding: 0; }
.install-step { position: relative; display: flex; gap: var(--tz-sp-3); padding-bottom: var(--tz-sp-6); }
.install-step:last-child { padding-bottom: 0; }
.install-step:not(:last-child)::before {
    content: ""; position: absolute; left: 15px; top: 36px; bottom: 0; width: 2px; background: var(--tz-n200);
}
.install-step__num {
    flex: 0 0 32px; width: 32px; height: 32px; border-radius: 50%;
    background: var(--tz-primary); color: var(--tz-white);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600; z-index: 1;
}
.install-step__body { flex: 1 1 auto; min-width: 0; padding-top: 3px; }
.install-step__title { font-size: var(--tz-text-lg); font-weight: 600; margin: 0 0 4px; }
.install-step__body p { color: var(--tz-n600); margin-bottom: var(--tz-sp-3); }

.install-method { margin-bottom: var(--tz-sp-2); }
.install-method__head { display: flex; align-items: center; gap: var(--tz-sp-2); margin-bottom: var(--tz-sp-2); }
.install-method__title { font-size: var(--tz-text-lg); font-weight: 600; margin: 0; }

.install-manual { margin-top: var(--tz-sp-4); border-top: 1px solid var(--tz-n200); padding-top: var(--tz-sp-4); }
.install-manual > summary { cursor: pointer; color: var(--tz-primary-dark); font-weight: 500; }

.install-code { position: relative; margin-bottom: 0; }
.install-code__copy { position: absolute; top: 8px; right: 8px; z-index: 1; }
.install-code pre {
    background: var(--tz-n100); border: 1px solid var(--tz-n200); border-radius: 8px;
    padding: var(--tz-sp-3) var(--tz-sp-4); margin: 0;
    white-space: pre-wrap; word-break: break-word;
    font-family: var(--tz-font-mono); font-size: var(--tz-text-sm); color: var(--tz-n800);
}
.install-qr { max-width: 220px; margin-bottom: var(--tz-sp-3); }
.install-qr svg, .install-qr img { width: 100%; height: auto; }

/* Locations page: tile grid with lazy zone mini-maps. */
.tz-loc-tile { transition: box-shadow .15s ease, transform .15s ease; }
.tz-loc-tile:hover { box-shadow: 0 6px 20px rgba(2, 35, 45, 0.12); }
.tz-loc-tile__map {
    height: 170px; position: relative; cursor: pointer; overflow: hidden;
    background: var(--tz-n100);
    border-top-left-radius: inherit; border-top-right-radius: inherit;
}
.tz-loc-tile__map-empty {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    color: var(--tz-n400); font-size: 2rem;
}
.tz-loc-tile__name {
    font-size: var(--tz-text-lg); font-weight: 600; margin: 0 0 4px; color: var(--tz-primary-dark);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tz-loc-tile__place {
    display: flex; align-items: center; gap: 6px;
    color: var(--tz-n600); font-size: var(--tz-text-sm); margin-bottom: 8px;
}
.tz-loc-tile__stats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.tz-loc-tile__stats .tz-tag { gap: 4px; }
.tz-loc-tile__created { color: var(--tz-n500); font-size: var(--tz-text-xs); }
.tz-loc-tile__actions { display: flex; align-items: center; gap: 8px; background: transparent; }

/* Zone editor: side list of zones (name + remove). */
.tz-zone-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.tz-zone-row .form-control { flex: 1 1 auto; min-width: 0; }

/* Error pages (error-main with app shell, error-plain standalone). */
.tz-error {
    min-height: 60vh;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: var(--tz-sp-8) var(--tz-sp-4);
}
.tz-error__code {
    font-family: var(--tz-font-mono); font-weight: 700; line-height: 1;
    font-size: clamp(3.5rem, 12vw, 6.5rem);
    color: var(--tz-primary); letter-spacing: -0.03em;
}
.tz-error__title {
    font-size: var(--tz-text-h3); font-weight: 600; color: var(--tz-primary-dark);
    margin: var(--tz-sp-3) 0 var(--tz-sp-2);
}
.tz-error__desc { color: var(--tz-n600); max-width: 460px; margin: var(--tz-sp-6) auto var(--tz-sp-8); line-height: 1.8; }
.tz-error__actions { display: flex; gap: var(--tz-sp-2); flex-wrap: wrap; justify-content: center; }
.tz-error--plain { min-height: 0; padding: var(--tz-sp-6) 0 0; }

/* ============================================================================
   COMPONENT LIBRARY (Catalyst-aligned, light-only). Strategy: override the
   Bootstrap classes already present in the markup (.btn, .form-control, .table,
   .alert, .modal, .badge, .nav-underline) so every page is restyled with no
   markup churn. Bespoke tz-* classes only where Bootstrap has no equivalent
   (status pills, tag chips, the auth-page layout). All colors via var(--tz-*).
   ============================================================================ */

/* ---- Form fields ---- */
.form-control, .form-select {
  border-color: var(--tz-n200); border-radius: var(--tz-r-md);
  color: var(--tz-n800); background-color: var(--tz-white);
}
.form-control::placeholder { color: var(--tz-n400); }
.form-control:hover:not(:focus):not(:disabled),
.form-select:hover:not(:focus):not(:disabled) { border-color: var(--tz-n300); }
.form-label { font-size: var(--tz-text-sm); font-weight: 500; color: var(--tz-n700); margin-bottom: 6px; }
.form-text, .form-control-plaintext { color: var(--tz-n500); }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--tz-error); }
.form-control.is-invalid:focus, .form-select.is-invalid:focus {
  box-shadow: 0 0 0 2px var(--tz-error); border-color: var(--tz-error);
}
.invalid-feedback { color: var(--tz-error-fg); font-size: var(--tz-text-sm); }
.form-floating > label { color: var(--tz-n500); }
.input-group-text { background: var(--tz-n100); border-color: var(--tz-n200); color: var(--tz-n600); }
.form-check-input:checked { background-color: var(--tz-primary); border-color: var(--tz-primary); }
.form-check-input:focus { border-color: var(--tz-primary); box-shadow: 0 0 0 2px rgba(var(--tz-primary-rgb),.25); }

/* ---- Alerts (flat, tinted, borderless) ---- */
.alert { border: 0; border-radius: var(--tz-r-md); font-size: var(--tz-text); padding: 12px 14px; }
.alert-danger  { --bs-alert-bg: var(--tz-error-bg);   --bs-alert-color: var(--tz-error-fg); }
.alert-success { --bs-alert-bg: var(--tz-success-bg); --bs-alert-color: var(--tz-success-fg); }
.alert-warning { --bs-alert-bg: var(--tz-warning-bg); --bs-alert-color: var(--tz-warning-fg); }
.alert-primary, .alert-info { --bs-alert-bg: var(--tz-info-bg); --bs-alert-color: var(--tz-info-fg); }
.alert a { color: inherit; font-weight: 600; text-decoration: underline; }

/* ---- Badges (override Bootstrap's .badge.text-bg-* to tinted token chips) ---- */
.badge.text-bg-light, .badge.text-bg-secondary {
  background: var(--tz-n100) !important; color: var(--tz-n700) !important; font-weight: 500;
}
.badge.text-bg-warning { background: var(--tz-warning-bg) !important; color: var(--tz-warning-fg) !important; font-weight: 500; }
.badge.text-bg-success { background: var(--tz-success-bg) !important; color: var(--tz-success-fg) !important; font-weight: 500; }
.badge.text-bg-danger  { background: var(--tz-error-bg) !important;   color: var(--tz-error-fg) !important;   font-weight: 500; }

/* ---- Tables (header, dividers, hover, stripe). tz-table density rules are above. ---- */
.table {
  --bs-table-color: var(--tz-n700);
  --bs-table-border-color: var(--tz-n100);
  --bs-table-striped-bg: var(--tz-n50);
  --bs-table-striped-color: var(--tz-n700);
  --bs-table-hover-bg: var(--tz-n50);
  --bs-table-hover-color: var(--tz-n800);
  font-size: var(--tz-text);
}
.table > thead > tr > th {
  font-size: var(--tz-text-xs); text-transform: uppercase; letter-spacing: .04em;
  font-weight: 600; color: var(--tz-n500);
  border-bottom: 1px solid var(--tz-n200); background: transparent;
}
.table > tbody > tr > td { border-bottom-color: var(--tz-n100); vertical-align: middle; color: var(--tz-n700); }

/* ---- Modals ---- */
.modal-content {
  border: 1px solid var(--tz-n200); border-radius: var(--tz-r-lg);
  box-shadow: var(--tz-shadow-lg);
}
.modal-header { border-bottom: 1px solid var(--tz-n100); padding: 16px 20px; }
.modal-title { font-size: var(--tz-text-lg); font-weight: 600; color: var(--tz-primary-dark); }
.modal-body { padding: 16px 20px; }
.modal-footer { border-top: 1px solid var(--tz-n100); padding: 12px 20px; }
.modal-backdrop { background-color: var(--tz-n950); }
.modal-backdrop.show { opacity: .4; }

/* ---- Tabs (underline) ---- */
.nav-underline { border-bottom: 1px solid var(--tz-n200); gap: 2px; }
.nav-underline .nav-link {
  color: var(--tz-n500); font-weight: 500; border: 0; border-bottom: 2px solid transparent;
  padding: 8px 12px; margin-bottom: -1px;
}
.nav-underline .nav-link:hover { color: var(--tz-n700); }
.nav-underline .nav-link.active {
  color: var(--tz-primary); border-bottom-color: var(--tz-primary);
  font-weight: 600; background: transparent;
}

/* ---- Auth card (login / reset / password) ---- */
.tz-auth-wrap {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px;
}
.tz-auth-card {
  width: 100%; max-width: 400px; margin: 0 auto;
  background: var(--tz-white); border: 1px solid var(--tz-n200);
  border-radius: var(--tz-r-lg); box-shadow: var(--tz-shadow-md);
  padding: 28px;
}
.tz-auth-logo { display: flex; justify-content: center; margin-bottom: 20px; }
.tz-auth-logo img { height: 32px; width: auto; }
.tz-auth-title { font-size: var(--tz-text-h4); font-weight: 600; color: var(--tz-primary-dark); text-align: center; margin: 0 0 4px; }
/* When a title has no subtitle below it (reset / password), the card sits
   directly under it — restore the gap the subtitle would otherwise provide. */
.tz-auth-title + .tz-auth-card { margin-top: 16px; }
.tz-auth-sub { font-size: var(--tz-text-sm); color: var(--tz-n500); text-align: center; margin: 0 0 20px; }
/* In-card intro paragraph (left-aligned, muted) — replaces heavy info alerts. */
.tz-auth-help { font-size: var(--tz-text-sm); color: var(--tz-n500); line-height: 1.5; margin: 0 0 20px; }
.tz-auth-card .form-label { margin-bottom: 6px; }
.tz-auth-footer { font-size: var(--tz-text-sm); color: var(--tz-n500); text-align: center; margin-top: 16px; }
.tz-auth-footer a { color: var(--tz-accent-blue); }

/* ---- Utilities: keep the .bg-light surface teal-tinted (code blocks, panels) ---- */
.bg-light { background-color: var(--tz-n100) !important; }

/* ============================================================================
   LEGACY BRIDGE — styles formerly supplied by NiceAdmin (static/css/style.css),
   which has been retired from header-head.html. style.css was ~90% dead code
   (old sidebar/header shell, dashboard, news, contact, faq, 404, iconslist —
   none of which exist in any template). Only the selectors below were still
   live in markup but lacked a token-based equivalent here.
   ============================================================================ */

/* .card-title appears on headings (already covered by the h* rules) AND on plain
   <div>s that previously relied solely on NiceAdmin. Style the class directly so
   both render identically. Montserrat is reserved for h1/h2, so card titles take
   the Inter sub-heading treatment to match .tz-card__title. */
.card-title {
  font-family: var(--tz-font-sans);
  font-size: var(--tz-text-lg);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.005em;
  color: var(--tz-primary-dark);
  margin-bottom: var(--tz-sp-3);
}

/* Dropdowns: NiceAdmin supplied the shadow/border polish; keep a tokenized one
   (topbar user menu, pagination per-page menu). */
.dropdown-menu {
  --bs-dropdown-border-color: var(--tz-n200);
  --bs-dropdown-border-radius: var(--tz-r-md);
  --bs-dropdown-box-shadow: var(--tz-shadow-md);
  --bs-dropdown-link-hover-bg: var(--tz-n100);
  --bs-dropdown-link-active-bg: var(--tz-primary);
  font-size: var(--tz-text);
}

/* TomSelect tag filter (agents toolbar): keep it inline with the native
   form-select-sm controls (don't let .form-select's width:100% push it to its
   own line) and tint the chips to the palette so every control matches. */
#agent-toolbar .ts-wrapper { width: auto; min-width: 200px; max-width: 280px; flex: 0 0 auto; }
#agent-toolbar .ts-wrapper.multi .ts-control > .item {
  background: var(--tz-n100); color: var(--tz-n700); border-radius: var(--tz-r-sm);
}
#agent-toolbar .ts-wrapper.multi .ts-control > .item.active {
  background: var(--tz-primary); color: var(--tz-white);
}
#agent-toolbar .ts-wrapper.focus.form-select {
  border-color: var(--tz-primary); box-shadow: 0 0 0 2px var(--tz-primary);
}

/* Pagination — Bootstrap compiles the active bg to a literal blue, so remap the
   --bs-pagination-* vars to brand tokens (teal active, neutral links). */
.pagination {
  --bs-pagination-color: var(--tz-n600);
  --bs-pagination-bg: var(--tz-white);
  --bs-pagination-border-color: var(--tz-n200);
  --bs-pagination-hover-color: var(--tz-primary-dark);
  --bs-pagination-hover-bg: var(--tz-n100);
  --bs-pagination-hover-border-color: var(--tz-n200);
  --bs-pagination-focus-color: var(--tz-primary-dark);
  --bs-pagination-focus-bg: var(--tz-n100);
  --bs-pagination-focus-box-shadow: 0 0 0 2px var(--tz-primary);
  --bs-pagination-active-color: var(--tz-white);
  --bs-pagination-active-bg: var(--tz-primary);
  --bs-pagination-active-border-color: var(--tz-primary);
  --bs-pagination-disabled-color: var(--tz-n400);
  --bs-pagination-disabled-bg: var(--tz-white);
  --bs-pagination-disabled-border-color: var(--tz-n200);
}
