/* SHARED portal stylesheet, shipped by the SeamlessRewards.Portal.Shell package and served from
   _content/SeamlessRewards.Portal.Shell/css/portal.css. Base resets plus the auth-page and
   Radzen-shell spacing tweaks below; the bulk of the authenticated chrome comes from RadzenLayout
   + the Material theme.

   App.razor links this file BEFORE the host's own wwwroot/app.css, so a host can override any rule
   here from its own stylesheet without forking this file.

   HOST-SUPPLIED ASSETS. This stylesheet references no images: the auth-page ground is the brand
   navy gradient (--sr-auth-ground / --sr-auth-ground-gradient), identical for every portal, and the
   brand mark (the shell's own crown.svg plus PortalShellOptions.PortalName as text) is shell-owned;
   hosts ship no logo and no background. */
html, body {
    /* Montserrat app-wide (loaded via the Google Fonts link in App.razor), matching the Radzen
       shell's --rz-text-font-family. Covers the static-SSR auth pages (login, forgot-password), which
       don't use Radzen and so read font-family from here. Falls back to Arial if Montserrat is
       unavailable. */
    font-family: 'Montserrat', Arial, Helvetica, sans-serif;
    margin: 0;
    /* Smoother (grayscale) text anti-aliasing - lighter, cleaner strokes than the default subpixel
       rendering. Applied to html/body so it inherits across the whole app incl. the Radzen shell. */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Routes.razor's <FocusOnNavigate Selector="h1"> programmatically focuses the first h1 after each
   navigation (a screen-reader affordance), which otherwise paints a focus outline around the page
   title on load (e.g. the "LOGIN" heading). The h1 is not in the tab order (tabindex=-1), so hiding
   its focus ring keeps the a11y focus behaviour without the visible box. */
h1:focus {
    outline: none;
}

/* Ent Design System type scale: Merriweather Light for the display headings (plain <h1>-<h3> and
   Radzen's RadzenText TextStyle="H1".."H3"), Montserrat SemiBold for h4-h6. */
h1, h2, h3, .rz-text-h1, .rz-text-h2, .rz-text-h3 {
    font-family: var(--sr-font-heading);
    font-weight: 300;
    line-height: 1.2;
}

h1, .rz-text-h1 { font-size: 40px; }
h2, .rz-text-h2 { font-size: 32px; }
h3, .rz-text-h3 { font-size: 24px; }

h4, h5, h6, .rz-text-h4, .rz-text-h5, .rz-text-h6 {
    font-weight: 600;
    line-height: 1.2;
}

h4, .rz-text-h4 { font-size: 24px; }
h5, .rz-text-h5 { font-size: 22px; }
h6, .rz-text-h6 { font-size: 20px; }

@media (max-width: 768px) {
    h1, .rz-text-h1 { font-size: 32px; }
    h2, .rz-text-h2 { font-size: 28px; }
    h3, .rz-text-h3, h4, .rz-text-h4 { font-size: 22px; }
    h5, .rz-text-h5 { font-size: 20px; }
    h6, .rz-text-h6 { font-size: 18px; }
    .auth-card { padding: 24px 20px; }
    .auth-brand-name { font-size: 28px; }
}

/* Auth pages (login, forgot-password): the brand mark above a centred card on the full-bleed Ent
   navy ground (Figma node 1:9). The ground is a brand constant, not a host asset - no image. */
.auth-page {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 3rem 1rem;
    background: var(--sr-auth-ground-gradient), var(--sr-auth-ground);
}

/* Brand mark above the card: the shell's crown over the portal name (PortalShellOptions.PortalName),
   in the cream on-brand ink because it sits on the navy ground, not on the card. */
.auth-brand {
    display: grid;
    justify-items: center;
    gap: 16px;
    margin: 0 auto 28px;
}

.auth-brand-crown {
    width: 54px;
    height: 44px;
}

.auth-brand-name {
    margin: 0;
    font-family: var(--sr-font-heading);
    font-weight: 300;
    font-size: 32px;
    line-height: 1.2;
    color: var(--sr-on-brand);
    text-align: center;
}

/* The card is flat on the ground (no shadow); its children stack on a 20px vertical rhythm. */
.auth-card {
    width: 100%;
    max-width: 521px;
    background: var(--sr-ink-7);
    border: 0;
    border-radius: 16px;
    padding: 36px 40px;
    box-shadow: none;
    box-sizing: border-box;
}

/* "LOGIN" heading + "Enter your Username and Password" subtitle, centred. */
.auth-title {
    margin: 0 0 16px;
    text-align: center;
    color: var(--sr-ink-1);
    /* Sits on an <h2>, so reset the Merriweather heading family: this is Montserrat SemiBold, not a display heading. */
    font-family: var(--rz-text-font-family);
    font-weight: 600;
    font-size: 22px;
    line-height: 1.2;
    text-transform: uppercase;
}

.auth-subtitle {
    margin: 0 0 20px;
    text-align: center;
    color: var(--sr-ink-1);
    font-family: var(--rz-text-font-family);
    font-weight: 400;
    font-size: 16px;
    line-height: 1.5;
}

.auth-field {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

.auth-field label {
    margin-bottom: 4px;
    font-size: 14px;
    color: var(--sr-ink-1);
}

/* Form control. Class-based so the password field keeps its styling when the eye toggle flips its
   type to "text". */
.auth-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--sr-ink-3);
    border-radius: var(--sr-radius-control);
    font-size: 14px;
    line-height: 1.5;
    color: var(--sr-ink-1);
    background: var(--sr-ink-7);
    box-sizing: border-box;
}

