/* ============================================================
   The Smart Blueprint Design System
   Deep purple + gold brand identity. Gotham (licensed, self-hosted)
   is the primary typeface everywhere, with Montserrat as an
   automatic free fallback until licensed files are added — see
   static/fonts/README.txt.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800&family=Inter:wght@400;500;600&display=swap');

/* Gotham — self-hosted, licensed. All three weights are supplied as
   .woff2 (Book/400, Medium/500, Bold/700), so the full body font stack
   below can use Gotham directly rather than falling back to Montserrat. */
@font-face {
    font-family: 'Gotham';
    src: url('/static/fonts/Gotham-Book.woff2') format('woff2'),
         url('/static/fonts/Gotham-Book.otf') format('opentype');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'Gotham';
    src: url('/static/fonts/Gotham-Medium.woff2') format('woff2'),
         url('/static/fonts/Gotham-Medium.otf') format('opentype');
    font-weight: 500;
    font-display: swap;
}
@font-face {
    font-family: 'Gotham';
    src: url('/static/fonts/Gotham-Bold.woff2') format('woff2'),
         url('/static/fonts/Gotham-Bold.otf') format('opentype');
    font-weight: 700;
    font-display: swap;
}

:root {
    /* --- Brand palette (from brand guidelines) --- */
    --deep-purple:   #36184F;
    --brand-purple:  #5A3089;
    --brand-purple-light: #7A4FB0;
    --gold:          #D4AF37;
    --gold-soft:     #E9CE7A;
    --gold-bright:   #F3D96B;
    --white:         #FFFFFF;

    /* --- Derived surface / text tokens --- */
    --page-bg:       #FAF9FC;
    --surface:       #FFFFFF;
    --surface-alt:   #F4F1F8;
    --border:        #E6E1EE;
    --border-strong: #D6CEE6;
    --text:          #241531;
    --text-muted:    #6B6478;
    --text-on-dark:  rgba(255, 255, 255, 0.95);
    --text-on-dark-muted: rgba(255, 255, 255, 0.70);

    --success:  #1A7F4B;
    --success-bg: #E7F6EE;
    --warning:  #B45309;
    --warning-bg: #FEF3E2;
    --error:    #B42318;
    --error-bg: #FDECEA;

    /* --- Brand gradient, richer multi-stop 135° --- */
    --gradient-brand: linear-gradient(135deg, #6B3AA0 0%, var(--brand-purple) 32%, var(--deep-purple) 70%, #22102F 100%);
    --gradient-brand-radiant: radial-gradient(ellipse 120% 90% at 15% 0%, rgba(122, 79, 176, 0.55), transparent 55%),
                              radial-gradient(ellipse 100% 80% at 100% 100%, rgba(212, 175, 55, 0.12), transparent 60%),
                              var(--gradient-brand);
    --gradient-gold: linear-gradient(135deg, #F6E7AE 0%, var(--gold-bright) 30%, var(--gold) 65%, #A8811C 100%);

    /* --- Elevation --- */
    --shadow-sm: 0 1px 2px rgba(54, 24, 79, 0.06), 0 1px 3px rgba(54, 24, 79, 0.08);
    --shadow-md: 0 4px 12px rgba(54, 24, 79, 0.10), 0 2px 4px rgba(54, 24, 79, 0.06);
    --shadow-lg: 0 24px 60px rgba(20, 8, 32, 0.35), 0 8px 20px rgba(54, 24, 79, 0.18);
    --shadow-gold-glow: 0 0 0 3px rgba(212, 175, 55, 0.22);

    /* --- Radius --- */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 24px;

    /* --- Motion --- */
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 150ms;
    --duration: 260ms;
    --duration-slow: 600ms;

    /* --- Type ---
       All three Gotham weights are supplied (Book/400, Medium/500,
       Bold/700), so it's used everywhere — headings and body text alike.
       Montserrat remains the fallback if the licensed files are ever
       removed from static/fonts/. */
    --font-display: 'Gotham', 'Montserrat', -apple-system, sans-serif;
    --font-body: 'Gotham', 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* --- Fluid type scale --- */
    --fs-h1: clamp(1.6rem, 1.15rem + 1.8vw, 2.4rem);
    --fs-h2: clamp(1.1rem, 1rem + 0.5vw, 1.3rem);
    --fs-base: clamp(0.92rem, 0.9rem + 0.1vw, 1rem);
}

@media (prefers-reduced-motion: reduce) {
    :root { --duration-fast: 0ms; --duration: 0ms; --duration-slow: 0ms; }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* Global HTMX loading bar - a slim animated progress indicator at the very
   top of the viewport during any HTMX request, for perceived performance.
   Toggled by a tiny JS snippet in base.html hooking htmx:beforeRequest /
   htmx:afterRequest, not per-page. */
#global-loading-bar {
    position: fixed; top: 0; left: 0; height: 3px; width: 100%;
    z-index: 2000; pointer-events: none;
    background: var(--gradient-gold);
    transform: scaleX(0); transform-origin: left;
    opacity: 0;
    transition: transform 400ms var(--ease), opacity 200ms var(--ease);
}
#global-loading-bar.active { opacity: 1; transform: scaleX(0.7); transition: transform 8s cubic-bezier(0.1, 0.6, 0.2, 1), opacity 200ms var(--ease); }
#global-loading-bar.done { opacity: 0; transform: scaleX(1); transition: transform 300ms var(--ease), opacity 400ms var(--ease) 200ms; }

::selection { background: var(--gold-soft); color: var(--deep-purple); }

:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Custom scrollbar - webkit browsers */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--surface-alt); }
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
    border: 3px solid var(--surface-alt);
}
::-webkit-scrollbar-thumb:hover { background: var(--brand-purple-light); }
* { scrollbar-color: var(--border-strong) var(--surface-alt); scrollbar-width: thin; }

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: var(--fs-base);
    background:
        radial-gradient(ellipse 60% 40% at 8% 0%, rgba(90, 48, 137, 0.05), transparent 60%),
        radial-gradient(ellipse 50% 35% at 100% 15%, rgba(212, 175, 55, 0.04), transparent 55%),
        var(--page-bg);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    font-variant-numeric: tabular-nums;
    overflow-x: hidden;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em; color: var(--deep-purple); margin: 0; }
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }

::selection { background: rgba(212, 175, 55, 0.35); color: var(--deep-purple); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--brand-purple); }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: none;
    box-shadow: var(--shadow-gold-glow);
    border-color: var(--gold);
}

/* ============================================================
   Top navigation
   ============================================================ */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 0.85rem 1.75rem;
    background: var(--gradient-brand-radiant);
    box-shadow: var(--shadow-md), inset 0 -1px 0 rgba(212, 175, 55, 0.18);
    position: sticky;
    top: 0;
    z-index: 40;
}

.brand-logo { height: 34px; display: block; transition: transform var(--duration) var(--ease); }
.brand-logo:hover { transform: scale(1.04); }
.brand-logo img { height: 100%; display: block; }

