/* ============================================================
   BMD OTP — Clean Light Mode Design System
   Mobile-first, minimal, inspired by Google Authenticator / Authy
   ============================================================ */

:root {
    color-scheme: light;

    /* Colors */
    --color-bg: #f9fafb;
    --color-surface: #ffffff;
    --color-surface-soft: #f3f4f6;
    --color-border: #e5e7eb;
    --color-border-strong: #d1d5db;
    --color-text: #111827;
    --color-muted: #6b7280;
    --color-primary: #0c7462;
    --color-primary-light: #e8f5f1;
    --color-primary-strong: #075346;
    --color-success: #16a34a;
    --color-success-light: #f0fdf4;
    --color-warn: #b45309;
    --color-warn-light: #fffbeb;
    --color-danger: #dc2626;
    --color-danger-strong: #991b1b;
    --color-danger-light: #fef2f2;

    /* Shadows — very subtle */
    --shadow-soft: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-focus: 0 0 0 3px rgba(12, 116, 98, 0.15);

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

    /* Typography */
    --text-xs: 11px;
    --text-sm: 13px;
    --text-base: 15px;
    --text-md: 15px;
    --text-lg: 18px;
    --text-xl: 22px;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-pill: 999px;

    /* Button heights */
    --btn-h-sm: 34px;
    --btn-h-md: 42px;
    --btn-h-lg: 48px;

    /* Icons */
    --icon-sm: 16px;
    --icon-md: 18px;
    --icon-lg: 20px;
}

/* ── Reset ── */
* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family: 'Inter', 'Space Grotesk', sans-serif;
    font-size: var(--text-base);
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    padding-bottom: env(safe-area-inset-bottom);
    -webkit-font-smoothing: antialiased;
}

/* ── Skip link ── */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 4000;
    background: #fff;
    color: var(--color-primary-strong);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border-strong);
    font-size: var(--text-sm);
    font-weight: 600;
}
.skip-link:focus { left: var(--space-3); top: var(--space-3); }

/* ── Site Header (desktop) ── */
.site-header {
    width: min(1200px, 96vw);
    margin: var(--space-4) auto 0;
    padding: 0 var(--space-5);
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
}

/* ── Brand ── */
.brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--color-text);
    text-decoration: none;
    flex-shrink: 0;
}

.brand-badge {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: #fff;
    background: var(--color-primary);
    flex-shrink: 0;
}

.brand-stack {
    display: inline-flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-text {
    font-size: var(--text-md);
    font-weight: 700;
    letter-spacing: -0.2px;
}

.brand-subtext {
    font-size: 11px;
    color: var(--color-muted);
    font-weight: 400;
}

/* ── Top Nav (desktop) ── */
.top-nav {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    flex-wrap: nowrap;
}

.top-nav a,
.top-nav .nav-user {
    flex: 0 0 auto;
}

.top-nav a {
    text-decoration: none;
    color: var(--color-muted);
    height: 36px;
    padding: 0 12px;
    border-radius: var(--radius-pill);
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: var(--text-sm);
    font-weight: 500;
    transition: color 0.15s ease, background 0.15s ease;
    white-space: nowrap;
}

.top-nav a:hover {
    color: var(--color-text);
    background: var(--color-surface-soft);
}

.top-nav a.is-current {
    color: var(--color-primary-strong);
    background: var(--color-primary-light);
    font-weight: 600;
}

.top-nav a.is-current::after { display: none; }

.nav-user {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 12px;
    border-radius: var(--radius-pill);
    background: var(--color-surface-soft);
    color: var(--color-text);
    font-size: var(--text-sm);
    font-weight: 500;
    white-space: nowrap;
}

.nav-icon,
.nav-user-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: var(--icon-md);
    height: var(--icon-md);
}

.top-nav svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.nav-label,
.nav-user-label {
    line-height: 1;
}

.danger-link {
    color: var(--color-danger) !important;
}

.danger-link:hover {
    color: var(--color-danger-strong) !important;
    background: var(--color-danger-light) !important;
}

