:root {
    --admin-bg: #f7f8fb;
    --admin-surface: #ffffff;
    --admin-surface-soft: #f1f4f8;
    --admin-surface-active: #e8f2fa;
    --admin-ink: #18202c;
    --admin-ink-strong: #111827;
    --admin-muted: #657184;
    --admin-line: #e2e8f0;
    --admin-line-strong: #cbd5e1;
    --admin-action: #1779be;
    --admin-action-hover: #116aa6;
    --admin-action-soft: #e7f3fc;
    --admin-success: #1b7a50;
    --admin-success-soft: #e8f7ef;
    --admin-warning: #a86308;
    --admin-warning-soft: #fff5df;
    --admin-danger: #c73f3b;
    --admin-danger-hover: #ad312e;
    --admin-danger-soft: #fdeeed;
    --admin-info-soft: #eaf5fc;
    --admin-focus: rgba(36, 139, 218, 0.28);
    --admin-radius-control: 8px;
    --admin-radius-field: 12px;
    --admin-radius-surface: 16px;
    --admin-shadow-overlay: 0 16px 36px rgba(24, 32, 44, 0.14);
    --admin-z-sticky: 20;
    --admin-z-modal-backdrop: 40;
    --admin-z-modal: 50;
    --admin-z-toast: 70;
    color-scheme: light;
}

html {
    background: var(--admin-bg);
    color: var(--admin-ink);
    font-family: Inter, "Segoe UI Variable", "Segoe UI", Arial, sans-serif;
    scroll-behavior: smooth;
}

