/* ============================================================
   PDFencrypt Admin — Design System
   Blumm brand identity · self-hosted fonts · light/dark tokens
   ============================================================ */

/* --- Font Face: Blumm brand type (self-hosted, no CDN) ---
   Outfit = body & UI · Syne = card titles · Playfair Display = headlines
   · IBM Plex Mono = labels, IDs, technical. Latin subsets. */
@font-face{font-family:'Outfit';font-style:normal;font-weight:300;font-display:swap;src:url('/assets/fonts/blumm/outfit-300.woff2') format('woff2')}
@font-face{font-family:'Outfit';font-style:normal;font-weight:400;font-display:swap;src:url('/assets/fonts/blumm/outfit-400.woff2') format('woff2')}
@font-face{font-family:'Outfit';font-style:normal;font-weight:500;font-display:swap;src:url('/assets/fonts/blumm/outfit-500.woff2') format('woff2')}
@font-face{font-family:'Outfit';font-style:normal;font-weight:600;font-display:swap;src:url('/assets/fonts/blumm/outfit-600.woff2') format('woff2')}
@font-face{font-family:'Outfit';font-style:normal;font-weight:700;font-display:swap;src:url('/assets/fonts/blumm/outfit-700.woff2') format('woff2')}
@font-face{font-family:'Syne';font-style:normal;font-weight:600;font-display:swap;src:url('/assets/fonts/blumm/syne-600.woff2') format('woff2')}
@font-face{font-family:'Syne';font-style:normal;font-weight:700;font-display:swap;src:url('/assets/fonts/blumm/syne-700.woff2') format('woff2')}
@font-face{font-family:'Playfair Display';font-style:normal;font-weight:700;font-display:swap;src:url('/assets/fonts/blumm/playfair-700.woff2') format('woff2')}
@font-face{font-family:'Playfair Display';font-style:italic;font-weight:700;font-display:swap;src:url('/assets/fonts/blumm/playfair-700i.woff2') format('woff2')}
@font-face{font-family:'IBM Plex Mono';font-style:normal;font-weight:400;font-display:swap;src:url('/assets/fonts/blumm/plexmono-400.woff2') format('woff2')}
@font-face{font-family:'IBM Plex Mono';font-style:normal;font-weight:500;font-display:swap;src:url('/assets/fonts/blumm/plexmono-500.woff2') format('woff2')}

/* --- Theme Variables --- */
:root {
    /* Typography — Blumm brand roles */
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
    --font-head: 'Syne', 'Outfit', system-ui, sans-serif;
    --font-mono: 'IBM Plex Mono', 'SF Mono', 'Consolas', monospace;

    /* Light theme (default) — Blumm palette */
    --color-bg: #f5f7fc;
    --color-surface: #ffffff;
    --color-surface-hover: #f4f6fa;
    --color-surface-alt: #f4f6fa;

    --color-sidebar: #171b30;
    --color-sidebar-hover: rgba(255, 255, 255, 0.05);
    --color-sidebar-active: rgba(255, 255, 255, 0.06);
    --color-sidebar-text: #9198b6;
    --color-sidebar-text-hover: #ffffff;
    --color-sidebar-text-active: #ffffff;
    --color-sidebar-border: rgba(255, 255, 255, 0.07);
    --color-sidebar-accent: #00c9a7;

    --color-primary: #3b5daf;
    --color-primary-hover: #2e4a8c;
    --color-primary-subtle: rgba(59, 93, 175, 0.09);
    --color-accent: #00c9a7;
    --color-accent-ink: #0e9f87;

    --color-text: #1a1f36;
    --color-text-secondary: #4a5068;
    --color-text-muted: #6e7590;
    --color-text-inverse: #ffffff;

    --color-border: #e5e9f2;
    --color-border-strong: #d4dbea;
    --color-input-bg: #ffffff;
    --color-input-border: #d9e0ee;
    --color-input-focus: #3b5daf;
    --color-input-focus-ring: rgba(59, 93, 175, 0.18);

    --color-success: #0e9f87;
    --color-success-bg: #e2f6f1;
    --color-success-text: #0b6d5d;
    --color-success-border: #b6e8dd;

    --color-danger: #c0453f;
    --color-danger-bg: #fbe9e8;
    --color-danger-text: #8f2e2a;
    --color-danger-border: #f3cbc8;

    --color-warning: #b27a16;
    --color-warning-bg: #fbf0da;
    --color-warning-text: #7d5410;
    --color-warning-border: #f0dcae;

    --color-info: #3b5daf;
    --color-info-bg: #eaeffa;
    --color-info-text: #2c4783;
    --color-info-border: #c9d6f0;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 8px 32px rgba(0, 0, 0, 0.12);

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --radius-xl: 14px;
    --radius-full: 9999px;

    /* Spacing base */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 60px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
    --transition-slow: 300ms ease;
}