/* ── Mobile: Top App Bar + Bottom Tab Nav ── */
@media (max-width: 768px) {
    .site-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        margin: 0;
        border-radius: 0;
        height: 52px;
        padding: 0 var(--space-4);
        border-top: none;
        border-left: none;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
        z-index: 900;
        box-shadow: none;
    }

    /* Hide brand subtext on mobile for cleaner look */
    .brand-subtext { display: none; }
    .brand-text { font-size: 16px; }
    .brand-badge { width: 28px; height: 28px; border-radius: 8px; }

    /* Bottom tab bar */
    .top-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        background: var(--color-surface);
        border-top: 1px solid var(--color-border);
        padding: 6px var(--space-2) calc(6px + env(safe-area-inset-bottom));
        display: flex;
        justify-content: space-around;
        align-items: center;
        z-index: 1000;
        box-shadow: 0 -1px 0 var(--color-border);
    }

    .top-nav a,
    .top-nav .nav-user {
        flex-direction: column;
        gap: 2px;
        min-height: 50px;
        padding: 4px 8px;
        flex: 1;
        border-radius: var(--radius-sm);
        font-size: 10px;
        font-weight: 500;
        color: var(--color-muted);
        background: transparent;
    }

    .top-nav a:hover,
    .top-nav .nav-user:hover {
        background: var(--color-surface-soft);
        color: var(--color-text);
    }

    .top-nav a.is-current {
        color: var(--color-primary);
        background: transparent;
        font-weight: 600;
    }

    .nav-icon,
    .nav-user-badge {
        width: 22px;
        height: 22px;
    }

    .nav-user {
        background: transparent;
        border-radius: var(--radius-sm);
    }
}

/* ── Page Container ── */
.page-container {
    width: min(1200px, 96vw);
    margin: var(--space-4) auto var(--space-8);
    position: relative;
}

@media (max-width: 768px) {
    .page-container {
        width: 100%;
        margin-top: calc(52px + var(--space-3)); /* top bar height + gap */
        padding: 0 var(--space-3) calc(70px + env(safe-area-inset-bottom));
    }
}

/* ── Page headings ── */
.page-hero,
.page-head {
    margin-bottom: var(--space-4);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.page-hero h1,
.page-hero h2,
.page-head h1,
.page-head h2 {
    margin: 0;
    font-size: var(--text-xl);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.3px;
}

.page-hero p,
.page-head p {
    margin: var(--space-1) 0 0;
    color: var(--color-muted);
    font-size: var(--text-sm);
}

/* ── Status Pill ── */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    height: 28px;
    border: 1px solid #bbf0e3;
    color: var(--color-primary-strong);
    background: var(--color-primary-light);
    border-radius: var(--radius-pill);
    padding: 0 var(--space-3);
    font-size: var(--text-xs);
    font-weight: 600;
}

/* ── Grid ── */
.grid-two {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: var(--space-4);
}

.admin-grid {
    grid-template-columns: 0.95fr 1.45fr;
}

/* ── Panel / Card ── */
.panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-soft);
}

