/* ================================================================================================
   ZuriPay staff UI — design system (ADR-009, refreshed by ADR-029).

   One stylesheet for every staff surface: the HQ/admin shell, Customer Care, sign-in, and the tokens the
   lane (Pos.razor.css) and till aliases. Organised top-down:
     1 fonts · 2 tokens · 3 base · 4 app shell · 5 page scaffold · 6 components · 7 legacy hooks kept for
     pages/tests · 8 utilities · 9 motion & print.
   Offline-safe: the only font is self-hosted (fonts/, OFL); nothing loads from a CDN, because edge nodes
   run without internet.
   ================================================================================================ */

/* ---- 1. Fonts ------------------------------------------------------------------------------------ */
@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url("fonts/manrope-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url("fonts/manrope-latin-ext.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---- 2. Tokens ----------------------------------------------------------------------------------
   Names are stable: the lane (Pos.razor.css), till, sign-in and Customer Care all read --zp-*. New tokens
   were added; none were renamed. */
:root,
:root[data-theme="light"] {
    --zp-bg:        #f4f6f5;
    --zp-bg-2:      #eceff0;
    --zp-surface:   #ffffff;
    --zp-surface-2: #f8faf9;
    --zp-elevated:  #ffffff;
    --zp-sunken:    rgba(15, 35, 28, 0.045);
    --zp-veil:      rgba(255, 255, 255, 0.86);
    --zp-line:        rgba(15, 35, 28, 0.09);
    --zp-line-strong: rgba(15, 35, 28, 0.16);
    --zp-text:       #0f1c17;
    --zp-text-dim:   #4a5a53;
    --zp-text-faint: #66776f;   /* 4.6:1 on white — still AA for small text */

    /* #00a676 is a fill colour; accent *text* uses the darker tone that clears WCAG AA. */
    --zp-accent:       #00a676;
    --zp-accent-2:     #008a62;
    --zp-accent-text:  #00674a;
    --zp-accent-bright:#00a676;
    --zp-on-accent:    #ffffff;
    --zp-accent-soft:  rgba(0, 166, 118, 0.10);
    --zp-accent-line:  rgba(0, 166, 118, 0.34);

    --zp-success:      #0a7a53;
    --zp-success-soft: rgba(10, 122, 83, 0.10);
    --zp-info:         #1f5fbf;
    --zp-info-soft:    rgba(31, 95, 191, 0.09);
    --zp-info-line:    rgba(31, 95, 191, 0.30);
    --zp-warn:         #8f6210;
    --zp-warn-soft:    rgba(176, 121, 20, 0.11);
    --zp-warn-line:    rgba(176, 121, 20, 0.36);
    --zp-danger:       #b3261e;
    --zp-danger-soft:  rgba(179, 38, 30, 0.08);
    --zp-danger-line:  rgba(179, 38, 30, 0.30);

    /* The deep emerald sidebar is the same in both themes — it anchors the brand. */
    --zp-nav-bg:          #0b2a20;
    --zp-nav-bg-2:        #0e3327;
    --zp-nav-text:        rgba(226, 243, 235, 0.74);
    --zp-nav-text-strong: #f2faf6;
    --zp-nav-group:       rgba(226, 243, 235, 0.46);
    --zp-nav-hover:       rgba(255, 255, 255, 0.06);
    --zp-nav-active:      rgba(31, 236, 170, 0.14);
    --zp-nav-active-text: #8ef5d0;
    --zp-nav-line:        rgba(255, 255, 255, 0.08);
    --zp-area:            #1fecaa;   /* per-area accent; Customer Care overrides */

    --zp-aurora-1: rgba(0, 166, 118, 0.08);
    --zp-aurora-2: rgba(0, 120, 90, 0.05);
    --zp-grain:    0.018;
    --zp-shadow-1:  0 1px 2px rgba(15, 35, 28, 0.06);
    --zp-shadow:    0 1px 2px rgba(15, 35, 28, 0.05), 0 6px 20px -12px rgba(15, 35, 28, 0.22);
    --zp-shadow-lg: 0 2px 6px rgba(15, 35, 28, 0.05), 0 24px 60px -30px rgba(15, 35, 28, 0.40);

    --zp-radius:    12px;
    --zp-radius-sm: 9px;
    --zp-radius-xs: 7px;
    --zp-font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    --zp-mono: ui-monospace, "Cascadia Code", "SF Mono", "JetBrains Mono", "Roboto Mono", Consolas, monospace;
    --zp-ease: cubic-bezier(0.22, 1, 0.36, 1);

    --zp-1: 4px; --zp-2: 8px; --zp-3: 12px; --zp-4: 16px; --zp-5: 20px; --zp-6: 24px; --zp-7: 32px; --zp-8: 48px;
    --zp-z-sticky: 20; --zp-z-sidebar: 40; --zp-z-overlay: 60; --zp-z-drawer: 70; --zp-z-palette: 90; --zp-z-toast: 100;

    --zp-sidebar-w: 256px;
    --zp-sidebar-rail: 68px;
    --zp-topbar-h: 60px;

    color-scheme: light;
}

:root[data-theme="dark"] {
    --zp-bg:        #0a0f0d;
    --zp-bg-2:      #0d1411;
    --zp-surface:   #111916;
    --zp-surface-2: #151f1b;
    --zp-elevated:  #1a2621;
    --zp-sunken:    rgba(0, 0, 0, 0.25);
    --zp-veil:      rgba(10, 15, 13, 0.82);
    --zp-line:        rgba(255, 255, 255, 0.075);
    --zp-line-strong: rgba(255, 255, 255, 0.14);
    --zp-text:       #e8f0ec;
    --zp-text-dim:   #9aaca3;
    --zp-text-faint: #73867c;

    --zp-accent:       #00d494;
    --zp-accent-2:     #00b07c;
    --zp-accent-text:  #4fe3b3;
    --zp-accent-bright:#14f2af;
    --zp-on-accent:    #03140e;
    --zp-accent-soft:  rgba(0, 212, 148, 0.13);
    --zp-accent-line:  rgba(0, 212, 148, 0.36);

    --zp-success:      #4fe3b3;
    --zp-success-soft: rgba(79, 227, 179, 0.12);
    --zp-info:         #7fb2ff;
    --zp-info-soft:    rgba(127, 178, 255, 0.12);
    --zp-info-line:    rgba(127, 178, 255, 0.34);
    --zp-warn:         #f2b552;
    --zp-warn-soft:    rgba(242, 181, 82, 0.12);
    --zp-warn-line:    rgba(242, 181, 82, 0.40);
    --zp-danger:       #ff8a80;
    --zp-danger-soft:  rgba(255, 138, 128, 0.11);
    --zp-danger-line:  rgba(255, 138, 128, 0.34);

    --zp-nav-bg:   #07150f;
    --zp-nav-bg-2: #0a1d15;

    --zp-aurora-1: rgba(0, 212, 148, 0.08);
    --zp-aurora-2: rgba(0, 120, 90, 0.08);
    --zp-grain:    0.35;
    --zp-shadow-1:  0 1px 2px rgba(0, 0, 0, 0.5);
    --zp-shadow:    0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 30px -18px rgba(0, 0, 0, 0.8);
    --zp-shadow-lg: 0 30px 70px -30px rgba(0, 0, 0, 0.9);

    color-scheme: dark;
}

/* ---- 3. Base ------------------------------------------------------------------------------------- */
html, body {
    font-family: var(--zp-font);
    background: var(--zp-bg);
    color: var(--zp-text);
    -webkit-font-smoothing: antialiased;
}
h1:focus { outline: none; }
a { color: var(--zp-accent-text); }
:focus-visible { outline: 2px solid var(--zp-accent); outline-offset: 2px; }
::selection { background: var(--zp-accent-soft); }
kbd, .kbd {
    display: inline-flex; align-items: center; justify-content: center; min-width: 1.4em;
    padding: 0.05rem 0.35rem; border-radius: 5px;
    font: 600 0.72em var(--zp-mono); line-height: 1.5;
    color: var(--zp-text-dim); background: var(--zp-surface-2);
    border: 1px solid var(--zp-line-strong); border-bottom-width: 2px;
}

.valid.modified:not([type=checkbox]) { outline: 1px solid var(--zp-success); }
.invalid { outline: 1px solid var(--zp-danger); }
.validation-message { color: var(--zp-danger); }
.blazor-error-boundary { background: var(--zp-danger); padding: 1rem 1rem 1rem 1.5rem; color: #fff; border-radius: var(--zp-radius-sm); }
.blazor-error-boundary::after { content: "An error has occurred."; }

/* ---- 4. App shell (Admin + Customer Care) ---------------------------------------------------------- */
.app-shell {
    display: grid;
    grid-template-columns: var(--zp-sidebar-w) minmax(0, 1fr);
    min-height: 100vh;
    background: var(--zp-bg);
    color: var(--zp-text);
    font-family: var(--zp-font);
}
:root[data-sidebar="collapsed"] .app-shell { grid-template-columns: var(--zp-sidebar-rail) minmax(0, 1fr); }
.app-shell[data-area="customer-care"] { --zp-area: #ffa24a; --zp-nav-active: rgba(255, 162, 74, 0.15); --zp-nav-active-text: #ffc58f; }

.app-sidebar {
    position: sticky; top: 0; height: 100vh; z-index: var(--zp-z-sidebar);
    display: flex; flex-direction: column;
    background: linear-gradient(180deg, var(--zp-nav-bg-2), var(--zp-nav-bg));
    color: var(--zp-nav-text);
    border-right: 1px solid rgba(0, 0, 0, 0.2);
}
.app-brand {
    display: flex; align-items: center; gap: 0.7rem;
    padding: 1.05rem 1.1rem 0.95rem; text-decoration: none; color: var(--zp-nav-text-strong);
    min-height: var(--zp-topbar-h);
}
.app-brand-logo { width: 34px; height: 34px; border-radius: 10px; flex: none; box-shadow: 0 6px 16px -8px rgba(0, 0, 0, 0.6); }
.app-brand-text { display: grid; line-height: 1.15; min-width: 0; }
.app-brand-name { font-weight: 800; font-size: 1.05rem; letter-spacing: -0.02em; }
.app-brand-area { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--zp-area); white-space: nowrap; }

.area-switch {
    display: flex; gap: 4px; margin: 0 0.85rem 0.6rem; padding: 3px;
    background: rgba(0, 0, 0, 0.22); border: 1px solid var(--zp-nav-line); border-radius: 10px;
}
.area-switch a {
    flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
    padding: 0.38rem 0.4rem; border-radius: 7px; text-decoration: none;
    font-size: 0.74rem; font-weight: 650; color: var(--zp-nav-text); white-space: nowrap;
}
.area-switch a:hover { color: var(--zp-nav-text-strong); background: var(--zp-nav-hover); }
.area-switch a[aria-current="true"] { background: rgba(255, 255, 255, 0.1); color: var(--zp-nav-text-strong); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }
.area-switch svg { width: 15px; height: 15px; flex: none; }

.app-nav { flex: 1; overflow-y: auto; padding: 0.2rem 0.6rem 1rem; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.15) transparent; }
.nav-group { margin: 0 0 0.15rem; }
.nav-group > summary {
    list-style: none; cursor: pointer; user-select: none;
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.5rem 0.6rem; border-radius: 8px;
    font-size: 0.7rem; font-weight: 750; letter-spacing: 0.09em; text-transform: uppercase;
    color: var(--zp-nav-group);
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:hover { color: var(--zp-nav-text-strong); background: var(--zp-nav-hover); }
.nav-group > summary .nav-group-icon { width: 16px; height: 16px; flex: none; opacity: 0.85; }
.nav-group > summary .nav-chev { margin-left: auto; width: 14px; height: 14px; transition: transform 0.18s var(--zp-ease); }
.nav-group[open] > summary .nav-chev { transform: rotate(90deg); }
.nav-items { display: grid; gap: 1px; padding: 0.1rem 0 0.45rem; }
.side-link {
    position: relative; display: flex; align-items: center; gap: 0.65rem;
    padding: 0.46rem 0.65rem 0.46rem 2.15rem; border-radius: 8px;
    color: var(--zp-nav-text); text-decoration: none; font-size: 0.875rem; font-weight: 550;
    transition: background 0.14s, color 0.14s;
}
.side-link:hover { background: var(--zp-nav-hover); color: var(--zp-nav-text-strong); }
.side-link.active { background: var(--zp-nav-active); color: var(--zp-nav-active-text); font-weight: 700; }
.side-link.active::before {
    content: ""; position: absolute; left: 0.95rem; top: 50%; translate: 0 -50%;
    width: 6px; height: 6px; border-radius: 50%; background: var(--zp-area); box-shadow: 0 0 10px var(--zp-area);
}
.side-link-icon { display: none; width: 18px; height: 18px; flex: none; }
.side-link-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.app-sidebar-foot { display: grid; gap: 2px; padding: 0.6rem; border-top: 1px solid var(--zp-nav-line); }
.app-sidebar-foot a, .app-sidebar-foot button {
    display: flex; align-items: center; gap: 0.65rem; width: 100%;
    padding: 0.5rem 0.65rem; border-radius: 8px; border: 0; background: transparent; cursor: pointer;
    color: var(--zp-nav-text); text-decoration: none; font: 600 0.84rem var(--zp-font); text-align: left; justify-content: flex-start;
}
.app-sidebar-foot a:hover, .app-sidebar-foot button:hover { background: var(--zp-nav-hover); color: var(--zp-nav-text-strong); }
.app-sidebar-foot svg { width: 18px; height: 18px; flex: none; }

/* Collapsed rail: icons only, labels as tooltips (title attributes). */
:root[data-sidebar="collapsed"] .app-brand-text,
:root[data-sidebar="collapsed"] .area-switch span,
:root[data-sidebar="collapsed"] .nav-group > summary > span,
:root[data-sidebar="collapsed"] .nav-group > summary .nav-chev,
:root[data-sidebar="collapsed"] .side-link-label,
:root[data-sidebar="collapsed"] .app-sidebar-foot span { display: none; }
:root[data-sidebar="collapsed"] .app-brand { justify-content: center; padding-inline: 0; }
:root[data-sidebar="collapsed"] .area-switch { flex-direction: column; margin-inline: 0.55rem; }
:root[data-sidebar="collapsed"] .nav-group > summary { justify-content: center; padding: 0.55rem 0; }
:root[data-sidebar="collapsed"] .nav-group:not([open]) .nav-items { display: grid; }
:root[data-sidebar="collapsed"] .side-link { justify-content: center; padding: 0.55rem 0; }
:root[data-sidebar="collapsed"] .side-link::before { display: none; }
:root[data-sidebar="collapsed"] .side-link-icon { display: block; }
:root[data-sidebar="collapsed"] .nav-group > summary { display: none; }
:root[data-sidebar="collapsed"] .nav-group + .nav-group { border-top: 1px solid var(--zp-nav-line); padding-top: 0.25rem; margin-top: 0.25rem; }
:root[data-sidebar="collapsed"] .app-sidebar-foot a,
:root[data-sidebar="collapsed"] .app-sidebar-foot button { justify-content: center; }

.app-body { display: flex; flex-direction: column; min-width: 0; }
.app-topbar {
    position: sticky; top: 0; z-index: var(--zp-z-sticky);
    display: flex; align-items: center; gap: 0.75rem;
    min-height: var(--zp-topbar-h); padding: 0 1.5rem;
    background: var(--zp-veil); backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--zp-line);
}
.app-topbar .topbar-menu { display: none; }
.breadcrumb-trail { display: flex; align-items: center; gap: 0.35rem; min-width: 0; margin: 0; padding: 0; list-style: none; font-size: 0.86rem; color: var(--zp-text-faint); }
.breadcrumb-trail li { display: inline-flex; align-items: center; gap: 0.35rem; white-space: nowrap; }
.breadcrumb-trail li + li::before { content: "/"; color: var(--zp-line-strong); }
.breadcrumb-trail a { color: var(--zp-text-dim); text-decoration: none; }
.breadcrumb-trail a:hover { color: var(--zp-text); }
.breadcrumb-trail [aria-current="page"] { color: var(--zp-text); font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.topbar-spacer { flex: 1; }

.palette-trigger {
    display: inline-flex; align-items: center; gap: 0.55rem;
    min-width: 260px; height: 38px; padding: 0 0.5rem 0 0.75rem;
    border: 1px solid var(--zp-line-strong); border-radius: 10px; background: var(--zp-surface);
    color: var(--zp-text-faint); font: 500 0.86rem var(--zp-font); cursor: pointer;
    box-shadow: var(--zp-shadow-1);
}
.palette-trigger:hover { border-color: var(--zp-accent-line); color: var(--zp-text-dim); }
.palette-trigger svg { width: 16px; height: 16px; flex: none; }
.palette-trigger .kbd { margin-left: auto; }

.icon-button {
    display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none;
    border-radius: 10px; border: 1px solid var(--zp-line-strong); background: var(--zp-surface);
    color: var(--zp-text-dim); cursor: pointer; box-shadow: var(--zp-shadow-1);
}
.icon-button:hover { color: var(--zp-text); border-color: var(--zp-accent-line); }
.icon-button svg { width: 18px; height: 18px; }
:root[data-theme="dark"] .theme-icon-moon, :root:not([data-theme="dark"]) .theme-icon-sun { display: none; }

.user-menu { position: relative; }
.user-menu > summary {
    list-style: none; cursor: pointer; display: flex; align-items: center; gap: 0.6rem;
    padding: 0.25rem 0.45rem 0.25rem 0.25rem; border-radius: 12px;
}
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary:hover { background: var(--zp-sunken); }
.avatar {
    width: 34px; height: 34px; border-radius: 10px; flex: none; display: grid; place-items: center;
    font-weight: 800; font-size: 0.82rem; color: var(--zp-on-accent);
    background: linear-gradient(140deg, var(--zp-accent), var(--zp-accent-2));
}
.user-meta { display: grid; line-height: 1.2; text-align: left; }
.user-name { font-weight: 700; font-size: 0.86rem; color: var(--zp-text); }
.user-role { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--zp-text-faint); }
.menu-panel {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: var(--zp-z-overlay);
    width: 240px; padding: 0.4rem; border-radius: var(--zp-radius);
    background: var(--zp-elevated); border: 1px solid var(--zp-line-strong); box-shadow: var(--zp-shadow-lg);
    animation: zp-pop 0.16s var(--zp-ease);
}
.menu-panel a, .menu-panel button {
    display: flex; align-items: center; gap: 0.6rem; width: 100%;
    padding: 0.55rem 0.65rem; border: 0; border-radius: 8px; background: transparent; cursor: pointer;
    color: var(--zp-text); text-decoration: none; font: 600 0.86rem var(--zp-font); text-align: left;
}
.menu-panel a:hover, .menu-panel button:hover { background: var(--zp-sunken); }
.menu-panel svg { width: 17px; height: 17px; color: var(--zp-text-dim); flex: none; }
.menu-panel hr { border: 0; border-top: 1px solid var(--zp-line); margin: 0.35rem 0; }
.menu-panel form { margin: 0; }
.menu-panel .danger { color: var(--zp-danger); }
.menu-panel .danger svg { color: var(--zp-danger); }

.app-main { padding: 1.75rem 2rem 3rem; min-width: 0; }
.sidebar-scrim { display: none; }

/* Command palette */
.palette {
    width: min(640px, calc(100vw - 32px)); max-height: min(560px, 80vh);
    margin: 12vh auto auto; padding: 0; border: 1px solid var(--zp-line-strong); border-radius: 14px;
    background: var(--zp-elevated); color: var(--zp-text); box-shadow: var(--zp-shadow-lg);
    overflow: hidden;
}
.palette[open] { display: flex; flex-direction: column; animation: zp-pop 0.18s var(--zp-ease); }
.palette::backdrop { background: rgba(5, 15, 11, 0.45); backdrop-filter: blur(2px); }
.palette-search { display: flex; align-items: center; gap: 0.65rem; padding: 0.85rem 1rem; border-bottom: 1px solid var(--zp-line); }
.palette-search svg { width: 18px; height: 18px; color: var(--zp-text-faint); flex: none; }
.palette-search input { flex: 1; border: 0; outline: none; background: transparent; color: var(--zp-text); font: 500 1rem var(--zp-font); }
.palette-list { list-style: none; margin: 0; padding: 0.4rem; overflow-y: auto; }
.palette-section { padding: 0.55rem 0.65rem 0.3rem; font-size: 0.68rem; font-weight: 750; letter-spacing: 0.09em; text-transform: uppercase; color: var(--zp-text-faint); }
.palette-item {
    display: flex; align-items: center; gap: 0.7rem; padding: 0.55rem 0.65rem; border-radius: 9px; cursor: pointer;
    font-size: 0.92rem; color: var(--zp-text);
}
.palette-item svg { width: 17px; height: 17px; color: var(--zp-text-dim); flex: none; }
.palette-item .palette-group { margin-left: auto; font-size: 0.76rem; color: var(--zp-text-faint); }
.palette-item[aria-selected="true"] { background: var(--zp-accent-soft); color: var(--zp-accent-text); }
.palette-item[aria-selected="true"] svg { color: var(--zp-accent-text); }
.palette-empty { padding: 1.4rem; text-align: center; color: var(--zp-text-faint); font-size: 0.9rem; }
.palette-foot { display: flex; gap: 1rem; padding: 0.55rem 1rem; border-top: 1px solid var(--zp-line); font-size: 0.74rem; color: var(--zp-text-faint); }
.palette-foot span { display: inline-flex; align-items: center; gap: 0.3rem; }

@media (max-width: 900px) {
    .app-shell, :root[data-sidebar="collapsed"] .app-shell { grid-template-columns: minmax(0, 1fr); }
    .app-sidebar { position: fixed; inset: 0 auto 0 0; width: min(290px, 86vw); translate: -100% 0; transition: translate 0.22s var(--zp-ease); box-shadow: var(--zp-shadow-lg); }
    :root[data-sidebar-open="true"] .app-sidebar { translate: 0 0; }
    :root[data-sidebar-open="true"] .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: calc(var(--zp-z-sidebar) - 1); background: rgba(5, 15, 11, 0.45); }
    .app-topbar .topbar-menu { display: inline-grid; }
    .palette-trigger { min-width: 0; width: 38px; padding: 0; justify-content: center; }
    .palette-trigger span, .palette-trigger .kbd { display: none; }
    .user-meta { display: none; }
    .app-topbar { padding: 0 1rem; }
    .app-main { padding: 1.25rem 1rem 2.5rem; }
    .breadcrumb-trail li:not(:last-child) { display: none; }
    /* the rail state never applies on phones — the drawer always shows labels */
    :root[data-sidebar="collapsed"] .app-sidebar .side-link-label,
    :root[data-sidebar="collapsed"] .app-sidebar .app-brand-text,
    :root[data-sidebar="collapsed"] .app-sidebar .area-switch span,
    :root[data-sidebar="collapsed"] .app-sidebar .app-sidebar-foot span,
    :root[data-sidebar="collapsed"] .nav-group > summary > span { display: revert; }
    :root[data-sidebar="collapsed"] .nav-group > summary { display: flex; }
    :root[data-sidebar="collapsed"] .side-link { justify-content: flex-start; padding: 0.46rem 0.65rem 0.46rem 2.15rem; }
    :root[data-sidebar="collapsed"] .side-link-icon { display: none; }
}