body.admin-dashboard,
body.admin-login {
    min-width: 320px;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
    background: var(--admin-bg);
    color: var(--admin-ink);
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body.admin-dashboard button,
body.admin-dashboard input,
body.admin-dashboard select,
body.admin-dashboard textarea,
body.admin-login button,
body.admin-login input {
    font: inherit;
}

.skip-link {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: calc(var(--admin-z-toast) + 1);
    padding: 10px 14px;
    border-radius: var(--admin-radius-control);
    background: var(--admin-ink-strong);
    color: #ffffff;
    font-weight: 650;
    text-decoration: none;
    transform: translateY(-160%);
}

.skip-link:focus {
    transform: translateY(0);
}

/* Dashboard shell */

body.admin-dashboard .container {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    grid-template-rows: 72px minmax(0, 1fr);
    grid-template-areas:
        "header header"
        "navigation content";
    width: 100%;
    max-width: none;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    overflow: visible;
    border-radius: 0;
    background: var(--admin-bg);
    box-shadow: none;
}

body.admin-dashboard header {
    grid-area: header;
    position: sticky;
    top: 0;
    z-index: var(--admin-z-sticky);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-width: 0;
    padding: 0 24px;
    border-bottom: 1px solid var(--admin-line);
    background: var(--admin-surface);
    color: var(--admin-ink);
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.admin-brand-mark {
    display: grid;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 10px;
    background: #245bff;
    color: #ffffff;
    font-size: 13px;
    font-weight: 760;
    letter-spacing: -0.02em;
}

.admin-brand-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    line-height: 1.2;
}

body.admin-dashboard header h1 {
    margin: 0;
    color: var(--admin-ink-strong);
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.015em;
}

.admin-brand-context {
    overflow: hidden;
    margin-top: 2px;
    color: var(--admin-muted);
    font-size: 12px;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-header-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
}

body.admin-dashboard .tabs {
    grid-area: navigation;
    position: sticky;
    top: 72px;
    align-self: start;
    display: flex;
    height: calc(100vh - 72px);
    height: calc(100dvh - 72px);
    flex-direction: column;
    gap: 4px;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 16px 12px;
    border-right: 1px solid var(--admin-line);
    border-bottom: 0;
    background: var(--admin-surface-soft);
    scrollbar-width: thin;
    scrollbar-color: var(--admin-line-strong) transparent;
}

body.admin-dashboard .tab {
    position: relative;
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 0;
    border-radius: var(--admin-radius-control);
    background: transparent;
    color: #435064;
    cursor: pointer;
    font-size: 14px;
    font-weight: 580;
    line-height: 1.3;
    text-align: left;
    white-space: nowrap;
    transition:
        background-color 160ms ease,
        color 160ms ease;
}

body.admin-dashboard .tab:hover {
    background: #e7ebf0;
    color: var(--admin-ink-strong);
}

body.admin-dashboard .tab.active {
    border-bottom: 0;
    background: var(--admin-surface-active);
    color: #116da9;
    font-weight: 680;
}

body.admin-dashboard .tab.active::after {
    width: 7px;
    height: 7px;
    margin-left: auto;
    border-radius: 50%;
    background: var(--admin-action);
    content: "";
}

body.admin-dashboard .content {
    grid-area: content;
    min-width: 0;
    padding: 28px clamp(18px, 3vw, 40px) 48px;
}

body.admin-dashboard .tab-content {
    display: none;
    width: 100%;
    max-width: 1480px;
    margin: 0 auto;
    overflow: visible;
}

body.admin-dashboard .tab-content.active {
    display: block;
    animation: admin-panel-in 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

body.admin-dashboard .tab-content > .content {
    padding: 0;
}

.section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.section-heading-copy {
    min-width: 0;
}

body.admin-dashboard h2,
body.admin-dashboard h3 {
    color: var(--admin-ink-strong);
    text-wrap: balance;
}

body.admin-dashboard h2 {
    margin: 28px 0 16px;
    font-size: 22px;
    font-weight: 720;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

body.admin-dashboard h3 {
    font-size: 17px;
    line-height: 1.3;
}

.section-heading h2 {
    margin: 0;
    font-size: 25px;
}

.section-heading p {
    max-width: 70ch;
    margin: 6px 0 0;
    color: var(--admin-muted);
    text-wrap: pretty;
}

/* Data and tables */

body.admin-dashboard .stats-grid,
body.admin-dashboard #refStats {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)) !important;
    gap: 12px !important;
    margin: 0 0 28px !important;
}

body.admin-dashboard .stat-card {
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--admin-line);
    border-left: 1px solid var(--admin-line);
    border-radius: var(--admin-radius-field);
    background: var(--admin-surface);
}

body.admin-dashboard .stat-value {
    color: var(--admin-ink-strong);
    font-size: 28px;
    font-weight: 720;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.025em;
    overflow-wrap: anywhere;
}

body.admin-dashboard .stat-label {
    margin-top: 5px;
    color: var(--admin-muted);
    font-size: 13px;
    line-height: 1.4;
}

.table-scroll {
    position: relative;
    width: 100%;
    margin: 16px 0 28px;
    overflow-x: auto;
    border: 1px solid var(--admin-line);
    border-radius: var(--admin-radius-field);
    background: var(--admin-surface);
    scrollbar-width: thin;
    scrollbar-color: var(--admin-line-strong) transparent;
    overscroll-behavior-inline: contain;
}

.table-scroll:focus-visible {
    outline: 3px solid var(--admin-focus);
    outline-offset: 2px;
}

body.admin-dashboard table {
    width: max-content;
    min-width: 100%;
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--admin-surface);
    color: var(--admin-ink);
    font-size: 13px;
}

body.admin-dashboard th,
body.admin-dashboard td {
    min-width: 88px;
    padding: 12px 14px !important;
    border-bottom: 1px solid var(--admin-line) !important;
    text-align: left !important;
    vertical-align: middle;
}

body.admin-dashboard th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--admin-surface-soft) !important;
    color: #4b586b;
    font-size: 12px;
    font-weight: 680;
    line-height: 1.3;
    white-space: nowrap;
}

body.admin-dashboard td {
    color: #2b3544;
}

body.admin-dashboard tbody tr:last-child td {
    border-bottom: 0 !important;
}

body.admin-dashboard tbody tr {
    transition: background-color 140ms ease;
}

body.admin-dashboard tbody tr:hover {
    background: #f8fafc;
}

body.admin-dashboard td:last-child {
    min-width: 160px;
}

body.admin-dashboard code {
    display: inline-block;
    max-width: 280px;
    padding: 3px 6px;
    overflow: hidden;
    border-radius: 6px;
    background: var(--admin-surface-soft);
    color: #334155;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    line-height: 1.4;
    text-overflow: ellipsis;
    vertical-align: middle;
    white-space: nowrap;
}

/* Controls */