/* --- Dark Theme --- */
[data-theme="dark"] {
    --color-bg: #0f1327;
    --color-surface: #181d34;
    --color-surface-hover: #1f2542;
    --color-surface-alt: #1f2542;

    --color-sidebar: #0b0f20;
    --color-sidebar-hover: rgba(255, 255, 255, 0.06);
    --color-sidebar-active: rgba(255, 255, 255, 0.07);
    --color-sidebar-text: #828ab0;
    --color-sidebar-text-hover: #ffffff;
    --color-sidebar-text-active: #f4f6fc;
    --color-sidebar-border: rgba(255, 255, 255, 0.06);
    --color-sidebar-accent: #2bd4b4;

    --color-primary: #7c97de;
    --color-primary-hover: #9db2e9;
    --color-primary-subtle: rgba(124, 151, 222, 0.15);
    --color-accent: #2bd4b4;
    --color-accent-ink: #2bd4b4;

    --color-text: #eaedf8;
    --color-text-secondary: #b7beda;
    --color-text-muted: #8990b0;
    --color-text-inverse: #10142a;

    --color-border: rgba(255, 255, 255, 0.10);
    --color-border-strong: rgba(255, 255, 255, 0.18);
    --color-input-bg: #12172e;
    --color-input-border: rgba(255, 255, 255, 0.14);
    --color-input-focus: #7c97de;
    --color-input-focus-ring: rgba(124, 151, 222, 0.28);

    --color-success: #2bd4b4;
    --color-success-bg: rgba(43, 212, 180, 0.14);
    --color-success-text: #7fe6d3;
    --color-success-border: rgba(43, 212, 180, 0.3);

    --color-danger: #e5726b;
    --color-danger-bg: rgba(229, 114, 107, 0.14);
    --color-danger-text: #f0a9a4;
    --color-danger-border: rgba(229, 114, 107, 0.3);

    --color-warning: #e0a93e;
    --color-warning-bg: rgba(224, 169, 62, 0.14);
    --color-warning-text: #eecb84;
    --color-warning-border: rgba(224, 169, 62, 0.3);

    --color-info: #7c97de;
    --color-info-bg: rgba(124, 151, 222, 0.14);
    --color-info-text: #aebfe8;
    --color-info-border: rgba(124, 151, 222, 0.3);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* --- Reset --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* --- Base --- */
body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Theme transition — only applied after initial load to avoid flash */
body.theme-transition,
body.theme-transition *,
body.theme-transition *::before,
body.theme-transition *::after {
    transition: background-color var(--transition-normal), color var(--transition-normal),
                border-color var(--transition-normal), box-shadow var(--transition-normal) !important;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-hover); }

/* ============================================================
   LAYOUT — Sidebar + Main
   ============================================================ */

/* --- Sidebar --- */
.admin-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--color-sidebar);
    color: var(--color-sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition-slow);
    border-right: 1px solid var(--color-sidebar-border);
}

.sidebar-brand {
    padding: 28px 24px 24px;
    border-bottom: 1px solid var(--color-sidebar-border);
}

.sidebar-brand h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-sidebar-text-active);
    letter-spacing: -0.3px;
}

.sidebar-brand .subtitle {
    font-size: 11px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-top: 4px;
    font-weight: 500;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 10px 24px;
    color: var(--color-sidebar-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background var(--transition-fast), color var(--transition-fast);
    border-left: 3px solid transparent;
    gap: 12px;
}

.sidebar-nav a:hover {
    background: var(--color-sidebar-hover);
    color: var(--color-sidebar-text-hover);
}

.sidebar-nav a.active {
    background: var(--color-sidebar-active);
    color: var(--color-sidebar-text-active);
    border-left-color: var(--color-sidebar-accent);
}

.sidebar-nav a .nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
}