.auth-input:focus {
    outline: 0;
    border-color: var(--rz-primary);
    box-shadow: var(--sr-focus-ring);
}

/* Password field wrapper + the inline show/hide eye button pinned to the right. */
.password-toggle {
    position: relative;
}

.password-toggle .auth-input {
    padding-right: 40px;
}

.password-eye {
    position: absolute;
    right: 2px;
    top: 2px;
    bottom: 2px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border: 0;
    background: transparent;
    color: var(--sr-ink-3);
    font-size: 16px;
    cursor: pointer;
}

.password-eye:hover {
    color: var(--rz-primary);
}

/* Row: "Keep me logged in" checkbox on the left, "Forgot password?" link on the right. */
.password-option {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 20px;
    font-size: 14px;
}

.password-option label {
    margin: 0;
    color: var(--sr-ink-1);
}

.password-option a {
    color: var(--rz-primary);
    text-decoration: underline;
}

.password-option .auth-remember {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* "Keep me logged in" checkbox: a custom box (card fill, grey border) that fills with the brand
   accent and a white tick when checked, instead of the browser/OS default blue accent. */
.auth-checkbox {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    margin: 0;
    flex: 0 0 auto;
    border: 1px solid var(--sr-ink-3);
    border-radius: var(--sr-radius-control);
    background: var(--sr-ink-7);
    cursor: pointer;
    position: relative;
}

.auth-checkbox:checked {
    border-color: var(--rz-primary);
    background: var(--rz-primary);
}

.auth-checkbox:checked::after {
    content: "";
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid var(--sr-on-primary);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.auth-checkbox:focus-visible {
    outline: 0;
    border-color: var(--rz-primary);
    box-shadow: var(--sr-focus-ring);
}

/* Full-width brand-coloured "Login" button. inline-flex so the in-flight spinner sits in reserved space to
   the LEFT of the label instead of replacing it - the button keeps its width and the row does not
   reflow when the spinner appears. */
.auth-submit {
    width: 100%;
    padding: 12px 16px;
    border: 0;
    border-radius: var(--sr-radius-control);
    background: var(--rz-primary);
    color: var(--sr-on-primary);
    font-family: var(--rz-text-font-family);
    font-weight: 600;
    font-size: 16px;
    line-height: 1.5;
    letter-spacing: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.auth-submit:hover {
    background: var(--rz-primary-dark);
}

.auth-submit:disabled {
    opacity: 0.65;
    cursor: default;
}

/* Submitting state. The label text deliberately does not change: "Login" stays truthful while the
   request is in flight, and swapping it for "Signing in..." would shift the button's width. The
   in-flight state is announced to assistive technology by .auth-submit-status below instead. */
.auth-submit-spinner {
    display: none;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: var(--sr-on-primary);
    border-radius: 50%;
    animation: auth-submit-spin 0.6s linear infinite;
}

.auth-submit.is-submitting .auth-submit-spinner {
    display: inline-block;
}

/* The disabled button is already at 0.65 opacity; without this the spinner is barely visible
   against the dimmed brand colour. */
.auth-submit.is-submitting {
    opacity: 0.85;
}

@keyframes auth-submit-spin {
    to { transform: rotate(360deg); }
}

/* Respect a reduced-motion preference: the spinner still marks the state, it just does not
   animate. Removing it entirely would leave no in-progress affordance at all. */
@media (prefers-reduced-motion: reduce) {
    .auth-submit-spinner {
        animation: none;
    }
}

/* The in-flight state, for screen readers only. Without it a non-sighted user presses Login and
   gets silence: the spinner is aria-hidden (it is decorative), the label is unchanged by design,
   and setting `disabled` on the focused button drops focus to <body> without announcing anything -
   the same "did that work?" ambiguity that made sighted users press the button a second time.
   Clipped rather than display:none, because a hidden element is not announced at all. */
.auth-submit-status {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.auth-error {
    color: var(--sr-error);
    margin-bottom: 1rem;
    text-align: center;
}

.auth-note {
    margin-bottom: 1rem;
}

.auth-links {
    margin-top: 1rem;
    font-size: 14px;
    text-align: center;
}

/* Brand the auth links in the primary colour (.password-option a has its own rule above). */
.auth-links a {
    color: var(--rz-primary);
    text-decoration: none;
}

.auth-links a:hover {
    text-decoration: underline;
}

/* Bare content links (grid cells, "< Back to ..." links). Neither Radzen's theme nor this file
   coloured a plain <a>, so they fell back to the browser's default #0000ee - unreadable on the dark
   surfaces. Track the primary token instead: navy in light, gold in dark. :where() keeps the
   specificity at zero, so every classed link rule (nav, buttons, .auth-links) still wins. */
:where(a:any-link) {
    color: var(--rz-primary);
}

/* Authenticated Radzen Material shell (Task 5b). The header/sidebar/body chrome comes from
   RadzenLayout + the Material theme; only small spacing tweaks + brand tokens live here. */

/* Ent Design System theme: recolour Radzen's default blue Material palette to the Ent navy
   (light) / gold (dark) accent and keep the header white. These override the Radzen CSS custom
   properties defined in material-base.css. The --sr-* tokens are the shell's own semantic palette,
   read by the hand-written classes below so that dark mode only needs to swap this block. */
:root {
    /* Montserrat for the whole shell: Radzen's body + every .rz-* control reads font-family from
       this variable (default Roboto). Merriweather is the h1-h3 display face. Both are loaded via
       the Google Fonts link in App.razor. */
    --rz-text-font-family: 'Montserrat', Arial, Helvetica, sans-serif;
    --sr-font-heading: 'Merriweather', Georgia, serif;
    --rz-text-h4-font-weight: 600;
    --rz-text-h4-font-size: 24px;
    --rz-text-h5-font-weight: 600;
    --rz-text-h5-font-size: 22px;
    --rz-text-h6-font-weight: 600;
    --rz-text-h6-font-size: 20px;
    --rz-primary: #0e334e;
    --rz-primary-dark: #003c73;
    --rz-primary-darker: #003c73;
    --rz-primary-light: #004e85;
    --rz-primary-lighter: #e8ebee;
    /* Navy header in light mode, matching the sign-in ground; the crown, title, toggle and header
       icons sit on it in the same cream (--sr-on-brand) as the sign-in brand name. */
    --rz-header-background-color: #0e334e;
    --rz-header-color: #fef9ef;
    --rz-header-border: 1px solid #0e334e;
    --rz-header-shadow: 0 0 4px #9f8247;
    --rz-header-min-height: 64px;
    --rz-sidebar-toggle-color: #fef9ef;
    --rz-sidebar-toggle-hover-color: #fef9ef;
    /* Radzen card corner radius (default inherits --rz-border-radius). */
    --rz-card-border-radius: 8px;
    /* Data grid text at a fixed 14px (cells, headers, filter inputs). */
    --rz-grid-cell-font-size: 14px;
    --rz-grid-header-font-size: 14px;
    --rz-grid-filter-font-size: 14px;
    /* Ent greyscale ramp, darkest (0) to lightest (7); inverted in dark mode. */
    --sr-ink-0: #0c0c0c;
    --sr-ink-1: #333333;
    --sr-ink-2: #4f4f4f;
    --sr-ink-3: #828282;
    --sr-ink-4: #bdbdbd;
    --sr-ink-5: #e0e0e0;
    --sr-ink-6: #f2f2f2;
    --sr-ink-7: #ffffff;
    --sr-tile: #e8ebee;
    --sr-error: #c34848;
    --sr-shadow: 0 0 4px #9f8247;
    --sr-focus-ring: 0 0 0 0.15rem rgba(14, 51, 78, 0.2);
    --sr-radius-control: 4px;
    /* Auth-page ground and the inks that sit on brand colour. Brand constants (except --sr-on-primary,
       which turns #0c0c0c on the dark gold primary): the same in dark mode,
       where --sr-ink-7 is black and so cannot stand in for "white on the accent". */
    --sr-auth-ground: #0e334e;
    --sr-auth-ground-gradient: linear-gradient(180deg, rgba(14, 51, 78, 0.5) 0%, rgba(0, 78, 133, 0.5) 100%);
    --sr-on-brand: #fef9ef;
    --sr-on-primary: #ffffff;
    /* Grid loading veil behind the crown: same translucent white as the chart loading overlay. */
    --rz-grid-loading-indicator-background-color: #ffffff;
    --rz-grid-loading-indicator-background-opacity: 0.6;
    /* Radzen accent tokens left at their defaults show Radzen's own purple/indigo/pink: the selected
       nav item and select-bar text read --rz-on-primary-lighter, the nav indicator and Secondary
       badges read --rz-secondary*, and every chart reads --rz-series-N. All mapped to the brand. */
    --rz-on-primary-lighter: #0e334e;
    --rz-secondary: #b4975b;
    --rz-secondary-dark: #ae9155;
    --rz-secondary-darker: #9f8247;
    --rz-secondary-light: #b4975b;
    --rz-secondary-lighter: #fcf2dc;
    --rz-on-secondary: #0c0c0c;
    --rz-on-secondary-lighter: #9f8247;
    /* Chart series: Blue and Gold ramps first, then the Green / Orange / Red primitives; 9-24 repeat
       the eight so a chart with many series never falls back to Radzen's purple defaults. */
    --rz-series-1: #0e334e;
    --rz-series-2: #b4975b;
    --rz-series-3: #004e85;
    --rz-series-4: #219653;
    --rz-series-5: #ff5314;
    --rz-series-6: #c34848;
    --rz-series-7: #003c73;
    --rz-series-8: #9f8247;
    --rz-series-9: #0e334e;
    --rz-series-10: #b4975b;
    --rz-series-11: #004e85;
    --rz-series-12: #219653;
    --rz-series-13: #ff5314;
    --rz-series-14: #c34848;
    --rz-series-15: #003c73;
    --rz-series-16: #9f8247;
    --rz-series-17: #0e334e;
    --rz-series-18: #b4975b;
    --rz-series-19: #004e85;
    --rz-series-20: #219653;
    --rz-series-21: #ff5314;
    --rz-series-22: #c34848;
    --rz-series-23: #003c73;
    --rz-series-24: #9f8247;
}

/* Force 14px on the grid itself so TEMPLATED column content (currency spans, dates, custom markup)
   inherits it too - that content renders outside .rz-cell-data (which already reads the 14px var
   above), so it would otherwise inherit the body's 16px. */
.rz-data-grid,
.rz-datatable {
    font-size: 14px;
}

/* Give the header content a little breathing room from the viewport edges. */
.rz-header .rz-stack {
    padding: 0 0.75rem;
}

/* A bit more weight on the side-nav item text. Radzen drives menu weight via these variables (on
   .rz-panel-menu / the items), not the text span - so override the variables. 600 is a loaded
   Montserrat weight, so it renders true rather than being synthesised. */
.rz-sidebar {
    --rz-panel-menu-font-weight: 600;                         /* top-level items (default 500) */
    --rz-panel-menu-item-2nd-level-font-weight: 600;          /* submenu items (default 400) */
    --rz-panel-menu-item-2nd-level-active-font-weight: 600;   /* active submenu (default 500) */
}

/* Side-nav icons rendered lighter. Radzen's icon font is Material Symbols (a variable font), and the
   icon otherwise inherits the 600 nav-item weight; 400 thins the glyphs. Text weight is unaffected. */
.rz-sidebar .rz-navigation-item-icon {
    font-weight: 400;
    --rz-icon-weight: 400;
}

/* Header left (toggle + title) shrinks first so a long PortalName truncates on narrow screens;
   the right-hand actions keep their size. */
.header-brand {
    min-width: 0;
    flex: 1 1 auto;
}

.header-actions {
    flex: 0 0 auto;
}

/* Header title: PortalShellOptions.PortalName next to the sidebar toggle. */
.header-title {
    font-family: var(--sr-font-heading);
    font-weight: 300;
    font-size: 20px;
    line-height: 1.2;
    color: var(--rz-header-color);
    white-space: nowrap;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Header right-side actions (full-screen and theme toggles) read the header ink, so they stay
   visible on the navy (light) and near-black (dark) header. */
.header-actions .rz-button {
    color: var(--rz-header-color);
}

/* The shell's crown, top-left between the sidebar toggle and the portal name. flex-shrink 0 keeps
   it whole while a long name truncates beside it. */
.header-crown {
    height: 32px;
    width: auto;
    display: block;
    flex-shrink: 0;
}

/* Narrow phones: drop the decorative crown so the name and actions keep their room. */
@media (max-width: 480px) {
    .header-crown {
        display: none;
    }
}

/* Dashboard: cards sharing a row (Transaction Activity + Top performing merchants; the two
   performance-by-week sub-charts) stretch to the same height. RadzenRow's columns already match
   height via flex (align-items:stretch is the flex default), but RadzenCard itself is a block
   element that only grows to fit its content - so make each column a flex column and let its card
   fill it. */
.dashboard-row > div {
    display: flex;
}

.dashboard-row .rz-card {
    width: 100%;
    flex: 1 1 auto;
}

/* Transaction Activity chart: a translucent overlay + spinner shown while the period selector's
   async reload is in flight (Dashboard._loadingChart), so switching Day/Month/Year gives feedback
   instead of the chart silently sitting still until new data arrives. */
.chart-loading-wrap {
    position: relative;
}

.chart-loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.6);
    z-index: 2;
}

:root[data-theme="dark"] .chart-loading-overlay {
    background: rgba(12, 12, 12, 0.6);
}

/* PortalLoader: the gold crown turning on its vertical axis, a full turn every 1.6s. perspective on
   the wrapper gives the rotateY real depth instead of a flat squash. */
.sr-crown-loader {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    perspective: 400px;
}

.sr-crown-loader img {
    width: 54px;
    height: 44px;
    display: block;
    animation: sr-crown-spin 1.6s linear infinite;
}

@keyframes sr-crown-spin {
    from { transform: rotateY(0deg); }
    to { transform: rotateY(360deg); }
}

@keyframes sr-crown-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* RadzenDataGrid's own loading indicator (IsLoading) becomes the crown on every grid, no host
   markup change: hide Radzen's icon-font spinner and paint the crown on its container. Radzen
   centres that container with transform: translate(-50%, -50%), which the spin animation would
   replace, so it is re-centred with inset + auto margins and the transform freed for the spin.
   The image path is relative to this stylesheet (_content/SeamlessRewards.Portal.Shell/css/). */
.rz-datatable-loading-content .rzi-circle-o-notch {
    display: none;
}

.rz-datatable-loading-content {
    inset: 0;
    margin: auto;
    /* Two-thirds of the chart loader's 54x44, same proportions: a grid is denser than a chart. */
    width: 36px;
    height: 29px;
    transform: none;
    background: url('../images/crown.svg') center / contain no-repeat;
    animation: sr-crown-spin 1.6s linear infinite;
}

/* Users who ask for less motion get a slow fade instead of a spin. */
@media (prefers-reduced-motion: reduce) {
    .sr-crown-loader img {
        animation: sr-crown-pulse 1.6s ease-in-out infinite;
    }

    .rz-datatable-loading-content {
        animation: sr-crown-pulse 1.6s ease-in-out infinite;
    }
}

/* Generic version of the above for a row where a column may hold MULTIPLE stacked cards (e.g.
   Transactions' widget row: two single-chart columns beside a column of three stacked stat tiles).
   flex-direction:column keeps cards stacked vertically inside each column, while flex:1 1 auto lets
   every card in a column share the growth needed to match the row's tallest column - so all three
   columns' bottom edges line up. */
.stretch-row > div {
    display: flex;
    flex-direction: column;
}

.stretch-row .rz-card {
    width: 100%;
    flex: 1 1 auto;
}

/* Stat tiles (Total Sales/Earnings/Payouts on Transactions - and reusable by any future tile row):
   the number/label on the left, the decorative sparkline pinned to the right. */
.stat-tile-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.stat-tile-spark svg {
    width: 70px;
    height: 40px;
    display: block;
}

/* Tile numbers use TextStyle.H3, which the heading rule makes Merriweather Light; beside Montserrat
   labels that reads as a font mismatch, so a metric stays in the body face, semibold. */
.stat-tile .rz-text-h3 {
    font-family: var(--rz-text-font-family);
    font-weight: 600;
}

/* Decorative sparkline in the gold accent (navy at low opacity read as grey). */
.stat-tile-spark rect {
    fill: var(--rz-secondary);
    opacity: 0.7;
}

/* Merchant list: two-column layout. The Filters card is the left column; opening it widens that
   column (11rem -> 15rem) so the search + grid (right column) slide right, animated by the width
   transition. The Filters body max-height animates so its fields reveal smoothly. */
/* Top row: Filters toggle + search, same height, side by side. */
.merchant-top {
    display: flex;
    align-items: stretch;
    gap: 1rem;
}

.filters-header {
    flex-grow: 0;
    flex-shrink: 0;
    flex-basis: 11rem;            /* collapsed: narrow toggle */
    height: 40px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 1rem;
    background: var(--sr-ink-7);
    border: 1px solid var(--sr-ink-5);
    border-radius: 8px;
    box-shadow: var(--sr-shadow);
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--sr-ink-1);
    white-space: nowrap;
    transition: flex-basis 0.3s ease;
}

.merchant-top.filters-open .filters-header {
    flex-basis: 22rem;           /* expanded: match the panel width so they line up */
}

/* Match the search input height to the Filters toggle. */
.filters-search {
    flex: 1 1 auto;
    height: 40px;
}

/* Body row: the filters panel (left, zero-width when collapsed) + the grid (right). No flex gap -
   when collapsed the filters column is 0 wide and a gap would still indent the grid; the spacing
   lives on the filters card (margin-right) so it only applies when the column is open. */
.merchant-body {
    display: flex;
    align-items: flex-start;
}

.filters-body-col {
    flex: 0 0 auto;
    width: 0;
    overflow: hidden;
    transition: width 0.3s ease;
}

.merchant-body.filters-open .filters-body-col {
    width: 23rem;   /* 22rem card + 1rem gap before the grid; matches the header width */
}

.grid-col {
    flex: 1 1 auto;
    min-width: 0;
}

/* Round the grid corners. */
.grid-col .rz-datatable,
.grid-col .rz-data-grid {
    border-radius: 8px;
    overflow: hidden;
}

.filters-label {
    font-weight: 600;
    flex: 1 1 auto;
    text-align: left;
}

.filters-clear {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--rz-primary);
    border: 1px solid var(--rz-primary);
    border-radius: 999px;
    padding: 0.05rem 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
}

.filters-clear-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.1rem;
    height: 1.1rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    background: var(--rz-primary);
    color: var(--sr-ink-7);
    font-size: 0.72rem;
    font-weight: 600;
}