.nav { display: flex; align-items: center; gap: 0.25rem; flex: 1; margin-left: 2rem; }
.nav a {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-on-dark-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-sm);
    transition: color var(--duration) var(--ease), background var(--duration) var(--ease);
}
.nav a:hover { color: var(--text-on-dark); background: rgba(255, 255, 255, 0.08); }
.nav a.active { color: var(--white); }

.nav-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }
.nav-icon-glyph {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1;
}
.nav a.active::after {
    content: "";
    position: absolute;
    left: 0.85rem; right: 0.85rem; bottom: 0.15rem;
    height: 2px;
    background: var(--gold);
    border-radius: 2px;
    animation: underlineIn var(--duration) var(--ease-spring) both;
}
@keyframes underlineIn { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* --- Settings dropdown (native <details>/<summary>, works without JS) --- */
.nav-dropdown { position: relative; }
.nav-dropdown summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-on-dark-muted);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-sm);
    user-select: none;
    transition: color var(--duration) var(--ease), background var(--duration) var(--ease);
}
.nav-dropdown summary::-webkit-details-marker { display: none; }
.nav-dropdown summary::after {
    content: "";
    width: 6px; height: 6px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg);
    margin-top: -3px;
    transition: transform var(--duration) var(--ease);
}
.nav-dropdown[open] summary::after { transform: rotate(-135deg); margin-top: 3px; }
.nav-dropdown summary:hover { color: var(--text-on-dark); background: rgba(255, 255, 255, 0.08); }
.nav-dropdown.active summary { color: var(--white); }
.nav-dropdown.active summary::before {
    content: "";
    position: absolute;
    left: 0.85rem; right: 0.85rem; bottom: 0.15rem;
    height: 2px;
    background: var(--gold);
    border-radius: 2px;
}

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 180px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    z-index: 50;
    animation: dropdownIn var(--duration) var(--ease) both;
}
@keyframes dropdownIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.nav-dropdown-menu a {
    color: var(--text);
    text-decoration: none;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}
.nav-dropdown-menu a:hover { background: var(--surface-alt); color: var(--brand-purple); }

.user-menu { display: flex; align-items: center; gap: 1rem; font-size: 0.85rem; color: var(--text-on-dark-muted); }
.user-menu strong { color: var(--white); font-weight: 700; }
.role-pill {
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: rgba(212, 175, 55, 0.16);
    color: var(--gold-soft);
    border: 1px solid rgba(212, 175, 55, 0.35);
}

/* Mobile nav toggle — hidden above tablet breakpoint */
.nav-toggle {
    display: none;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    width: 42px; height: 42px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--white);
}
.nav-toggle svg { width: 20px; height: 20px; }

.container {
    max-width: min(90vw, 1360px);
    margin: 0 auto;
    padding: clamp(1.25rem, 1rem + 1vw, 2.5rem) clamp(1rem, 0.5rem + 2vw, 2rem) 4rem;
    animation: fadeInUp var(--duration-slow) var(--ease) both;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

.subtitle { color: var(--text-muted); margin-top: 0.3rem; margin-bottom: 1.75rem; font-size: 0.98rem; }

/* ============================================================
   Auth screens — animated gradient mesh with glass card
   ============================================================ */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #ffffff 0%, #f4ecfb 22%, #dcc3f0 48%, #9d6fc9 72%, var(--brand-purple) 100%);
    isolation: isolate;
}
.auth-shell--embedded { min-height: calc(100vh - 66px); }

/* Layered ambient gradient blobs + a subtle grain texture for depth */
.auth-shell::before, .auth-shell::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    z-index: -2;
    opacity: 0.55;
}
.auth-shell::before {
    width: 52vw; height: 52vw;
    top: -16vw; left: -12vw;
    background: radial-gradient(circle at 30% 30%, rgba(212, 175, 55, 0.4), transparent 70%);
    animation: driftA 20s ease-in-out infinite alternate;
}
.auth-shell::after {
    width: 42vw; height: 42vw;
    bottom: -16vw; right: -10vw;
    background: radial-gradient(circle at 70% 70%, rgba(90, 48, 137, 0.4), transparent 70%);
    animation: driftB 24s ease-in-out infinite alternate;
}
@keyframes driftA { from { transform: translate(0,0) scale(1); } to { transform: translate(5vw, 6vw) scale(1.15); } }
@keyframes driftB { from { transform: translate(0,0) scale(1); } to { transform: translate(-4vw, -5vw) scale(1.1); } }
@media (prefers-reduced-motion: reduce) { .auth-shell::before, .auth-shell::after { animation: none; } }

/* Floating symbol.svg particles — slow, gentle drift behind the glass card */
.particle-field {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}
.particle {
    position: absolute;
    opacity: 0.4;
    filter: drop-shadow(0 6px 14px rgba(54, 24, 79, 0.18));
    animation-name: floatParticle;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
}
@keyframes floatParticle {
    0%   { transform: translate(0, 0) rotate(0deg); }
    25%  { transform: translate(3vw, -4vh) rotate(12deg); }
    50%  { transform: translate(-2vw, -7vh) rotate(-8deg); }
    75%  { transform: translate(-3.5vw, -2vh) rotate(6deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}
@media (prefers-reduced-motion: reduce) { .particle { animation: none; } }

.auth-shell-inner { position: relative; z-index: 1; width: 100%; max-width: 400px; }

.auth-logo-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 1.75rem;
    animation: fadeInUp var(--duration-slow) var(--ease) both;
}

.auth-logo {
    display: block;
    width: auto;
    height: 64px;
    max-width: 220px;
    filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.35));
}

/* ============================================================
   Rotating symbol.svg — the site-wide loading indicator.
   Used for form-submit feedback and (ready for Phase 2) htmx
   requests. Slow, deliberate rotation reads as "working", not "stuck".
   ============================================================ */
.spin-loader {
    display: inline-block;
    width: 20px;
    height: 20px;
    vertical-align: -4px;
    animation: spin360 2.4s linear infinite;
}
@keyframes spin360 { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .spin-loader { animation-duration: 7s; }
}

.btn-primary.is-loading { cursor: progress; opacity: 0.9; pointer-events: none; }

/* Full-page loading overlay (shown briefly during navigations/HTMX swaps) */
.page-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(36, 21, 49, 0.35);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration) var(--ease);
}
.page-loading-overlay.visible { opacity: 1; pointer-events: auto; }
.page-loading-overlay .spin-loader { width: 44px; height: 44px; }