/* ---- 5. Page scaffold ---------------------------------------------------------------------------- */
.admin-page { color: var(--zp-text); max-width: 1280px; margin: 0 auto; }
.admin-page > * { animation: zp-rise 0.4s var(--zp-ease) both; }
.admin-page > *:nth-child(2) { animation-delay: 0.03s; }
.admin-page > *:nth-child(3) { animation-delay: 0.06s; }
.admin-page > *:nth-child(4) { animation-delay: 0.09s; }
.admin-page > *:nth-child(n+5) { animation-delay: 0.12s; }
.admin-page.wide { max-width: none; }

.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem 1.5rem; margin-bottom: 1.5rem; }
.page-header-text { min-width: 0; flex: 1 1 420px; }
.page-header .eyebrow { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.72rem; font-weight: 750; letter-spacing: 0.1em; text-transform: uppercase; color: var(--zp-accent-text); margin-bottom: 0.35rem; }
.page-header .eyebrow svg { width: 15px; height: 15px; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

.admin-page h1 { font-size: 1.65rem; font-weight: 800; letter-spacing: -0.025em; line-height: 1.2; margin: 0 0 0.3rem; color: var(--zp-text); }
.admin-page h2 { font-size: 1rem; font-weight: 750; letter-spacing: -0.01em; color: var(--zp-text); margin: 0 0 0.9rem; }
.admin-page h3 { font-size: 0.86rem; font-weight: 750; color: var(--zp-text-dim); margin: 1.1rem 0 0.6rem; }
.admin-page .hint { color: var(--zp-text-dim); font-size: 0.9rem; margin: 0 0 1.1rem; line-height: 1.6; max-width: 78ch; }
.page-header .hint { margin-bottom: 0; }
.admin-page code, .admin-page .hint code { font-family: var(--zp-mono); color: var(--zp-accent-text); font-size: 0.84em; background: var(--zp-accent-soft); padding: 0.05em 0.35em; border-radius: 5px; }
.capability-note { display: inline-flex; align-items: center; gap: 0.35rem; margin-top: 0.4rem; font-size: 0.76rem; color: var(--zp-text-faint); }
.capability-note svg { width: 14px; height: 14px; }

.readonly-note {
    display: flex; gap: 0.6rem; align-items: flex-start;
    border: 1px solid var(--zp-warn-line); background: var(--zp-warn-soft); color: var(--zp-warn);
    border-radius: var(--zp-radius-sm); padding: 0.7rem 0.9rem; font-size: 0.88rem;
}

/* ---- 6. Components ------------------------------------------------------------------------------- */
/* Cards */
.admin-card {
    position: relative;
    background: var(--zp-surface);
    border: 1px solid var(--zp-line);
    border-radius: var(--zp-radius);
    padding: 1.25rem 1.35rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--zp-shadow);
}
.admin-card.dense { padding: 0.9rem 1rem; }
.admin-card.flush { padding: 0; overflow: hidden; }
.admin-card.flush > .card-head { padding: 1rem 1.25rem 0; }
.admin-card.flush .admin-table-scroll { border-radius: 0 0 var(--zp-radius) var(--zp-radius); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem 1rem; margin-bottom: 0.95rem; }
.card-head h2 { margin: 0; }
.card-head .card-sub { display: block; font-size: 0.82rem; color: var(--zp-text-faint); font-weight: 500; margin-top: 0.15rem; }
.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.25rem; align-items: start; }
.card-grid > .admin-card { margin-bottom: 0; }