.sidebar-nav a:hover .nav-icon,
.sidebar-nav a.active .nav-icon {
    opacity: 1;
}

.sidebar-nav a .nav-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--color-sidebar-border);
    font-size: 12px;
    color: var(--color-text-muted);
}

.sidebar-footer .user-info { margin-bottom: 10px; }
.sidebar-footer .user-name { color: var(--color-sidebar-text-active); font-weight: 600; }
.sidebar-footer .user-role {
    display: inline-block;
    background: var(--color-primary-subtle);
    color: var(--color-primary);
    font-size: 10px;
    padding: 2px 7px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-left: 6px;
}

.sidebar-footer .logout-form { margin-top: 8px; }
.sidebar-footer .logout-btn {
    background: none;
    border: 1px solid var(--color-sidebar-border);
    color: var(--color-sidebar-text);
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.sidebar-footer .logout-btn:hover {
    background: var(--color-sidebar-hover);
    color: var(--color-sidebar-text-active);
}

/* --- Mobile toggle --- */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 14px; left: 14px;
    z-index: 200;
    background: var(--color-sidebar);
    color: var(--color-sidebar-text-active);
    border: none;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
}

/* --- Main content --- */
.admin-main {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.admin-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    /* full-width bar; content aligned to a centered 1400px column */
    padding: 0 max(var(--space-8), calc((100% - 1400px) / 2));
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    position: sticky;
    top: 0;
    z-index: 50;
}

.admin-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text);
    letter-spacing: -0.2px;
}

.admin-header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.admin-body {
    /* content capped at 1400px and centered on wide screens */
    padding: var(--space-6) max(var(--space-8), calc((100% - 1400px) / 2));
}

/* ============================================================
   THEME TOGGLE
   ============================================================ */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.theme-toggle:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
    border-color: var(--color-border-strong);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.theme-toggle .icon-sun,
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.theme-toggle .icon-moon,
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* Standalone page theme toggle (login, TOTP) */
.theme-toggle-standalone {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
}

/* ============================================================
   FLASH MESSAGES
   ============================================================ */
.flash-message {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-5);
    font-size: 13px;
    font-weight: 500;
    position: relative;
    border: 1px solid;
}

.flash-message.success {
    background: var(--color-success-bg);
    color: var(--color-success-text);
    border-color: var(--color-success-border);
}

.flash-message.error {
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
    border-color: var(--color-danger-border);
}

.flash-message.warning {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
    border-color: var(--color-warning-border);
}

.flash-message.info {
    background: var(--color-info-bg);
    color: var(--color-info-text);
    border-color: var(--color-info-border);
}

.flash-dismiss {
    position: absolute;
    top: 8px; right: 12px;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: inherit;
    opacity: 0.5;
    line-height: 1;
}

.flash-dismiss:hover { opacity: 1; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
}

.card-body {
    padding: var(--space-6);
}

.card-body--narrow {
    max-width: 640px;
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-row {
    display: flex;
    gap: var(--space-5);
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
}

.stat-card {
    flex: 1;
    min-width: 180px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
}

.stat-label {
    font-size: 12px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-text);
    margin-top: 4px;
    letter-spacing: -0.5px;
}

.stat-value--primary { color: var(--color-primary); }

/* ============================================================
   DATA TABLES
   ============================================================ */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead th {
    background: var(--color-surface-alt);
    border-bottom: 2px solid var(--color-border);
    padding: 10px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table tbody td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--color-border);
    font-size: 13px;
    color: var(--color-text);
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr:hover { background: var(--color-surface-hover); }

.data-table tbody tr:nth-child(even) { background: var(--color-surface-alt); }
.data-table tbody tr:nth-child(even):hover { background: var(--color-surface-hover); }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1.5;
}

.badge-success { background: var(--color-success-bg); color: var(--color-success-text); }
.badge-danger { background: var(--color-danger-bg); color: var(--color-danger-text); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning-text); }
.badge-info { background: var(--color-info-bg); color: var(--color-info-text); }
.badge-neutral { background: var(--color-surface-alt); color: var(--color-text-muted); }

/* Role badges. These carried the PRE-migration-005 role names (superadmin,
   staff_admin, client_admin) long after 005 renamed them, so every badge has
   actually rendered unstyled since then — fixed here alongside the 021 rename
   to super_admin / super_user. */
