/* DRISHTI overrides. Loaded last so the five prototype stylesheets stay unmodified
   and can be re-synced from C:\thsti-dashboard-ui without losing anything here. */

/* Light panel with a solid maroon active row - the version that read cleanest.
   Ground stays achromatic so maroon AND navy both remain available as accents.
   --shell-bg is a warm off-white, not #fff: see the surface hierarchy below. */
:root {
  --shell-bg:          #F8F6F6;
  --shell-active:      var(--thsti-maroon);
  --shell-rule-active: var(--thsti-orange);
}

/* real logo instead of the lettermark; 36px keeps it inside the 72px rail */
.brand-logo {
  flex: 0 0 auto;
  height: 36px;
  width: auto;
  display: block;
}

/* the coloured figures the old dashboard had via text-warning / -success / -danger */
.kpi-value.is-warning { color: var(--thsti-warning); }
.kpi-value.is-success { color: var(--thsti-success); }
.kpi-value.is-error   { color: var(--thsti-error); }

/* Six tiles: always full rows. auto-fit stranded the 6th on a line of its own.
   The figure scales with the column count - 34px in a 170px-wide tile was too big. */
.kpi-grid-6 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  --fs-kpi: 34px;
  --kpi-label-fs: 13px;
}
@media (min-width: 1000px) {
  .kpi-grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); --fs-kpi: 30px; }
}
@media (min-width: 1500px) {
  .kpi-grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); --fs-kpi: 26px; --kpi-label-fs: 12px; }
}

/* slightly larger than the 12px default, and tighter tracking so long labels
   like "Access Requests Approved" wrap to two lines instead of three */
.kpi-grid-6 .kpi-label {
  font-size: var(--kpi-label-fs);
  letter-spacing: .04em;
  line-height: 1.35;
}

/* label and icon share the top line; the figure is pushed to the bottom so the
   numbers stay on one baseline no matter how many lines the label wraps to */
.kpi-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-2);
  min-height: 2.6em;
}

/* Decoration is neutral, not brand. Maroon on every icon spends the colour
   budget on ornament and leaves nothing to signal what actually needs attention. */
.kpi-icon { flex: 0 0 auto; color: var(--thsti-disabled); }
.kpi-icon .icon { width: 20px; height: 20px; }

.kpi-value { margin-top: auto; line-height: 1.1; }

/* vertical rhythm between the stacked sections on the dashboard */
.app-content > .kpi-grid,
.app-content > .card,
.app-content > .grid { margin-bottom: var(--gutter); }
.app-content > .card:last-child,
.app-content > .grid:last-child { margin-bottom: 0; }

/* Application Workflow row */
.workflow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding: var(--sp-2) 0;
}

.workflow-step {
  flex: 1 1 0;
  min-width: 96px;
  display: grid;
  justify-items: center;
  gap: var(--sp-1);
  text-align: center;
}

.workflow-icon { color: var(--thsti-text-2nd); }
.workflow-icon .icon { width: 28px; height: 28px; }

.workflow-label {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--thsti-text-2nd);
}

.workflow-count {
  font-family: var(--thsti-font-heading);
  font-weight: 700;
  font-size: var(--fs-kpi);
  line-height: 1.1;
  color: var(--thsti-text);
}

/* prominent through size and weight rather than colour: #E1E1E1 was invisible,
   full maroon was one of 13 red marks competing on the page */
.workflow-arrow { flex: 0 0 auto; color: var(--thsti-text-2nd); }
.workflow-arrow .icon { width: 30px; height: 30px; stroke-width: 2.25; }

/* the Pending / Approved / Rejected pairs read as label + figure, not a data grid */
.status-table td { font-size: var(--fs-body); }
.status-table td.num-cell { font-weight: 700; font-size: var(--fs-section); }
.status-table .is-warning { color: var(--thsti-warning); }
.status-table .is-success { color: var(--thsti-success); }
.status-table .is-error   { color: var(--thsti-error); }

@media (max-width: 640px) {
  .workflow-arrow { display: none; }
  .workflow-step { min-width: 45%; }
}

/* ---------------------------------------------------------------------------
   If it still reads too red, uncomment ONE of these. Each is a step further
   down. Nothing else needs touching - every colour above comes from a token.

   STEP 1 - card rules go navy; maroon then appears ONLY in the sidebar,
   the active nav row and primary buttons.
     .kpi, .card { border-top-color: var(--thsti-navy); }

   STEP 2 - no coloured rules at all; cards are white with a hairline.
   Colour survives only where it means something: the status figures.
     .kpi, .card { border-top-color: var(--thsti-border); }

   STEP 3 - colour marks exceptions only. Approved figures go near-black so
   the eye lands on what needs action rather than on all six tiles at once.
     .kpi-value.is-success { color: var(--thsti-text); }
   --------------------------------------------------------------------------- */

/* --- finishing details --------------------------------------------------- */

/* the active row's left rule was maroon-dark on maroon - invisible. Orange is
   the spec's own choice for it, and on a white panel it reads as a crisp
   accent rather than the glare it was on a dark maroon ground. */
:root { --shell-rule-active: var(--thsti-orange); }