/* Forms */
.admin-form-row { display: flex; flex-wrap: wrap; gap: 0.85rem 1rem; align-items: flex-end; }
.admin-form-row + .admin-form-row { margin-top: 0.85rem; }
.admin-form-row label, .field > label, .field-label {
    display: flex; flex-direction: column; gap: 0.35rem;
    font-size: 0.78rem; font-weight: 650; color: var(--zp-text-dim);
}
.admin-form-row label.check, label.check { flex-direction: row; align-items: center; gap: 0.5rem; font-size: 0.86rem; font-weight: 600; color: var(--zp-text); }
.admin-form-row input:not([type=checkbox]):not([type=radio]), .admin-form-row select, .admin-form-row textarea,
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea, .input {
    background: var(--zp-surface);
    border: 1px solid var(--zp-line-strong);
    color: var(--zp-text);
    border-radius: var(--zp-radius-xs);
    padding: 0 0.75rem; height: 38px;
    font: 500 0.9rem var(--zp-font);
    min-width: 10rem;
    transition: border-color 0.16s, box-shadow 0.16s;
}
.admin-form-row textarea, .field textarea, textarea.input { height: auto; min-height: 5.5rem; padding: 0.55rem 0.75rem; line-height: 1.5; }
.admin-form-row input:hover, .admin-form-row select:hover, .field input:hover, .field select:hover { border-color: var(--zp-text-faint); }
.admin-form-row input:focus, .admin-form-row select:focus, .admin-form-row textarea:focus,
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
    outline: none; border-color: var(--zp-accent); box-shadow: 0 0 0 3px var(--zp-accent-soft);
}
.admin-form-row input:disabled, .admin-form-row select:disabled { opacity: 0.6; }
.admin-form-row input[type=checkbox], .admin-form-row input[type=radio], label.check input { accent-color: var(--zp-accent); width: 16px; height: 16px; }
.field { display: grid; gap: 0.3rem; }
.field-hint { font-size: 0.76rem; color: var(--zp-text-faint); font-weight: 500; }
.field-error { font-size: 0.76rem; color: var(--zp-danger); font-weight: 600; }
.form-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 1rem; }