.panel-tight {
    padding: var(--space-4);
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.panel h2,
.panel h3,
.panel h4 {
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.panel h2 { font-size: var(--text-lg); }

.sub-title {
    margin: var(--space-4) 0 var(--space-2);
    font-size: var(--text-md);
    font-weight: 600;
}

.sub-title-compact {
    margin-top: var(--space-2);
    margin-bottom: 6px;
    font-size: var(--text-sm);
}

.panel p,
.muted {
    color: var(--color-muted);
    margin: var(--space-1) 0 var(--space-3);
    font-size: var(--text-sm);
}

/* ── Form ── */
.form-grid {
    display: grid;
    gap: var(--space-2);
}

.form-grid + .form-grid {
    margin-top: var(--space-3);
}

label {
    margin-top: var(--space-1);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text);
}

.field-hint,
.helper-inline {
    margin-top: -2px;
    margin-bottom: var(--space-1);
    color: var(--color-muted);
    font-size: var(--text-xs);
}

input,
textarea,
select {
    width: 100%;
    min-height: var(--btn-h-md);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font: inherit;
    font-size: var(--text-base);
    color: var(--color-text);
    background: var(--color-surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder,
textarea::placeholder {
    color: #9ca3af;
}

textarea {
    resize: vertical;
    min-height: 92px;
}

:where(a, button, input, select, textarea):focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-focus);
    outline: none;
}

/* Mobile — larger touch targets, prevent zoom */
@media (max-width: 768px) {
    input, textarea, select {
        font-size: 16px;
        min-height: 48px;
        padding: 12px 14px;
    }
}

/* ── Buttons ── */
.btn {
    min-height: var(--btn-h-md);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 0 var(--space-4);
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.btn:active {
    transform: scale(0.97);
}

@media (max-width: 768px) {
    .btn {
        min-height: 48px;
        font-size: var(--text-base);
    }
}

.btn-primary {
    color: #fff;
    background: var(--color-primary);
    border-color: var(--color-primary);
}

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

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

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

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

.btn-danger:hover {
    background: var(--color-danger-strong);
    border-color: var(--color-danger-strong);
}

.btn-small {
    min-height: var(--btn-h-sm);
    font-size: var(--text-xs);
    padding: 0 var(--space-3);
}

.btn-icon-label {
    min-height: var(--btn-h-sm);
    padding: 0 10px;
    font-size: var(--text-xs);
    border-radius: var(--radius-pill);
}

@media (max-width: 768px) {
    .btn-small,
    .btn-icon-label {
        min-height: 40px;
        padding: 0 var(--space-3);
    }
}

.btn-icon-label svg {
    width: var(--icon-md);
    height: var(--icon-md);
    fill: currentColor;
}

/* ── Alerts ── */
.alert {
    margin-bottom: var(--space-4);
    border: 1px solid var(--color-border);
    border-left-width: 4px;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: var(--text-sm);
    font-weight: 500;
    background: var(--color-surface);
}

.alert a {
    color: inherit;
    font-weight: 600;
}

.alert-success {
    border-color: #bbf7d0;
    border-left-color: var(--color-success);
    background: var(--color-success-light);
}

.alert-error {
    border-color: #fecaca;
    border-left-color: var(--color-danger);
    background: var(--color-danger-light);
}

.alert-info {
    border-color: #bfdbfe;
    border-left-color: #2563eb;
    background: #eff6ff;
}

/* ── Auth Card ── */
.auth-card {
    width: min(440px, 96vw);
    margin: var(--space-8) auto var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-md);
}

.auth-card h1 {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.4px;
}

.auth-links {
    margin-top: var(--space-3);
    margin-bottom: 0;
    color: var(--color-muted);
    font-size: var(--text-sm);
}

.auth-links a {
    color: var(--color-primary);
    font-weight: 600;
}

@media (max-width: 768px) {
    .auth-card {
        margin-top: calc(52px + var(--space-4));
        border-radius: var(--radius-lg);
        padding: var(--space-5);
    }
}

/* ── Inline check ── */
.inline-check {
    display: inline-flex;
    align-items: flex-start;
    gap: var(--space-2);
    margin-top: var(--space-1);
    font-size: var(--text-sm);
    font-weight: 500;
}

.inline-check input[type='checkbox'] {
    width: 16px;
    height: 16px;
    min-height: 16px;
    margin-top: 2px;
    padding: 0;
    flex-shrink: 0;
}

.inline-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.inline-actions input[type='file'] {
    flex: 1 1 240px;
}

/* ── Home Page Toolbar ── */
.home-live-panel {
    padding: var(--space-4);
}

.home-toolbar {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.home-search-row {
    display: flex;
    gap: var(--space-2);
    align-items: center;
}

.home-search-row input[type="search"] {
    flex: 1;
    border-radius: var(--radius-pill);
    padding-left: 16px;
    padding-right: 16px;
    min-height: 44px;
    font-size: var(--text-sm);
    background: var(--color-surface-soft);
    border: 1px solid var(--color-border);
}

.home-search-row input[type="search"]:focus {
    background: var(--color-surface);
    border-color: var(--color-primary);
}

.home-filter-row {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    flex-wrap: wrap;
}

.home-filter-row select {
    min-height: 36px;
    font-size: var(--text-sm);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    flex: 1;
    min-width: 130px;
    max-width: 200px;
}

.home-filter-row select:focus {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-focus);
}

.home-tools-icons {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin-left: auto;
}

.home-tools-icons .btn-icon-label {
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    border: 1px solid transparent;
    background: transparent;
    border-radius: var(--radius-sm);
    box-shadow: none;
    color: var(--color-muted);
}

.home-tools-icons .btn-icon-label:hover {
    background: var(--color-surface-soft);
    color: var(--color-text);
}

.home-tools-icons .btn-icon-label.btn-outline {
    color: var(--color-primary-strong);
}

.home-tools-icons .btn-icon-label.btn-danger {
    color: var(--color-danger-strong);
}

.home-tools-icons .btn-icon-label.btn-outline,
.home-tools-icons .btn-icon-label.btn-danger,
.home-tools-icons .btn-icon-label.btn-outline:hover,
.home-tools-icons .btn-icon-label.btn-danger:hover {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}

.home-tools-icons .btn-icon-label:disabled {
    opacity: 0.38;
    pointer-events: none;
}

@media (max-width: 680px) {
    .home-live-panel { padding: var(--space-3); }

    .home-search-row input[type="search"] {
        font-size: 16px;
        min-height: 48px;
    }

    .home-filter-row select {
        font-size: 15px;
        min-height: 40px;
    }

    .home-filter-row {
        flex-wrap: nowrap;
        gap: var(--space-2);
    }

    .home-filter-row select {
        flex: 1;
        min-width: 0;
        max-width: none;
    }
}

/* ── OTP Account List ── */
.accounts-list,
.home-accounts-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.home-accounts-list.section-gap {
    margin-top: var(--space-3);
}

/* ── OTP Item Card ── */
.otp-item {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    padding: 12px 14px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(130px, 148px);
    gap: 4px 12px;
    align-items: center;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
    cursor: default;
}

.otp-item:hover {
    background: #fafcfb;
    border-color: #c9dfd7;
}

.otp-item:active {
    transform: scale(0.99);
}

.otp-item-selected {
    border-color: #86c9bb;
    background: #f0faf7;
    box-shadow: 0 0 0 1px #c2e8df inset;
}

.otp-row-main {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.otp-row-title {
    font-size: var(--text-md);
    font-weight: 600;
    line-height: 1.3;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    color: var(--color-text);
}

.otp-row-meta {
    margin-top: 0;
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    color: var(--color-muted);
    font-size: var(--text-xs);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-pill);
    border: 1px solid #bbf0e3;
    background: var(--color-primary-light);
    color: var(--color-primary-strong);
    height: 18px;
    padding: 0 7px;
    font-size: 10px;
    font-weight: 600;
}

/* ── OTP Code Button ── */
.otp-copy-btn {
    width: 100%;
    border: 1px solid var(--color-border);
    background: var(--color-surface-soft);
    color: var(--color-primary-strong);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-size: 22px;
    font-weight: 700;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    letter-spacing: 3px;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.otp-copy-btn:hover {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
    color: var(--color-primary-strong);
}

.otp-copy-btn.copied-glow {
    animation: otpCopyGlow 0.8s ease;
}

@keyframes otpCopyGlow {
    0% { background: var(--color-surface-soft); }
    40% { background: #c8f0e3; border-color: var(--color-primary); }
    100% { background: var(--color-surface-soft); }
}

/* ── OTP Row Bottom ── */
.otp-row-bottom {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    min-width: 0;
}

.otp-row-specs {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--color-muted);
    font-size: var(--text-xs);
    white-space: nowrap;
    flex-wrap: wrap;
    min-width: 0;
}

.otp-row-specs span {
    padding: 2px 6px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    line-height: 1.2;
}

.otp-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    flex: 0 0 auto;
}

/* ── Progress bar ── */
.otp-row-progress {
    grid-column: 1 / -1;
    margin-top: 2px;
}

.progress-track {
    height: 3px;
    border-radius: var(--radius-pill);
    overflow: hidden;
    background: var(--color-border);
}

.progress-fill {
    height: 100%;
    width: 100%;
    background: var(--color-primary);
    transition: width 0.2s linear;
    opacity: 0.6;
}

/* ── Icon Buttons ── */
.icon-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    color: var(--color-muted);
    background: var(--color-surface);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
    border-color: var(--color-border-strong);
    color: var(--color-primary);
    background: var(--color-primary-light);
}

