/* Functional admin styling only - deliberately not a design system.
   Single stylesheet so the portal CSP can stay style-src 'self'. */
:root {
    color-scheme: light;
    --background: #ffffff;
    --surface: #f4f4f6;
    --text: #1c1c1e;
    --muted: #5f6269;
    --border: #d6d6da;
    --accent: #12507d;
    --accent-contrast: #ffffff;
    --danger: #a01b1b;
    --success: #176b37;
    --focus: #005fcc;
    --disabled-background: #e8e8eb;
    --disabled-text: #73737a;
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.5 "Segoe UI", system-ui, sans-serif; color: var(--text); background: var(--background); }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}
.admin-header { border-bottom: 1px solid var(--border); background: var(--surface); padding: 12px 20px; }
.admin-header__brand { font-weight: 600; }
.admin-main { max-width: 1100px; margin: 0 auto; padding: 20px; }
h1, h2 { line-height: 1.25; }
table { border-collapse: collapse; width: 100%; margin: 16px 0; }
th, td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
th { background: var(--surface); font-weight: 600; }
code, .token { font-family: Consolas, "Courier New", monospace; }
label { display: block; margin: 12px 0 4px; font-weight: 600; }
input[type=text], input[type=email], input[type=number], input[type=password], input[type=file], select, textarea { width: 100%; max-width: 420px; padding: 8px; border: 1px solid var(--border); border-radius: 4px; color: var(--text); background: var(--background); font: inherit; }
button, .button { min-height: 44px; padding: 10px 16px; border: 1px solid var(--border); border-radius: 4px; color: var(--text); background: var(--surface); font: inherit; cursor: pointer; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
button.danger { background: var(--danger); border-color: var(--danger); color: var(--accent-contrast); }
button:disabled, input:disabled, select:disabled, textarea:disabled, .button:disabled {
    color: var(--disabled-text);
    background: var(--disabled-background);
    cursor: not-allowed;
    opacity: 1;
}
.error { color: var(--danger); }
.success { color: var(--success); }
.muted { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.actions form { margin: 0; }
.notice { border: 1px solid var(--border); border-left: 4px solid var(--success); background: var(--surface); padding: 10px 12px; margin: 12px 0; }
.notice--warn { border-left-color: var(--danger); }
/* MVC renders an empty <ul><li style="display:none"></li></ul> for a valid
   form. The <li> is hidden but the <ul> still paints its list marker, which
   showed as a stray red bullet above every form. */
.validation-summary-valid { display: none; }
.field-validation-valid { display: none; }

/* Header sign-out: a real POST form, styled to sit inline with the nav links. */
.admin-header__signout { display: inline; margin: 0; }
.linklike { background: none; border: none; padding: 0; min-height: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; }
label.inline { display: inline; font-weight: normal; }

/* Phase 4 analytics summary cards. Plain CSS on purpose - no charting
   library, no third-party analytics widget. */
.analytics-summary { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0; }
.analytics-card { border: 1px solid var(--border); border-radius: 4px; background: var(--surface); padding: 12px 16px; min-width: 110px; }
.analytics-card__value { display: block; font-size: 1.6rem; font-weight: 600; }
.analytics-card__label { display: block; font-size: 0.85rem; color: var(--muted); }
.company-logo { max-width: 160px; max-height: 100px; }

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --background: #121316;
        --surface: #1e2024;
        --text: #f1f3f5;
        --muted: #b8bdc6;
        --border: #4a4f57;
        --accent: #8ab4f8;
        --accent-contrast: #10263a;
        --danger: #ff8a80;
        --success: #81c995;
        --focus: #a8c7fa;
        --disabled-background: #2c2f35;
        --disabled-text: #8e949d;
    }
}

/* ---------------------------------------------------------------------------
   Three audiences, three shells. Same stylesheet, because the CSP is
   style-src 'self' and one file is one fewer thing to forget in a deployment.

   Both toggles below are checkboxes. The portal's CSP is script-src 'self'
   with no inline script, and navigation that stops working when a script fails
   to load is worse than navigation that never needed one.
   --------------------------------------------------------------------------- */

/* ---- shared bits ---- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0 8px; }
.stat {
    display: block;
    padding: 16px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 6px;
    background: var(--surface);
    color: inherit;
    text-decoration: none;
}
a.stat:hover, a.stat:focus-visible { border-color: var(--accent); }
.stat--warn { border-left-color: var(--danger); }
.stat__value { display: block; font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat__label { display: block; margin-top: 4px; color: var(--muted); font-size: 14px; }

.panel {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    padding: 20px;
    margin: 20px 0;
}
.panel__head { margin-bottom: 12px; }
.panel h2 { margin: 0 0 4px; }
.panel h3 { margin: 20px 0 8px; font-size: 16px; }
.panel__head p { margin: 0; }

.pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--disabled-background);
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}
.pill--live { background: var(--success); color: #fff; }
.pill--warn { background: var(--danger); color: #fff; }

.card-status { list-style: none; margin: 0; padding: 0; }
.card-status li { margin-bottom: 12px; }

/* ---- anonymous sign-in shell ---- */

