/* Archive Station brand palette — derived from the application logo (navy / steel-blue family).
   Centralized tokens: change these five values to re-brand the whole UI. Loaded AFTER the theme so it
   wins. Only the PRIMARY family + links + focus/selection are re-skinned; semantic colors
   (success / warning / danger / info) are deliberately left to the theme so operational & security
   states stay immediately recognisable. Direction-agnostic (works for LTR and RTL). */
:root {
  /* ---- brand tokens (single source of truth) ---- */
  --brand-primary:        #1e3a5f;   /* deep navy-blue (logo wordmark / emblem) — white text ≈ 11:1 (AAA) */
  --brand-primary-rgb:    30, 58, 95;
  --brand-primary-hover:  #274a75;   /* lighter steel for visible feedback on the dark button */
  --brand-primary-active: #16304e;   /* darker pressed state */
  --brand-secondary:      #2e5a86;   /* steel blue (emblem mid-tone) — accents/badges, white text ≈ 6.5:1 */
  --brand-secondary-rgb:  46, 90, 134;
  --brand-accent:         #5a7196;   /* muted slate (logo "Station") — subtle highlights (AA large) */
  --brand-primary-soft:   #eaf0f7;   /* very light tint for selected rows / soft section backgrounds */
  --brand-primary-border: #c3d2e4;
  --brand-text-on-primary:#ffffff;

  /* ---- map the theme's primary onto the brand so every var(--bs-primary*) accent re-colours ---- */
  --bs-primary:            var(--brand-primary);
  --bs-primary-rgb:        var(--brand-primary-rgb);
  --bs-link-color:         var(--brand-primary);
  --bs-link-color-rgb:     var(--brand-primary-rgb);
  --bs-link-hover-color:   var(--brand-primary-active);
  --bs-link-hover-color-rgb: 22, 48, 78;
  --bs-primary-bg-subtle:     var(--brand-primary-soft);
  --bs-primary-border-subtle: var(--brand-primary-border);
  --bs-primary-text-emphasis: var(--brand-primary-active);
}

/* ---- primary buttons ---- */
.btn-primary {
  --bs-btn-bg: var(--brand-primary);
  --bs-btn-border-color: var(--brand-primary);
  --bs-btn-hover-bg: var(--brand-primary-hover);
  --bs-btn-hover-border-color: var(--brand-primary-hover);
  --bs-btn-active-bg: var(--brand-primary-active);
  --bs-btn-active-border-color: var(--brand-primary-active);
  --bs-btn-disabled-bg: var(--brand-primary);
  --bs-btn-disabled-border-color: var(--brand-primary);
  --bs-btn-focus-shadow-rgb: var(--brand-primary-rgb);
  --bs-btn-color: var(--brand-text-on-primary);
  --bs-btn-hover-color: var(--brand-text-on-primary);
  --bs-btn-active-color: var(--brand-text-on-primary);
}
.btn-outline-primary {
  --bs-btn-color: var(--brand-primary);
  --bs-btn-border-color: var(--brand-primary);
  --bs-btn-hover-bg: var(--brand-primary);
  --bs-btn-hover-border-color: var(--brand-primary);
  --bs-btn-hover-color: var(--brand-text-on-primary);
  --bs-btn-active-bg: var(--brand-primary-active);
  --bs-btn-active-border-color: var(--brand-primary-active);
  --bs-btn-focus-shadow-rgb: var(--brand-primary-rgb);
}

/* ---- primary utilities (theme compiles these as literal hex, so override explicitly) ---- */
.text-primary { color: var(--brand-primary) !important; }
.bg-primary { background-color: var(--brand-primary) !important; }
.border-primary { border-color: var(--brand-primary) !important; }
.link-primary { color: var(--brand-primary) !important; }
.link-primary:hover, .link-primary:focus { color: var(--brand-primary-active) !important; }
.badge.bg-primary, .text-bg-primary { background-color: var(--brand-primary) !important; color: var(--brand-text-on-primary) !important; }