/* 9px rows read cramped next to an 18px icon */
.nav-link { padding-top: 11px; padding-bottom: 11px; }

/* a divider under the final row inside a card looks like a cut-off list */
.status-table tr:last-child td { border-bottom: none; }

/* the figure column is the point of these two cards - give it room */
.status-table td.num-cell { padding-right: var(--sp-5); }

/* --- topbar: intuitive toggle + profile on the right --------------------- */

/* one icon per state, pointing the way the panel will move */
.sidebar-toggle .when-rail,
body[data-sidebar="rail"] .sidebar-toggle .when-expanded { display: none; }
body[data-sidebar="rail"] .sidebar-toggle .when-rail { display: block; }
.sidebar-toggle { border: 1px solid var(--thsti-border); }
.sidebar-toggle:hover { border-color: var(--thsti-maroon); color: var(--thsti-maroon); }

/* pushed hard right, and a flex row so the bell sits beside the profile -
   layout.css only sets margin-left, which was fine when this held one child */
.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* profile: a bordered chip rather than three loose text nodes */
.user-btn {
  border-color: var(--thsti-border);
  padding: 5px 10px 5px 6px;
  gap: var(--sp-3);
}
.user-btn:hover { border-color: var(--thsti-maroon); background: var(--thsti-surface); }
.user-btn .avatar { background: var(--thsti-maroon); width: 32px; height: 32px; font-size: 13px; }
.user-btn .text-left { display: grid; gap: 1px; text-align: left; line-height: 1.2; }
.user-btn .who  { font-family: var(--thsti-font-heading); font-weight: 600; font-size: 13px; color: var(--thsti-text); }
.user-btn .role { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--thsti-text-2nd); }
.user-btn .icon { color: var(--thsti-text-2nd); width: 16px; height: 16px; }

@media (max-width: 560px) { .user-btn .text-left { display: none; } }

/* --- surface hierarchy ---------------------------------------------------
   Sidebar white, ground #F7F7F7, cards white: #F7F7F7 on white is 1.06:1, so
   nothing read as a distinct surface. Deeper ground + a firmer card edge.
   Three steps now, darkest to lightest: ground #EDEEF0, panel #F8F6F6, then
   cards and topbar at #fff - so the panel reads as chrome, not as content. */