/* The glass card */
.auth-card {
    position: relative;
    background: rgba(54, 24, 79, 0.52);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: var(--radius-lg);
    padding: clamp(1.75rem, 1.4rem + 1.5vw, 2.6rem) clamp(1.5rem, 1.2rem + 1vw, 2.3rem);
    box-shadow: var(--shadow-lg);
    animation: cardIn var(--duration-slow) var(--ease-spring) both;
    animation-delay: 80ms;
    overflow: hidden;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(24px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* Shimmering gold border sweep on load */
.auth-card::before {
    content: "";
    position: absolute;
    inset: -1px;
    padding: 1px;
    border-radius: inherit;
    background: linear-gradient(115deg, transparent 30%, rgba(212, 175, 55, 0.9) 48%, transparent 66%);
    background-size: 300% 300%;
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: shimmerSweep 2.6s var(--ease) 500ms 1;
    pointer-events: none;
}
@keyframes shimmerSweep { from { background-position: 200% 0; } to { background-position: -50% 0; } }
@media (prefers-reduced-motion: reduce) { .auth-card::before { animation: none; } }

.auth-card h1 { text-align: center; color: var(--white); font-size: 1.35rem; letter-spacing: -0.005em; margin-bottom: 0.35rem; }
.auth-card .subtitle { text-align: center; color: var(--text-on-dark-muted); margin-bottom: 1.5rem; }
.auth-card label { color: var(--text-on-dark-muted); }
.auth-card input {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.4);
}
.auth-card input::placeholder { color: var(--text-muted); }
.auth-card input:focus-visible { box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.4); border-color: var(--gold); }
.auth-card .hint, .auth-card .field-hint { color: var(--text-on-dark-muted); }

/* --- Icon-prefixed inputs (bank-style trust cue) --- */
.input-icon-group { position: relative; }
.input-icon-group .field-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color var(--duration) var(--ease);
}
.input-icon-group input[type] { padding-left: 2.6rem; width: 100%; }
.input-icon-group:focus-within .field-icon { color: var(--gold); }

/* --- Security trust strip beneath the form --- */
.security-strip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin-top: 1.5rem;
    padding-top: 1.1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    color: var(--text-on-dark-muted);
    font-size: 0.76rem;
    letter-spacing: 0.01em;
}
.security-strip svg, .security-strip img { width: 16px; height: 16px; flex-shrink: 0; }
.security-strip svg { color: var(--gold-soft); }

/* ============================================================
   Cards / grid
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem 1.6rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.card h2 { font-size: 1.05rem; margin-bottom: 0.75rem; }
.card ul { margin: 0; padding-left: 1.1rem; color: var(--text-muted); }
.card li { margin-bottom: 0.35rem; }

.hero-banner {
    background: var(--gradient-brand-radiant);
    background-size: 200% 200%;
    animation: gradientDrift 20s ease infinite;
    border-radius: var(--radius-lg);
    padding: clamp(1.5rem, 1.2rem + 1.5vw, 2.25rem) clamp(1.25rem, 1rem + 1.5vw, 2.25rem);
    color: var(--white);
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}
@media (prefers-reduced-motion: reduce) { .hero-banner { animation: none; } }
.hero-banner::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 3px;
    background: var(--gradient-gold);
}
.hero-banner h1 { color: var(--white); }
.hero-banner .subtitle { color: var(--text-on-dark-muted); margin-bottom: 0; }
.hero-banner .role-pill { display: inline-block; margin-top: 0.6rem; }
.hero-banner .last-login {
    margin: 0.85rem 0 0;
    font-size: 0.82rem;
    color: var(--text-on-dark-muted);
    display: block;
}
.hero-banner .last-login .flag-emoji { font-size: 0.95rem; }

/* ============================================================
   Action cards — big clickable tiles on the Home landing page
   ============================================================ */

/* Ambient colour wash behind the cards — glass needs something
   colourful to refract, otherwise "frosted" reads as just "grey". */
.action-section {
    position: relative;
    padding: 2.5rem clamp(1rem, 0.5rem + 2vw, 2rem);
    border-radius: var(--radius-lg);
    overflow: hidden;
    isolation: isolate;
}
.action-section::before, .action-section::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    filter: blur(64px);
    z-index: -1;
    opacity: 0.8;
}
.action-section::before {
    width: 380px; height: 380px;
    top: -140px; left: -100px;
    background: radial-gradient(circle, rgba(90, 48, 137, 0.4), transparent 70%);
}
.action-section::after {
    width: 320px; height: 320px;
    bottom: -120px; right: -70px;
    background: radial-gradient(circle, rgba(212, 175, 55, 0.32), transparent 70%);
}

.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.25rem; }

.action-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.65rem;
    background: rgba(255, 255, 255, 0.55);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    backdrop-filter: blur(18px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 8px 24px rgba(54, 24, 79, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.6);
    position: relative;
    overflow: hidden;
    transition: transform var(--duration) var(--ease-spring), box-shadow var(--duration) var(--ease), border-color var(--duration) var(--ease), background var(--duration) var(--ease);
}

/* Diagonal shine sweep on hover */
.action-card::before {
    content: "";
    position: absolute;
    top: -50%; left: -60%;
    width: 40%; height: 220%;
    background: linear-gradient(115deg, transparent, rgba(255, 255, 255, 0.55), transparent);
    transform: rotate(20deg) translateX(-120%);
    transition: transform 850ms var(--ease);
    pointer-events: none;
}
.action-card:hover::before { transform: rotate(20deg) translateX(220%); }

/* Gold underline sweep on hover */
.action-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--gradient-gold);
    opacity: 0;
    transform: scaleX(0);
    transform-origin: left;
    height: 3px;
    top: auto;
    transition: transform var(--duration-slow) var(--ease), opacity var(--duration) var(--ease);
}
.action-card:hover {
    transform: translateY(-8px) scale(1.015);
    box-shadow: 0 20px 40px rgba(54, 24, 79, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.7);
    border-color: rgba(212, 175, 55, 0.5);
    background: rgba(255, 255, 255, 0.7);
}
.action-card:hover::after { opacity: 1; transform: scaleX(1); }
.action-card:active { transform: translateY(-4px) scale(1.005); }

.action-card .action-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: var(--gradient-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(54, 24, 79, 0.25);
    transition: transform 480ms var(--ease-spring), box-shadow var(--duration) var(--ease);
}
.action-card .action-icon svg { width: 24px; height: 24px; }
.action-card .action-icon .action-icon-glyph {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1;
}
.action-card:hover .action-icon {
    transform: scale(1.12) rotate(-6deg);
    box-shadow: 0 8px 20px rgba(212, 175, 55, 0.35);
}

.action-card h2 { font-size: 1.15rem; margin: 0; }
.action-card p { color: var(--text-muted); margin: 0; font-size: 0.9rem; line-height: 1.5; }

.action-card .action-arrow {
    margin-top: auto;
    padding-top: 0.75rem;
    color: var(--brand-purple);
    font-weight: 600;
    font-size: 0.88rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: color var(--duration) var(--ease), gap var(--duration) var(--ease);
}
.action-card .action-arrow svg { width: 15px; height: 15px; transition: transform var(--duration) var(--ease); }
.action-card:hover .action-arrow { color: var(--gold); gap: 0.55rem; }
.action-card:hover .action-arrow svg { transform: translateX(3px); }

.placeholder-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: var(--surface-alt);
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

/* ============================================================
   Forms
   ============================================================ */