.badge-role-super_admin { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }
.badge-role-super_user { background: var(--color-info-bg); color: var(--color-info-text); }
.badge-role-tenant_admin { background: var(--color-success-bg); color: var(--color-success-text); }
.badge-role-tenant_user { background: var(--color-surface-alt); color: var(--color-text-muted); }

[data-theme="dark"] .badge-role-super_admin { background: rgba(139, 92, 246, 0.2); color: #c4b5fd; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: none;
    font-family: var(--font-sans);
    transition: background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
    gap: 6px;
    line-height: 1.4;
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-text-inverse);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    color: var(--color-text-inverse);
}

.btn-secondary {
    background: var(--color-surface-alt);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
    border-color: var(--color-border-strong);
}

.btn-danger {
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
    border: 1px solid var(--color-danger-border);
}

.btn-danger:hover {
    background: var(--color-danger);
    color: #fff;
}

.btn-warning {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
    border: 1px solid var(--color-warning-border);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-group {
    margin-bottom: var(--space-5);
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 6px;
}

.form-required { color: var(--color-danger); }

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--color-input-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font-sans);
    color: var(--color-text);
    background: var(--color-input-bg);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-input-focus);
    box-shadow: 0 0 0 3px var(--color-input-focus-ring);
    background: var(--color-surface);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--color-text-muted);
}

.form-input--readonly {
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
    cursor: not-allowed;
}

.form-input--narrow { width: 120px; }
.form-input--medium { width: 200px; }

.form-textarea { resize: vertical; }

.form-help {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 4px;
}

.form-help code {
    background: var(--color-surface-alt);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 11px;
}

.form-error {
    font-size: 11px;
    color: var(--color-danger);
    margin-top: 4px;
}

.form-section {
    border-top: 1px solid var(--color-border);
    margin: var(--space-5) 0;
    padding-top: var(--space-5);
}

.form-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-4);
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-primary);
}

.form-checkbox span { font-weight: 600; color: var(--color-text-secondary); }

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    padding-top: var(--space-2);
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 48px var(--space-5);
    color: var(--color-text-muted);
}

.empty-icon {
    font-size: 36px;
    margin-bottom: var(--space-3);
    opacity: 0.6;
}

.empty-state p { font-size: 14px; }

.empty-state a {
    color: var(--color-primary);
    font-weight: 500;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

[data-theme="dark"] .modal-overlay {
    background: rgba(0, 0, 0, 0.7);
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 80vh;
    box-shadow: var(--shadow-xl);
    position: relative;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--color-border);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5) var(--space-6) var(--space-3);
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color var(--transition-fast);
}

.modal-close:hover { color: var(--color-text); }

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 var(--space-6) var(--space-5);
}

.modal-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--color-border);
    flex-shrink: 0;
}

/* ============================================================
   CODE / PRE
   ============================================================ */
.code-block {
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: var(--space-4);
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    white-space: pre;
    overflow-x: auto;
    margin: 0;
    user-select: all;
    color: var(--color-text);
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    margin-bottom: var(--space-5);
    box-shadow: var(--shadow-sm);
}

