/* ===========================================================================
   Brand tokens and app shell, shared by the dashboard, login and public form.

   Styling follows the Marshall Freeman intranet: a brand-coloured sidebar, a
   flat light-grey page, white panels with a hairline border, and no gradients.
   brand.js sets <html data-brand> from the hostname; each brand below only
   overrides the brand tokens, so every page restyles from one place.
   =========================================================================== */

:root {
    /* Neutrals (identical for every brand) */
    --page: #f3f5f7;
    --surface: #ffffff;
    --ink: #202b38;
    --text: #566571;
    --label: #394854;
    --muted: #7a8790;
    --line: #dce2e7;
    --row-line: #e8ecef;
    --head-bg: #f6f8fa;
    --input-line: #bbc7cf;
    --danger: #a03030;
    --danger-bg: #fdecea;
    --notice-bg: #fff3d9;
    --notice-line: #c28b28;
    --success-bg: #e1f2e8;
    --success-ink: #1d4f3c;

    --radius-panel: 7px;
    --radius-button: 5px;
    --radius-control: 4px;
    --radius-nav: 10px;

    /* Buttons and inputs, after the MF debts dashboard */
    --control-height: 40px;
    --control-height-sm: 32px;
    --control-radius: 8px;
    --control-line: #cad6e1;
    --control-placeholder: #8a9bb0;
    --neutral-fill: #c7ced5;
    --neutral-fill-hover: #b9c2cb;
    --font: system-ui, -apple-system, "Segoe UI", sans-serif;
    --sidebar-width: 225px;

    /* Brand: Marshall Freeman (default), copied from the intranet */
    --brand: #02539c;
    --nav-bg: #02539c;
    --nav-line: #1c65a6;
    --nav-ink: #e6eef6;
    --nav-text: #c9dbeb;
    --nav-muted: #9abad7;
    --nav-current: #0a64b5;
    /* Primary buttons are the brand navy, as on the MF debts dashboard */
    --action: #054992;
    --action-soft: #0d59ac;
    --action-border: #b3c8e0;
    --action-tint: #e7eef7;
    --action-tint-ink: #054992;
    --focus-ring: rgba(5, 73, 146, 0.18);
    --link: #216b55;
    --focus: #6f9fd8;
    --eyebrow: #37725d;
    --accent: #02539c;          /* brand colour readable as text on white */
    --accent-tint: #e8f0f8;

    /* Older names still used across the stylesheets. Flat colours now: the
       intranet uses no gradients. */
    --primary-color: var(--accent);
    --secondary-color: var(--nav-bg);
    --primary-gradient: var(--action);
    --secondary-gradient: var(--action-soft);
}

/* Pay Advantage: black sidebar, red accents. The action red is a shade darker
   than the brand red so white button text stays readable. */
[data-brand="payadvantage"] {
    --brand: #d51e33;
    --nav-bg: #151515;
    --nav-line: #2c2c2c;
    --nav-ink: #f2f2f2;
    --nav-text: #d4d4d4;
    --nav-muted: #9b9b9b;
    --nav-current: #d51e33;
    --action: #c01b2f;
    --action-soft: #d51e33;
    --action-border: #ebbcc2;
    --action-tint: #fbeaec;
    --action-tint-ink: #8f1626;
    --focus-ring: rgba(192, 27, 47, 0.18);
    --link: #b0192c;
    --focus: #ef8a97;
    --eyebrow: #b0192c;
    --accent: #c01b2f;
    --accent-tint: #fbeaec;
}

/* Local Recoveries: the brand teal is too light for white text, so the
   sidebar and buttons use deeper shades of it. */
[data-brand="local-recoveries"] {
    --brand: #00d1d0;
    --nav-bg: #00605f;
    --nav-line: #137473;
    --nav-ink: #eefafa;
    --nav-text: #c8ecec;
    --nav-muted: #8ccfcd;
    --nav-current: #00807e;
    --action: #00706e;
    --action-soft: #00807e;
    --action-border: #b3dedd;
    --action-tint: #e2f5f5;
    --action-tint-ink: #00605f;
    --focus-ring: rgba(0, 112, 110, 0.2);
    --link: #2a7a1c;
    --focus: #4fc3c2;
    --eyebrow: #00807e;
    --accent: #00807e;
    --accent-tint: #e2f5f5;
}

/* ---------------------------------------------------------------------------
   Base
   --------------------------------------------------------------------------- */

html, body {
    background: var(--page);
}

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
}

a {
    color: var(--link);
}

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 1px;
}

/* ---------------------------------------------------------------------------
   App shell: fixed sidebar + main column
   --------------------------------------------------------------------------- */

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    background: var(--nav-bg);
    color: var(--nav-ink);
    padding: 30px 22px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 50;
}