form.form, .auth-card form { display: flex; flex-direction: column; }
label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0.9rem 0 0.35rem;
    color: var(--text-muted);
}
input[type="text"], input[type="email"], input[type="password"], select, textarea {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: var(--font-body);
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
    min-height: 44px;
}
textarea { min-height: auto; resize: vertical; line-height: 1.5; }
input:hover, select:hover, textarea:hover { border-color: var(--brand-purple); }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--gold); box-shadow: var(--shadow-gold-glow); }
input:disabled, textarea:disabled { background: var(--surface-alt); color: var(--text-muted); }
.field-hint { font-size: 0.8rem; color: var(--text-muted); margin: 0.3rem 0 0; }

/* ============================================================
   Buttons
   ============================================================ */
.btn-primary {
    margin-top: 1.75rem;
    padding: 0.75rem 1.3rem;
    min-height: 46px;
    background: var(--gradient-brand);
    background-size: 160% 160%;
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-sm);
    transition: transform var(--duration-fast) var(--ease-spring), box-shadow var(--duration) var(--ease), background-position var(--duration-slow) var(--ease);
    position: relative;
    overflow: hidden;
}
.btn-primary::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.35), transparent 60%);
    opacity: 0;
    transition: opacity var(--duration) var(--ease);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-md), 0 0 0 1px rgba(212, 175, 55, 0.4); background-position: 100% 100%; }
.btn-primary:hover::before { opacity: 1; }
.btn-primary:active { transform: translateY(0) scale(0.98); }

.auth-card .btn-primary { background: var(--gradient-gold); color: var(--deep-purple); font-weight: 800; }
.auth-card .btn-primary:hover { box-shadow: var(--shadow-md), 0 0 28px rgba(212, 175, 55, 0.5); }

.link-button {
    background: none;
    border: none;
    color: var(--brand-purple);
    cursor: pointer;
    padding: 0.25rem 0;
    font-size: 0.88rem;
    font-weight: 500;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color var(--duration) var(--ease), color var(--duration) var(--ease);
}
.link-button:hover { color: var(--deep-purple); border-color: var(--gold); }
.link-button-on-dark { color: var(--text-on-dark-muted); }
.link-button-on-dark:hover { color: var(--white); border-color: var(--gold); }

/* ============================================================
   Alerts
   ============================================================ */
.alert {
    padding: 0.8rem 1.05rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.1rem;
    font-size: 0.9rem;
    animation: fadeInUp var(--duration) var(--ease) both;
}
.alert-error { background: var(--error-bg); color: var(--error); border: 1px solid #f5c2c0; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #b7e4cc; }
.auth-card .alert-error { background: rgba(180, 35, 24, 0.16); color: #ffd6d2; border: 1px solid rgba(255, 120, 108, 0.4); }

/* ============================================================
   Data table — collapses to labeled cards on small screens
   ============================================================ */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.data-table th, .data-table td { text-align: left; padding: 0.75rem 1.1rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; position: relative; }
.data-table th { background: var(--surface-alt); font-weight: 700; color: var(--text-muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }
.data-table tbody tr { transition: background var(--duration-fast) var(--ease); }
.data-table tbody tr:hover { background: var(--surface-alt); }
.data-table tbody tr td:first-child { box-shadow: inset 3px 0 0 transparent; transition: box-shadow var(--duration) var(--ease); }
.data-table tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--brand-purple); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .actions a, .data-table .actions .link-button { margin-right: 0.9rem; }

/* ============================================================
   Badges
   ============================================================ */
.badge { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.2rem 0.65rem; border-radius: 999px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-success::before { animation: pulseDot 2s ease-in-out infinite; }
@keyframes pulseDot { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-error { background: var(--error-bg); color: var(--error); }
.badge-info { background: rgba(90, 48, 137, 0.12); color: var(--brand-purple); }
.badge-muted { background: var(--surface-alt); color: var(--text-muted); }

/* ============================================================
   Misc
   ============================================================ */
.page-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }

.temp-password {
    display: block;
    background: var(--surface-alt);
    border: 1px dashed var(--border-strong);
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-sm);
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: clamp(0.95rem, 0.9rem + 0.3vw, 1.1rem);
    letter-spacing: 0.03em;
    color: var(--deep-purple);
    margin-top: 0.5rem;
    word-break: break-all;
}

.checkbox-row { display: flex; align-items: center; gap: 0.6rem; font-weight: 400; margin: 0.5rem 0; text-transform: none; letter-spacing: normal; min-height: 32px; }
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--brand-purple); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.1rem 1.25rem; }

.hint { font-size: 0.85rem; color: var(--text-on-dark-muted); margin-top: 1.75rem; text-align: center; }

.htmx-indicator { opacity: 0; transition: opacity var(--duration) var(--ease); }
.htmx-request.htmx-indicator, .htmx-request .htmx-indicator { opacity: 1; }

#services-section { transition: opacity 150ms ease; }
#services-section.htmx-swapping { opacity: 0.4; }

/* ============================================================
   Pricing Engine — collapsible lookup panels (Business Types, Resources)
   ============================================================ */
.lookup-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.25rem; margin-bottom: 1.75rem; }

.lookup-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.lookup-panel summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    font-weight: 700;
    font-family: var(--font-display);
    color: var(--deep-purple);
    user-select: none;
    transition: background var(--duration) var(--ease);
}
.lookup-panel summary:hover { background: var(--surface-alt); }
.lookup-panel summary::-webkit-details-marker { display: none; }
.lookup-panel summary .lookup-panel-count { font-family: var(--font-body); font-weight: 500; color: var(--text-muted); font-size: 0.85rem; }
.lookup-panel summary::after {
    content: "";
    width: 8px; height: 8px;
    border-right: 1.5px solid var(--text-muted);
    border-bottom: 1.5px solid var(--text-muted);
    transform: rotate(45deg);
    transition: transform var(--duration) var(--ease);
    margin-left: 0.5rem;
}
.lookup-panel[open] summary::after { transform: rotate(-135deg); }
.lookup-panel-body { padding: 0 1.25rem 1.25rem; border-top: 1px solid var(--border); }

.lookup-panel--flush { background: none; border: none; box-shadow: none; }
.lookup-panel--flush summary { padding: 0; }

.lookup-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}
.lookup-row:last-of-type { border-bottom: none; }
.lookup-row form.lookup-rename-form { flex: 1; display: flex; gap: 0.4rem; margin: 0; }
.lookup-row input[type="text"] {
    min-height: 36px;
    padding: 0.4rem 0.6rem;
    font-size: 0.88rem;
    background: transparent;
    border-color: transparent;
}
.lookup-row input[type="text"]:hover { border-color: var(--border-strong); }
.lookup-row input[type="text"]:focus-visible { background: var(--surface); border-color: var(--gold); }
.lookup-row .badge { flex-shrink: 0; }
.lookup-row .link-button { flex-shrink: 0; white-space: nowrap; }