.icon-btn svg {
    width: var(--icon-sm);
    height: var(--icon-sm);
    fill: currentColor;
}

.icon-btn-danger,
.icon-btn-danger:hover {
    color: var(--color-danger);
}

.icon-btn-danger:hover {
    background: var(--color-danger-light);
    border-color: #fca5a5;
}

.icon-btn.is-active,
.otp-action-select.is-active,
.btn.is-active {
    background: var(--color-primary-light);
    border-color: #86c9bb;
    color: var(--color-primary-strong);
}

.icon-btn:disabled,
.disabled-icon {
    opacity: 0.38;
    pointer-events: none;
}

/* ── Copy Toast ── */
.copy-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%) translateY(12px);
    opacity: 0;
    pointer-events: none;
    z-index: 2400;
    border-radius: var(--radius-pill);
    padding: 9px 18px;
    color: #fff;
    font-size: var(--text-sm);
    font-weight: 600;
    box-shadow: var(--shadow-md);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.copy-toast.is-success { background: var(--color-success); }
.copy-toast.is-error   { background: var(--color-danger); }
.copy-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 768px) {
    .copy-toast { bottom: calc(70px + env(safe-area-inset-bottom) + 8px); }
}

/* ── Modal ── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2200;
    padding: var(--space-4);
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.modal-card {
    width: min(500px, 96vw);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    background: var(--color-surface);
    box-shadow: var(--shadow-md);
    padding: var(--space-5);
}

.modal-card h3 {
    margin: 0 0 var(--space-4);
    font-size: var(--text-lg);
    font-weight: 700;
}

.modal-actions {
    margin-top: var(--space-4);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
}

.hidden { display: none !important; }

/* ── Empty State ── */
.empty-state {
    margin: 0;
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-md);
    background: var(--color-surface-soft);
    color: var(--color-muted);
    text-align: center;
    padding: var(--space-8) var(--space-4);
    font-size: var(--text-sm);
}