body { background: #EDEEF0; }
.kpi, .card { border-color: #DDE0E4; }
.app-topbar  { border-bottom-color: #DDE0E4; }

/* --- narrower panel, toggle closer to the edge --------------------------- */

/* 4-6 short items don't need 264px; the longest label still fits at 240px */
:root { --sidebar-w: 240px; }

/* pull the toggle out of the gutter so it sits near the panel edge */
.topbar-row { padding-left: var(--sp-3); }

/* --- profile chip ------------------------------------------------------- */

.user-btn .avatar { border-radius: var(--r-pill); }

/* borderless until hovered - a permanent border read as a form field */
.user-btn { border-color: transparent; }
.user-btn:hover,
.dropdown.is-open .user-btn { border-color: var(--thsti-border); background: var(--thsti-surface); }

/* --- content on-theme ---------------------------------------------------- */

/* square, per the house rule - the rounded right edge fought every other
   corner in the system */
.nav-link.is-active { border-radius: 0; }

/* the 3px top rule is the system's card mark, but components.css only puts it
   on .kpi. Without it the cards read as generic panels next to themed tiles. */
.card { border-top: 3px solid var(--thsti-maroon); }

/* tables sit edge-to-edge inside the card, as they do on the prototype pages,
   instead of floating inside 20px of padding */
.card-body.flush .table th:first-child,
.card-body.flush .table td:first-child { padding-left: var(--sp-5); }
.card-body.flush .table th:last-child,
.card-body.flush .table td:last-child  { padding-right: var(--sp-5); }

/* --- tile edges ----------------------------------------------------------
   The edge echoes the status the tile reports, so it reinforces the figure
   colour rather than decorating: pending is warned, approved is settled,
   queries need attention, the total is neutral information. */
.kpi-success { border-top-color: var(--thsti-success); }
.kpi-info    { border-top-color: var(--thsti-navy); }
.kpi-alert   { border-top-color: var(--thsti-maroon); }

/* --- sidebar on a light ground ------------------------------------------
   Explicit because layout.css hardcodes #fff / rgba(255,255,255,..) for a dark
   panel rather than reading tokens. */

.app-sidebar {
  color: var(--thsti-text);
  border-right: 1px solid #D7DADE;
}
.sidebar-head { border-bottom: 1px solid var(--thsti-border); }
.sidebar-brand, .sidebar-brand:hover { color: var(--thsti-text); }
.brand-name { color: var(--thsti-text); }
.brand-sub  { color: var(--thsti-text-2nd); }
.sidebar-nav { padding-top: var(--sp-3); }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--thsti-disabled); }
.nav-list { display: grid; gap: 2px; }
.nav-link { color: var(--thsti-text); }
.nav-link:hover { background: rgba(168, 37, 43, 0.06); color: var(--thsti-maroon); }
.nav-link .icon { opacity: .6; }
.nav-link.is-active { background: var(--shell-active); color: #fff; font-weight: 700; }
.nav-link.is-active .icon { opacity: 1; }
.sidebar-foot { border-top: 1px solid var(--thsti-border); }
.btn-ghost-light { background: transparent; border: 1px solid var(--thsti-border); color: var(--thsti-text-2nd); }
.btn-ghost-light:hover { background: var(--thsti-maroon-100); color: var(--thsti-maroon); }

/* --- footer alignment ----------------------------------------------------
   .app-content is max-width 1680px and centred; .app-footer had neither, so
   past that width the content inset and the footer did not. */
.app-footer {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

/* --- brand lockup -------------------------------------------------------
   The wordmark sits beside the logo, so it should read as part of the mark
   rather than as two lines of grey label text. */
.brand-logo { height: 38px; }
.sidebar-brand { gap: var(--sp-3); }

.brand-name {
  font-size: 19px;
  letter-spacing: .03em;
  color: var(--thsti-maroon);
}
.brand-sub {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  color: var(--thsti-text-2nd);
}

/* the sidebar's foot rule and the page footer's top rule should land on the
   same line. Only holds when the page fits the viewport - the sidebar is
   position:fixed, so on a scrolling page its foot stays at the viewport edge. */
:root { --foot-h: 74px; }
.sidebar-foot,
.app-footer { min-height: var(--foot-h); display: flex; align-items: center; }
.sidebar-foot { padding: 0 var(--sp-4); }
.app-footer { padding-top: 0; padding-bottom: 0; }

/* --- converted pages ----------------------------------------------------- */

/* label/value blocks (contact details) */
.detail-list { display: grid; gap: var(--sp-5); }
.detail-list h4 {
  font-family: var(--thsti-font-heading);
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--thsti-maroon);
  margin: 0 0 var(--sp-1);
}

/* stacked form fields */
.field + .field { margin-top: var(--sp-4); }
.field > label {
  display: block;
  margin-bottom: var(--sp-1);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--thsti-text);
}
form .btn { margin-top: var(--sp-5); }

/* the "no records" state inside a flush card body */
.empty { padding: var(--sp-8) var(--sp-5); text-align: center; color: var(--thsti-text-2nd); }

/* "no records" row inside a table */
.empty-cell { text-align: center; color: var(--thsti-text-2nd); padding: var(--sp-8) var(--sp-5); }

/* =========================================================================
   DASHBOARD TABLE STYLE - use on every dashboard table
   <div class="table-wrap"><table class="table table-drishti" data-paginate="15">

   Header is a quiet grey band, not navy: these tables sit inside a card that
   already has a head, and navy beside the maroon card rule was the clash.
   The 2px maroon rule under the header carries the brand instead.
   ========================================================================= */

/* Column headers carry their weight through TYPOGRAPHY, not a tinted band.
   Pale bands (navy, grey, pink) all read washed out; #222 on white is 15.9:1
   and needs no second colour competing with the maroon. */
.table-drishti thead tr { background: var(--thsti-surface); }
.table-drishti thead th {
  color: var(--thsti-text);
  font-family: var(--thsti-font-heading);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .045em;
  text-transform: uppercase;
  padding: 16px;
  border-bottom: 2px solid var(--thsti-text);
  white-space: nowrap;
  vertical-align: bottom;
}

.table-drishti tbody td { padding: 13px 16px; border-bottom: 1px solid var(--thsti-rule); }
.table-drishti tbody tr { transition: background var(--dur-1) var(--ease); }
.table-drishti tbody tr:hover { background: var(--thsti-maroon-100); }
.table-drishti tbody tr:last-child td { border-bottom: none; }
.table-drishti td:first-child {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--thsti-text-2nd);
}

/* .btn-navy:hover is the one variant that never restated color, so base.css
   a:hover (0,1,1) outranked .btn-navy (0,1,0) and turned the label navy on the
   maroon hover fill. .btn-primary and .btn-secondary both restate it. */
.btn-navy:hover { color: #fff; }

/* components.css:225 sets .table th { text-align: left } at higher specificity
   than the .text-center utility, so a centred action column kept a left-aligned
   header sitting over centred buttons */
.table th.text-center,
.table td.text-center { text-align: center; }

/* -------- status: just the word, in its colour ------------------------- */
.status {
  font-weight: 600;
  color: var(--thsti-text-2nd);
  white-space: nowrap;
}
.status-approved { color: var(--thsti-success); }
.status-pending  { color: #A85D0E; }
.status-rejected { color: var(--thsti-error); }

/* -------- pagination -------------------------------------------------- */
.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--thsti-rule);
  font-size: var(--fs-xs);
  color: var(--thsti-text-2nd);
}
.pager { display: flex; gap: 4px; }
.pager button {
  min-width: 30px;
  padding: 5px 8px;
  font-family: var(--thsti-font-body);
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--thsti-text);
  background: var(--thsti-surface);
  border: 1px solid var(--thsti-border);
  border-radius: var(--r-2);
  cursor: pointer;
}
.pager button:hover:not(:disabled) { border-color: var(--thsti-maroon); color: var(--thsti-maroon); }
.pager button[aria-current="page"] {
  background: var(--thsti-maroon);
  border-color: var(--thsti-maroon);
  color: #fff;
}
.pager button:disabled { opacity: .4; cursor: default; }