body.admin-dashboard .btn,
body.admin-login .btn,
body.admin-dashboard #referrals button:not(.tab) {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin: 2px;
    padding: 10px 15px;
    border: 0;
    border-radius: var(--admin-radius-control);
    background: #e6eaf0;
    color: #2f3b4c;
    cursor: pointer;
    font-size: 13px;
    font-weight: 650;
    line-height: 1.25;
    text-align: center;
    text-decoration: none;
    transition:
        background-color 150ms ease,
        color 150ms ease,
        transform 120ms ease;
}

body.admin-dashboard .btn:hover,
body.admin-dashboard #referrals button:not(.tab):hover {
    background: #d9dfe7;
    color: var(--admin-ink-strong);
}

body.admin-dashboard .btn:active,
body.admin-login .btn:active,
body.admin-dashboard #referrals button:not(.tab):active {
    transform: translateY(1px);
}

body.admin-dashboard .btn:disabled,
body.admin-login .btn:disabled,
body.admin-dashboard button[aria-disabled="true"] {
    background: #e7eaf0 !important;
    color: #7c8797 !important;
    cursor: not-allowed;
    transform: none;
}

body.admin-dashboard .btn-sm {
    min-width: 44px;
    min-height: 44px;
    padding: 8px 10px;
    font-size: 12px;
}

body.admin-dashboard .btn-primary,
body.admin-dashboard #referrals button[onclick*="loadReferralStats"],
body.admin-dashboard #referrals button[onclick*="searchReferralUser"],
body.admin-dashboard .modal button[onclick*="showCreate"] {
    background: var(--admin-action) !important;
    color: #ffffff !important;
}

body.admin-dashboard .btn-primary:hover,
body.admin-dashboard #referrals button[onclick*="loadReferralStats"]:hover,
body.admin-dashboard #referrals button[onclick*="searchReferralUser"]:hover,
body.admin-dashboard .modal button[onclick*="showCreate"]:hover {
    background: var(--admin-action-hover) !important;
}

body.admin-dashboard .btn-success {
    background: var(--admin-success);
    color: #ffffff;
}

body.admin-dashboard .btn-success:hover {
    background: #176e48;
}

body.admin-dashboard .btn-danger {
    background: var(--admin-danger);
    color: #ffffff;
}

body.admin-dashboard .btn-danger:hover {
    background: var(--admin-danger-hover);
}

body.admin-dashboard .btn-warning {
    background: var(--admin-warning);
    color: #ffffff;
}

body.admin-dashboard .btn-info {
    background: #12689e;
    color: #ffffff;
}

body.admin-dashboard .btn-secondary {
    background: #4f5d70;
    color: #ffffff;
}

body.admin-dashboard .btn-secondary:hover {
    background: #3d495a;
    color: #ffffff;
}

body.admin-dashboard input,
body.admin-dashboard select,
body.admin-dashboard textarea,
body.admin-login input {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px !important;
    border: 1px solid var(--admin-line-strong) !important;
    border-radius: var(--admin-radius-field) !important;
    outline: 0;
    background: var(--admin-surface) !important;
    color: var(--admin-ink-strong);
    font-size: 15px;
    line-height: 1.4;
    transition:
        border-color 150ms ease,
        box-shadow 150ms ease,
        background-color 150ms ease;
}

body.admin-dashboard input::placeholder,
body.admin-dashboard textarea::placeholder,
body.admin-login input::placeholder {
    color: #697589;
    opacity: 1;
}

body.admin-dashboard textarea {
    min-height: 120px;
    resize: vertical;
}

body.admin-dashboard input:hover,
body.admin-dashboard select:hover,
body.admin-dashboard textarea:hover,
body.admin-login input:hover {
    border-color: #aeb8c6 !important;
}

body.admin-dashboard input:focus,
body.admin-dashboard select:focus,
body.admin-dashboard textarea:focus,
body.admin-login input:focus {
    border-color: var(--admin-action) !important;
    box-shadow: 0 0 0 3px var(--admin-focus);
}

body.admin-dashboard input:disabled,
body.admin-dashboard select:disabled,
body.admin-dashboard textarea:disabled {
    background: var(--admin-surface-soft) !important;
    color: #7c8797;
    cursor: not-allowed;
}

body.admin-dashboard input[type="checkbox"],
body.admin-login input[type="checkbox"] {
    width: 20px;
    min-width: 20px;
    height: 20px;
    min-height: 20px;
    margin: 0 9px 0 0;
    padding: 0 !important;
    border-radius: 5px !important;
    accent-color: var(--admin-action);
}