.auth-shell { display: flex; justify-content: center; padding: 48px 16px; }
.auth-card {
    width: 100%;
    max-width: 460px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    padding: 28px;
}
.auth-brand { margin: 0 0 20px; font-size: 20px; font-weight: 700; }
.auth-card h1 { margin: 0 0 12px; font-size: 24px; }
.auth-card input[type=text], .auth-card input[type=email], .auth-card input[type=password] { max-width: none; }

/* ---- cardholder portal ---- */

body.portal { background: var(--background); }
.portal-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.portal-header__inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 24px;
}
.portal-header__brand { font-size: 19px; font-weight: 700; color: var(--text); text-decoration: none; }
.portal-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; margin-left: auto; }
.portal-nav a { color: var(--muted); text-decoration: none; padding: 6px 0; border-bottom: 2px solid transparent; }
.portal-nav a:hover { color: var(--text); }
.portal-nav a.is-active { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.portal-nav__signout { display: inline; margin: 0; }
.portal-nav__toggle { display: none; }
.portal-nav__button { display: none; }
.portal-main { max-width: 900px; margin: 0 auto; padding: 24px 20px 48px; }
.portal-footer { max-width: 900px; margin: 0 auto; padding: 0 20px 32px; }

@media (max-width: 720px) {
    .portal-nav__button {
        display: inline-block;
        margin-left: auto;
        padding: 8px 14px;
        min-height: 40px;
        border: 1px solid var(--border);
        border-radius: 4px;
        background: var(--background);
        cursor: pointer;
    }
    .portal-nav { display: none; width: 100%; flex-direction: column; align-items: stretch; gap: 0; margin-left: 0; }
    .portal-nav a, .portal-nav__signout { padding: 12px 0; border-bottom: 1px solid var(--border); }
    .portal-nav a.is-active { border-bottom-color: var(--border); }
    .portal-nav__toggle:checked ~ .portal-nav { display: flex; }
}

/* ---- provider admin shell ---- */

body.admin { background: var(--background); }
.admin-shell__toggle { display: none; }
.admin-topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.admin-topbar__brand { font-size: 18px; font-weight: 700; color: var(--text); text-decoration: none; }
.admin-topbar__brand span { color: var(--muted); font-weight: 400; }
.admin-topbar__right { margin-left: auto; }
.admin-topbar__signout { display: inline; margin: 0; }
.admin-topbar__menu {
    display: none;
    padding: 8px 14px;
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--background);
    cursor: pointer;
}

.admin-shell { display: flex; align-items: flex-start; }
.admin-sidebar {
    flex: 0 0 220px;
    padding: 20px 12px 40px;
    border-right: 1px solid var(--border);
    background: var(--surface);
    min-height: calc(100vh - 61px);
    position: sticky;
    top: 61px;
}
.admin-sidebar__group {
    margin: 20px 0 6px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}
.admin-sidebar__link {
    display: block;
    padding: 9px 10px;
    border-radius: 5px;
    color: var(--text);
    text-decoration: none;
}
.admin-sidebar__link:hover { background: var(--background); }
.admin-sidebar__link.is-active { background: var(--accent); color: var(--accent-contrast); font-weight: 600; }

/* Overrides the pre-existing .admin-main centring, which assumed no sidebar. */
.admin-shell .admin-main { flex: 1 1 auto; max-width: 1100px; margin: 0; padding: 24px 24px 56px; min-width: 0; }

/* Wide tables must scroll inside the page rather than widening it. */
.admin-shell .admin-main table { display: block; overflow-x: auto; max-width: 100%; }

@media (max-width: 900px) {
    .admin-topbar__menu { display: inline-block; }
    .admin-shell { display: block; }
    .admin-sidebar {
        display: none;
        position: static;
        min-height: 0;
        width: 100%;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }
    .admin-shell__toggle:checked ~ .admin-shell .admin-sidebar { display: block; }
    .admin-shell .admin-main { padding: 20px 16px 48px; }
}

@media (prefers-color-scheme: dark) {
    /* admin.css declares color-scheme: light and a light palette. The shells
       above are built entirely from those tokens, so they stay consistent
       rather than half-inverting. */
    body.admin, body.portal, body.auth { background: var(--background); }
}