.filter-row {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-group {
    flex: 1;
    min-width: 130px;
}

.filter-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group .form-input,
.filter-group .form-select {
    font-size: 13px;
    padding: 7px 10px;
}

.filter-actions {
    display: flex;
    gap: 6px;
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin-top: var(--space-5);
    flex-wrap: wrap;
}

.page-link {
    padding: 6px 10px;
    font-size: 12px;
    text-decoration: none;
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.page-link:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.page-link--active {
    background: var(--color-primary);
    color: var(--color-text-inverse);
    border-color: var(--color-primary);
    font-weight: 600;
}

.page-link--active:hover {
    background: var(--color-primary-hover);
    color: var(--color-text-inverse);
}

.page-ellipsis {
    padding: 6px 4px;
    color: var(--color-text-muted);
    font-size: 12px;
}

/* ============================================================
   TIMELINE (Email Detail)
   ============================================================ */
.timeline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.timeline-step {
    text-align: center;
}

.timeline-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    margin: 0 auto 6px;
    border: 2px solid;
}

.timeline-circle--done {
    background: var(--color-success-bg);
    color: var(--color-success);
    border-color: var(--color-success);
}

.timeline-circle--error {
    background: var(--color-danger-bg);
    color: var(--color-danger);
    border-color: var(--color-danger);
}

.timeline-circle--pending {
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
    border-color: var(--color-border);
}

.timeline-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.timeline-label--done { color: var(--color-success); }
.timeline-label--error { color: var(--color-danger); }
.timeline-label--pending { color: var(--color-text-muted); }

.timeline-connector {
    width: 60px;
    height: 2px;
    margin-bottom: 20px;
}

.timeline-connector--done { background: var(--color-success); }
.timeline-connector--error { background: var(--color-danger); }
.timeline-connector--pending { background: var(--color-border); }

/* ============================================================
   DETAIL TABLE (Email Detail, SMTP Details)
   ============================================================ */
.detail-table {
    width: 100%;
    font-size: 13px;
}

.detail-table td {
    padding: 6px 0;
    vertical-align: top;
}

.detail-table .detail-label {
    color: var(--color-text-muted);
    font-weight: 600;
    width: 140px;
}

.detail-table .detail-value {
    color: var(--color-text);
}

/* ============================================================
   INFO BOX
   ============================================================ */
.info-box {
    border-radius: var(--radius-md);
    padding: 10px 16px;
    font-size: 13px;
    border: 1px solid;
}

.info-box--info {
    background: var(--color-info-bg);
    color: var(--color-info-text);
    border-color: var(--color-info-border);
}

.info-box--muted {
    background: var(--color-surface-alt);
    color: var(--color-text-secondary);
    border-color: var(--color-border);
}

.info-box--warning {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
    border-color: var(--color-warning-border);
}

.info-box--danger {
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
    border-color: var(--color-danger-border);
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-mono { font-family: var(--font-mono); font-size: 12px; }
.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-bold { font-weight: 600; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-success { color: var(--color-success-text); font-weight: 600; }
.text-warning { color: var(--color-warning-text); }
.text-nowrap { white-space: nowrap; }

.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center { display: flex; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.inline-flex { display: inline-flex; }
.gap-xs { gap: 4px; }
.gap-sm { gap: 6px; }
.gap-md { gap: 10px; }
.gap-lg { gap: 12px; }
.inline { display: inline; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }
.mb-6 { margin-bottom: 24px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-6 { margin-top: 24px; }
.pt-5 { padding-top: 20px; }
.ml-2 { margin-left: 8px; }

.back-link {
    font-size: 13px;
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.back-link:hover { color: var(--color-primary-hover); }

.error-message {
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
    border: 1px solid var(--color-danger-border);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: var(--space-5);
    font-weight: 500;
}

/* ============================================================
   LOGIN / STANDALONE PAGES
   ============================================================ */
.standalone-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-5);
}

.auth-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: 40px 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.auth-card--wide { max-width: 440px; }

.auth-brand {
    text-align: center;
    margin-bottom: var(--space-8);
}

.auth-brand .logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: var(--color-primary);
    color: #ffffff;
    border-radius: var(--radius-xl);
    font-size: 26px;
    font-weight: 700;
    margin-bottom: var(--space-4);
}

.auth-brand h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.3px;
}

.auth-brand .subtitle {
    font-size: 12px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-top: 4px;
}

.auth-brand p {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-top: 8px;
    line-height: 1.5;
}

.btn-login {
    width: 100%;
    padding: 11px 20px;
    background: var(--color-primary);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: background var(--transition-fast);
    margin-top: 4px;
}

.btn-login:hover { background: var(--color-primary-hover); }

/* TOTP code input */
.code-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--color-input-border);
    border-radius: var(--radius-sm);
    font-size: 20px;
    font-family: var(--font-mono);
    text-align: center;
    letter-spacing: 8px;
    font-weight: 700;
    background: var(--color-input-bg);
    color: var(--color-text);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.code-input:focus {
    outline: none;
    border-color: var(--color-input-focus);
    box-shadow: 0 0 0 3px var(--color-input-focus-ring);
    background: var(--color-surface);
}

.code-input--large {
    font-size: 24px;
    padding: 14px;
    letter-spacing: 10px;
}

/* TOTP enrolment QR (inline SVG from src/TotpQr.php).
   The SVG is drawn in currentColor-agnostic black on transparent, so it needs a
   white plate to stay scannable in dark mode — authenticator apps need the
   light-module contrast regardless of the page theme. */
.totp-qr {
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-6);
}