body.admin-dashboard input[type="file"] {
    padding: 8px !important;
}

body.admin-dashboard label,
body.admin-login label {
    display: block;
    margin-bottom: 7px;
    color: #445064;
    font-size: 13px;
    font-weight: 650;
    line-height: 1.35;
}

body.admin-dashboard .form-group {
    max-width: 760px;
    margin-bottom: 18px;
}

body.admin-dashboard .form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

body.admin-dashboard .checkbox-group,
body.admin-dashboard label:has(> input[type="checkbox"]) {
    display: flex;
    min-height: 44px;
    align-items: center;
    margin-bottom: 8px;
}

body.admin-dashboard .help-text,
body.admin-dashboard small {
    display: block;
    margin-top: 5px;
    color: var(--admin-muted);
    font-size: 12px;
    line-height: 1.45;
}

body.admin-dashboard .history-fields,
body.admin-dashboard .session-fields,
body.admin-dashboard .ai-survey-fields,
body.admin-dashboard .schedule-fields,
body.admin-dashboard #addPromptForm,
body.admin-dashboard #addScenarioForm {
    margin: 12px 0 18px !important;
    padding: 16px !important;
    border: 1px solid #ead6ae !important;
    border-left: 1px solid #ead6ae !important;
    border-radius: var(--admin-radius-field) !important;
    background: var(--admin-warning-soft) !important;
}

/* Notices and status */

body.admin-dashboard .alert {
    max-width: 82ch;
    margin-bottom: 22px;
    padding: 13px 15px;
    border: 1px solid var(--admin-line);
    border-left: 1px solid var(--admin-line);
    border-radius: var(--admin-radius-field);
    font-size: 13px;
    line-height: 1.5;
}

body.admin-dashboard .alert-info {
    border-color: #c9e4f6;
    background: var(--admin-info-soft);
    color: #25506d;
}

body.admin-dashboard .alert-warning {
    border-color: #ead6ae;
    background: var(--admin-warning-soft);
    color: #714708;
}

body.admin-dashboard .badge,
body.admin-dashboard .token-badge {
    display: inline-flex;
    min-height: 24px;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 680;
    line-height: 1.2;
    white-space: nowrap;
}

body.admin-dashboard .badge-client {
    background: #ecebfc;
    color: #5147a8;
}

body.admin-dashboard .badge-corporate,
body.admin-dashboard .badge-info,
body.admin-dashboard .badge-primary {
    background: var(--admin-action-soft);
    color: #12689e;
}

body.admin-dashboard .badge-success {
    background: var(--admin-success-soft);
    color: #166b45;
}

body.admin-dashboard .badge-danger {
    background: var(--admin-danger-soft);
    color: #9e312f;
}

body.admin-dashboard .badge-warning {
    background: var(--admin-warning-soft);
    color: #82510a;
}

body.admin-dashboard .badge-secondary {
    background: #e8ebef;
    color: #4d596b;
}

body.admin-dashboard .prompt-list,
body.admin-dashboard .scenario-list {
    margin-top: 12px;
}

body.admin-dashboard .prompt-item,
body.admin-dashboard .scenario-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    padding: 12px 14px;
    border: 1px solid var(--admin-line);
    border-radius: var(--admin-radius-control);
    background: var(--admin-surface-soft);
}

/* Referral legacy inline layout normalization */

body.admin-dashboard #referrals > .content > div[style*="background"] {
    margin: 18px 0 24px !important;
    padding: 14px !important;
    border: 1px solid var(--admin-line);
    border-radius: var(--admin-radius-field) !important;
    background: var(--admin-surface-soft) !important;
}

body.admin-dashboard #customDates {
    flex-wrap: wrap;
}

body.admin-dashboard #refPeriod,
body.admin-dashboard #topSort,
body.admin-dashboard #refStartDate,
body.admin-dashboard #refEndDate,
body.admin-dashboard #refSearch,
body.admin-dashboard #refSearchStartDate,
body.admin-dashboard #refSearchEndDate {
    min-width: 150px;
}

/* Modal layer */

body.admin-dashboard .modal {
    position: fixed;
    inset: 0;
    z-index: var(--admin-z-modal-backdrop);
    display: none;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 18px;
    background: rgba(17, 24, 39, 0.56);
    overscroll-behavior: contain;
}