/* --- application progress ------------------------------------------------
   Thin ring per stage, coloured by what the stage actually reports: green when
   it is done, amber while it waits, red if refused, grey before it starts.
   A solid fill made every stage look equally urgent. */
.stepline {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  position: relative;
  padding: var(--sp-2) 0;
  overflow-x: auto;
}

.step {
  flex: 1 1 0;
  min-width: 108px;
  display: grid;
  justify-items: center;
  gap: var(--sp-2);
  text-align: center;
  position: relative;   /* no z-index: that would make each step its own
                           stacking context and later connectors would paint
                           over earlier dots */
}

.step-dot {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--thsti-surface);
  border: 2px solid var(--thsti-border);
  color: var(--thsti-disabled);
}
.step-dot .icon { width: 22px; height: 22px; }

/* the dot must sit above its connector */
.step-dot { position: relative; z-index: 1; }

/* One colour per stage. The four non-green slots are the colour-blindness
   validated categorical palette from the prototype README - the token set only
   holds two well-separated hues, so these come from that validated set. */
.stepline {
  /* ring colour, then a darker ink for the label under it: the orange and the
     violet are fine as a 2px ring but fail 4.5:1 as 13px text on white */
  --stage-1: #2E7D46;  --ink-1: #2E7D46;   /* green   5.07:1 - Signup */
  --stage-2: #4F4F9C;  --ink-2: #4F4F9C;   /* navy    7.17:1 - Registration */
  --stage-3: #F58920;  --ink-3: #C2410C;   /* orange  ring / 5.18:1 ink - Explore Data */
  --stage-4: #A8252B;  --ink-4: #A8252B;   /* maroon  7.08:1 - Access Request */
  --stage-5: #7A7ABF;  --ink-5: #5A5A9E;   /* violet  ring / 6.19:1 ink - Data Sharing */
}

.step.stage-1 { --stage: var(--stage-1); --ink: var(--ink-1); }
.step.stage-2 { --stage: var(--stage-2); --ink: var(--ink-2); }
.step.stage-3 { --stage: var(--stage-3); --ink: var(--ink-3); }
.step.stage-4 { --stage: var(--stage-4); --ink: var(--ink-4); }
.step.stage-5 { --stage: var(--stage-5); --ink: var(--ink-5); }

.step .step-dot {
  border-color: var(--stage);
  color: var(--stage);
  background: var(--thsti-surface);
}

/* a stage that is finished fills with its own colour; otherwise it stays a
   thin ring, so completion still reads at a glance */
.step.is-done .step-dot { background: var(--stage); color: #fff; }

/* One connector per gap, owned by the step it leads INTO. The grey base is
   always full width; a coloured overlay grows across it on load, as far as
   progress actually reaches. */
.step + .step::before,
.step + .step::after {
  content: "";
  position: absolute;
  top: 24px;
  left: calc(-50% - var(--sp-2));
  width: calc(100% + var(--sp-2));
  height: 2px;
  z-index: 0;
}
.step + .step::before { background: var(--thsti-border); }

.step + .step::after {
  --fill: 0%;
  background: var(--stage);
  width: 0;
  max-width: calc(100% + var(--sp-2));
  animation: seg-grow 700ms cubic-bezier(.3, .7, .3, 1) forwards;
}

/* both ends done - the segment fills all the way */
.step.is-done + .step.is-done::after { --fill: calc(100% + var(--sp-2)); }

/* left end done, right end not - stops halfway, showing where progress ends */
.step.is-done + .step:not(.is-done)::after { --fill: calc(50% + var(--sp-2) / 2); }

@keyframes seg-grow {
  from { width: 0; }
  to   { width: var(--fill); }
}

/* left to right: each segment starts after the one before it */
.step:nth-child(2)::after { animation-delay: 120ms; }
.step:nth-child(3)::after { animation-delay: 320ms; }
.step:nth-child(4)::after { animation-delay: 520ms; }
.step:nth-child(5)::after { animation-delay: 720ms; }

@media (prefers-reduced-motion: reduce) {
  .step + .step::after { animation: none; width: var(--fill); }
}

.step-title { font-size: var(--fs-xs); font-weight: 700; color: var(--thsti-text); line-height: 1.3; }
.step-state { font-size: var(--fs-xs); font-weight: 600; color: var(--ink); }
.step-state a { color: var(--ink); }

/* --- application status --------------------------------------------------
   Was one sentence in a tick list, indistinguishable from the SOP checklist
   below it. Tone now rides the left edge and the pill. */
.statusbox {
  padding: var(--sp-4);
  background: var(--thsti-panel);
  border: 1px solid var(--thsti-border);
  border-left: 3px solid var(--thsti-text-2nd);
}
.statusbox-main { display: grid; justify-items: start; gap: var(--sp-2); }
.statusbox-text { margin: 0; font-size: var(--fs-body); color: var(--thsti-body); }

/* no leading dot here, so the pill's left padding goes back to even */
.statusbox .pill { padding: 3px 10px; }
.statusbox .pill::before { display: none; }

.statusbox.is-success { border-left-color: var(--thsti-success); }
.statusbox.is-warning { border-left-color: var(--thsti-warning); }
.statusbox.is-error   { border-left-color: var(--thsti-error); }
.statusbox.is-info    { border-left-color: var(--thsti-info); }

/* the one state the user has to act on keeps pulsing until they do.
   rgba of --thsti-navy; a token cannot be fed to rgba(). */
@keyframes statusbox-attention {
  0%   { box-shadow: 0 0 0 0 rgba(64, 64, 126, 0.38); }
  70%  { box-shadow: 0 0 0 9px rgba(64, 64, 126, 0); }
  100% { box-shadow: 0 0 0 0 rgba(64, 64, 126, 0); }
}
.statusbox .pill.is-attention { animation: statusbox-attention 2.2s var(--ease) infinite; }
@media (prefers-reduced-motion: reduce) {
  .statusbox .pill.is-attention { animation: none; }
}

/* --- tick lists ---------------------------------------------------------- */
.ticklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.ticklist li {
  position: relative;
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--thsti-rule);
  font-size: var(--fs-body);
}
.ticklist li:last-child { border-bottom: none; }