/* Buttons */
.admin-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
    height: 38px; padding: 0 0.95rem; white-space: nowrap;
    background: var(--zp-surface); border: 1px solid var(--zp-line-strong); color: var(--zp-text);
    border-radius: var(--zp-radius-xs); box-shadow: var(--zp-shadow-1);
    font: 650 0.86rem var(--zp-font); text-decoration: none; cursor: pointer;
    transition: background 0.14s, border-color 0.14s, color 0.14s, box-shadow 0.14s, transform 0.1s;
}
.admin-btn:hover { border-color: var(--zp-text-faint); background: var(--zp-surface-2); color: var(--zp-text); }
.admin-btn:active { transform: translateY(1px); }
.admin-btn svg { width: 16px; height: 16px; flex: none; }
.admin-btn.primary { background: var(--zp-accent); border-color: var(--zp-accent); color: var(--zp-on-accent); box-shadow: 0 1px 2px rgba(0, 80, 56, 0.25), 0 6px 14px -8px rgba(0, 166, 118, 0.7); }
.admin-btn.primary:hover { background: var(--zp-accent-2); border-color: var(--zp-accent-2); color: var(--zp-on-accent); }
.admin-btn.danger { color: var(--zp-danger); border-color: var(--zp-danger-line); background: var(--zp-surface); }
.admin-btn.danger:hover { background: var(--zp-danger-soft); color: var(--zp-danger); }
.admin-btn.danger.solid { background: var(--zp-danger); border-color: var(--zp-danger); color: #fff; }
.admin-btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--zp-text-dim); }
.admin-btn.ghost:hover { background: var(--zp-sunken); color: var(--zp-text); }
.admin-btn.small, .admin-table .admin-btn { height: 32px; padding: 0 0.7rem; font-size: 0.8rem; }
.admin-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.admin-btn[aria-busy="true"]::after { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: zp-spin 0.7s linear infinite; }