/* ── Section utilities ── */
.section-gap { margin-top: var(--space-4); }

.section-tools {
    margin-top: var(--space-1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
}

.compact-controls { grid-template-columns: 1fr 110px auto; }

.compact-controls label,
.compact-form label {
    margin-top: 0;
    font-size: var(--text-xs);
}

.compact-form { gap: 6px; }

.compact-form select {
    min-height: var(--btn-h-sm);
    padding-top: 6px;
    padding-bottom: 6px;
}

.compact-actions { gap: 6px; margin-top: 0; }

.compact-actions .icon-btn {
    width: 28px;
    height: 28px;
    min-width: 28px;
}

/* ── Pagination ── */
.pagination-config {
    display: grid;
    grid-template-columns: 1fr 110px auto;
    gap: var(--space-2);
    align-items: end;
}

.pagination-config .icon-btn {
    width: 40px;
    height: 40px;
}

.pagination-config-inline {
    margin-bottom: var(--space-2);
}

.pagination-bar {
    margin-top: var(--space-3);
    border-top: 1px solid var(--color-border);
    padding-top: var(--space-3);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
}

.pagination-links {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.page-chip {
    min-width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-text);
    background: var(--color-surface);
    text-decoration: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

button.page-chip { cursor: pointer; }

.page-chip:hover {
    border-color: var(--color-border-strong);
    background: var(--color-surface-soft);
}

.page-chip.is-current {
    color: var(--color-primary-strong);
    border-color: #86c9bb;
    background: var(--color-primary-light);
}

.pagination-ellipsis {
    color: var(--color-muted);
    font-size: var(--text-xs);
    padding: 0 3px;
}

/* ── CSV / other layouts ── */
.csv-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--space-2);
    align-items: center;
}

.deleted-list {
    display: grid;
    gap: var(--space-2);
}

.deleted-row {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
}

.deleted-row strong {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
}

.deleted-row small {
    display: block;
    color: var(--color-muted);
    font-size: var(--text-xs);
    margin-top: 2px;
}

.warning-note {
    border: 1px solid #fcd34d;
    border-left: 4px solid var(--color-warn);
    border-radius: var(--radius-sm);
    background: var(--color-warn-light);
    color: #78350f;
    padding: 10px 14px;
    font-size: var(--text-sm);
}

.danger-zone {
    border-color: #fecaca;
    background: var(--color-danger-light);
}

.backup-box {
    margin-top: var(--space-2);
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-sm);
    background: var(--color-surface-soft);
    padding: var(--space-3);
}

.backup-codes {
    display: grid;
    gap: var(--space-2);
    grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
}

.backup-codes code {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    padding: 7px 10px;
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 1px;
}

/* ── Tables ── */
.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 560px;
}

th, td {
    border-bottom: 1px solid var(--color-border);
    padding: 10px 10px;
    text-align: left;
    vertical-align: middle;
    font-size: var(--text-sm);
}

th {
    color: var(--color-muted);
    font-weight: 600;
    white-space: nowrap;
    background: var(--color-surface-soft);
}

.table-dense th,
.table-dense td {
    padding-top: 7px;
    padding-bottom: 7px;
    font-size: 12px;
}

/* ── Stack ── */
.stack-md > * + * { margin-top: var(--space-3); }

/* ── Screen-reader only ── */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ── Responsive: tablet ── */
@media (max-width: 980px) {
    .grid-two,
    .admin-grid {
        grid-template-columns: 1fr;
    }

    .otp-item {
        grid-template-columns: minmax(0, 1fr) minmax(126px, 142px);
    }
}

/* ── Responsive: mobile ── */
@media (max-width: 680px) {
    .auth-card,
    .panel {
        border-radius: var(--radius-md);
        padding: var(--space-4);
    }

    .otp-item {
        grid-template-columns: minmax(0, 1fr) 126px;
        gap: 4px 8px;
        padding: 10px 12px;
    }

    .otp-copy-btn {
        font-size: 20px;
        padding: 7px 8px;
        letter-spacing: 2px;
    }

    .pagination-config {
        grid-template-columns: 1fr;
    }

    .pagination-config .icon-btn {
        width: 100%;
    }

    .page-chip {
        min-width: 32px;
        height: 32px;
    }

    .deleted-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .inline-actions,
    .modal-actions,
    .csv-row {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }

    .btn-small,
    .btn,
    .modal-actions .btn {
        width: 100%;
    }
}