/* base note - the colour variants below only re-tint this */
.note {
  padding: var(--sp-3) var(--sp-4);
  border-left: 3px solid var(--thsti-info);
  background: var(--thsti-info-bg);
  font-size: var(--fs-sm);
  color: var(--thsti-body);
}
.note + .note { margin-top: var(--sp-3); }

/* a warning-toned note */
.note.note-warn { border-left-color: var(--thsti-warning); background: var(--thsti-warning-bg); }
.note.note-error { border-left-color: var(--thsti-error); background: var(--thsti-error-bg); }
.note.note-ok { border-left-color: var(--thsti-success); background: var(--thsti-success-bg); }

/* select2 borrows the system's input look */
.select2-container--default .select2-selection--multiple { border-color: var(--thsti-border) !important; border-radius: var(--r-2) !important; }

/* --- confirmation dialog -------------------------------------------------
   Uses the system's modal, whose head is one of the two places the spec
   sanctions the signature gradient. Centred, over a blurred page. */
.confirm-modal { align-items: center; backdrop-filter: blur(3px); }
.confirm-modal .modal-box { max-width: 440px; width: 100%; }
.confirm-modal .modal-body p { margin: 0; font-size: var(--fs-body); color: var(--thsti-body); }

/* stop the page behind from scrolling while a dialog is up */
body.has-modal { overflow: hidden; }

/* a form that should not break the table cell layout */
.inline-form { display: inline; margin: 0; }
.inline-form .btn { margin-top: 0; }

/* --- the signature gradient, used where it can actually read ------------
   Not on table headers: white on the gradient measures 2.48:1 at the light
   stop, well under the 4.5:1 small text needs. So it goes on surfaces with
   no text over it, and only on wide ones - a 90deg gradient compressed into
   a 170px tile is just orange, not a gradient. */

/* wide cards get the gradient strip; the six narrow tiles keep solid maroon */
.card {
  border-top: none;
  background-image: var(--thsti-gradient);
  background-repeat: no-repeat;
  background-size: 100% 3px;
  background-position: top left;
}

/* frames the app chrome once per page */
.app-topbar {
  border-bottom: none;
  box-shadow: none;
  background-image: var(--thsti-gradient);
  background-repeat: no-repeat;
  background-size: 100% 2px;
  background-position: bottom left;
}

/* the panel's own segment of that rule: solid maroon, so the sidebar reads as
   a distinct surface. Height is explicit and the border gone because the old
   1px border sat outside a --topbar-h brand, 2px below the topbar's strip. */
.sidebar-head {
  height: var(--topbar-h);
  border-bottom: none;
  background-image: linear-gradient(var(--thsti-maroon), var(--thsti-maroon));
  background-repeat: no-repeat;
  background-size: 100% 2px;
  background-position: bottom left;
}

/* a card nested inside a card (Variables Definition on Explore Data) keeps a
   plain edge - two gradient strips stacked reads as noise */
.card .card {
  background-image: none;
  border-top: 1px solid var(--thsti-border);
}

/* --- long forms ---------------------------------------------------------- */
.frow { display: grid; gap: var(--sp-2); padding: var(--sp-3) 0; border-bottom: 1px solid var(--thsti-rule); }
@media (min-width: 900px) { .frow { grid-template-columns: 320px 1fr; gap: var(--sp-5); align-items: start; } }
.frow > label { font-size: var(--fs-sm); font-weight: 700; color: var(--thsti-text); padding-top: 9px; }
.frow textarea.input { min-height: 74px; resize: vertical; }
.fsplit { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }
.fsplit .input { flex: 1 1 180px; min-width: 0; }
.inline-label { font-size: var(--fs-sm); font-weight: 700; flex: 0 0 auto; }
.hint-danger { font-size: var(--fs-xs); color: var(--thsti-error); }
.declaration { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-5) 0; font-size: var(--fs-sm); }
.declaration input { margin-top: 3px; flex: 0 0 auto; }
.form-actions { display: flex; justify-content: center; padding-top: var(--sp-5); }
.form-actions .btn { margin-top: 0; }
.note ul { margin: var(--sp-2) 0 0; padding-left: var(--sp-5); }
.note li + li { margin-top: 4px; }