.confirm-inline { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.15rem 0.2rem 0.15rem 0.6rem; border-radius: var(--zp-radius-xs); background: var(--zp-danger-soft); border: 1px solid var(--zp-danger-line); }
.confirm-inline .confirm-q { font-size: 0.8rem; font-weight: 700; color: var(--zp-danger); white-space: nowrap; }

/* Tables */
.admin-table-scroll { overflow-x: auto; border: 1px solid var(--zp-line); border-radius: var(--zp-radius-sm); background: var(--zp-surface); }
.admin-card .admin-table-scroll { border-radius: var(--zp-radius-sm); }
.admin-table-scroll.tall { max-height: 34rem; overflow-y: auto; }
.admin-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.875rem; }
.admin-table thead th {
    position: sticky; top: 0; z-index: 1;
    text-align: left; padding: 0.6rem 0.85rem; white-space: nowrap;
    font-size: 0.72rem; font-weight: 750; letter-spacing: 0.04em; text-transform: uppercase;
    color: var(--zp-text-faint); background: var(--zp-surface-2);
    border-bottom: 1px solid var(--zp-line-strong);
}
.admin-table td { padding: 0.62rem 0.85rem; border-bottom: 1px solid var(--zp-line); vertical-align: middle; }
.admin-table tbody tr:last-child td { border-bottom: 0; }
.admin-table tbody tr { transition: background 0.12s; }
.admin-table tbody tr:hover { background: var(--zp-surface-2); }
.admin-table tbody tr.sel, .admin-table tbody tr.selected { background: var(--zp-accent-soft); }
.admin-table tbody tr.inactive td { color: var(--zp-text-faint); }
.admin-table tbody tr.clickable { cursor: pointer; }
.admin-table td.detail { color: var(--zp-text-dim); max-width: 30rem; font-family: var(--zp-mono); font-size: 0.8rem; }
.admin-table .empty { color: var(--zp-text-faint); text-align: center; padding: 2.25rem 1rem; }
.admin-table .row-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; justify-content: flex-end; }
.admin-table th.num, .admin-table td.num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.admin-table code { color: var(--zp-text); background: var(--zp-sunken); font-size: 0.8rem; }
.admin-table .num.pos, .num.pos { color: var(--zp-success); }
.admin-table .num.neg, .num.neg { color: var(--zp-danger); }
.admin-table .sub, .cell-sub { display: block; font-size: 0.76rem; color: var(--zp-text-faint); margin-top: 0.1rem; }
.admin-table tr.skeleton-row td { padding: 0.75rem 0.85rem; }
.table-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem; padding-top: 0.75rem; font-size: 0.82rem; color: var(--zp-text-faint); }