.lookup-add-form { display: flex; gap: 0.5rem; margin-top: 0.9rem; }
.lookup-add-form input[type="text"] { min-height: 40px; }
.lookup-add-form button {
    flex-shrink: 0;
    margin-top: 0;
    min-height: 40px;
    padding: 0.5rem 0.9rem;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

/* Compact single-line stat summary (replaces large stat cards on pages
   where the stats are secondary to the main content, e.g. Pricing Engine) */
.pe-stat-strip {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0 0 1.5rem;
}
.pe-stat-strip strong { color: var(--deep-purple); font-family: var(--font-display); }
.pe-stat-strip .pe-stat-sep { margin: 0 0.6rem; color: var(--border-strong); }

/* Tab interface — client-side only, no page navigation between tabs */
.pe-tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}
.pe-tab {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.7rem 1.1rem;
    font-family: var(--font-body);
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-muted);
    position: relative;
    transition: color var(--duration) var(--ease);
}
.pe-tab:hover { color: var(--brand-purple); }
.pe-tab.active { color: var(--deep-purple); }
.pe-tab.active::after {
    content: "";
    position: absolute;
    left: 0.3rem; right: 0.3rem; bottom: -1px;
    height: 2px;
    background: var(--gradient-gold);
    border-radius: 2px;
}
.pe-tab-panel { animation: fadeInUp var(--duration) var(--ease) both; }

/* Overview stat cards */
.pe-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.75rem; }
.pe-stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 1.1rem 1.3rem;
    transition: box-shadow var(--duration) var(--ease), transform var(--duration) var(--ease), border-color var(--duration) var(--ease);
    animation: fadeInUp var(--duration-slow) var(--ease-spring) both;
}
.pe-stat-grid .pe-stat-card:nth-child(1) { animation-delay: 0ms; }
.pe-stat-grid .pe-stat-card:nth-child(2) { animation-delay: 60ms; }
.pe-stat-grid .pe-stat-card:nth-child(3) { animation-delay: 120ms; }
.pe-stat-grid .pe-stat-card:nth-child(4) { animation-delay: 180ms; }
.pe-stat-grid .pe-stat-card:nth-child(5) { animation-delay: 240ms; }
.pe-stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.pe-stat-card .pe-stat-value { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; color: var(--deep-purple); line-height: 1.1; }
.pe-stat-card .pe-stat-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.3rem; }

/* Filter bar above data tables */
.filter-bar { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; margin-bottom: 1.1rem; }
.filter-bar .filter-field { display: flex; flex-direction: column; gap: 0.25rem; }
.filter-bar label { margin: 0; }
.filter-bar select, .filter-bar input { min-width: 160px; }

.search-input-wrap { position: relative; }
.search-input-wrap input { padding-right: 2.4rem; }
.search-input-wrap .search-spinner {
    position: absolute;
    right: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    width: 17px;
    height: 17px;
}

/* Two-column detail/edit layout */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }

/* Read-only key/value summary panel */
.kv-list { display: grid; grid-template-columns: auto 1fr; gap: 0.5rem 1rem; font-size: 0.9rem; }
.kv-list dt { color: var(--text-muted); font-weight: 600; }
.kv-list dd { margin: 0; }

/* Condition / rule builder rows (HTMX-driven add/remove) */
.builder-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    background: var(--surface-alt);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    font-size: 0.88rem;
    animation: fadeInUp var(--duration) var(--ease) both;
}
.builder-row .builder-row-label { flex: 1; }
.builder-row .builder-row-remove {
    background: none;
    border: none;
    color: var(--error);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius-sm);
    transition: background var(--duration) var(--ease);
}
.builder-row .builder-row-remove:hover { background: var(--error-bg); }

.inline-add-form { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: flex-end; margin-top: 0.75rem; padding-top: 0.9rem; border-top: 1px dashed var(--border-strong); }
.inline-add-form .filter-field { min-width: 140px; }
.inline-add-form label { margin-top: 0; }
.inline-add-form .btn-primary { margin-top: 0; min-height: 44px; padding: 0.55rem 1rem; font-size: 0.85rem; }

/* Compact sub-panel used to list related records inside a detail view */
.sub-panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; }
.sub-panel-header h3 { font-size: 0.95rem; margin: 0; color: var(--deep-purple); }
.mini-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.mini-table th, .mini-table td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border); }
.mini-table th { color: var(--text-muted); font-weight: 600; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; }
.mini-table tr:last-child td { border-bottom: none; }

.money { font-variant-numeric: tabular-nums; font-weight: 600; }

/* Financial figure blur/reveal — starts hidden on every page load (a
   privacy default, not a remembered preference, so it can't accidentally
   stay "revealed" on a shared or unattended screen), toggled per-page by
   a small eye button. */
.amount-blur-toggle {
    display: inline-flex; align-items: center; gap: 0.4rem;
    background: var(--surface); border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm); padding: 0.5rem 0.9rem;
    font-size: 0.85rem; font-weight: 600; color: var(--text-muted);
    cursor: pointer; transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}
.amount-blur-toggle:hover { background: var(--surface-alt); color: var(--deep-purple); }
.amount-blur-toggle svg { width: 16px; height: 16px; flex-shrink: 0; }
.amount-blur-toggle .icon-eye-off { display: none; }
body.amounts-revealed .amount-blur-toggle .icon-eye { display: none; }
body.amounts-revealed .amount-blur-toggle .icon-eye-off { display: inline; }
.amount-blur-toggle .label-hide { display: none; }
body.amounts-revealed .amount-blur-toggle .label-show { display: none; }
body.amounts-revealed .amount-blur-toggle .label-hide { display: inline; }

.blurrable-amount {
    filter: blur(6px);
    user-select: none;
    transition: filter var(--duration) var(--ease);
}
body.amounts-revealed .blurrable-amount { filter: none; user-select: text; }

.text-muted { color: var(--text-muted); }

/* Proposals overview — status breakdown bar chart */
/* Proposal status stepper — a visual progress indicator replacing a plain badge */
.status-stepper-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.6rem clamp(1rem, 4vw, 2rem) 1.4rem;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}
.status-stepper-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--gradient-gold);
}
.status-stepper { display: flex; align-items: flex-start; }
.status-step { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; flex-shrink: 0; width: 92px; }
.status-step-dot {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--surface-alt);
    border: 2px solid var(--border-strong);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem;
    color: var(--text-muted);
    transition: all var(--duration) var(--ease);
}
.status-step.done .status-step-dot { background: var(--brand-purple); border-color: var(--brand-purple); color: var(--white); }
.status-step.current .status-step-dot { background: var(--gold); border-color: var(--gold); color: var(--deep-purple); box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.25); }
.status-step.accepted .status-step-dot { background: var(--success); border-color: var(--success); color: var(--white); }
.status-step.declined .status-step-dot { background: var(--error); border-color: var(--error); color: var(--white); }
.status-step-label { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); text-align: center; line-height: 1.25; }
.status-step.done .status-step-label, .status-step.current .status-step-label, .status-step.accepted .status-step-label, .status-step.declined .status-step-label { color: var(--deep-purple); }
.status-step-connector { flex: 1; height: 2px; background: var(--border-strong); margin-top: 17px; min-width: 16px; transition: background var(--duration) var(--ease); }
.status-step-connector.done { background: var(--brand-purple); }
.status-archived-tag {
    position: absolute; top: 1rem; right: 1.5rem;
    font-size: 0.72rem; font-weight: 700; color: var(--text-muted);
    background: var(--surface-alt); padding: 0.3rem 0.7rem; border-radius: 999px;
    text-transform: uppercase; letter-spacing: 0.04em;
}
@media (max-width: 640px) {
    .status-step-label { font-size: 0.66rem; }
    .status-step { width: 56px; }
    .status-step-connector { min-width: 8px; }
}