/* --- payment ------------------------------------------------------------- */
.pay-confirm { text-align: center; color: var(--thsti-error); font-size: var(--fs-sm); padding: var(--sp-3) 0; }
.pay-form { max-width: 620px; margin: 0 auto; }
.form-actions-left { justify-content: flex-start; gap: var(--sp-2); }
.form-actions-left .btn { margin-top: 0; }
#bd_btn .icon { font-family: var(--thsti-font-mono); }

/* --- label / value detail tables (preview pages) ------------------------- */
.detail-table th[scope="row"] {
  width: 34%;
  text-align: left;
  color: var(--thsti-text-2nd);
  font-family: var(--thsti-font-body);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  border-bottom: 1px solid var(--thsti-rule);
  vertical-align: top;
  padding: 13px 16px;
}
.detail-table td { font-size: var(--fs-body); }
.detail-table tbody tr:last-child th,
.detail-table tbody tr:last-child td { border-bottom: none; }

@media print {
  .no-print { display: none !important; }
  .app-sidebar, .app-topbar, .app-footer { display: none !important; }
  .app-main { margin-left: 0 !important; }
}

/* --- receipt + query ----------------------------------------------------- */
.receipt { max-width: 720px; margin: 0 auto; }
.receipt-title { text-align: center; font-family: var(--thsti-font-heading); font-size: 24px; margin: 0 0 var(--sp-5); }
.receipt-title.is-success { color: var(--thsti-success); }
.receipt-title.is-warning { color: var(--thsti-warning); }
.block-label {
  font-size: var(--fs-label); font-weight: 700; letter-spacing: var(--ls-label);
  text-transform: uppercase; color: var(--thsti-text-2nd);
  margin: var(--sp-6) 0 var(--sp-3);
}
.note.note-quiet { border-left-color: var(--thsti-disabled); background: var(--thsti-zebra); }
.form-actions-right { justify-content: flex-end; }
.form-actions-right .btn { margin-top: 0; }

/* =========================================================================
   Sample and data access application form
   Three columns - number | question | answer - so the numbers align down one
   edge and a wrapped question hangs under itself instead of under the number.
   ========================================================================= */

.qform { display: block; }

.qrow {
  display: grid;
  grid-template-columns: 46px minmax(0, 300px) minmax(0, 1fr);
  gap: var(--sp-2) var(--sp-4);
  align-items: start;
  padding: var(--sp-4) var(--sp-6);
  border-bottom: 1px solid var(--thsti-rule);
}
.qrow:nth-of-type(even) { background: var(--thsti-zebra); }

.qnum {
  font-family: var(--thsti-font-heading);
  font-weight: 700;
  font-size: var(--fs-sm);
  color: var(--thsti-maroon);
  padding-top: 9px;
  font-variant-numeric: tabular-nums;
}

.qlabel {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--thsti-text);
  line-height: 1.45;
  padding-top: 8px;
}

.qsub {
  display: block;
  margin-top: 4px;
  font-size: var(--fs-xs);
  font-weight: 400;
  color: var(--thsti-text-2nd);
}
.qsub a { word-break: break-all; }

.qfield { display: grid; gap: var(--sp-2); min-width: 0; }

/* answer widths, so a date field does not stretch the width of the page */
.qfield .input { width: 100%; }
.qfield .input.is-wide   { max-width: 520px; }
.qfield .input.is-mid    { max-width: 280px; }
.qfield .input.is-narrow { max-width: 130px; }
.qfield textarea.input   { min-height: 72px; max-width: 640px; resize: vertical; }
.qfield .input.is-file   { max-width: 420px; padding: 7px 9px; }

/* item 6 heads three sub-rows. Same type size and colour as every other
   question - the indent, tick and rail on the children mark the grouping. */
.qrow.is-group .qlabel { color: var(--thsti-text); }
.qrow.is-group .qfield { display: none; }

/* sub-rows of item 6: indented, lighter, and tied to the parent by a tick */
.qrow.is-sub,
.qrow.is-child { padding-top: var(--sp-3); padding-bottom: var(--sp-3); }
.qrow.is-sub .qlabel,
.qrow.is-child .qlabel { font-weight: 400; color: var(--thsti-body); }

.qrow.is-sub .qlabel { padding-left: 26px; position: relative; }
.qrow.is-sub .qlabel::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 15px;
  width: 12px;
  height: 1px;
  background: var(--thsti-navy-300);
}
/* a rail down the number column groups the three together */
.qrow.is-sub .qnum {
  border-left: 2px solid var(--thsti-navy-100);
  align-self: stretch;
  padding-top: 0;
}

/* radios and paired inputs */
.radioset { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-6); padding-top: 9px; }
.opt { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); cursor: pointer; }
.opt input { flex: 0 0 auto; margin: 0; }
.pairset { display: flex; flex-wrap: wrap; gap: var(--sp-5); }
.pairset label { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); }

/* item 27 spans the full width */
.qrow.is-block { grid-template-columns: 46px minmax(0, 1fr); border-bottom: none; padding-bottom: 0; }