.app-main {
    margin-left: var(--sidebar-width);
    padding: 0 38px 32px;
    max-width: calc(1600px + var(--sidebar-width));
    min-height: 100vh;
}

/* Brand lockup (filled by brand.js) */
.brand-lockup {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    padding-bottom: 26px;
    border-bottom: 1px solid var(--nav-line);
    min-height: 120px;
}

.brand-mark svg {
    display: block;
    width: 58px;
    height: 44px;
    margin-bottom: 10px;
}

.brand-name {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.2px;
    white-space: nowrap;
    text-transform: uppercase;
    color: #fff;
    line-height: 1.2;
}

/* The Local Recoveries wordmark is dark; render it white on the sidebar. */
.brand-logo {
    display: block;
    width: 120px;
    height: auto;
    filter: brightness(0) invert(1);
    margin-bottom: 4px;
}

.brand-product {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--nav-muted);
}

/* Sidebar navigation */
.side-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 24px;
}

.side-nav a,
.side-nav button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border: 0;
    border-radius: var(--radius-nav);
    background: transparent;
    color: var(--nav-text);
    font: inherit;
    font-size: 14px;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.side-nav i {
    width: 16px;
    text-align: center;
    font-size: 13px;
    opacity: 0.85;
}

.side-nav a:hover,
.side-nav button:hover,
.side-nav a:focus-visible,
.side-nav button:focus-visible {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.side-nav .active {
    background: var(--nav-current);
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

/* Signed-in user, pinned to the bottom of the sidebar */
.sidebar-account {
    margin-top: auto;
    padding-top: 24px;
    color: var(--nav-ink);
    font-size: 13px;
}

.sidebar-account .account-name {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
}

.account-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.account-actions .role-badge {
    font-size: 11px;
    color: var(--nav-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-weight: 700;
}

.sidebar-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: var(--radius-button);
    background: transparent;
    color: var(--nav-ink);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.sidebar-button:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.sidebar-note {
    color: var(--nav-muted);
    font-size: 12px;
    line-height: 1.5;
}

/* ---------------------------------------------------------------------------
   Page heading: eyebrow + title, under a hairline like the intranet
   --------------------------------------------------------------------------- */

.page-header {
    border-top: 1px solid var(--line);
    margin-top: 68px;
    padding-top: 28px;
    margin-bottom: 8px;
}

.eyebrow {
    font-size: 10px;
    font-weight: 750;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--eyebrow);
    margin: 0 0 16px;
}

.page-title {
    font-size: 32px;
    font-weight: 650;
    letter-spacing: -1px;
    line-height: 1.2;
    color: var(--ink);
    margin: 0 0 12px;
}

.page-lead {
    color: var(--text);
    font-size: 14px;
    margin: 0 0 8px;
}

/* ---------------------------------------------------------------------------
   Buttons, after the MF debts dashboard: solid brand primary, white outlined
   secondary, grey neutral. Every page's button classes map onto these three,
   so this block wins over the older per-page button rules (it loads last).
   --------------------------------------------------------------------------- */

.app-main .button,
.app-main .btn,
.app-main .btn-primary,
.app-main .action-btn,
.app-main .filter-btn,
.app-main .export-report-btn,
.app-main .security-btn,
.app-main .toggle-form-btn,
.app-main .next-btn,
.app-main .submit-btn,
.app-main .prev-btn,
.app-main .reset-btn,
.app-main .back-btn,
.app-main .btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--control-height);
    padding: 0 18px;
    border: 1px solid var(--action);
    border-radius: var(--control-radius);
    background: var(--action);
    color: #fff;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.12);
    transform: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.app-main .button:hover,
.app-main .btn:hover,
.app-main .btn-primary:hover,
.app-main .action-btn:hover,
.app-main .filter-btn:hover,
.app-main .export-report-btn:hover,
.app-main .security-btn:hover,
.app-main .toggle-form-btn:hover,
.app-main .next-btn:hover,
.app-main .submit-btn:hover {
    background: var(--action-soft);
    border-color: var(--action-soft);
    transform: none;
}

/* Secondary: white with a grey outline, like "Export". Exports use it too,
   leaving the solid button for the main action, as in the reference. */
.app-main .button.secondary,
.app-main .action-btn.secondary,
.app-main .btn-secondary,
.app-main .prev-btn,
.app-main .back-btn,
.app-main .export-btn,
.app-main .export-report-btn,
.app-main .qualification-card .btn-secondary {
    background: var(--surface);
    border-color: var(--control-line);
    color: var(--ink);
}

.app-main .button.secondary:hover,
.app-main .action-btn.secondary:hover,
.app-main .btn-secondary:hover,
.app-main .prev-btn:hover,
.app-main .back-btn:hover,
.app-main .export-btn:hover,
.app-main .export-report-btn:hover,
.app-main .qualification-card .btn-secondary:hover {
    background: #f3f6f9;
    border-color: #b7c5d5;
    color: var(--ink);
}

/* Neutral: grey fill, like "Clear" */
.app-main .reset-btn {
    background: var(--neutral-fill);
    border-color: var(--neutral-fill);
    color: var(--ink);
    box-shadow: none;
}

.app-main .reset-btn:hover {
    background: var(--neutral-fill-hover);
    border-color: var(--neutral-fill-hover);
}

.app-main .action-btn.danger,
.app-main .security-btn.danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.app-main .action-btn.danger:hover,
.app-main .security-btn.danger:hover {
    background: #8a2828;
    border-color: #8a2828;
}

.app-main .action-btn.small,
.app-main .security-btn.small,
.app-main .btn-sm {
    min-height: var(--control-height-sm);
    padding: 0 12px;
    font-size: 13px;
}

.app-main button:disabled,
.app-main .button:disabled {
    background: var(--neutral-fill);
    border-color: var(--neutral-fill);
    color: var(--muted);
    box-shadow: none;
    cursor: not-allowed;
}

.app-main button:focus-visible,
.app-main .button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Segmented control: pill track with the active option filled, like the
   "All / Debt Lodgement / Reminder Notice" switch */
.segmented {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--row-line);
    border-radius: 999px;
    background: var(--surface);
}