.totp-qr svg {
    width: 200px;
    height: 200px;
    max-width: 100%;
    background: #fff;
    padding: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

/* TOTP secret display */
.secret-box {
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    margin-bottom: var(--space-6);
    text-align: center;
}

.secret-box .secret-label {
    font-size: 11px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    margin-bottom: 8px;
}

.secret-box .secret-key {
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: 3px;
    word-break: break-all;
    user-select: all;
    padding: 8px;
    background: var(--color-surface);
    border: 1px solid var(--color-input-border);
    border-radius: var(--radius-sm);
    cursor: text;
}

.secret-box .copy-hint {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 8px;
}

.instructions-box {
    background: var(--color-info-bg);
    border: 1px solid var(--color-info-border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: var(--space-6);
    font-size: 13px;
    color: var(--color-info-text);
}

.instructions-box ol {
    padding-left: 20px;
    line-height: 1.8;
}

.back-link-center {
    display: block;
    text-align: center;
    margin-top: var(--space-4);
    font-size: 13px;
    color: var(--color-text-muted);
    text-decoration: none;
}

.back-link-center:hover { color: var(--color-primary); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .sidebar-toggle { display: block; }
    .admin-sidebar { transform: translateX(-100%); }
    .admin-sidebar.open { transform: translateX(0); }
    .admin-main { margin-left: 0; }
    .admin-header { padding: 0 var(--space-4) 0 56px; }
    .admin-body { padding: var(--space-4); }
    .stats-row { flex-direction: column; }
    .filter-row { flex-direction: column; }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
    .admin-sidebar, .sidebar-toggle, .admin-header, .theme-toggle { display: none !important; }
    .admin-main { margin-left: 0 !important; }
    body { background: #fff; color: #000; }
}

/* ============================================================
   BLUMM BRAND TYPE LAYER (2026-08-19)
   Applies the four-font system + brand refinements on top of the
   tokenised components above. Playfair = headlines · Syne = card
   titles · Outfit = UI (via --font-sans) · IBM Plex Mono = labels,
   IDs, technical. Appended last so it wins at equal specificity.
   ============================================================ */

/* Sidebar brand: wordmark image + mono product eyebrow */
.sidebar-brand { display: flex; flex-direction: column; gap: 9px; }
.sidebar-brand .brand-logo {
    height: 30px; width: auto; max-width: 148px;
    align-self: flex-start;           /* prevents column-flex stretch */
    object-fit: contain; display: block;
}
.sidebar-brand .subtitle {
    font-family: var(--font-mono); font-size: 9.5px; font-weight: 500;
    letter-spacing: 0.28em; text-transform: uppercase; color: var(--color-sidebar-text);
    margin: 0;
}

/* Nav: mono section idea kept subtle; teal keyline on the active item */
.sidebar-nav a.active { position: relative; }
.sidebar-nav a.active::before {
    content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px;
    width: 3px; border-radius: 0 3px 3px 0; background: var(--color-accent);
}
.sidebar-footer .user-role {
    font-family: var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; font-size: 9.5px;
}

/* Page title: editorial Playfair */
.admin-header h2 {
    font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em;
    font-size: 24px; line-height: 1.15;
}

/* Reusable page eyebrow (mono + teal tick) — for page intros */
.eyebrow {
    display: inline-flex; align-items: center; gap: 9px;
    font-family: var(--font-mono); font-size: 11px; font-weight: 500;
    letter-spacing: 0.2em; text-transform: uppercase; color: var(--color-primary);
}
.eyebrow::before { content: ""; width: 18px; height: 1.5px; background: var(--color-accent); }

/* Card / section / modal titles: Syne */
.card-header h3,
.form-section-title,
.modal-header h3 {
    font-family: var(--font-head); font-weight: 700; letter-spacing: -0.01em;
}

/* Stat cards: mono label, Playfair number */
.stat-label {
    font-family: var(--font-mono); font-weight: 500; font-size: 10.5px;
    letter-spacing: 0.15em; text-transform: uppercase; color: var(--color-text-muted);
}
.stat-value {
    font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}

/* Data tables: mono uppercase column heads */
.data-table thead th {
    font-family: var(--font-mono); font-weight: 500; font-size: 10.5px;
    letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-text-muted);
}

/* Badges → mono status pills with a state dot */
.badge {
    font-family: var(--font-mono); font-weight: 500; font-size: 10px;
    letter-spacing: 0.07em; text-transform: uppercase;
    display: inline-flex; align-items: center; gap: 6px; line-height: 1;
}
.badge::before {
    content: ""; width: 6px; height: 6px; border-radius: 50%;
    background: currentColor; flex: none;
}
/* keep the purple role badge on-brand */
.badge-role-super_admin { background: var(--color-primary-subtle); color: var(--color-primary); }
.badge-role-super_user { background: var(--color-info-bg); color: var(--color-info-text); }
.badge-role-tenant_admin { background: var(--color-success-bg); color: var(--color-success-text); }
.badge-role-tenant_user { background: var(--color-surface-alt); color: var(--color-text-muted); }

/* Buttons: Outfit 600 with a touch of tracking; accent variant */
.btn { font-family: var(--font-sans); font-weight: 600; letter-spacing: 0.01em; }
.btn-accent { background: var(--color-accent); color: #04352c; border-color: transparent; }
.btn-accent:hover { filter: brightness(0.96); }
[data-theme="dark"] .btn-accent { color: #04241e; }

/* Form labels: mono */
.form-label {
    font-family: var(--font-mono); font-weight: 500; font-size: 10.5px;
    letter-spacing: 0.12em; text-transform: uppercase; color: var(--color-text-muted);
}

/* Inline technical text — IDs, keys, timestamps — reads as "precision" */
.text-mono, .mono, code, .code {
    font-family: var(--font-mono); font-variant-numeric: tabular-nums;
}

/* Login card: brand wordmark, theme-swapped (the card follows the theme;
   the sidebar logo is always white on its navy panel). */
.auth-brand .auth-logo { height: 40px; width: auto; max-width: 172px; display: block; margin: 0 auto 10px; object-fit: contain; }
.auth-brand .auth-logo-dark { display: none; }
[data-theme="dark"] .auth-brand .auth-logo-light { display: none; }
[data-theme="dark"] .auth-brand .auth-logo-dark { display: block; }
.auth-brand .subtitle { font-family: var(--font-mono); font-size: 10px; font-weight: 500; letter-spacing: 0.22em; text-transform: uppercase; color: var(--color-text-muted); }
.btn-login { font-family: var(--font-sans); font-weight: 600; letter-spacing: 0.02em; }

/* ============================================================
   FULL-SCREEN SPLIT LOGIN (editorial — matches the design proof)
   ============================================================ */
.login-split { display: grid; grid-template-columns: 1.05fr 0.95fr; min-height: 100vh; }
.login-aside {
    background: var(--color-sidebar); color: #fff;
    padding: 48px 46px; display: flex; flex-direction: column; justify-content: space-between;
    position: relative; overflow: hidden;
}
.login-aside .glow {
    position: absolute; width: 380px; height: 380px; border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 201, 167, 0.22), transparent 68%);
    top: -100px; right: -90px; pointer-events: none;
}
.login-aside .login-logo { height: 34px; width: auto; align-self: flex-start; position: relative; object-fit: contain; }
.login-lead {
    font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em;
    font-size: clamp(26px, 3vw, 34px); line-height: 1.22; max-width: 15ch; position: relative; color: #fff;
}
.login-lead em { font-style: italic; color: var(--color-accent); }
.login-tags { display: flex; gap: 8px; flex-wrap: wrap; position: relative; }
.login-tags span {
    font-family: var(--font-mono); font-size: 9px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase;
    color: rgba(255, 255, 255, 0.72); border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 5px; padding: 4px 9px;
}
.login-form-wrap { background: var(--color-bg); display: flex; align-items: center; justify-content: center; padding: 44px; }
.login-card { width: 100%; max-width: 340px; }
.login-title {
    font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em;
    font-size: 28px; color: var(--color-text); margin: 0.32em 0 1.15em;
}
.login-note {
    font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.06em;
    color: var(--color-text-muted); text-align: center; margin-top: 18px;
}
.login-page .btn-login { margin-top: 6px; }
@media (max-width: 820px) {
    .login-split { grid-template-columns: 1fr; }
    .login-aside { display: none; }
    .login-form-wrap { padding: 32px 24px; }
}

/* Tabbed panels — shared by Settings and the tenant edit form. Previously
   defined inline in templates/admin/settings.php only; promoted here when the
   tenant form adopted the same pattern, so one definition serves both. */
.settings-tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
}
.settings-tab {
    appearance: none;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 18px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}
.settings-tab:hover { color: var(--color-text); }
.settings-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}
.settings-panel { display: none; }
.settings-panel.active { display: block; }