/* The filters card revealed inside the width-animated left column. Fixed width so it doesn't
   reflow as the column widens. */
.filters-body {
    width: 22rem;
    margin-right: 1rem;   /* space before the grid; clipped to nothing while the column is collapsed */
    box-sizing: border-box;
    background: var(--sr-ink-7);
    border: 1px solid var(--sr-ink-5);
    border-radius: 8px;
    box-shadow: var(--sr-shadow);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.filters-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.filters-field label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--sr-ink-1);
}

/* Task 8i: the Billing Threshold column's inline pencil-edit affordance on MerchantList - the
   numeric input and its Save/Cancel buttons sit on one row inside the grid cell. */
.billing-threshold-edit {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    justify-content: flex-end;
}

.billing-threshold-error {
    color: var(--sr-error);
}

/* Sidebar: nav fills the space, the signed-in user + logout are pinned to the bottom. */
.sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
}

.sidebar-user {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--sr-ink-5);
}

.avatar-initials {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--rz-primary);
    color: var(--sr-ink-7);
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}

.sidebar-user-meta {
    flex: 1 1 auto;
    min-width: 0;
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--sr-ink-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-email {
    font-size: 0.75rem;
    color: var(--sr-ink-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-logout button {
    flex: 0 0 auto;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--sr-ink-2);
    padding: 0.35rem;
    border-radius: var(--sr-radius-control);
    display: flex;
    align-items: center;
}

.sidebar-logout button:hover {
    color: var(--rz-primary);
    background: var(--rz-primary-lighter);
}

/* Task 8e: the avatar/name in the sidebar now link to /account. NavLink wraps the existing
   avatar-initials + sidebar-user-meta markup unchanged - this just resets link chrome and keeps
   the same flex layout .sidebar-user already relied on. */
.sidebar-user-link {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: inherit;
    text-decoration: none;
}

/* Task 8e: small read-only Account page. */
.account-card {
    max-width: 32rem;
}

.account-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.account-avatar {
    width: 48px;
    height: 48px;
    font-size: 1rem;
}

.account-permissions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.account-no-permissions {
    color: var(--sr-ink-2);
}

/* Task 8j: dedicated error pages (404/500/401) - a bare centred card, no nav chrome, mirroring
   .auth-page/.auth-card's layout but with the brand accent on the error code. Used both as
   standalone /error/* routes and rendered directly inside Routes.razor's NotFound/NotAuthorized
   slots. */
.error-page {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 4rem 1rem;
    background: var(--sr-ink-6);
}

.error-card {
    width: 100%;
    max-width: 22rem;
    text-align: center;
    background: var(--sr-ink-7);
    border: 1px solid var(--sr-ink-5);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: var(--sr-shadow);
}

.error-code {
    font-size: 3rem;
    font-weight: 700;
    color: var(--rz-primary);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.error-message {
    font-size: 1.1rem;
    margin: 0 0 1.5rem 0;
    color: var(--sr-ink-1);
}

/* ============================================================================
   Dark mode. Toggled by the header's sun/moon button (MainLayout.ToggleTheme)
   via App.razor's cloSetTheme JS helper, which swaps the loaded Radzen
   stylesheet (material-base.css <-> material-dark-base.css) and stamps
   data-theme="dark" on <html>. material-dark-base.css already reskins every
   Radzen component (cards, grids, buttons, sidebar, dialogs, badges, etc. all
   read their own colours from Radzen's CSS variables). The hand-written
   classes above read the --sr-* / --rz-* tokens, so the dark counterpart is
   a single token block: the Radzen variables THIS file forces to a fixed
   light value in the :root block above, plus the dark --sr-* palette.
   ============================================================================ */
:root[data-theme="dark"] {
    /* Dark column of the Ent Design System: gold accent on near-black surfaces, greyscale ramp
       inverted. Every --rz-* value THIS file forces to a fixed light value above gets its dark
       counterpart here, so the hand-written classes below need no per-class dark override. */
    --rz-primary: #b4975b;
    --rz-primary-dark: #fcf2dc;
    --rz-primary-darker: #9f8247;
    --rz-primary-light: #ae9155;
    --rz-primary-lighter: #333333;
    --rz-header-background-color: #0c0c0c;
    --rz-header-color: #f2f2f2;
    --rz-header-border: 1px solid #4f4f4f;
    --rz-header-shadow: 0 0 4px #9f8247;
    --rz-sidebar-toggle-color: #b4975b;
    --rz-sidebar-toggle-hover-color: #b4975b;
    --sr-ink-0: #ffffff;
    --sr-ink-1: #f2f2f2;
    --sr-ink-2: #e0e0e0;
    --sr-ink-3: #bdbdbd;
    --sr-ink-4: #828282;
    --sr-ink-5: #4f4f4f;
    --sr-ink-6: #333333;
    --sr-ink-7: #0c0c0c;
    --sr-tile: #333333;
    --sr-error: #eb5757;
    --sr-shadow: 0 0 4px #9f8247;
    --sr-focus-ring: 0 0 0 0.15rem rgba(180, 151, 91, 0.3);
    /* Brand constants, unchanged in dark mode (see the light block). */
    --sr-auth-ground: #0e334e;
    --sr-auth-ground-gradient: linear-gradient(180deg, rgba(14, 51, 78, 0.5) 0%, rgba(0, 78, 133, 0.5) 100%);
    --sr-on-brand: #fef9ef;
    /* Ink on gold fills: charcoal #333333 (design choice). White on #b4975b is 2.79:1 and fails AA;
       #333333 is 4.52:1 on the gold and about 11:1 on the #fcf2dc hover. --sr-on-primary drives the
       shell's own buttons, tick and spinner; --rz-on-primary drives every Radzen primary button. */
    --sr-on-primary: #333333;
    --rz-on-primary: #333333;
    --rz-grid-loading-indicator-background-color: #0c0c0c;
    --rz-grid-loading-indicator-background-opacity: 0.6;
    /* Dark accents: gold leads, because navy #0e334e is near-invisible on the dark surfaces. Series
       use the dark-mode (lighter) steps of each primitive so lines read on #121212-#1e1e1e. */
    --rz-on-primary-lighter: #b4975b;
    --rz-secondary: #b4975b;
    --rz-secondary-dark: #ae9155;
    --rz-secondary-darker: #9f8247;
    --rz-secondary-light: #ae9155;
    --rz-secondary-lighter: #333333;
    --rz-on-secondary: #333333;
    --rz-on-secondary-lighter: #b4975b;
    --rz-series-1: #b4975b;
    --rz-series-2: #f2f2f2;
    --rz-series-3: #27ae60;
    --rz-series-4: #ff9a47;
    --rz-series-5: #eb5757;
    --rz-series-6: #fcf2dc;
    --rz-series-7: #828282;
    --rz-series-8: #ae9155;
    --rz-series-9: #b4975b;
    --rz-series-10: #f2f2f2;
    --rz-series-11: #27ae60;
    --rz-series-12: #ff9a47;
    --rz-series-13: #eb5757;
    --rz-series-14: #fcf2dc;
    --rz-series-15: #828282;
    --rz-series-16: #ae9155;
    --rz-series-17: #b4975b;
    --rz-series-18: #f2f2f2;
    --rz-series-19: #27ae60;
    --rz-series-20: #ff9a47;
    --rz-series-21: #eb5757;
    --rz-series-22: #fcf2dc;
    --rz-series-23: #828282;
    --rz-series-24: #ae9155;
}

/* Light-surface token block: the sign-in card is a fixed white brand surface on the navy ground
   in both themes (Figma frame), so it re-declares the LIGHT values of every token its contents
   read, making everything inside render as light mode regardless of data-theme. */
.sr-light-surface {
    --sr-ink-0: #0c0c0c;
    --sr-ink-1: #333333;
    --sr-ink-2: #4f4f4f;
    --sr-ink-3: #828282;
    --sr-ink-4: #bdbdbd;
    --sr-ink-5: #e0e0e0;
    --sr-ink-6: #f2f2f2;
    --sr-ink-7: #ffffff;
    --rz-primary: #0e334e;
    --rz-primary-dark: #003c73;
    --sr-on-primary: #ffffff;
    --sr-focus-ring: 0 0 0 0.15rem rgba(14, 51, 78, 0.2);
    --sr-error: #c34848;
    color-scheme: light;
}

/* =================================================================================================
   Mobile nav drawer (<= 768px)
   -------------------------------------------------------------------------------------------------
   Below this breakpoint the sidebar stops being a layout column and becomes an overlay drawer, so
   page content gets the full viewport width. The header's RadzenSidebarToggle is the hamburger.

   How it works: RadzenLayout is a CSS grid whose columns are `auto 1fr` with the sidebar in the
   `rz-sidebar` area. Taking the sidebar to position:fixed removes it from grid flow, so that `auto`
   track collapses to zero and the body spans the full width - no change to the layout markup needed.

   width/opacity are forced because Radzen drives its own collapse through .rz-sidebar-collapsed
   { width: 0 !important }, which would otherwise win and leave the drawer zero-width when opened.
   Visibility here is transform-only, controlled solely by .sr-nav-open, which keeps ONE mechanism in
   charge on mobile instead of two competing over width.
   ================================================================================================= */
@media (max-width: 768px) {
    .rz-layout .rz-sidebar {
        position: fixed;
        top: var(--rz-header-min-height, 64px);
        bottom: 0;
        left: 0;
        width: var(--rz-sidebar-width, 250px) !important;
        max-width: 85vw;                 /* never let the drawer swallow a narrow screen whole */
        opacity: 1 !important;
        transform: translateX(-100%);     /* off-canvas by default - the drawer is opt-in */
        transition: transform var(--rz-transition, 0.2s ease);
        z-index: 1001;                    /* above the scrim */
    }

    .rz-layout .rz-sidebar.sr-nav-open {
        transform: translateX(0);
    }

    .sr-nav-scrim {
        position: fixed;
        top: var(--rz-header-min-height, 64px);
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1000;                    /* under the drawer, over the body */
        border: 0;
        padding: 0;
        margin: 0;
        appearance: none;
        cursor: pointer;
        background: rgba(0, 0, 0, 0.45);
    }
}

/* Above the breakpoint the drawer machinery is inert: the sidebar is a normal grid column again and
   the toggle is the desktop collapse control, so the backdrop must never paint even though _navOpen
   may still be true from an earlier narrow-viewport session. */
@media (min-width: 769px) {
    .sr-nav-scrim {
        display: none;
    }
}

/* Respect a reduced-motion preference - the slide is decoration, the state change is the point. */
@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
    .rz-layout .rz-sidebar {
        transition: none;
    }
}