.undertaking { padding: 0 var(--sp-6) var(--sp-6) calc(46px + var(--sp-6) + var(--sp-4)); }
.u-lead { margin: 0 0 var(--sp-2); font-size: var(--fs-sm); }
.u-list {
  margin: 0;
  padding: var(--sp-4) var(--sp-5) var(--sp-4) calc(var(--sp-5) + 14px);
  background: var(--thsti-surface);
  border: 1px solid var(--thsti-border);
  border-left: 3px solid var(--thsti-maroon);
  font-size: var(--fs-sm);
  line-height: 1.55;
}
.u-list li { margin-bottom: var(--sp-3); padding-left: 4px; }
.u-list li:last-child { margin-bottom: 0; }
.u-ack { font-style: italic; font-size: var(--fs-sm); color: var(--thsti-body); margin: var(--sp-3) 0 0; }
.u-confirm { margin-top: var(--sp-5); font-weight: 700; }

.signrow { display: grid; gap: var(--sp-4); margin-top: var(--sp-5); }
@media (min-width: 860px) { .signrow { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.signrow .field > label { font-size: var(--fs-xs); }

.attachments { padding: var(--sp-6) var(--sp-6) 0; }
.attachments h4 {
  font-family: var(--thsti-font-heading);
  font-size: var(--fs-sm);
  font-weight: 700;
  margin: 0 0 var(--sp-2);
}
.attachments .qrow { padding-left: 0; padding-right: 0; }
.attachments .qrow:nth-of-type(even) { background: none; }
.hint { font-size: var(--fs-xs); color: var(--thsti-text-2nd); padding-top: 9px; display: inline-block; }

.qfoot { display: flex; justify-content: center; padding: var(--sp-6); }
.qfoot .btn { margin-top: 0; min-width: 160px; }

/* stack on narrow screens - the number keeps its column so the list still reads */
@media (max-width: 900px) {
  .qrow { grid-template-columns: 34px minmax(0, 1fr); padding: var(--sp-4); }
  .qrow .qfield { grid-column: 2; }
  .undertaking { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .attachments { padding-left: var(--sp-4); padding-right: var(--sp-4); }
}

/* --- card headers --------------------------------------------------------
   Background stays as the system has it. Only the title takes navy, which is
   otherwise unspent on these pages. #40407E on white is 8.6:1. */
.card-head h3 {
  color: var(--thsti-navy);
  font-size: 18px;
  letter-spacing: .01em;
}

/* --- workflow stage -> status card ---------------------------------------
   Hovering Registration or Data Access lifts the card that reports it. Kept
   subtle: a shadow, a maroon edge and a nudge - no colour flooding. */
.workflow-step.is-linked { cursor: default; border-radius: var(--r-2); transition: background var(--dur-2) var(--ease); }
.workflow-step.is-linked:hover { background: var(--thsti-maroon-100); }
.workflow-step.is-linked .workflow-count { transition: color var(--dur-2) var(--ease); }
.workflow-step.is-linked:hover .workflow-count { color: var(--thsti-maroon); }

.card { transition: box-shadow var(--dur-2) var(--ease), transform var(--dur-2) var(--ease); }
.card.is-highlighted {
  box-shadow: 0 6px 18px rgba(168, 37, 43, .18);
  transform: translateY(-2px);
}
.card.is-highlighted .card-head { background: var(--thsti-maroon-100); }
.card.is-highlighted .card-head h3 { color: var(--thsti-maroon-dark); }

@media (prefers-reduced-motion: reduce) {
  .card, .workflow-step.is-linked { transition: none; }
  .card.is-highlighted { transform: none; }
}

/* --- sheen sweep ---------------------------------------------------------
   A thin diagonal line crosses the card when its workflow stage is pointed at.
   Warm-tinted rather than white: the card surface IS white, so a white sheen
   would be invisible on it. */
#card-registration-status,
#card-access-status { position: relative; overflow: hidden; }

#card-registration-status::after,
#card-access-status::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 55%;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-140%) skewX(-16deg);
  background: linear-gradient(
    105deg,
    transparent 42%,
    rgba(168, 37, 43, .10) 47%,
    rgba(245, 137, 32, .34) 50%,
    rgba(168, 37, 43, .10) 53%,
    transparent 58%
  );
}

.card.is-highlighted::after {
  animation: card-sheen 820ms cubic-bezier(.25, .6, .25, 1) forwards;
}

@keyframes card-sheen {
  0%   { transform: translateX(-140%) skewX(-16deg); opacity: 0; }
  12%  { opacity: 1; }
  88%  { opacity: 1; }
  100% { transform: translateX(260%) skewX(-16deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .card.is-highlighted::after { animation: none; }
}

/* a tick appears under the status line once a stage is complete */
.step-tick { display: none; line-height: 1; color: var(--ink); }
.step-tick .icon { width: 15px; height: 15px; stroke-width: 3; }
.step.is-done .step-tick { display: block; }

/* --- notifications -------------------------------------------------------
   Derived on each request, so there is no read/unread state - the badge is a
   live count of what currently needs attention, not an inbox. */
.notif-btn { position: relative; }

.notif-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  background: var(--thsti-maroon);
  color: #fff;
  font-family: var(--thsti-font-body);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
  border: 2px solid var(--thsti-surface);
}

.notif-menu { width: 340px; max-width: calc(100vw - 32px); padding-bottom: 4px; }

.notif-item {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: var(--sp-3);
  align-items: start;
  padding: var(--sp-3) var(--sp-4);
  border-left: 3px solid transparent;
  font-size: var(--fs-sm);
  color: var(--thsti-body);
  text-decoration: none;
}
.notif-item + .notif-item { border-top: 1px solid var(--thsti-rule); }
.notif-item:hover { background: var(--thsti-panel); }

.notif-icon { display: grid; place-items: center; padding-top: 1px; }
.notif-icon .icon { width: 17px; height: 17px; }
.notif-text { line-height: 1.4; }

.notif-item.is-success { border-left-color: var(--thsti-success); }
.notif-item.is-success .notif-icon { color: var(--thsti-success); }
.notif-item.is-warning { border-left-color: var(--thsti-warning); }
.notif-item.is-warning .notif-icon { color: #A85D0E; }
.notif-item.is-error   { border-left-color: var(--thsti-error); }
.notif-item.is-error .notif-icon { color: var(--thsti-error); }
.notif-item.is-info    { border-left-color: var(--thsti-info); }
.notif-item.is-info .notif-icon { color: var(--thsti-info); }

.notif-empty {
  padding: var(--sp-5) var(--sp-4);
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--thsti-text-2nd);
}

/* --- topbar control sizing -----------------------------------------------
   Every topbar control shares one height, so the toggle, the bell and the
   profile chip sit on the same band. Before: bell was a 19px stroke glyph in
   a 36px button beside a 32px FILLED circle in a 42px chip - different heights
   and very different optical weight. */
:root { --control-h: 38px; }

.topbar-row .icon-btn { width: var(--control-h); height: var(--control-h); }
.topbar-row .icon-btn .icon { width: 20px; height: 20px; }

.user-btn {
  height: var(--control-h);
  padding: 0 var(--sp-3) 0 5px;
}
.user-btn .avatar { width: 28px; height: 28px; font-size: 12px; }

/* the bell reads lighter than the filled avatar beside it, so it carries a
   slightly larger glyph than the toggle chevron */
.topbar-row .notif-btn .icon { width: 22px; height: 22px; }

/* --- explore data -------------------------------------------------------- */
/* a rule between the note block and each working section below it */
.explore-card > .card-body + .card-body { border-top: 1px solid var(--thsti-rule); }
.explore-card > .card-body:first-of-type { padding-bottom: var(--sp-4); }

.grid-2-1 { display: grid; gap: var(--gutter); grid-template-columns: 1fr; }
@media (min-width: 1000px) { .grid-2-1 { grid-template-columns: 2fr 1fr; } }

/* both scroll areas the same depth so the two columns read as a pair */
.explore-defs { max-height: 350px; overflow-y: auto; }

.filter-row {
  display: grid;
  grid-template-columns: 2fr 1.2fr 1fr auto;
  gap: var(--sp-2);
  align-items: center;
}
.filter-row + .filter-row { margin-top: var(--sp-2); }
@media (max-width: 760px) { .filter-row { grid-template-columns: 1fr; } }

/* the script re-renders value fields with Bootstrap's class - match .input so
   the row keeps its alignment after a column is picked */
.filter-row .form-control {
  width: 100%;
  padding: 8px 11px;
  background: var(--thsti-surface);
  border: 1px solid var(--thsti-border);
  border-radius: var(--r-1);
  font-size: var(--fs-sm);
  color: var(--thsti-body);
}
.filter-row .form-control:hover { border-color: var(--thsti-muted); }
.filter-row .form-control:focus {
  outline: none;
  border-color: var(--thsti-navy);
  box-shadow: 0 0 0 3px var(--thsti-navy-100);
}

.remove-filter { color: var(--thsti-text-2nd); }
.remove-filter:hover { color: var(--thsti-error); background: var(--thsti-error-bg); }

.explore-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}

.availability #record-count {
  font-family: var(--thsti-font-heading);
  font-size: 40px;
  color: var(--thsti-success);
  margin: 0;
}
.availability #variable-count { font-family: var(--thsti-font-heading); font-size: 26px; margin: 0; }
.availability h6 {
  font-size: var(--fs-label);
  font-weight: 700;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--thsti-text-2nd);
  margin: 0 0 2px;
}
.availability p { font-size: var(--fs-xs); color: var(--thsti-text-2nd); margin: 0; }
.availability hr { border: none; border-top: 1px solid var(--thsti-rule); margin: var(--sp-4) 0; }
/* the CTA lines up with the card edges */
.availability .btn { width: 100%; }

/* section headings under the rule - one step below a card title, and with the
   breathing room the bare h5 default did not give them */
.explore-card h5 {
  font-size: 15px;
  font-weight: 700;
  color: var(--thsti-text);
  margin: 0 0 var(--sp-3);
}

.explore-pick { margin-bottom: var(--gutter); }

/* select2 hides the native list and renders its own box - match .input */
.explore-card .select2-container { width: 100% !important; }
.explore-card .select2-selection--multiple {
  min-height: var(--control-h);
  padding: 2px 4px;
}

/* headings, not boxes, set the top of each column */
.grid-2-1 { align-items: start; }