body.admin-dashboard .modal.active {
    display: flex;
}

body.admin-dashboard .modal-content {
    position: relative;
    z-index: var(--admin-z-modal);
    width: min(100%, 760px) !important;
    max-height: calc(100vh - 36px) !important;
    max-height: calc(100dvh - 36px) !important;
    margin: auto;
    overflow-y: auto;
    padding: clamp(18px, 3vw, 28px) !important;
    border-radius: var(--admin-radius-surface) !important;
    background: var(--admin-surface) !important;
    box-shadow: var(--admin-shadow-overlay) !important;
    scrollbar-width: thin;
    scrollbar-color: var(--admin-line-strong) transparent;
}

body.admin-dashboard .modal-content[style*="max-width:1200"],
body.admin-dashboard .modal-content[style*="max-width: 1200"],
body.admin-dashboard .modal-content[style*="max-width:1000"],
body.admin-dashboard .modal-content[style*="max-width: 1000"] {
    width: min(100%, 1180px) !important;
}

body.admin-dashboard .modal-content[style*="max-width:900"],
body.admin-dashboard .modal-content[style*="max-width: 900"],
body.admin-dashboard .modal-content[style*="max-width:800"],
body.admin-dashboard .modal-content[style*="max-width: 800"] {
    width: min(100%, 900px) !important;
}

body.admin-dashboard .modal-header {
    position: sticky;
    top: calc(clamp(18px, 3vw, 28px) * -1);
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: calc(clamp(18px, 3vw, 28px) * -1) calc(clamp(18px, 3vw, 28px) * -1) 20px;
    padding: 18px clamp(18px, 3vw, 28px) 14px;
    border-bottom: 1px solid var(--admin-line);
    background: var(--admin-surface);
}

body.admin-dashboard .modal-header h2 {
    margin: 0;
}

body.admin-dashboard .modal button[onclick*="close"]:not(.btn),
body.admin-dashboard .modal button[onclick*="remove"]:not(.btn) {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0 !important;
    border-radius: var(--admin-radius-control) !important;
    background: transparent !important;
    color: #526074 !important;
    font-size: 25px !important;
}

body.admin-dashboard .modal button[onclick*="close"]:not(.btn):hover,
body.admin-dashboard .modal button[onclick*="remove"]:not(.btn):hover {
    background: var(--admin-surface-soft) !important;
    color: var(--admin-ink-strong) !important;
}

/* Login */