.segmented button {
    min-height: 30px;
    padding: 0 16px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--label);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.segmented button:hover {
    background: var(--head-bg);
}

.segmented button.active {
    background: var(--action);
    color: #fff;
}

/* ---------------------------------------------------------------------------
   Inputs: light blue-grey 2px outline, 8px corners, brand focus ring, like the
   "Quick Filter" field. Search fields are fully rounded as in the reference.
   --------------------------------------------------------------------------- */

.app-main input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]):not([type="range"]),
.app-main select,
.app-main textarea {
    min-height: var(--control-height);
    padding: 8px 12px;
    border: 2px solid var(--control-line);
    border-radius: var(--control-radius);
    background-color: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 14px;
    box-shadow: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.app-main textarea {
    line-height: 1.5;
}

.app-main input::placeholder,
.app-main textarea::placeholder {
    color: var(--control-placeholder);
    opacity: 1;
}

.app-main input:not([type="checkbox"]):not([type="radio"]):hover,
.app-main select:hover,
.app-main textarea:hover {
    border-color: #b7c5d5;
}

.app-main input:not([type="checkbox"]):not([type="radio"]):focus,
.app-main select:focus,
.app-main textarea:focus {
    outline: none;
    border-color: var(--action);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Native selects get a consistent chevron so they match the text fields */
.app-main select:not([multiple]) {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23566571' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px 8px;
    cursor: pointer;
}

.app-main input[type="search"] {
    border-radius: 999px;
    padding-left: 18px;
    padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24'%3E%3Ccircle cx='10.5' cy='10.5' r='7' fill='none' stroke='%23202b38' stroke-width='2'/%3E%3Cpath d='M16 16l5.5 5.5' stroke='%23202b38' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 18px 18px;
}

.app-main input:disabled,
.app-main select:disabled,
.app-main textarea:disabled {
    background-color: var(--head-bg);
    color: var(--muted);
    cursor: not-allowed;
}

.app-main input[type="checkbox"],
.app-main input[type="radio"] {
    accent-color: var(--action);
}

/* ---------------------------------------------------------------------------
   Responsive: same breakpoints as the intranet
   --------------------------------------------------------------------------- */

@media (max-width: 1000px) {
    :root { --sidebar-width: 190px; }
    .app-sidebar { padding: 25px 15px; }
    .app-main { padding: 0 20px 24px; }
    .brand-name { font-size: 14px; }
}

@media (max-width: 650px) {
    .app-sidebar {
        position: static;
        width: auto;
        padding: 16px;
    }
    .brand-lockup {
        flex-direction: row;
        justify-content: center;
        min-height: 0;
        padding-bottom: 14px;
    }
    .brand-mark svg { width: 32px; height: 24px; margin: 0; }
    .brand-logo { width: 80px; }
    .side-nav {
        flex-direction: row;
        flex-wrap: wrap;
        margin-top: 12px;
        gap: 2px;
    }
    .side-nav a, .side-nav button { width: auto; padding: 8px; }
    .sidebar-account {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        margin-top: 12px;
        padding-top: 0;
    }
    .sidebar-account .account-name { margin: 0; }
    .app-main { margin-left: 0; padding: 0 14px 24px; }
    .page-header { margin-top: 24px; }
    .page-title { font-size: 27px; }
}

@media print {
    .app-sidebar { display: none !important; }
    .app-main { margin: 0; padding: 0; max-width: none; }
}
