/*
 * Patriot Business Advisors — site stylesheet.
 * Plain CSS on purpose: shared hosting has no Node/Vite build step,
 * so this file is served directly with no compilation required.
 */

:root {
    --navy: #002868;
    --navy-dark: #001a4d;
    --navy-darker: #001233;
    --red: #bf0a30;
    --red-dark: #a00828;
    --ink: #0f172a;
    --body: #475569;
    --muted: #64748b;
    --line: #e2e8f0;
    --bg: #f8fafc;
    --white: #fff;
    --gold: #c9a227;
    --green: #047857;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .1);
    --shadow: 0 4px 6px -1px rgba(15, 23, 42, .08), 0 2px 4px -2px rgba(15, 23, 42, .06);
    --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, .12), 0 8px 10px -6px rgba(15, 23, 42, .08);
    --radius: 10px;
    --wrap: 1200px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.65;
    color: var(--body);
    background: var(--white);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 { color: var(--ink); line-height: 1.2; margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -.02em; }
h2 { font-size: clamp(1.6rem, 3vw, 2.25rem); letter-spacing: -.015em; }
h3 { font-size: 1.25rem; }
p { margin: 0 0 1rem; }
a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--red); }
img { max-width: 100%; height: auto; display: block; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 1.25rem; }
.section { padding: 4.5rem 0; }
.section-sm { padding: 3rem 0; }
.section-alt { background: var(--bg); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.tiny { font-size: .8125rem; }
.strong { font-weight: 600; color: var(--ink); }
.nowrap { white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .75rem 1.5rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: .9375rem;
    cursor: pointer;
    transition: background-color .15s, color .15s, border-color .15s, transform .15s;
    text-align: center;
    line-height: 1.3;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-dark); color: #fff; }
.btn-red { background: var(--red); color: #fff; }
.btn-red:hover { background: var(--red-dark); color: #fff; }
.btn-outline { background: transparent; color: var(--navy); border-color: var(--navy); }
.btn-outline:hover { background: var(--navy); color: #fff; }
.btn-light { background: #fff; color: var(--navy); }
.btn-light:hover { background: var(--bg); color: var(--navy); }
.btn-ghost { background: transparent; color: var(--body); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); color: var(--ink); }
.btn-danger { background: #fff; color: var(--red); border-color: #fecaca; }
.btn-danger:hover { background: var(--red); color: #fff; border-color: var(--red); }
.btn-sm { padding: .45rem .85rem; font-size: .8125rem; border-radius: 8px; }
.btn-block { display: flex; width: 100%; }

/* ---------- Header ---------- */
.topbar { background: var(--navy-darker); color: rgba(255, 255, 255, .82); font-size: .8125rem; padding: .5rem 0; }
.topbar .wrap { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.topbar a { color: #fff; }
.topbar a:hover { color: #fca5a5; }
.topbar-links { display: flex; gap: 1.25rem; align-items: center; }

.site-header {
    background: #fff;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 50;
    transition: box-shadow .25s ease, background-color .25s ease;
}
/* Condensed state, toggled by scroll. Only the paddings and the brand shrink —
   the nav links stay put so the row never reflows under the cursor. */
.site-header.is-condensed { box-shadow: 0 2px 12px rgba(15, 23, 42, .09); }

.site-header .wrap {
    display: flex;
    align-items: center;
    /* Fixed 3-column track: brand | nav | actions. The nav sits in a centred
       track of its own instead of being shoved around by space-between. */
    gap: 2rem;
    min-height: 76px;
    transition: min-height .25s ease;
}
.site-header.is-condensed .wrap { min-height: 60px; }

.brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    flex: 0 0 auto;
    margin-right: auto;
}
.brand-mark {
    width: 44px; height: 44px; border-radius: 8px; flex: none;
    background: var(--navy); color: #fff;
    display: grid; place-items: center;
    font-weight: 800; font-size: 1.4rem;
    border-bottom: 3px solid var(--red);
    transition: width .25s ease, height .25s ease, font-size .25s ease;
}
.site-header.is-condensed .brand-mark { width: 36px; height: 36px; font-size: 1.15rem; }

.brand-text { line-height: 1.15; }
.brand-text strong {
    display: block; color: var(--navy); font-size: 1.0625rem; font-weight: 800; letter-spacing: -.01em;
    transition: font-size .25s ease;
}
.brand-text span {
    display: block; color: var(--muted); font-size: .75rem; letter-spacing: .09em; text-transform: uppercase;
    max-height: 1.4em; opacity: .999; overflow: hidden;
    transition: max-height .25s ease, opacity .2s ease;
}
.site-header.is-condensed .brand-text strong { font-size: .975rem; }
/* Drop the "ADVISORS" strapline when condensed — keeps the lockup balanced. */
.site-header.is-condensed .brand-text span { max-height: 0; opacity: 0; }

.nav {
    display: flex;
    align-items: center;
    gap: 1.75rem;
    flex: 0 1 auto;
}
.nav a {
    position: relative;
    color: var(--ink);
    font-weight: 500;
    font-size: .9375rem;
    padding: .5rem 0;
    white-space: nowrap;
    transition: color .18s ease;
}
/* Underline grows from the centre rather than snapping on, and reserves no
   layout space, so hovering never nudges the row. */
.nav a::after {
    content: "";
    position: absolute;
    left: 50%; right: 50%; bottom: 0;
    height: 2px;
    background: var(--red);
    border-radius: 2px;
    transition: left .22s ease, right .22s ease;
}
.nav a:hover { color: var(--navy); }
.nav a:hover::after, .nav a.is-active::after { left: 0; right: 0; }
.nav a.is-active { color: var(--navy); font-weight: 600; }

.nav-actions { display: flex; align-items: center; gap: .75rem; flex: 0 0 auto; }

/* Drawer-only extras (CTA, login, phone). Hidden on desktop — the header
   already shows these; they are revealed inside the mobile drawer. */
.nav-drawer-extra { display: none; }

.nav-toggle {
    display: none; background: none; border: 1px solid var(--line);
    border-radius: 8px; padding: .5rem .65rem; cursor: pointer;
    transition: border-color .18s ease, background-color .18s ease;
}
.nav-toggle:hover { border-color: var(--navy); background: var(--bg); }
.nav-toggle span {
    display: block; width: 20px; height: 2px; background: var(--navy); margin: 4px 0;
    transition: transform .25s ease, opacity .2s ease;
}
/* Hamburger morphs into an X while the drawer is open. */
.nav-toggle.is-open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle.is-open span:nth-child(2) { opacity: 0; }
.nav-toggle.is-open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Topbar collapses away on scroll so the sticky header stays compact. */
.topbar {
    overflow: hidden;
    max-height: 44px;
    transition: max-height .25s ease, opacity .2s ease;
}
.topbar.is-hidden { max-height: 0; opacity: 0; }

@media (prefers-reduced-motion: reduce) {
    .site-header, .site-header .wrap, .brand-mark, .brand-text strong,
    .brand-text span, .nav a, .nav a::after, .nav-toggle span, .topbar {
        transition: none !important;
    }
}

/* ---------- Hero ---------- */
.hero {
    background: linear-gradient(135deg, var(--navy-darker) 0%, var(--navy) 55%, var(--navy-dark) 100%);
    color: #fff;
    padding: 5rem 0 4rem;
    position: relative;
    overflow: hidden;
}
.hero::after {
    content: ""; position: absolute; inset: 0;
    background: repeating-linear-gradient(90deg, rgba(255,255,255,.03) 0 2px, transparent 2px 60px);
    pointer-events: none;
}
.hero .wrap { position: relative; z-index: 1; }
.hero h1 { color: #fff; max-width: 20ch; }
.hero p { color: rgba(255, 255, 255, .85); font-size: 1.125rem; max-width: 60ch; }
.eyebrow {
    display: inline-flex; align-items: center; gap: .5rem;
    background: rgba(191, 10, 48, .18);
    border: 1px solid rgba(255, 255, 255, .25);
    color: #fff; font-size: .8125rem; font-weight: 600;
    letter-spacing: .07em; text-transform: uppercase;
    padding: .4rem .9rem; border-radius: 999px; margin-bottom: 1.25rem;
}
.hero-actions { display: flex; gap: .875rem; flex-wrap: wrap; margin-top: 1.75rem; }

.page-head { background: linear-gradient(135deg, var(--navy-darker), var(--navy)); color: #fff; padding: 3rem 0; }
.page-head h1 { color: #fff; margin-bottom: .35rem; }
.page-head p { color: rgba(255, 255, 255, .82); margin: 0; max-width: 70ch; }
.crumbs { font-size: .8125rem; color: rgba(255,255,255,.7); margin-bottom: .75rem; }
.crumbs a { color: rgba(255,255,255,.9); }
.crumbs a:hover { color: #fff; text-decoration: underline; }

/* ---------- Stat strip ---------- */
.stat-strip { background: var(--navy-darker); color: #fff; padding: 2rem 0; }
.stat-strip .grid { text-align: center; }
.stat-value { font-size: clamp(1.75rem, 3vw, 2.5rem); font-weight: 800; color: #fff; line-height: 1.1; }
.stat-value em { font-style: normal; color: var(--red); }
.stat-label { font-size: .8125rem; letter-spacing: .09em; text-transform: uppercase; color: rgba(255,255,255,.72); margin-top: .25rem; }

/* ---------- Grid ---------- */
.grid { display: grid; gap: 1.5rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-sidebar { grid-template-columns: 300px 1fr; align-items: start; gap: 2rem; }
.grid-detail { grid-template-columns: 1fr 360px; align-items: start; gap: 2.5rem; }

/* ---------- Cards ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 1.5rem; }
.card-head { padding: 1.15rem 1.5rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; font-size: 1.0625rem; }

.feature { padding: 1.75rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); border-top: 3px solid var(--navy); height: 100%; }
.feature h3 { color: var(--navy); }
.feature-icon {
    width: 48px; height: 48px; border-radius: 10px; margin-bottom: 1rem;
    background: rgba(0, 40, 104, .08); color: var(--navy);
    display: grid; place-items: center; font-size: 1.35rem; font-weight: 700;
}

/* ---------- Listing cards ---------- */
.listing-card {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    overflow: hidden; display: flex; flex-direction: column; height: 100%;
    transition: box-shadow .18s, transform .18s, border-color .18s;
}
.listing-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-3px); border-color: #cbd5e1; }
.listing-media {
    height: 168px; position: relative;
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%);
    display: grid; place-items: center; color: rgba(255,255,255,.9);
}
.listing-media img { width: 100%; height: 100%; object-fit: cover; }
.listing-media-label { font-size: .8125rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 600; }
.listing-body { padding: 1.35rem; display: flex; flex-direction: column; flex: 1; }
.listing-body h3 { font-size: 1.125rem; margin-bottom: .4rem; }
.listing-body h3 a { color: var(--ink); }
.listing-body h3 a:hover { color: var(--navy); }
.listing-loc { font-size: .875rem; color: var(--muted); margin-bottom: .75rem; display: flex; align-items: center; gap: .35rem; }
.listing-summary { font-size: .9rem; margin-bottom: 1rem; flex: 1; }
.listing-figures { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; padding: .9rem 0; border-top: 1px solid var(--line); }
.figure-label { font-size: .6875rem; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.figure-value { font-size: 1.0625rem; font-weight: 700; color: var(--navy); }
.figure-value.red { color: var(--red); }
.listing-foot { padding-top: .9rem; border-top: 1px solid var(--line); display: flex; gap: .5rem; }

.badge {
    display: inline-flex; align-items: center; gap: .3rem;
    font-size: .6875rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
    padding: .3rem .6rem; border-radius: 999px; line-height: 1.4;
}
.badge-featured { background: var(--red); color: #fff; }
.badge-cat { background: rgba(0, 40, 104, .09); color: var(--navy); }
.badge-published { background: #dcfce7; color: #166534; }
.badge-draft { background: #f1f5f9; color: #475569; }
.badge-under_contract { background: #fef3c7; color: #92400e; }
.badge-sold { background: #e0e7ff; color: #3730a3; }
.badge-archived { background: #fee2e2; color: #991b1b; }
.badge-new { background: var(--red); color: #fff; }
.badge-contacted { background: #fef3c7; color: #92400e; }
.badge-qualified { background: #dbeafe; color: #1e40af; }
.badge-nda_signed { background: #dcfce7; color: #166534; }
.badge-closed { background: #f1f5f9; color: #475569; }
.badge-admin { background: var(--navy); color: #fff; }
.badge-user { background: #f1f5f9; color: #475569; }
.badge-stack { position: absolute; top: .75rem; left: .75rem; display: flex; gap: .4rem; z-index: 2; }

/* ---------- Forms ---------- */
.field { margin-bottom: 1.1rem; }
.field label, .label { display: block; font-size: .875rem; font-weight: 600; color: var(--ink); margin-bottom: .4rem; }
.req { color: var(--red); }
.input, .select, .textarea {
    width: 100%; padding: .7rem .85rem; font-size: .9375rem; font-family: inherit; color: var(--ink);
    background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(0, 40, 104, .12);
}
.textarea { min-height: 130px; resize: vertical; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%2364748b'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .7rem center; background-size: 16px; padding-right: 2.25rem; }
.hint { font-size: .8125rem; color: var(--muted); margin-top: .35rem; }
.error { font-size: .8125rem; color: var(--red); margin-top: .35rem; }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--red); }
.check { display: flex; gap: .65rem; align-items: flex-start; font-size: .9rem; }
.check input { margin-top: .25rem; flex: none; width: 16px; height: 16px; accent-color: var(--navy); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; padding-top: .5rem; }

/* ---------- Alerts ---------- */
.alert { padding: .9rem 1.15rem; border-radius: 8px; margin-bottom: 1.5rem; font-size: .9375rem; border: 1px solid; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.alert ul { margin: .5rem 0 0; padding-left: 1.1rem; }

/* ---------- Search panel ---------- */
.search-panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.search-panel .card-head { background: var(--navy); color: #fff; border-radius: var(--radius) var(--radius) 0 0; border-bottom: 0; }
.search-panel .card-head h3 { color: #fff; }
.search-bar { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: .75rem; align-items: end; }
.chip-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .4rem .85rem; border-radius: 999px; font-size: .8125rem; font-weight: 600;
    background: #fff; border: 1px solid var(--line); color: var(--body);
}
.chip:hover { border-color: var(--navy); color: var(--navy); }
.chip.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
.result-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
    text-align: left; padding: .8rem 1rem; background: var(--bg);
    font-size: .75rem; letter-spacing: .07em; text-transform: uppercase; color: var(--muted);
    font-weight: 700; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: .85rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fbfdff; }
.table .actions { display: flex; gap: .4rem; justify-content: flex-end; }
.table-empty { padding: 3rem 1rem; text-align: center; color: var(--muted); }

/* ---------- Definition list ---------- */
.dl { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.dl div { background: #fff; padding: .9rem 1.1rem; }
.dl dt { font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin-bottom: .2rem; }
.dl dd { margin: 0; font-weight: 600; color: var(--ink); font-size: 1rem; }

/* ---------- Process steps ---------- */
.step { display: flex; gap: 1.1rem; align-items: flex-start; }
.step-num {
    flex: none; width: 46px; height: 46px; border-radius: 10px;
    background: var(--navy); color: #fff; display: grid; place-items: center;
    font-weight: 800; font-size: 1rem;
}
.step h3 { font-size: 1.0625rem; margin-bottom: .3rem; }
.step p { font-size: .9rem; margin: 0; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: .35rem; list-style: none; padding: 0; margin: 2rem 0 0; flex-wrap: wrap; justify-content: center; }
.pagination li span, .pagination li a {
    display: grid; place-items: center; min-width: 38px; height: 38px; padding: 0 .7rem;
    border: 1px solid var(--line); border-radius: 8px; font-size: .875rem; background: #fff; color: var(--body);
}
.pagination li a:hover { border-color: var(--navy); color: var(--navy); }
.pagination .active span { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600; }
.pagination .disabled span { color: #cbd5e1; }
.pagination svg { width: 14px; height: 14px; }

/* ---------- CTA band ---------- */
.cta-band { background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%); color: #fff; padding: 3.5rem 0; text-align: center; }
.cta-band h2 { color: #fff; }
.cta-band p { color: rgba(255,255,255,.9); max-width: 60ch; margin: 0 auto 1.75rem; }
.cta-actions { display: flex; gap: .875rem; justify-content: center; flex-wrap: wrap; }

/* ---------- Footer ---------- */
.site-footer { background: var(--navy-darker); color: rgba(255,255,255,.72); padding: 3.5rem 0 0; font-size: .9rem; }
.site-footer h4 { color: #fff; font-size: .8125rem; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 1rem; }
.site-footer a { color: rgba(255,255,255,.72); }
.site-footer a:hover { color: #fff; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: .5rem; }
.footer-brand .brand-mark { background: #fff; color: var(--navy); }
.footer-brand .brand-text strong { color: #fff; }
.footer-brand .brand-text span { color: rgba(255,255,255,.6); }
.footer-bottom {
    border-top: 1px solid rgba(255,255,255,.12); margin-top: 3rem; padding: 1.35rem 0;
    display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: .8125rem;
}

/* ---------- Admin shell ---------- */
.admin-body { background: var(--bg); min-height: 100vh; }
.admin-shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.admin-side { background: var(--navy-darker); color: #fff; padding: 1.25rem 0; }
.admin-side .brand { padding: 0 1.25rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,.1); margin-bottom: 1rem; }
.admin-side .brand-mark { background: #fff; color: var(--navy); }
.admin-side .brand-text strong { color: #fff; font-size: .9375rem; }
.admin-side .brand-text span { color: rgba(255,255,255,.55); font-size: .6875rem; }
.admin-nav { list-style: none; margin: 0; padding: 0 .75rem; }
.admin-nav > li { margin-bottom: .15rem; }
.admin-nav a {
    display: flex; align-items: center; justify-content: space-between; gap: .6rem;
    padding: .6rem .8rem; border-radius: 8px; color: rgba(255,255,255,.78); font-size: .9rem; font-weight: 500;
}
.admin-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.admin-nav a.is-active { background: var(--red); color: #fff; font-weight: 600; }
.admin-nav-label { padding: 1.25rem .8rem .4rem; font-size: .6875rem; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.4); font-weight: 700; }
.pill { background: rgba(255,255,255,.16); color: #fff; border-radius: 999px; padding: .1rem .5rem; font-size: .75rem; font-weight: 700; }
.admin-nav a.is-active .pill { background: rgba(255,255,255,.28); }

.admin-main { display: flex; flex-direction: column; min-width: 0; }

/* Off-canvas backdrop. Fixed and hidden at every width so it never
   participates in the .admin-shell grid. */
.admin-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .5);
    z-index: 150;
}
.admin-top {
    background: #fff; border-bottom: 1px solid var(--line); padding: 1rem 1.75rem;
    display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.admin-top h1 { font-size: 1.35rem; margin: 0; }
.admin-content { padding: 1.75rem; flex: 1; }
.admin-user { display: flex; align-items: center; gap: .7rem; font-size: .875rem; }
.avatar {
    width: 36px; height: 36px; border-radius: 50%; flex: none;
    background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .8125rem;
}

.stat-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; border-left: 3px solid var(--navy); }
.stat-card.red { border-left-color: var(--red); }
.stat-card.green { border-left-color: var(--green); }
.stat-card.gold { border-left-color: var(--gold); }
.stat-card .n { font-size: 1.85rem; font-weight: 800; color: var(--ink); line-height: 1.1; }
.stat-card .l { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-top: .2rem; }

.toolbar { display: flex; gap: .75rem; align-items: end; flex-wrap: wrap; margin-bottom: 1.25rem; }
.toolbar .field { margin-bottom: 0; }
.toolbar .input, .toolbar .select { min-width: 180px; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 2.5rem 1.25rem; background: linear-gradient(135deg, var(--navy-darker), var(--navy)); }
.auth-card { width: 100%; max-width: 440px; background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); padding: 2.25rem; }
.auth-card .brand { justify-content: center; margin-bottom: 1.5rem; }
.auth-foot { text-align: center; font-size: .875rem; margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.demo-box { background: var(--bg); border: 1px dashed #cbd5e1; border-radius: 8px; padding: .85rem 1rem; font-size: .8125rem; margin-top: 1.25rem; }
.demo-box code { background: #fff; padding: .1rem .35rem; border-radius: 4px; border: 1px solid var(--line); font-size: .8125rem; }

.prose { max-width: 72ch; }
.prose p { margin-bottom: 1.1rem; }
.check-list { list-style: none; padding: 0; margin: 0; }
.check-list li { padding-left: 1.75rem; position: relative; margin-bottom: .65rem; }
.check-list li::before {
    content: "✓"; position: absolute; left: 0; top: 0;
    color: var(--green); font-weight: 800;
}

.confidential-note {
    background: #fffbeb; border: 1px solid #fde68a; border-left: 3px solid var(--gold);
    border-radius: 8px; padding: 1rem 1.15rem; font-size: .875rem; color: #78350f;
}

/* ---------- Responsive ---------- */
/* ==========================================================================
   Responsive
   Mobile-first adjustments. Breakpoints: 1100 (nav), 1024 (sidebars),
   860 (tablet), 640 (phone), 400 (small phone).
   ========================================================================== */

/* Nothing may push the page wider than the viewport. */
/* Overflow guard. Deliberately NOT on <html>: setting overflow-x there makes
   the browser compute overflow-y as auto, which turns <html> into the scroll
   container — that breaks position:sticky and pins window.pageYOffset at 0.
   Constraining <body> alone stops sideways scroll without that side effect. */
html { max-width: 100%; }
body { max-width: 100%; overflow-x: hidden; }
@supports (overflow-x: clip) {
    /* clip does not create a scroll container, so sticky keeps working. */
    body { overflow-x: clip; }
}
img, video, canvas, table, pre { max-width: 100%; }

@media (max-width: 1100px) {
    /* Collapse the desktop nav early — 5 links + CTA stop fitting here. */
    .nav { display: none; }
    .nav.is-open {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #fff;
        border-top: 1px solid var(--line);
        border-bottom: 1px solid var(--line);
        padding: .5rem 1.25rem 1.25rem;
        box-shadow: var(--shadow-lg);
        max-height: calc(100vh - 76px);
        overflow-y: auto;
    }
    .nav.is-open a {
        padding: .9rem .25rem;
        border-bottom: 1px solid var(--line);
        border-left: 0;
        font-size: 1rem;
    }
    .nav.is-open a.is-active { color: var(--navy); font-weight: 700; }
    .site-header .nav-toggle { display: block; order: 3; }
    .site-header .wrap { position: relative; flex-wrap: nowrap; gap: .75rem; }
    .nav-drawer-extra {
        display: flex;
        flex-direction: column;
        gap: .5rem;
        padding-top: 1rem;
    }
    .nav-drawer-extra .btn { width: 100%; }
}

@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-detail, .grid-sidebar { grid-template-columns: 1fr; }
    .search-bar { grid-template-columns: 1fr 1fr; }

    /* Admin sidebar becomes an off-canvas drawer. */
    .admin-shell { grid-template-columns: 1fr; }
    .admin-side {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 260px;
        z-index: 200;
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform .2s ease;
        display: block;
    }
    .admin-side.is-open { transform: translateX(0); }
    .admin-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .5);
        z-index: 150;
    }
    .admin-backdrop.is-open { display: block; }
    .admin-main { min-width: 0; }
    .admin-top .nav-toggle { display: block; }
}

@media (max-width: 860px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .topbar-links { display: none; }
    .topbar .wrap { justify-content: center; text-align: center; }
    .cert-sig-block { grid-template-columns: 1fr; gap: 1.5rem; }
}

@media (max-width: 720px) {
    /* The header CTA lives in the drawer below this width. */
    .nav-actions { display: none; }
}

@media (max-width: 640px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .form-row, .search-bar, .dl, .audit-grid { grid-template-columns: 1fr; }

    .section { padding: 2.5rem 0; }
    .section-sm { padding: 2rem 0; }
    .wrap { padding: 0 1rem; }

    .hero { padding: 3rem 0 2.5rem; }
    .hero h1 { font-size: 1.85rem; }
    .hero p { font-size: 1rem; }
    .hero-actions { flex-direction: column; }
    .hero-actions .btn { width: 100%; }

    .page-head { padding: 2rem 0; }
    .page-head h1 { font-size: 1.6rem; }

    /* Full-width tap targets read better than side-by-side buttons on a phone. */
    .btn { padding: .8rem 1.25rem; }
    .cta-actions { flex-direction: column; }
    .cta-actions .btn { width: 100%; }
    .listing-foot { flex-direction: column; }
    .listing-foot .btn { width: 100%; flex: none; }
    .form-actions { flex-direction: column; align-items: stretch; }
    .form-actions .btn { width: 100%; }

    .stat-value { font-size: 1.6rem; }
    .stat-strip { padding: 1.5rem 0; }
    .stat-strip .grid { gap: 1.25rem; }

    .card-pad { padding: 1.15rem; }
    .card-head { padding: 1rem 1.15rem; }
    .step { gap: .85rem; }
    .footer-bottom { flex-direction: column; gap: .5rem; text-align: center; }

    /* Toolbars stack instead of forcing a horizontal scroll. */
    .toolbar { flex-direction: column; align-items: stretch; gap: .75rem; }
    .toolbar .field, .toolbar .btn { width: 100%; }
    .toolbar .input, .toolbar .select { min-width: 0; width: 100%; }
    .toolbar .btn[style*="margin-left"] { margin-left: 0 !important; }

    .admin-top { padding: .85rem 1rem; }
    .admin-top h1 { font-size: 1.1rem; }
    .admin-content { padding: 1rem; }
    .admin-user { gap: .5rem; }
    .admin-user > div { display: none; }

    .result-bar { flex-direction: column; align-items: stretch; gap: .85rem; }
    .result-bar .btn { width: 100%; }

    .auth-card { padding: 1.5rem; }
    .auth-wrap { padding: 1.5rem 1rem; }

    .nda-scroll { max-height: 320px; padding: 1rem; font-size: .78125rem; }
    .sig-pad { height: 170px; }
    .sig-actions { flex-direction: column; align-items: flex-start; gap: .5rem; }
    .doc-row { flex-wrap: wrap; }
    .doc-row .btn { width: 100%; }

}

@media (max-width: 400px) {
    h1 { font-size: 1.55rem; }
    h2 { font-size: 1.3rem; }
    .brand-text strong { font-size: .95rem; }
    .brand-text span { font-size: .6875rem; }
    .brand-mark { width: 38px; height: 38px; font-size: 1.2rem; }
    .badge { font-size: .625rem; }
    .table th, .table td { padding: .65rem .5rem; }
}

/* Comfortable tap targets on touch devices. */
@media (hover: none) and (pointer: coarse) {
    .btn, .nav a, .chip, .pagination li a, .pagination li span { min-height: 44px; }
    .btn-sm { min-height: 38px; }
    .nav-toggle { min-width: 44px; min-height: 44px; }
    .check input { width: 20px; height: 20px; }
}

@media print {
    .site-header, .topbar, .site-footer, .admin-side, .admin-top,
    .btn, .nav-toggle, .no-print { display: none !important; }
}


/* ---------- NDA e-signature ---------- */
.nda-scroll {
    max-height: 460px;
    overflow-y: auto;
    padding: 1.5rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .8125rem;
    line-height: 1.75;
    white-space: pre-wrap;
    color: var(--ink);
    background: #fdfdfd;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}
.nda-scroll::-webkit-scrollbar { width: 10px; }
.nda-scroll::-webkit-scrollbar-track { background: var(--bg); }
.nda-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 5px; }
.nda-scroll::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* Typed signature takes on a handwritten look so it reads as a signature */
.signature-type {
    font-family: "Segoe Script", "Brush Script MT", "Snell Roundhand", cursive;
    font-size: 1.5rem;
    color: var(--navy);
    padding-top: .55rem;
    padding-bottom: .55rem;
}

.sig-pad-wrap { position: relative; background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; overflow: hidden; }
.sig-pad { display: block; width: 100%; height: 200px; cursor: crosshair; touch-action: none; }
.sig-pad-line {
    position: absolute; left: 8%; right: 8%; bottom: 46px;
    border-bottom: 1px dashed #cbd5e1; pointer-events: none;
}
.sig-actions { display: flex; align-items: center; gap: .85rem; margin-top: .6rem; flex-wrap: wrap; }

.btn[disabled] { background: #cbd5e1 !important; border-color: #cbd5e1 !important; color: #fff !important; cursor: not-allowed; transform: none; }

/* Executed agreement / certificate */
.certificate { max-width: 900px; margin: 0 auto; background: #fff; }
.cert-head { text-align: center; padding-bottom: 1.5rem; border-bottom: 3px double var(--navy); margin-bottom: 1.75rem; }
.cert-body {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .8125rem; line-height: 1.75; white-space: pre-wrap; color: var(--ink);
}
.cert-sig-block {
    margin-top: 2.5rem; padding-top: 1.5rem; border-top: 2px solid var(--navy);
    display: grid; grid-template-columns: 1fr 1fr; gap: 2rem;
}
.cert-sig-img { max-height: 90px; border-bottom: 1px solid var(--ink); padding-bottom: .35rem; }
.cert-sig-typed {
    font-family: "Segoe Script", "Brush Script MT", "Snell Roundhand", cursive;
    font-size: 1.75rem; color: var(--navy);
    border-bottom: 1px solid var(--ink); padding-bottom: .35rem;
}
.audit-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px;
    background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
    font-size: .8125rem;
}
.audit-grid > div { background: #fff; padding: .75rem 1rem; }
.audit-grid dt { font-size: .6875rem; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.audit-grid dd { margin: .15rem 0 0; color: var(--ink); word-break: break-all; font-family: ui-monospace, monospace; font-size: .75rem; }

.verify-badge { display: inline-flex; align-items: center; gap: .4rem; font-weight: 700; font-size: .8125rem; }
.verify-ok { color: var(--green); }
.verify-bad { color: var(--red); }

.doc-row {
    display: flex; align-items: center; gap: 1rem; padding: 1rem 0;
    border-bottom: 1px solid var(--line);
}
.doc-row:last-child { border-bottom: 0; }
.doc-icon {
    width: 42px; height: 42px; border-radius: 8px; flex: none; display: grid; place-items: center;
    background: rgba(0,40,104,.08); color: var(--navy); font-size: .6875rem; font-weight: 800; letter-spacing: .03em;
}
.doc-meta { flex: 1; min-width: 0; }
.doc-meta strong { display: block; color: var(--ink); }

@media (max-width: 640px) {
    .cert-sig-block, .audit-grid { grid-template-columns: 1fr; }
    .nda-scroll { max-height: 320px; padding: 1rem; }
}

@media print {
    .nda-scroll { max-height: none; overflow: visible; border: 0; }
    .certificate { max-width: none; }
    .no-print { display: none !important; }
}

/* ---------- NDA e-signature ---------- */
.nda-scroll {
    max-height: 460px;
    overflow-y: auto;
    padding: 1.25rem 1.4rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: .8125rem;
    line-height: 1.75;
    white-space: pre-wrap;
    color: #334155;
}
.nda-scroll::-webkit-scrollbar { width: 10px; }
.nda-scroll::-webkit-scrollbar-track { background: #eef2f7; border-radius: 8px; }
.nda-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; }
.nda-scroll::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.signature-font {
    font-family: "Segoe Script", "Bradley Hand", "Brush Script MT", cursive;
    font-size: 1.35rem !important;
    color: var(--navy) !important;
    letter-spacing: .01em;
}

.sig-pad-wrap { position: relative; }
.sig-pad {
    width: 100%;
    height: 200px;
    display: block;
    background: #fff;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    cursor: crosshair;
    touch-action: none;
}
.sig-pad:hover { border-color: var(--navy); }
.sig-pad-baseline {
    position: absolute;
    left: 2.5rem; right: 2.5rem; bottom: 3.2rem;
    border-bottom: 1px solid #cbd5e1;
    pointer-events: none;
}
.sig-pad-actions {
    display: flex; align-items: center; gap: .75rem;
    margin-top: .5rem; flex-wrap: wrap;
}

.step-list { margin: 0 0 1rem; padding-left: 1.15rem; font-size: .875rem; }
.step-list li { margin-bottom: .5rem; }

/* Executed signature block, used on the certificate and admin review */
.sig-block {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1.25rem 1.4rem;
    background: #fff;
}
.sig-line {
    border-bottom: 1px solid var(--ink);
    padding-bottom: .35rem;
    margin-bottom: .35rem;
    min-height: 3.2rem;
    display: flex;
    align-items: flex-end;
    gap: 1rem;
}
.sig-line img { max-height: 74px; width: auto; }
.sig-typed {
    font-family: "Segoe Script", "Bradley Hand", "Brush Script MT", cursive;
    font-size: 1.6rem;
    color: var(--navy);
    line-height: 1.2;
}
.sig-caption { font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.audit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}
.audit-grid > div { background: #fff; padding: .8rem 1rem; }
.audit-grid dt {
    font-size: .625rem; letter-spacing: .09em; text-transform: uppercase;
    color: var(--muted); font-weight: 700; margin-bottom: .2rem;
}
.audit-grid dd {
    margin: 0; font-size: .8125rem; color: var(--ink);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    word-break: break-all;
}

.doc-row {
    display: flex; align-items: center; gap: 1rem;
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--line);
}
.doc-row:last-child { border-bottom: 0; }
.doc-icon {
    flex: none; width: 42px; height: 42px; border-radius: 8px;
    background: rgba(0,40,104,.08); color: var(--navy);
    display: grid; place-items: center; font-size: .625rem; font-weight: 800; letter-spacing: .04em;
}
.doc-meta { flex: 1; min-width: 0; }
.doc-meta strong { display: block; color: var(--ink); }

.verify-ok   { color: var(--green); font-weight: 700; }
.verify-fail { color: var(--red); font-weight: 700; }

@media print {
    .nda-scroll { max-height: none; overflow: visible; border: 0; background: transparent; padding: 0; }
    .no-print { display: none !important; }
}

/* ---------- Modal (in-page NDA signing) ---------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    background: rgba(10, 22, 40, .68);
    backdrop-filter: blur(2px);
}
.modal.is-open { display: flex; }
body.modal-open { overflow: hidden; }

/*
 * The dialog owns the available height and lays its three regions out as a
 * flex column. Only .modal-body scrolls, so the header and footer stay put
 * without position:sticky (which would anchor them to the viewport and let
 * them float over the content).
 */
.modal-dialog {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
    width: 100%;
    max-width: 760px;
    max-height: calc(100vh - 3rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modal-in .18s ease-out;
}
.modal-dialog > form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}
@keyframes modal-in {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: none; }
}

.modal-head {
    flex: none;
    display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--line);
    border-top: 4px solid var(--red);
    background: #fff;
}
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-head p { margin: .2rem 0 0; font-size: .8125rem; color: var(--muted); }
.modal-close {
    flex: none; width: 34px; height: 34px; border-radius: 8px;
    border: 1px solid var(--line); background: #fff; color: var(--muted);
    font-size: 1.25rem; line-height: 1; cursor: pointer;
}
.modal-close:hover { background: var(--bg); color: var(--ink); }

.modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 1.5rem;
}

.modal-foot {
    flex: none;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--line);
    background: var(--bg);
    display: flex; gap: .75rem; align-items: center; flex-wrap: wrap;
}
.modal .nda-scroll { max-height: 260px; }

.modal-step {
    font-size: .6875rem; letter-spacing: .09em; text-transform: uppercase;
    color: var(--muted); font-weight: 700; margin: 1.5rem 0 .6rem;
    padding-top: 1.25rem; border-top: 1px solid var(--line);
}
.modal-step:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }

@media (max-width: 640px) {
    .modal { padding: 0; }
    .modal-dialog { border-radius: 0; max-height: 100vh; height: 100vh; }
    .modal-body { padding: 1.15rem; }
    .modal-foot { padding: .85rem 1.15rem; }
    .modal-foot .btn { flex: 1; }
}

/* ---------- Mobile table & overflow safety ---------- */
.table-wrap { -webkit-overflow-scrolling: touch; }

@media (max-width: 860px) {
    /* Admin tables carry 7-13 columns. Let them scroll horizontally inside
       their own container rather than crushing every column to unreadable
       width — the page body itself never scrolls sideways. */
    .table-wrap { overflow-x: auto; }
    /* 720px crushed every admin table — the widest needs ~1005px. Let each
       table size to its own content and scroll, rather than forcing one
       arbitrary floor that still squeezes columns. */
    .table-wrap > .table { min-width: max-content; }
    .table-wrap > .table th,
    .table-wrap > .table td { white-space: nowrap; }
    /* Columns that hold prose still need to wrap, or rows get absurdly wide. */
    .table-wrap > .table td .small,
    .table-wrap > .table td .tiny { white-space: normal; }

    /* Give the scroll affordance a visible edge. */
    .table-wrap { box-shadow: inset -8px 0 8px -8px rgba(15,23,42,.15); }
}

@media (max-width: 640px) {
    /* Long unbroken strings (hashes, tokens, emails) must wrap, not overflow. */
    .audit-grid dd, .dl dd, .doc-meta, .card-pad { overflow-wrap: anywhere; }

    /* Read-only vault link input */
    .card-pad input[readonly] { font-size: .6875rem; }

    /* Certificate signature images scale down */
    .cert-sig-img { max-width: 100%; height: auto; }
    .cert-sig-typed { font-size: 1.3rem; }
}

/* ---------- Horizontal search filters ---------- */
.filter-bar {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.15rem 1.25rem;
    margin-bottom: 1.25rem;
}
.filter-row {
    display: flex;
    align-items: flex-end;
    gap: .85rem;
    flex-wrap: wrap;
}
.filter-field { display: flex; flex-direction: column; min-width: 150px; flex: 0 1 auto; }
/* The keyword box absorbs the leftover width. */
.filter-grow { flex: 1 1 220px; min-width: 200px; }
.filter-field label {
    font-size: .6875rem;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: .3rem;
}
.filter-field .input, .filter-field .select { padding: .6rem .75rem; font-size: .9rem; }
.filter-actions { display: flex; gap: .5rem; align-items: flex-end; flex: 0 0 auto; }

/* Advanced numeric filters: collapsed by default, animated open. */
.filter-advanced {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    transition: grid-template-rows .25s ease, opacity .2s ease, margin-top .25s ease;
    margin-top: 0;
}
.filter-advanced > .filter-row { overflow: hidden; min-height: 0; }
.filter-bar.adv-open .filter-advanced {
    grid-template-rows: 1fr;
    opacity: 1;
    margin-top: .9rem;
    padding-top: .9rem;
    border-top: 1px solid var(--line);
}

/* Active filter chips */
.active-filters {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: 1.25rem;
}
.active-filters-label {
    font-size: .75rem;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 700;
    margin-right: .15rem;
}
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .38rem .7rem;
    border-radius: 999px;
    font-size: .8125rem;
    font-weight: 600;
    background: rgba(0, 40, 104, .07);
    border: 1px solid rgba(0, 40, 104, .16);
    color: var(--navy);
    transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}
.filter-chip:hover { background: var(--red); border-color: var(--red); color: #fff; }
.filter-chip-x { font-size: 1.05rem; line-height: 1; opacity: .65; }
.filter-chip:hover .filter-chip-x { opacity: 1; }

.filter-clear-all {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--red);
    text-decoration: underline;
    text-underline-offset: 3px;
    margin-left: .25rem;
}
.filter-clear-all:hover { color: var(--red-dark); }

@media (max-width: 900px) {
    .filter-field, .filter-grow { flex: 1 1 calc(50% - .5rem); min-width: 0; }
    .filter-actions { flex: 1 1 100%; }
    .filter-actions .btn { flex: 1; }
}

@media (max-width: 560px) {
    .filter-bar { padding: 1rem; }
    .filter-field, .filter-grow { flex: 1 1 100%; }
    .filter-actions { flex-direction: column; }
    .filter-actions .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .filter-advanced, .filter-chip { transition: none !important; }
}

/* ---------- Admin tables on small screens ---------- */
@media (max-width: 860px) {
    /* Keep the row actions reachable without scrolling the table back. */
    .table th:last-child,
    .table td:last-child {
        position: sticky;
        right: 0;
        background: #fff;
        box-shadow: -6px 0 6px -6px rgba(15, 23, 42, .18);
        z-index: 2;
    }
    .table th:last-child { background: var(--bg); }
    .table tbody tr:hover td:last-child { background: #fbfdff; }

    /* Buttons stack so labels stay readable instead of truncating. */
    .table .actions {
        flex-direction: column;
        align-items: stretch;
        gap: .3rem;
        min-width: 84px;
    }
    .table .actions .btn { width: 100%; justify-content: center; }
    .table .actions form { display: block; }
    .table .actions form .btn { width: 100%; }

    /* Scroll hint so it is obvious the table moves sideways. */
    .table-wrap::after {
        content: "";
        display: block;
        height: 0;
    }
}

/* Admin toolbars: the "new" button should not be stranded mid-row. */
@media (max-width: 860px) {
    .toolbar { flex-wrap: wrap; }
    .toolbar .btn[style*="margin-left"] { margin-left: auto !important; }
}

/* Admin form pages: sidebar column drops below the form. */
@media (max-width: 1024px) {
    .admin-content .grid-detail { grid-template-columns: 1fr; }
    .admin-content .grid-detail aside { order: 2; }
}

/* Category popover: full-width sheet on phones instead of a 300px box. */
/* The sticky actions cell becomes a containing block, which would trap and
   clip this popover. Promote it to a centred fixed sheet wherever the column
   is sticky (<=860px), not only on phones. */
@media (max-width: 860px) {
    .table .actions details > form {
        position: fixed !important;
        left: 1rem !important;
        right: 1rem !important;
        top: 50% !important;
        width: auto !important;
        transform: translateY(-50%);
        max-height: 80vh;
        overflow-y: auto;
        z-index: 300;
    }
    /* Row actions must sit above neighbouring sticky cells while open. */
    .table td:last-child:has(details[open]) { z-index: 5; }
}

@media (max-width: 640px) {
    .admin-content .card-head { flex-direction: column; align-items: flex-start; gap: .6rem; }
    .admin-content .card-head .btn { width: 100%; }
    .stat-card .n { font-size: 1.5rem; }
}