/* A licence switched off locks the rest of its tab (tenant edit form). The
   fields are disabled in the DOM; this just makes the state legible. */
.settings-panel.licence-off .form-section:last-of-type,
.settings-panel.licence-off .form-group:not(:has(input[name$="[enabled]"])) {
    opacity: 0.55;
}
.settings-panel.licence-off input:disabled,
.settings-panel.licence-off textarea:disabled,
.settings-panel.licence-off select:disabled {
    background: var(--color-surface-alt);
    cursor: not-allowed;
}

/* Clinic activation-key reveal + split-key status. Moved out of the tenant
   form's inline <style> when the regenerate flow became available to the
   clinic on /admin/settings too — both pages need these rules. */
/* Partial key reveal modal */
.partial-key-reveal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.partial-key-reveal__overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.partial-key-reveal__modal { position: relative; background: #fff; border-radius: 12px; padding: 32px; max-width: 480px; width: 90%; text-align: center; box-shadow: 0 8px 32px rgba(0,0,0,0.2); }
.partial-key-reveal__icon { font-size: 40px; margin-bottom: 12px; }
.partial-key-reveal__modal h3 { font-size: 18px; margin-bottom: 8px; }
.partial-key-reveal__desc { font-size: 13px; color: #6c757d; margin-bottom: 20px; line-height: 1.5; }
.partial-key-reveal__key {
    font-family: 'Courier New', monospace; font-size: 24px; font-weight: 700; letter-spacing: 3px;
    padding: 16px; background: #f8f9fa; border: 2px dashed #4a90d9; border-radius: 8px; margin-bottom: 16px;
    user-select: all; color: #333;
}
.partial-key-reveal__actions { display: flex; gap: 8px; justify-content: center; }

/* Split-key status */
.split-key-status { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 6px; font-size: 13px; }
.split-key-status--active { background: #d4edda; border: 1px solid #c3e6cb; }
.split-key-status--pending { background: #fff3cd; border: 1px solid #ffeaa7; }
.split-key-badge { padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; background: #28a745; color: #fff; }
.split-key-badge--pending { background: #856404; }
.split-key-desc { color: #495057; }


/* Misc */
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.btn-warning { background: #e67e22; color: #fff; border-color: #d35400; }
.btn-warning:hover { background: #d35400; }
.btn-outline { background: transparent; border: 1px solid #ced4da; color: #495057; }
.btn-outline:hover { background: #f8f9fa; }

/* Permission grid (task 11) — module cards on the user edit page. */
.permission-presets { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Two cards per row when there is room for two, one when there is not. The
   basis (not a media query) is what makes this respond to the CONTAINER — this
   panel sits inside a card body whose width is narrower than the viewport, so a
   viewport media query would break the moment the sidebar or padding changed.
   A card left alone on the last row grows to fill it, which reads as deliberate.
   min-width:0 lets a long description wrap instead of forcing the card wider. */
.permission-modules {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: flex-start;
}
/* The user form's card body dropped card-body--narrow so the row above has room
   for two cards; the 640px reading width moves here, onto the panels that want
   it. Form fields at full card width would be unpleasant to read. */
.settings-panel[data-panel="account"],
.settings-panel[data-panel="security"] { max-width: 640px; }
.permission-module {
    flex: 1 1 360px;
    min-width: 0;
}
.permission-module .card-body { padding: 14px 16px; }
.permission-module-count { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.permission-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 6px 0;
    border-top: 1px solid var(--color-border);
    cursor: pointer;
}
.permission-row:first-of-type { border-top: none; }
.permission-row input[type="checkbox"] { margin-top: 3px; flex-shrink: 0; }
.permission-row__text { display: flex; flex-direction: column; gap: 2px; }
.permission-label { font-weight: 600; color: var(--color-text-secondary); }
.permission-description { font-size: 12px; }
.permission-destructive { font-size: 11px; margin-right: 6px; }
.permission-row--destructive .permission-label { color: var(--color-danger-text); }
.permission-no-cap { font-size: 12px; font-style: italic; }
.permission-row input[type="checkbox"]:disabled { cursor: not-allowed; }
.permission-row:has(input:disabled) { cursor: not-allowed; }