/* Actions row directly below the stepper — the "what do I do next" row */
.status-actions-bar {
    display: flex; flex-wrap: wrap; align-items: center;
    justify-content: space-between; gap: 0.75rem;
    margin-bottom: 1.75rem;
}
.status-actions-bar form { margin: 0; }
.status-actions-forward, .status-actions-back { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.status-arrow { display: inline-block; font-size: 0.85em; }

/* Backward actions are deliberately quieter than forward ones — a ghost
   button, not an outlined one — so the eye is drawn to "what's next" and
   "go back" reads as the lower-emphasis escape hatch it actually is. */
.btn-back {
    display: inline-flex; align-items: center; gap: 0.4rem;
    background: none; border: 1px solid transparent;
    color: var(--text-muted); font-weight: 600; font-size: 0.9rem;
    padding: 0.65rem 1rem; border-radius: var(--radius-sm);
    cursor: pointer; transition: all var(--duration) var(--ease);
}
.btn-back:hover { background: var(--surface-alt); color: var(--deep-purple); border-color: var(--border); }

@media (max-width: 640px) {
    .status-actions-bar { justify-content: flex-start; }
    .status-actions-back { margin-left: 0; }
}
.btn-outline.btn-outline-success { color: var(--success); border-color: var(--success); }
.btn-outline.btn-outline-success:hover { background: var(--success); color: var(--white); border-color: var(--success); }
.btn-outline.btn-outline-danger { color: var(--error); border-color: var(--error); }
.btn-outline.btn-outline-danger:hover { background: var(--error); color: var(--white); border-color: var(--error); }

/* De-emphasized override section, kept apart from the guided flow */
.status-override-section {
    margin-top: 2rem;
    padding-top: 1.25rem;
    border-top: 1px dashed var(--border-strong);
}
.status-override-section summary {
    list-style: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.status-override-section summary::-webkit-details-marker { display: none; }
.status-override-section summary::before { content: "▸"; font-size: 0.7rem; transition: transform var(--duration) var(--ease); }
.status-override-section[open] summary::before { transform: rotate(90deg); }

/* Client profitability — revenue vs. cost comparison bars */
/* ============================================================
   Dashboard
   ============================================================ */
.dash-range-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.75rem; }
.dash-range-bar .subtitle { margin: 0; }

/* Pricing Engine — category tags, colour dots, grouped service tables */
/* Tag picker — "pick from a list, add with +" replacement for a native
   multi-select. Used for a service's categories and resources. */
.tag-picker-list {
    display: flex; flex-direction: column; gap: 0.4rem;
    margin-bottom: 0.6rem;
}
.tag-picker-list:empty { margin-bottom: 0; }
.tag-picker-item {
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.6rem;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    font-size: 0.88rem;
    animation: fadeInUp var(--duration) var(--ease) both;
}
.tag-picker-remove {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; flex-shrink: 0;
    background: none; border: none; border-radius: 50%;
    color: var(--text-muted); font-size: 1rem; line-height: 1; cursor: pointer;
    transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}
.tag-picker-remove:hover { background: var(--error-bg); color: var(--error); }
.tag-picker-add { display: flex; gap: 0.5rem; }
.tag-picker-add select { flex: 1; }
.btn-icon-add {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; flex-shrink: 0;
    background: var(--brand-purple); color: var(--white);
    border: none; border-radius: var(--radius-sm);
    font-size: 1.3rem; line-height: 1; cursor: pointer;
    transition: background var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.btn-icon-add:hover { background: var(--deep-purple); transform: translateY(-1px); }
.btn-icon-add:disabled { background: var(--border-strong); cursor: not-allowed; transform: none; }
.tag-picker-empty { font-size: 0.85rem; color: var(--text-muted); font-style: italic; }

/* Service picker — searchable combobox replacing a plain <select> for
   adding a service to a proposal. Filters client-side against embedded
   JSON (the full catalogue is already in the page either way), grouped
   by category with the same colour tags used in the Pricing Engine. */
.service-picker { position: relative; }
.service-picker-control {
    position: relative; display: flex; align-items: center;
    background: var(--surface); border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm); transition: box-shadow var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.service-picker-control:focus-within { border-color: var(--gold); box-shadow: var(--shadow-gold-glow); }
.service-picker-icon { position: absolute; left: 0.9rem; width: 17px; height: 17px; color: var(--text-muted); pointer-events: none; }
.service-picker-search {
    width: 100%; min-height: 44px; padding: 0.6rem 2.6rem 0.6rem 2.6rem;
    border: none; background: transparent; font-family: var(--font-body); font-size: 0.92rem; color: var(--text);
}
.service-picker-search:focus { outline: none; }
.service-picker.has-selection .service-picker-search { font-weight: 600; color: var(--deep-purple); }
.service-picker-clear {
    position: absolute; right: 0.6rem; width: 24px; height: 24px; border-radius: 50%;
    display: none; align-items: center; justify-content: center;
    background: none; border: none; color: var(--text-muted); font-size: 1.1rem; line-height: 1; cursor: pointer;
    transition: background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}
.service-picker.has-selection .service-picker-clear { display: flex; }
.service-picker-clear:hover { background: var(--error-bg); color: var(--error); }

.service-picker-dropdown {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60;
    max-height: 340px; overflow-y: auto;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.4rem;
    animation: dropdownIn var(--duration) var(--ease) both;
}
.service-picker-group-label {
    display: flex; align-items: center; gap: 0.4rem;
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted);
    padding: 0.55rem 0.6rem 0.3rem;
}
.service-picker-group-label:not(:first-child) { margin-top: 0.3rem; border-top: 1px solid var(--border); padding-top: 0.6rem; }
.service-picker-option {
    display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
    padding: 0.6rem 0.7rem; border-radius: var(--radius-sm); cursor: pointer;
    transition: background var(--duration-fast) var(--ease);
}
.service-picker-option:hover, .service-picker-option.is-highlighted { background: var(--surface-alt); }
.service-picker-option-name { font-size: 0.9rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.service-picker-option-name mark { background: var(--gold-soft); color: var(--deep-purple); border-radius: 3px; padding: 0 1px; }
.service-picker-option-price { font-size: 0.82rem; font-weight: 600; color: var(--brand-purple); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.service-picker-empty { padding: 1rem 0.7rem; text-align: center; color: var(--text-muted); font-size: 0.88rem; }

/* Security page */
.security-alert-card { border-left: 4px solid var(--gold); margin-bottom: 1.5rem; }
.security-filters {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 1rem; margin-bottom: 1.25rem;
}
.security-search-form { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.security-search-form select, .security-search-form input[type="text"] { min-height: 44px; width: auto; }
.security-search-form input[type="text"] { min-width: 220px; }

/* Flash toast — a transient confirmation after a redirect (e.g. "Client created") */
.flash-toast {
    position: fixed; top: 1.25rem; right: 1.25rem; z-index: 1000;
    display: flex; align-items: center; gap: 0.6rem;
    background: var(--surface); border-radius: var(--radius-md);
    box-shadow: var(--shadow-md), 0 0 0 1px rgba(0,0,0,0.04);
    padding: 0.85rem 1rem; max-width: 360px;
    font-size: 0.9rem; font-weight: 600;
    animation: flashToastIn var(--duration-slow) var(--ease) both;
}
.flash-toast--leaving { animation: flashToastOut 0.3s var(--ease) both; }
.flash-toast svg { width: 20px; height: 20px; flex-shrink: 0; }
.flash-toast--success { color: var(--success); border-left: 3px solid var(--success); }
.flash-toast--error { color: var(--error); border-left: 3px solid var(--error); }
.flash-toast span { color: var(--text); flex: 1; }
.flash-toast button { background: none; border: none; color: var(--text-muted); font-size: 1.1rem; cursor: pointer; line-height: 1; padding: 0 0.2rem; }
.flash-toast button:hover { color: var(--text); }
@keyframes flashToastIn { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes flashToastOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-12px); } }
@media (max-width: 640px) { .flash-toast { left: 1rem; right: 1rem; max-width: none; } }

.category-tag {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    margin: 0 0.3rem 0.2rem 0;
    white-space: nowrap;
}
.category-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 0.5rem; vertical-align: middle; }
.pe-category-group { margin-bottom: 2rem; }
.pe-category-heading { display: flex; align-items: center; font-size: 1rem; margin: 0 0 0.6rem; color: var(--deep-purple); }
select[multiple] { padding: 0.4rem; }

.dash-kpi-grid { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.75rem; }
.dash-kpi-card {
    flex: 1 1 160px;
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.4rem;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow var(--duration) var(--ease), transform var(--duration) var(--ease), border-color var(--duration) var(--ease);
    animation: fadeInUp var(--duration-slow) var(--ease-spring) both;
}
.dash-kpi-grid .dash-kpi-card:nth-child(1) { animation-delay: 0ms; }
.dash-kpi-grid .dash-kpi-card:nth-child(2) { animation-delay: 60ms; }
.dash-kpi-grid .dash-kpi-card:nth-child(3) { animation-delay: 120ms; }
.dash-kpi-grid .dash-kpi-card:nth-child(4) { animation-delay: 180ms; }
.dash-kpi-grid .dash-kpi-card:nth-child(5) { animation-delay: 240ms; }
.dash-kpi-grid .dash-kpi-card:nth-child(6) { animation-delay: 300ms; }
.dash-kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.dash-kpi-card::before {
    content: "";
    position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.dash-kpi-card::after {
    content: "";
    position: absolute; top: -40%; right: -20%; width: 60%; height: 90%;
    background: radial-gradient(circle, currentColor, transparent 70%);
    opacity: 0; transition: opacity var(--duration-slow) var(--ease);
    pointer-events: none;
}
.dash-kpi-card:hover::after { opacity: 0.05; }
.dash-kpi-card.accent-purple::before { background: var(--gradient-brand); }
.dash-kpi-card.accent-gold::before { background: var(--gradient-gold); }
.dash-kpi-card.accent-success::before { background: var(--success); }
.dash-kpi-card.accent-info::before { background: var(--brand-purple); }
.dash-kpi-card.accent-purple { color: var(--brand-purple); }
.dash-kpi-card.accent-gold { color: var(--gold); }
.dash-kpi-card.accent-gold .dash-kpi-icon svg { color: var(--deep-purple); }
.dash-kpi-card.accent-success { color: var(--success); }
.dash-kpi-card.accent-info { color: var(--brand-purple); }
.dash-kpi-icon {
    width: 36px; height: 36px; border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, currentColor, transparent 130%);
    background-color: var(--surface-alt);
    margin-bottom: 0.75rem;
    transition: transform var(--duration) var(--ease-spring);
}
.dash-kpi-card:hover .dash-kpi-icon { transform: scale(1.08) rotate(-4deg); }
.dash-kpi-icon svg { width: 18px; height: 18px; position: relative; z-index: 1; }
.dash-kpi-value { font-family: var(--font-display); font-size: 1.65rem; font-weight: 700; color: var(--deep-purple); line-height: 1.15; }
.dash-kpi-label { font-size: 0.82rem; color: var(--text-muted); font-weight: 600; margin-top: 0.3rem; }
.dash-kpi-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.35rem; }