/* ---- selected / active states ---- */
.nav-tabs .nav-link.active { color: var(--brand-primary); border-color: var(--bs-border-color) var(--bs-border-color) #fff; }
.nav-tabs .nav-link.active { box-shadow: inset 0 -2px 0 var(--brand-primary); }
.nav-pills .nav-link.active, .nav-pills .show > .nav-link { background-color: var(--brand-primary); color: var(--brand-text-on-primary); }
.list-group-item.active { background-color: var(--brand-primary); border-color: var(--brand-primary); }
.page-link { color: var(--brand-primary); }
.page-item.active .page-link { background-color: var(--brand-primary); border-color: var(--brand-primary); color: var(--brand-text-on-primary); }
.dropdown-item.active, .dropdown-item:active { background-color: var(--brand-primary); color: var(--brand-text-on-primary); }

/* ---- form controls (focus ring + checked state), non-semantic ---- */
.form-check-input:checked { background-color: var(--brand-primary); border-color: var(--brand-primary); }
.form-check-input:focus { border-color: var(--brand-primary); box-shadow: 0 0 0 .2rem rgba(var(--brand-primary-rgb), .22); }
.form-control:focus, .form-select:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 .2rem rgba(var(--brand-primary-rgb), .18);
}
.form-switch .form-check-input:checked { background-color: var(--brand-primary); border-color: var(--brand-primary); }

/* ---- progress / spinners (decorative accents) ---- */
.progress-bar { background-color: var(--brand-primary); }
.spinner-border.text-primary, .spinner-grow.text-primary { color: var(--brand-primary) !important; }

/* ---- login page: strongest brand identity, still clean & readable ---- */
.login-page .login-card { border-top: 4px solid var(--brand-primary) !important; }
.login-page .btn-primary { --bs-btn-bg: var(--brand-primary); }

/* ---- subtle brand section markers used around the app ---- */
.card .card-header.bg-primary-soft, .section-accent { background-color: var(--brand-primary-soft); }

/* ---- Secure Viewer -------------------------------------------------------
   Layout only. The watermark lives in the server-rendered page image, so none
   of these rules can affect it -- including in the expanded state. */
.sv-root { min-height: 320px; }
.sv-root .sv-stage { min-height: 260px; }
@media (min-width: 992px) {
  .sv-root { min-height: 68vh; }
  .sv-root .sv-stage { min-height: 60vh; }
}
.sv-root.sv-expanded {
  /* 1045 sits deliberately between the page chrome (<= 1040) and the modal backdrop (1050).
     Above the chrome, so an expanded viewer covers the sidebar and header -- which is what it must
     do on the Checker page, where the viewer is NOT inside a modal. Below the backdrop, so a child
     action dialog opened over an expanded viewer is still layered above it instead of being hidden
     by a viewer that had declared itself higher than the modal layer (the old 1085 did exactly
     that, and would have re-created the reported defect on the Checker viewer). */
  position: fixed; inset: 0; z-index: 1045;
  margin: 0; border-radius: 0;
  background: var(--bs-body-bg, #fff);
  min-height: 100vh; height: 100vh;
}
.sv-root.sv-expanded .sv-stage { min-height: 0; height: auto; }
body.sv-expanded-open { overflow: hidden; }

/* ---------------------------------------------------------------------------------------------
   A row action that cannot be scrolled off the edge.

   A wide table inside .table-responsive scrolls horizontally, and the action column is last --
   so on a narrow pane the only way to reach View was to discover a horizontal scrollbar that
   gives no sign it is there. Pinning the last column keeps the action in view while the
   informational columns scroll under it. Opt-in via .table-sticky-action, so no other table
   changes behaviour.

   Direction-aware: the action column is the LAST one, which is the right edge under LTR and the
   left edge under RTL. --------------------------------------------------------------------- */
.table-sticky-action thead th:last-child,
.table-sticky-action tbody td:last-child {
  position: sticky;
  right: 0;
  /* Keep the action on one line and claim no more width than it needs, so the informational
     columns get the rest. This does not remove the overflow on a narrow card -- the column is
     already at its content width there -- the sticky positioning above is what keeps the action
     reachable. */
  width: 1%;
  white-space: nowrap;
  background: var(--bs-card-bg, #fff);
  /* A hairline so a scrolled cell passing underneath is visibly behind, not merged with, it. */
  box-shadow: -8px 0 8px -8px rgba(15, 23, 42, 0.18);
}
html[dir="rtl"] .table-sticky-action thead th:last-child,
html[dir="rtl"] .table-sticky-action tbody td:last-child {
  right: auto;
  left: 0;
  box-shadow: 8px 0 8px -8px rgba(15, 23, 42, 0.18);
}