/* Badges / status */
.badge {
    display: inline-flex; align-items: center; gap: 0.35rem; white-space: nowrap;
    font: 700 0.72rem var(--zp-font); padding: 0.18rem 0.55rem; border-radius: 999px; letter-spacing: 0.01em;
    background: var(--zp-sunken); color: var(--zp-text-dim); border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.active, .badge.success { background: var(--zp-success-soft); color: var(--zp-success); }
.badge.locked, .badge.danger { background: var(--zp-danger-soft); color: var(--zp-danger); }
.badge.warning, .badge.warn { background: var(--zp-warn-soft); color: var(--zp-warn); }
.badge.info { background: var(--zp-info-soft); color: var(--zp-info); }
.badge.accent { background: var(--zp-accent-soft); color: var(--zp-accent-text); }
.badge.neutral { background: var(--zp-sunken); color: var(--zp-text-dim); }

/* Alerts */
.admin-error, .admin-notice, .admin-warning, .admin-info, .chain-status, .alert {
    display: flex; align-items: flex-start; gap: 0.6rem;
    padding: 0.75rem 1rem; border-radius: var(--zp-radius-sm); margin-bottom: 1.1rem; font-size: 0.88rem; line-height: 1.5;
    border: 1px solid;
}
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert-body { flex: 1; min-width: 0; }
.alert-title { display: block; font-weight: 750; }
.alert-close { margin-left: auto; border: 0; background: transparent; color: inherit; cursor: pointer; opacity: 0.7; padding: 0; }
.alert-close:hover { opacity: 1; }
.admin-error, .chain-status.broken, .alert.error { background: var(--zp-danger-soft); border-color: var(--zp-danger-line); color: var(--zp-danger); }
.admin-notice, .chain-status.ok, .alert.success { background: var(--zp-success-soft); border-color: var(--zp-accent-line); color: var(--zp-success); }
.admin-warning, .alert.warning { background: var(--zp-warn-soft); border-color: var(--zp-warn-line); color: var(--zp-warn); }
.admin-info, .alert.info { background: var(--zp-info-soft); border-color: var(--zp-info-line); color: var(--zp-info); }

/* KPIs */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi {
    position: relative; display: flex; flex-direction: column; gap: 0.15rem;
    background: var(--zp-surface); border: 1px solid var(--zp-line); border-radius: var(--zp-radius);
    padding: 1rem 1.15rem; box-shadow: var(--zp-shadow);
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.kpi-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--zp-accent-soft); color: var(--zp-accent-text); }
.kpi-icon svg { width: 17px; height: 17px; }
.kpi.warning .kpi-icon { background: var(--zp-warn-soft); color: var(--zp-warn); }
.kpi.danger .kpi-icon { background: var(--zp-danger-soft); color: var(--zp-danger); }
.kpi.info .kpi-icon { background: var(--zp-info-soft); color: var(--zp-info); }
.kpi-label { display: block; font-size: 0.78rem; font-weight: 650; color: var(--zp-text-dim); }
.kpi-value { display: block; font: 800 1.75rem var(--zp-font); font-variant-numeric: tabular-nums; letter-spacing: -0.025em; color: var(--zp-text); margin-top: 0.3rem; line-height: 1.15; }
.kpi-value small { font-size: 0.55em; font-weight: 700; color: var(--zp-text-faint); margin-left: 0.25rem; letter-spacing: 0; }
.kpi-sub { display: block; font-size: 0.78rem; color: var(--zp-text-faint); }
.kpi-delta { display: inline-flex; align-items: center; gap: 0.2rem; font-size: 0.76rem; font-weight: 750; padding: 0.1rem 0.4rem; border-radius: 6px; width: fit-content; }
.kpi-delta.up { color: var(--zp-success); background: var(--zp-success-soft); }
.kpi-delta.down { color: var(--zp-danger); background: var(--zp-danger-soft); }
.kpi-delta.flat { color: var(--zp-text-faint); background: var(--zp-sunken); }
.kpi-delta svg { width: 13px; height: 13px; }
.kpi.compact .kpi-value { font-size: 1.35rem; }

/* Stat tiles (small figures inside cards) */
.stat-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.stat { display: grid; gap: 0.15rem; padding: 0.7rem 0.9rem; min-width: 9rem; border-radius: var(--zp-radius-sm); background: var(--zp-surface-2); border: 1px solid var(--zp-line); }
.stat .hint { margin: 0; font-size: 0.75rem; }
.stat strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }

/* Charts — offline-safe CSS marks on ChartPalette (no chart library) */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.25rem; align-items: start; }
.chart-grid > .admin-card { margin-bottom: 0; }
.chart-card { min-height: 200px; }
.chart-card.wide { grid-column: 1 / -1; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; margin-bottom: 1rem; }
.chart-head h2 { margin: 0; }
.chart-note { font-size: 0.74rem; font-weight: 650; color: var(--zp-text-faint); }
.col-chart { display: flex; align-items: flex-end; gap: 4px; height: 190px; padding-top: 0.5rem; }
.col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.col-fill { width: 100%; min-height: 3px; background: linear-gradient(180deg, var(--zp-accent), var(--zp-accent-2)); border-radius: 5px 5px 2px 2px; transition: height 0.5s var(--zp-ease); }
.col:hover .col-fill { filter: brightness(1.12); }
.col-x { margin-top: 0.35rem; font-size: 0.66rem; color: var(--zp-text-faint); font-variant-numeric: tabular-nums; }
.hbars { display: flex; flex-direction: column; gap: 0.65rem; }
.hbar { display: grid; grid-template-columns: minmax(5rem, 10rem) 1fr auto; align-items: center; gap: 0.75rem; }
.hbar-label { font-size: 0.84rem; color: var(--zp-text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 8px; background: var(--zp-sunken); border-radius: 999px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; min-width: 3px; background: linear-gradient(90deg, var(--zp-accent-2), var(--zp-accent)); border-radius: 999px; transition: width 0.55s var(--zp-ease); }
.hbar-val { font-size: 0.84rem; font-weight: 700; color: var(--zp-text); text-align: right; font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 0.5rem 1.1rem; margin-bottom: 0.9rem; }
.legend-item { display: flex; align-items: center; gap: 0.45rem; font-size: 0.82rem; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend-label { color: var(--zp-text-dim); }
.legend-val { color: var(--zp-text); font-weight: 700; font-variant-numeric: tabular-nums; }
.stack-bar { display: flex; gap: 2px; height: 14px; border-radius: 999px; overflow: hidden; background: var(--zp-sunken); }
.stack-seg { min-width: 2px; transition: width 0.55s var(--zp-ease); }

/* Filter bar + date range presets */
.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem 1rem; margin-bottom: 1.25rem; padding: 0.85rem 1rem; background: var(--zp-surface); border: 1px solid var(--zp-line); border-radius: var(--zp-radius); box-shadow: var(--zp-shadow-1); }
.filter-bar .admin-form-row { margin: 0; }
.filter-bar .grow { flex: 1; }
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--zp-sunken); border: 1px solid var(--zp-line); }
.segmented button, .segmented a {
    border: 0; background: transparent; cursor: pointer; padding: 0 0.75rem; height: 30px; border-radius: 7px;
    font: 650 0.82rem var(--zp-font); color: var(--zp-text-dim); text-decoration: none; display: inline-flex; align-items: center; white-space: nowrap;
}
.segmented button:hover, .segmented a:hover { color: var(--zp-text); }
.segmented .active, .segmented [aria-pressed="true"] { background: var(--zp-surface); color: var(--zp-text); box-shadow: var(--zp-shadow-1); }