body.admin-login {
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-shell {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(360px, 440px);
    width: min(100%, 980px);
    overflow: hidden;
    border: 1px solid var(--admin-line);
    border-radius: var(--admin-radius-surface);
    background: var(--admin-surface);
}

.login-intro {
    display: flex;
    min-height: 520px;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(30px, 5vw, 56px);
    background: #18202c;
    color: #ffffff;
}

.login-intro .admin-brand-mark {
    background: #ffffff;
    color: #245bff;
}

.login-intro-copy {
    max-width: 36ch;
}

.login-intro h1 {
    margin: 0 0 14px;
    font-size: 28px;
    font-weight: 720;
    line-height: 1.15;
    letter-spacing: -0.025em;
    text-wrap: balance;
}

.login-intro p {
    margin: 0;
    color: #cbd5e1;
    font-size: 14px;
    line-height: 1.6;
    text-wrap: pretty;
}

.login-intro-note {
    color: #9ca8b8;
    font-size: 12px;
}

body.admin-login .login-container {
    align-self: center;
    width: 100%;
    max-width: none;
    padding: clamp(28px, 5vw, 48px);
    border-radius: 0;
    background: var(--admin-surface);
    box-shadow: none;
}

body.admin-login .logo {
    margin-bottom: 28px;
    text-align: left;
}

body.admin-login .logo h2 {
    margin: 0 0 8px;
    color: var(--admin-ink-strong);
    font-size: 24px;
    font-weight: 720;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

body.admin-login .logo p {
    max-width: 45ch;
    margin: 0;
    color: var(--admin-muted);
    font-size: 14px;
    line-height: 1.5;
}

body.admin-login .form-group {
    margin-bottom: 18px;
}

body.admin-login .btn {
    width: 100%;
    margin: 4px 0 0;
    background: var(--admin-action);
    color: #ffffff;
    font-size: 14px;
}

body.admin-login .btn:hover {
    background: var(--admin-action-hover);
}

body.admin-login .btn[aria-busy="true"]::before {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: #ffffff;
    border-radius: 50%;
    content: "";
    animation: admin-spin 700ms linear infinite;
}

body.admin-login .error {
    display: none;
    margin-bottom: 18px;
    padding: 12px 14px;
    border: 1px solid #f1c3c1;
    border-radius: var(--admin-radius-field);
    background: var(--admin-danger-soft);
    color: #8c2e2b;
    font-size: 13px;
    line-height: 1.5;
}

body.admin-login .error.active {
    display: block;
}

body.admin-login .attempts-warning {
    display: none;
    margin-top: 12px;
    color: #85520b;
    font-size: 12px;
    line-height: 1.4;
    text-align: center;
}

body.admin-login .attempts-warning.active {
    display: block;
}

body.admin-login .link {
    margin-top: 22px;
    color: var(--admin-muted);
    font-size: 13px;
    text-align: center;
}

body.admin-login .link a {
    color: #176fa9;
    font-weight: 600;
    text-decoration: none;
    text-underline-offset: 3px;
}

body.admin-login .link a:hover {
    text-decoration: underline;
}

/* Shared focus and responsive states */

body.admin-dashboard :where(button, a, [tabindex]):focus-visible,
body.admin-login :where(button, a, [tabindex]):focus-visible {
    outline: 3px solid var(--admin-focus);
    outline-offset: 2px;
}

@keyframes admin-panel-in {
    from {
        opacity: 0.65;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@media (max-width: 900px) {
    body.admin-dashboard .container {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: 64px auto minmax(0, 1fr);
        grid-template-areas:
            "header"
            "navigation"
            "content";
    }

    body.admin-dashboard header {
        min-height: 64px;
        padding: 0 16px;
    }

    body.admin-dashboard .tabs {
        position: sticky;
        top: 64px;
        z-index: calc(var(--admin-z-sticky) - 1);
        display: flex;
        width: 100%;
        height: auto;
        flex-direction: row;
        gap: 6px;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 8px 12px;
        border-right: 0;
        border-bottom: 1px solid var(--admin-line);
        background: var(--admin-surface);
        scroll-snap-type: x proximity;
    }

    body.admin-dashboard .tab {
        width: auto;
        padding-inline: 13px;
        scroll-snap-align: start;
    }

    body.admin-dashboard .tab.active::after {
        display: none;
    }

    body.admin-dashboard .content {
        padding: 22px 16px 40px;
    }

    .login-shell {
        grid-template-columns: 1fr;
        width: min(100%, 480px);
    }

    .login-intro {
        min-height: 0;
        padding: 24px;
    }

    .login-intro-copy {
        margin-top: 36px;
    }

    .login-intro-note {
        display: none;
    }
}

@media (max-width: 620px) {
    body.admin-dashboard header {
        gap: 8px;
    }

    .admin-brand-context {
        display: none;
    }

    .admin-header-actions {
        gap: 4px;
    }

    .admin-header-actions .btn {
        min-width: 44px;
        padding-inline: 11px;
    }

    .admin-header-actions .btn-label-wide {
        display: none;
    }

    body.admin-dashboard .content {
        padding-inline: 12px;
    }

    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .section-heading h2 {
        font-size: 22px;
    }

    body.admin-dashboard .stats-grid,
    body.admin-dashboard #refStats {
        grid-template-columns: 1fr !important;
    }

    body.admin-dashboard .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    body.admin-dashboard .modal {
        align-items: flex-end;
        padding: 8px;
    }

    body.admin-dashboard .modal-content {
        width: 100% !important;
        max-height: calc(100dvh - 16px) !important;
        border-radius: 14px 14px 8px 8px !important;
    }

    body.admin-login {
        align-items: stretch;
        padding: 0;
        background: var(--admin-surface);
    }

    .login-shell {
        min-height: 100dvh;
        border: 0;
        border-radius: 0;
    }

    .login-intro {
        padding: 22px 20px;
    }

    .login-intro-copy {
        margin-top: 26px;
    }

    .login-intro h1 {
        font-size: 23px;
    }

    body.admin-login .login-container {
        padding: 30px 20px 24px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