.dash-charts-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.25rem; margin-bottom: 1.25rem; align-items: stretch; }
.dash-lower-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
@media (max-width: 1000px) { .dash-charts-grid, .dash-lower-grid { grid-template-columns: 1fr; } }

.dash-chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 1.4rem 1.5rem; }
.dash-chart-card h3 { margin: 0 0 1rem; font-size: 1rem; }
.dash-chart-canvas-wrap { position: relative; height: 240px; }
.dash-chart-canvas-wrap.small { height: 200px; }

.dash-rank-list { display: flex; flex-direction: column; gap: 0.65rem; }
.dash-rank-row { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; align-items: center; }
.dash-rank-name { font-size: 0.85rem; color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-rank-value { font-size: 0.85rem; font-weight: 700; color: var(--deep-purple); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dash-rank-track { grid-column: 1 / -1; height: 6px; background: var(--surface-alt); border-radius: 999px; overflow: hidden; margin-top: -0.35rem; }
.dash-rank-fill { height: 100%; border-radius: 999px; background: var(--gradient-gold); }

.profit-bars { display: flex; flex-direction: column; gap: 0.7rem; }
.profit-bar-row { display: grid; grid-template-columns: 70px 1fr 80px; align-items: center; gap: 0.75rem; }
.profit-bar-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.profit-bar-track { height: 12px; background: var(--surface-alt); border-radius: 999px; overflow: hidden; }
.profit-bar-fill { height: 100%; border-radius: 999px; transition: width var(--duration-slow) var(--ease); min-width: 3px; }
.profit-bar-fill.profit-bar-revenue { background: var(--gradient-gold); }
.profit-bar-fill.profit-bar-cost { background: var(--text-muted); }
.profit-bar-value { text-align: right; font-weight: 700; color: var(--deep-purple); font-variant-numeric: tabular-nums; font-size: 0.9rem; }

.status-bar-chart { display: flex; flex-direction: column; gap: 0.6rem; }
.status-bar-row { display: grid; grid-template-columns: 130px 1fr 2rem; align-items: center; gap: 0.75rem; }
.status-bar-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.status-bar-track { height: 10px; background: var(--surface-alt); border-radius: 999px; overflow: hidden; }
.status-bar-fill { height: 100%; border-radius: 999px; transition: width var(--duration-slow) var(--ease); min-width: 2px; }
.status-bar-count { text-align: right; font-size: 0.85rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.status-bar-fill.badge-muted { background: var(--text-muted); }
.status-bar-fill.badge-warning { background: var(--warning); }
.status-bar-fill.badge-info { background: var(--brand-purple); }
.status-bar-fill.badge-success { background: var(--success); }
.status-bar-fill.badge-error { background: var(--error); }
@media (max-width: 640px) { .status-bar-row { grid-template-columns: 100px 1fr 1.5rem; } }

/* ============================================================
   Modal dialog (native <dialog>) — used for seamless Service create/edit
   ============================================================ */
.modal {
    border: none;
    border-radius: var(--radius-lg);
    padding: 0;
    box-shadow: var(--shadow-lg);
    width: min(640px, 92vw);
    max-height: 88vh;
    overflow-y: auto;
    background: var(--surface);
}
.modal::backdrop {
    background: rgba(36, 21, 49, 0.55);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}
.modal[open] { animation: modalIn var(--duration-slow) var(--ease-spring) both; }
@keyframes modalIn { from { opacity: 0; transform: scale(0.96) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal > div { padding: 1.75rem; }
.modal-header { margin-bottom: 1rem; }
.modal-header h2 { font-size: 1.3rem; margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.75rem; margin-top: 1.5rem; }

.btn-secondary {
    margin-top: 0;
    padding: 0.65rem 1.2rem;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.btn-secondary:hover { background: var(--surface-alt); border-color: var(--brand-purple); }

.btn-outline {
    margin-top: 0;
    padding: 0.65rem 1.2rem;
    background: transparent;
    color: var(--brand-purple);
    border: 1.5px solid var(--brand-purple);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    transition: background var(--duration) var(--ease), color var(--duration) var(--ease), border-color var(--duration) var(--ease), transform var(--duration-fast) var(--ease);
}
.btn-outline svg { width: 16px; height: 16px; }
.btn-outline:hover { background: var(--gradient-brand); color: var(--white); border-color: transparent; transform: translateY(-1px); }
.btn-outline:active { transform: translateY(0); }

.btn-danger {
    margin-top: 0;
    padding: 0.65rem 1.2rem;
    background: var(--error);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--duration) var(--ease), transform var(--duration-fast) var(--ease);
}
.btn-danger:hover { background: #942018; transform: translateY(-1px); }
.btn-danger:active { transform: translateY(0); }

.confirm-modal { width: min(420px, 90vw); }
.confirm-modal > div { padding: 2rem 1.75rem 1.75rem; text-align: center; }
.confirm-modal-icon {
    width: 44px; height: 44px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: var(--error-bg);
    color: var(--error);
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.confirm-modal #confirm-modal-message { font-size: 0.98rem; color: var(--text); margin: 0 0 0.5rem; line-height: 1.5; }
.confirm-modal .modal-actions { justify-content: center; margin-top: 1.5rem; }

.link-button-danger { color: var(--error); }
.link-button-danger:hover { color: #7a160e; border-color: var(--error); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row > div { display: flex; flex-direction: column; }
@media (max-width: 640px) { .form-row, .form-row-3 { grid-template-columns: 1fr; } }

.segmented-control {
    display: inline-flex;
    background: var(--surface-alt);
    border-radius: var(--radius-sm);
    padding: 0.25rem;
    gap: 0.25rem;
    margin-bottom: 1rem;
}
.segmented-option {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.9rem;
    border-radius: calc(var(--radius-sm) - 2px);
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
    margin: 0;
}
.segmented-option input[type="radio"] { accent-color: var(--brand-purple); margin: 0; }
.segmented-option:has(input:checked) { background: var(--surface); color: var(--deep-purple); box-shadow: var(--shadow-sm); }

.reorder-arrows { display: flex; flex-direction: column; gap: 0; }
.reorder-arrows form { margin: 0; }
.reorder-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.65rem;
    line-height: 1;
    padding: 0.15rem 0.3rem;
    border-radius: 3px;
    transition: color var(--duration) var(--ease), background var(--duration) var(--ease);
}
.reorder-btn:hover:not(:disabled) { color: var(--brand-purple); background: var(--surface-alt); }
.reorder-btn:disabled { opacity: 0.25; cursor: default; }

.archive-section {
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px dashed var(--border-strong);
}
.archive-section summary {
    list-style: none;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    user-select: none;
}
.archive-section summary::-webkit-details-marker { display: none; }
.archive-section summary::before {
    content: "▸";
    font-size: 0.7rem;
    transition: transform var(--duration) var(--ease);
}
.archive-section[open] summary::before { transform: rotate(90deg); }
.archive-section .lookup-row { opacity: 0.75; }
.archive-section .archived-name { flex: 1; font-size: 0.88rem; color: var(--text-muted); }


/* ============================================================
   Responsive — tablet & mobile
   ============================================================ */
@media (max-width: 900px) {
    .nav-toggle { display: inline-flex; }
    .nav {
        position: fixed;
        inset: 66px 0 auto 0;
        margin-left: 0;
        flex-direction: column;
        align-items: stretch;
        background: var(--deep-purple);
        padding: 0.75rem;
        gap: 0.15rem;
        box-shadow: var(--shadow-lg);
        transform: translateY(-8px);
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease);
        z-index: 39;
    }
    .nav.nav-open { transform: translateY(0); opacity: 1; pointer-events: auto; }
    .nav a { padding: 0.85rem 1rem; font-size: 1rem; }
    .nav-dropdown summary { padding: 0.85rem 1rem; font-size: 1rem; }
    .nav-dropdown-menu {
        position: static;
        box-shadow: none;
        border: none;
        background: transparent;
        padding: 0 0 0 1rem;
        animation: none;
    }
    .nav-dropdown-menu a { color: var(--text-on-dark-muted); padding: 0.7rem 1rem; }
    .nav-dropdown-menu a:hover { background: rgba(255, 255, 255, 0.08); color: var(--white); }
    .user-menu { gap: 0.6rem; }
    .user-menu span:first-child { display: none; }
}

@media (max-width: 640px) {
    .topbar { padding: 0.7rem 1rem; }
    .brand-logo { height: 28px; }
    .role-pill { display: none; }

    /* Card-ify the data table for small screens */
    .data-table thead { display: none; }
    .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table tr {
        border-bottom: 1px solid var(--border);
        padding: 0.9rem 1rem;
    }
    .data-table td {
        border: none;
        padding: 0.3rem 0;
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        text-align: right;
    }
    .data-table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--text-muted);
        font-size: 0.72rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        text-align: left;
    }
    .data-table td.actions { justify-content: flex-start; gap: 0.75rem; }
    .data-table td.actions::before { content: none; }

    .page-header { flex-direction: column; align-items: stretch; }
    .btn-primary { width: 100%; }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .container { max-width: 92vw; }
    .card-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}