/* Empty / loading states */
.empty-state { display: grid; justify-items: center; gap: 0.4rem; padding: 2.5rem 1rem; text-align: center; color: var(--zp-text-dim); }
.empty-state-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--zp-sunken); color: var(--zp-text-faint); margin-bottom: 0.3rem; }
.empty-state-icon svg { width: 22px; height: 22px; }
.empty-state strong { color: var(--zp-text); font-size: 0.98rem; }
.empty-state p { margin: 0; font-size: 0.86rem; max-width: 46ch; }
.skeleton { display: block; height: 0.9rem; border-radius: 6px; background: linear-gradient(90deg, var(--zp-sunken) 25%, var(--zp-line) 37%, var(--zp-sunken) 63%); background-size: 400% 100%; animation: zp-shimmer 1.3s ease infinite; }
.loading-state { display: grid; gap: 0.6rem; padding: 0.5rem 0; }
.loading-inline { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--zp-text-faint); font-size: 0.86rem; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--zp-line-strong); border-top-color: var(--zp-accent); animation: zp-spin 0.7s linear infinite; }

/* Tabs */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--zp-line); margin-bottom: 1.25rem; overflow-x: auto; }
.tabs button, .tabs a { border: 0; background: transparent; cursor: pointer; padding: 0.6rem 0.85rem; font: 650 0.88rem var(--zp-font); color: var(--zp-text-dim); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover, .tabs a:hover { color: var(--zp-text); }
.tabs .active, .tabs [aria-selected="true"] { color: var(--zp-accent-text); border-bottom-color: var(--zp-accent); }

/* Home launcher */
.home-hero { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.home-hero h1 { font-size: 1.85rem; }
.admin-page .home-section { margin: 1.75rem 0 0.75rem; display: flex; align-items: center; gap: 0.5rem; font-size: 0.78rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: var(--zp-text-faint); }
.admin-page .home-section svg { width: 16px; height: 16px; }
.admin-home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.85rem; }
.admin-home-card {
    display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 0.15rem 0.85rem;
    padding: 1rem 1.1rem; border-radius: var(--zp-radius); text-decoration: none;
    background: var(--zp-surface); border: 1px solid var(--zp-line); box-shadow: var(--zp-shadow-1);
    transition: border-color 0.16s, box-shadow 0.16s, transform 0.16s var(--zp-ease);
}
.admin-home-card:hover { border-color: var(--zp-accent-line); box-shadow: var(--zp-shadow); transform: translateY(-2px); }
.admin-home-icon { grid-row: span 2; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--zp-accent-soft); color: var(--zp-accent-text); }
.admin-home-icon svg { width: 19px; height: 19px; }
.admin-home-title { color: var(--zp-text); font-weight: 750; font-size: 0.95rem; }
.admin-home-sub { color: var(--zp-text-faint); font-size: 0.8rem; line-height: 1.45; }
.recent-links { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.recent-links a { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.4rem 0.75rem; border-radius: 999px; background: var(--zp-surface); border: 1px solid var(--zp-line); color: var(--zp-text); text-decoration: none; font-size: 0.84rem; font-weight: 600; }
.recent-links a:hover { border-color: var(--zp-accent-line); }

/* Theme toggle (lane bar + sign-in card; the admin shell uses .icon-button) */
.theme-toggle {
    display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer;
    padding: 0.28rem 0.6rem; border-radius: 999px;
    background: transparent; border: 1px solid var(--zp-line-strong); color: var(--zp-text-dim);
    font: inherit; font-size: 0.76rem; font-weight: 650; line-height: 1.6;
    transition: border-color 0.15s var(--zp-ease), color 0.15s var(--zp-ease), background 0.15s var(--zp-ease);
}
.theme-toggle:hover, .theme-toggle:focus-visible { border-color: var(--zp-accent-line); color: var(--zp-text); background: var(--zp-accent-soft); }
.theme-toggle .theme-glyph { font-size: 0.95rem; line-height: 1; }
.signin-theme { display: flex; justify-content: center; margin-top: 1.25rem; }

/* ---- 7. Legacy hooks kept for pages and tests ------------------------------------------------------ */
.elapsed { font-family: var(--zp-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.elapsed.is-late, .elapsed.was-late { color: var(--zp-danger); font-weight: 650; }

.report { background: var(--zp-surface); border: 1px solid var(--zp-line); border-radius: var(--zp-radius); padding: 1.15rem 1.3rem; margin-bottom: 1.25rem; box-shadow: var(--zp-shadow); }
.top-products, .tender-mix { list-style: none; padding: 0; margin: 0; }
.top-products li, .tender-mix li { display: flex; justify-content: space-between; padding: 0.5rem 0; border-bottom: 1px solid var(--zp-line); font-size: 0.88rem; }
.top-products li:last-child, .tender-mix li:last-child { border-bottom: 0; }
.top-products li span:last-child, .tender-mix li span:last-child { font-variant-numeric: tabular-nums; color: var(--zp-text-dim); }
.top-products li.empty { color: var(--zp-text-faint); }

.admin-entry-link {
    position: fixed; bottom: 1.1rem; right: 1.2rem; z-index: var(--zp-z-toast);
    display: inline-flex; align-items: center; gap: 0.45rem; text-decoration: none; white-space: nowrap;
    background: var(--zp-nav-bg); color: var(--zp-nav-text-strong);
    padding: 0.5rem 0.95rem; border-radius: 999px; font: 700 0.82rem var(--zp-font);
    box-shadow: var(--zp-shadow-lg);
}
.admin-entry-link:hover { background: var(--zp-nav-bg-2); color: #fff; }
.admin-entry-link svg { width: 16px; height: 16px; }

.matrix { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.matrix th, .matrix td { padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--zp-line); text-align: left; }
.matrix thead th { position: sticky; top: 0; background: var(--zp-surface-2); font-size: 0.72rem; font-weight: 750; text-transform: uppercase; letter-spacing: 0.04em; color: var(--zp-text-faint); border-bottom: 1px solid var(--zp-line-strong); }
.matrix tbody th { font-weight: 600; color: var(--zp-text); }
.matrix tbody tr:hover { background: var(--zp-surface-2); }
.matrix .granted { color: var(--zp-success); font-weight: 700; }
.matrix .denied { color: var(--zp-text-faint); }
.matrix .limited { color: var(--zp-warn); font-weight: 700; }
.table-scroll { overflow: auto; max-height: 70vh; border: 1px solid var(--zp-line); border-radius: var(--zp-radius-sm); background: var(--zp-surface); }

.auth-authorizing { display: flex; align-items: center; justify-content: center; gap: 0.6rem; height: 100vh; color: var(--zp-text-dim); font: 600 0.95rem var(--zp-font); background: var(--zp-bg); }
.not-authorized {
    max-width: 34rem; margin: 5rem auto; padding: 2.5rem; text-align: center; color: var(--zp-text); font-family: var(--zp-font);
    background: var(--zp-surface); border: 1px solid var(--zp-line); border-radius: var(--zp-radius); box-shadow: var(--zp-shadow-lg);
}
.not-authorized h1 { color: var(--zp-danger); font-size: 1.5rem; letter-spacing: -0.02em; margin-bottom: 0.75rem; }
.not-authorized-actions { margin-top: 1.75rem; display: flex; gap: 0.85rem; justify-content: center; }
.na-link {
    color: var(--zp-accent-text); text-decoration: none; border: 1px solid var(--zp-line-strong);
    padding: 0.55rem 1.1rem; border-radius: var(--zp-radius-xs); background: transparent; cursor: pointer;
    font: 650 0.88rem var(--zp-font); transition: border-color 0.18s, background 0.18s;
}
.na-link:hover { border-color: var(--zp-accent-line); background: var(--zp-accent-soft); }

.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.25rem; align-items: start; }
.report-grid .admin-card { margin-bottom: 0; }
.journal-split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.journal-split .admin-card { margin-bottom: 0; }
.detail-figures { display: flex; flex-direction: column; margin: 0; }
.detail-figures > div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.5rem 0; border-bottom: 1px solid var(--zp-line); }
.detail-figures > div:last-child { border-bottom: 0; }
.detail-figures dt { color: var(--zp-text-dim); font-size: 0.86rem; margin: 0; font-weight: 600; }
.detail-figures dd { margin: 0; font-variant-numeric: tabular-nums; color: var(--zp-text); font-weight: 650; text-align: right; }
.detail-figures .grand dt { color: var(--zp-text); font-weight: 750; }
.detail-figures .grand dd { color: var(--zp-accent-text); font-weight: 800; font-size: 1.05rem; }
.receipt-preview {
    margin-top: 1rem; padding: 1rem 1.1rem; background: var(--zp-surface-2); border: 1px solid var(--zp-line); border-radius: var(--zp-radius-sm);
    font-family: var(--zp-mono); font-size: 0.78rem; line-height: 1.55; color: var(--zp-text-dim);
    white-space: pre-wrap; max-height: 24rem; overflow-y: auto;
}
.admin-empty, p.empty { color: var(--zp-text-faint); font-size: 0.88rem; padding: 0.75rem 0; margin: 0; }

/* Bulk import wizard (ADR-026) */
.import-steps { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1.4rem; padding: 0; list-style: none; counter-reset: step; }
.import-steps li { padding: 0.4rem 0.85rem; border: 1px solid var(--zp-line); border-radius: 999px; font-size: 0.82rem; font-weight: 600; color: var(--zp-text-dim); background: var(--zp-surface); }
.import-steps li.current { background: var(--zp-accent-soft); border-color: var(--zp-accent); color: var(--zp-accent-text); font-weight: 750; }
.import-steps li.done { color: var(--zp-text); }
.import-progress { width: 100%; height: 0.75rem; border-radius: 999px; background: var(--zp-sunken); overflow: hidden; }
.import-progress > span { display: block; height: 100%; background: var(--zp-accent); transition: width 0.2s ease; }
.import-slot { display: flex; flex-wrap: wrap; align-items: center; gap: 0.8rem; padding: 0.7rem 0; border-top: 1px solid var(--zp-line); }
.import-slot:first-of-type { border-top: 0; }
.import-sev-error { color: var(--zp-danger); font-weight: 650; }
.import-sev-warning { color: var(--zp-warn); font-weight: 650; }
.import-row-error td { background: var(--zp-danger-soft); }

/* Sign-in atmosphere (SignIn.razor.css owns the card itself) */
.signin-root {
    position: relative; isolation: isolate;
    background:
        radial-gradient(1100px 620px at 82% -8%, var(--zp-aurora-1), transparent 60%),
        radial-gradient(900px 700px at 0% 108%, var(--zp-aurora-2), transparent 55%),
        linear-gradient(160deg, var(--zp-bg-2), var(--zp-bg));
    color: var(--zp-text); font-family: var(--zp-font);
}

/* ---- 8. Utilities (replace one-off inline styles) ------------------------------------------------- */
.zp-stack { display: grid; gap: 0.75rem; }
.zp-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.zp-row.top { align-items: flex-start; }
.zp-row.between { justify-content: space-between; }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1.25rem; align-items: start; }
.grow { flex: 1 1 auto; min-width: 0; }
.ml-auto { margin-left: auto; }
/* spacing: Bootstrap's mt-N and mb-N utilities (still loaded) are used rather than redefined here. */
.muted { color: var(--zp-text-dim); } .faint { color: var(--zp-text-faint); }
.small { font-size: 0.82rem; }
.strong { font-weight: 750; }
.mono { font-family: var(--zp-mono); }
.tabular { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-success { color: var(--zp-success); } .text-danger { color: var(--zp-danger); } .text-warn { color: var(--zp-warn); }
/* input widths — the 40 inline width:Nrem styles become these */
.admin-form-row .w-xs, .w-xs { width: 5.5rem; min-width: 5.5rem !important; }
.admin-form-row .w-sm, .w-sm { width: 7.5rem; min-width: 7.5rem !important; }
.admin-form-row .w-md, .w-md { width: 11rem; min-width: 11rem !important; }
.admin-form-row .w-lg, .w-lg { width: 16rem; }
.admin-form-row .w-xl, .w-xl { width: 24rem; max-width: 100%; }
.admin-form-row .w-full, .w-full { width: 100%; }
.panel-muted { background: var(--zp-surface-2); border: 1px solid var(--zp-line); border-radius: var(--zp-radius-sm); padding: 0.75rem 1rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---- 9. Motion, print ----------------------------------------------------------------------------- */
@keyframes zp-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes zp-pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes zp-spin { to { transform: rotate(360deg); } }
@keyframes zp-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

@media (max-width: 900px) {
    .journal-split { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
@media print {
    .app-sidebar, .app-topbar, .admin-entry-link, .page-actions, .filter-bar { display: none !important; }
    .app-shell { display: block; }
    .admin-card, .kpi { box-shadow: none; break-inside: avoid; }
}
