/* ════════════════════════════════════════════════════════════════
   AMS — Account Management System
   Modern green theme · light/dark · responsive on all devices
   ════════════════════════════════════════════════════════════════ */

:root {
    --primary: #16A34A;
    --primary-hover: #15803D;
    --primary-soft: #DCFCE7;
    --accent: #F59E0B;
    --accent2: #10B981;
    --bg: #F3FAF5;
    --surface: #FFFFFF;
    --surface2: #E8F7EE;
    --text: #10221A;
    --text-muted: #61756A;
    --border: #D3EDDC;
    --error: #EF4444;
    --success: #10B981;

    --shadow-sm: 0 1px 2px rgba(16, 60, 36, 0.06), 0 1px 3px rgba(16, 60, 36, 0.08);
    --shadow: 0 4px 14px rgba(16, 60, 36, 0.08), 0 1px 3px rgba(16, 60, 36, 0.06);
    --shadow-lg: 0 16px 40px rgba(16, 60, 36, 0.14), 0 4px 12px rgba(16, 60, 36, 0.08);
    --ring: 0 0 0 3px rgba(22, 163, 74, 0.22);

    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 18px;

    --nav-h: 62px;
}

[data-theme="dark"] {
    --primary: #22C55E;
    --primary-hover: #4ADE80;
    --primary-soft: #14351F;
    --accent: #FBBF24;
    --accent2: #34D399;
    --bg: #0B1510;
    --surface: #12241A;
    --surface2: #182E22;
    --text: #E2F5E9;
    --text-muted: #8FBBA0;
    --border: #22492F;
    --error: #F87171;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
    --ring: 0 0 0 3px rgba(34, 197, 94, 0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    transition: background 0.3s, color 0.3s;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

::selection { background: rgba(34, 197, 94, 0.25); }

/* Slim, theme-aware scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 99px;
    border: 2px solid transparent;
    background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--text-muted); }

/* Respect users who prefer less motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
    html { scroll-behavior: auto; }
}

/* ─── Navbar ─── */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    padding: 0.6rem 1.75rem;
    min-height: var(--nav-h);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Fallback for browsers without color-mix/backdrop-filter */
@supports not (background: color-mix(in srgb, red 50%, blue)) {
    .navbar { background: var(--surface); }
}

.nav-brand {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 2px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.nav-brand-logo {
    display: block;
    height: 38px;
    width: auto;
    transition: transform 0.2s;
}
.nav-brand:hover .nav-brand-logo { transform: scale(1.05); }

.nav-links {
    display: flex;
    list-style: none;
    gap: 0.2rem;
    flex-wrap: wrap;
    align-items: center;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.45rem 0.8rem;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
    display: block;
    position: relative;
}

.nav-links a:hover {
    color: var(--primary);
    background: var(--surface2);
}

.nav-links a.active-page {
    color: var(--primary);
    background: var(--primary-soft);
}

.nav-links a.active-page::after {
    content: '';
    position: absolute;
    left: 0.8rem;
    right: 0.8rem;
    bottom: 2px;
    height: 2.5px;
    border-radius: 2px;
    background: var(--primary);
}

.nav-links li {
    cursor: grab;
    border-radius: var(--radius-sm);
    transition: opacity 0.15s, transform 0.15s;
    user-select: none;
    -webkit-user-drag: element;
}

.nav-links li a {
    -webkit-user-drag: none;
    user-select: none;
    pointer-events: auto;
}

.nav-links li:active { cursor: grabbing; }

.nav-links li.dragging { opacity: 0.35; }

/* System dropdown nav item */
.nav-dropdown { position: relative; }

.nav-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: none;
    border: none;
    cursor: grab;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    font-family: inherit;
    padding: 0.45rem 0.8rem;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
    -webkit-user-drag: none;
}

.nav-dropdown-toggle:hover,
.nav-dropdown-toggle.active-page {
    color: var(--primary);
    background: var(--primary-soft);
}

.nav-dropdown-caret {
    font-size: 0.6rem;
    transition: transform 0.2s;
}

.nav-dropdown.open .nav-dropdown-caret { transform: rotate(180deg); }

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    list-style: none;
    padding: 0.4rem;
    z-index: 200;
    -webkit-user-drag: none;
    animation: dropdownIn 0.16s ease;
    transform-origin: top left;
}

@keyframes dropdownIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.nav-dropdown.open .nav-dropdown-menu { display: block; }

.nav-dropdown-menu li {
    cursor: default;
    -webkit-user-drag: none;
}

.nav-dropdown-menu li a {
    display: block;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    white-space: nowrap;
}

.nav-dropdown-menu li a.active-page::after { display: none; }

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

/* ─── Container ─── */
.container {
    max-width: 1280px;
    margin: 1.75rem auto;
    padding: 0 1.25rem;
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.15rem;
    min-height: 40px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
    background: linear-gradient(180deg, var(--primary), var(--primary-hover));
    color: #fff;
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.35), inset 0 1px 0 rgba(255,255,255,0.18);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(22, 163, 74, 0.4), inset 0 1px 0 rgba(255,255,255,0.18);
}

.btn:active { transform: translateY(0) scale(0.98); }

.btn:focus-visible,
.btn-outline:focus-visible,
.icon-btn:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

.btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    min-height: 40px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s, color 0.15s, background 0.15s, transform 0.15s;
}

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

.btn-outline:active { transform: scale(0.98); }

.btn-sm {
    padding: 0.35rem 0.75rem !important;
    font-size: 0.8rem !important;
    min-height: 32px !important;
    border-radius: var(--radius-sm) !important;
}

.btn-danger {
    background: linear-gradient(180deg, #EF4444, #DC2626);
    color: #fff;
    border: none;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.35);
}
.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
}

.btn-success {
    background: linear-gradient(180deg, #10B981, #059669);
    color: #fff;
    border: none;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
}

.btn:disabled,
.btn-outline:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
}

.btn-text {
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.45rem 0.65rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
    display: inline-flex;
    align-items: center;
}
.btn-text:hover { background: var(--surface2); }

/* ─── Role indicator badge ─── */
.role-badge {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    font-size: 0.6rem;
    font-weight: 800;
    line-height: 1;
    vertical-align: super;
    margin-left: 3px;
    color: #fff;
    cursor: default;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.role-badge-trial { background: var(--error, #dc2626); }
.role-badge-normal { background: #16a34a; }

.role-badge::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 130%;
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: var(--shadow);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, transform 0.15s ease;
    pointer-events: none;
    z-index: 50;
}
.role-badge::before {
    content: '';
    position: absolute;
    top: 130%;
    left: 50%;
    transform: translateX(-50%) translateY(-3px);
    border: 5px solid transparent;
    border-bottom-color: var(--surface);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease;
    z-index: 50;
}
.role-badge:hover::after,
.role-badge:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.icon-btn {
    background: var(--surface2);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 1.05rem;
    cursor: pointer;
    padding: 0.4rem 0.6rem;
    min-height: 38px;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.icon-btn:hover { background: var(--border); }
.icon-btn:active { transform: scale(0.94); }

/* ─── Language switch ─── */
.lang-switch {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    background: var(--surface2);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    padding: 0.25rem 0.5rem;
    min-height: 38px;
    font-size: 0.8rem;
    font-weight: 700;
}
.lang-switch a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.15rem 0.35rem;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}
.lang-switch a.active {
    color: var(--primary);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

/* ─── Cards ─── */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.6rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    transition: box-shadow 0.25s, transform 0.25s;
}

.card:hover { box-shadow: var(--shadow); }

.card h2 { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.01em; }
.card h3 { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }

.stat-card {
    border-radius: var(--radius);
    padding: 1.5rem;
    color: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.25s, box-shadow 0.25s;
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}
.stat-card::after {
    content: '';
    position: absolute;
    width: 110px; height: 110px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    top: -30px; right: -30px;
}
.stat-card::before {
    content: '';
    position: absolute;
    width: 60px; height: 60px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    bottom: -18px; left: -18px;
}
.stat-card h3 {
    opacity: 0.9;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-bottom: 0.5rem;
    font-weight: 700;
}
.stat-card .stat-value {
    font-size: clamp(1.7rem, 4vw, 2.2rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.02em;
}
.stat-card .stat-label {
    font-size: 0.78rem;
    opacity: 0.8;
    margin-top: 0.35rem;
}

.grid-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

/* ─── Forms ─── */
.form-group { margin-bottom: 1.1rem; }

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.9rem;
    min-height: 42px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 0.92rem;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.form-control:hover:not(:focus):not(:disabled) { border-color: var(--text-muted); }

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: var(--ring);
}

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

select.form-control { cursor: pointer; }

textarea.form-control { min-height: 90px; }

/* ─── Alerts ─── */
.alert {
    padding: 0.9rem 1.1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    border: 1px solid transparent;
    animation: alertIn 0.25s ease;
}

@keyframes alertIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.alert::before {
    font-size: 1rem;
    line-height: 1.4;
    flex-shrink: 0;
}

.alert-error   { background: #FEF2F2; color: #991B1B; border-color: #FECACA; }
.alert-error::before { content: '⚠'; }
.alert-success { background: #ECFDF5; color: #065F46; border-color: #A7F3D0; }
.alert-success::before { content: '✓'; font-weight: 800; }
.alert-info    { background: #EFF6FF; color: #1E40AF; border-color: #BFDBFE; }
.alert-info::before { content: 'ℹ'; font-weight: 700; }

[data-theme="dark"] .alert-error   { background: #3A1212; color: #FCA5A5; border-color: #7F1D1D; }
[data-theme="dark"] .alert-success { background: #06281E; color: #6EE7B7; border-color: #064E3B; }
[data-theme="dark"] .alert-info    { background: #0F2246; color: #93C5FD; border-color: #1E3A8A; }

/* ─── Tables ─── */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    padding: 0.75rem 1rem;
    text-align: left;
    background: var(--surface2);
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    border-bottom: 1.5px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s; }
tbody tr:hover td { background: var(--surface2); }

/* ─── Badge / Role pills ─── */
.badge {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: capitalize;
}
.badge-superadmin { background: #CCFBF1; color: #0F766E; }
.badge-admin      { background: #FEF3C7; color: #92400E; }
.badge-user       { background: #D1FAE5; color: #065F46; }
.badge-income     { background: #D1FAE5; color: #065F46; }
.badge-expense    { background: #FEE2E2; color: #991B1B; }

[data-theme="dark"] .badge-superadmin { background: #134E4A; color: #5EEAD4; }
[data-theme="dark"] .badge-admin      { background: #451A03; color: #FDE68A; }
[data-theme="dark"] .badge-user       { background: #022C22; color: #6EE7B7; }
[data-theme="dark"] .badge-income     { background: #022C22; color: #6EE7B7; }
[data-theme="dark"] .badge-expense    { background: #450A0A; color: #FCA5A5; }

.badge-used {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent);
    background: rgba(245, 158, 11, 0.14);
    border-radius: 6px;
    padding: 0.15rem 0.5rem;
    margin-left: 0.4rem;
    white-space: nowrap;
}

/* ─── Page headers ─── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.page-header h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.01em;
}

/* ─── Filter bar ─── */
.filter-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ─── Login / Auth ─── */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 2rem);
    min-height: calc(100dvh - 2rem);
    padding: 2rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    animation: authIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authIn {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-card h2 {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 0.3rem;
    text-align: center;
    letter-spacing: -0.01em;
}
.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: 1.75rem;
}

.auth-logo {
    text-align: center;
    font-size: 2.5rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 3px;
    margin-bottom: 0.75rem;
}

.auth-logo-img {
    display: block;
    margin: 0 auto 0.75rem;
    max-height: 64px;
    width: auto;
}

/* ─── Divider ─── */
hr.divider {
    border: none;
    border-top: 1.5px solid var(--border);
    margin: 1.5rem 0;
}

/* ─── Modal (edit popups) ───
   No backdrop-click-to-close handler is attached anywhere on purpose —
   these must only close via an explicit Cancel/X button. */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(8, 20, 13, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.open {
    display: flex;
    animation: overlayIn 0.2s ease;
}

@keyframes overlayIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1.6rem;
    max-width: 480px;
    width: 100%;
    max-height: 88vh;
    max-height: 88dvh;
    overflow-y: auto;
    animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-box h3 {
    margin-bottom: 1.1rem;
    font-size: 1.1rem;
    font-weight: 800;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* ─── Pagination ─── */
.per-page-form {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.per-page-form label {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.per-page-select {
    appearance: none;
    -webkit-appearance: none;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.3rem 1.75rem 0.3rem 0.65rem;
    min-height: 32px;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--text);
    cursor: pointer;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
    background-position: calc(100% - 14px) center, calc(100% - 9px) center;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    transition: border-color 0.15s;
}

.per-page-select:hover,
.per-page-select:focus {
    border-color: var(--primary);
    outline: none;
}

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

.pagination-info {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.pagination-links {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 0.4rem;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.pagination-btn:hover:not(.is-disabled) {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--surface2);
}

.pagination-btn.is-disabled {
    opacity: 0.35;
    pointer-events: none;
}

.pagination-page {
    font-size: 0.82rem;
    color: var(--text-muted);
    padding: 0 0.5rem;
    white-space: nowrap;
}

/* Remove number input spinner arrows everywhere */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
}

.required-asterisk {
    color: var(--error);
    font-weight: 700;
}

/* ─── Manage DB console ─── */
.db-tabs {
    display: flex;
    gap: 0.4rem;
    background: var(--surface2);
    border-radius: 10px;
    padding: 0.3rem;
}

.db-tab {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.45rem 1rem;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s, box-shadow 0.15s;
}

.db-tab:hover { color: var(--primary); }

.db-tab.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.db-sql-textarea {
    width: 100%;
    min-height: 160px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
}

.db-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 1.5rem;
    align-items: start;
}

.db-sidebar {
    position: sticky;
    top: calc(var(--nav-h) + 1.25rem);
}

.db-table-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-height: 65vh;
    overflow-y: auto;
}

.db-table-list a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text);
    padding: 0.5rem 0.65rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.15s, color 0.15s;
}

.db-table-list a:hover { background: var(--surface2); }

.db-table-list a.active {
    background: var(--primary);
    color: #fff;
}

.db-table-count {
    font-size: 0.72rem;
    font-weight: 700;
    opacity: 0.7;
    flex-shrink: 0;
}

.db-create-sql {
    background: var(--surface2);
    border-radius: var(--radius-sm);
    padding: 0.85rem;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.8rem;
    white-space: pre-wrap;
    word-break: break-word;
    margin-top: 0.5rem;
}

.db-result-scroll {
    max-height: 60vh;
    overflow-y: auto;
}

.db-result-scroll thead th {
    position: sticky;
    top: 0;
    background: var(--surface2);
    z-index: 1;
}

/* ════════════════════════════════════════════════════════════════
   Responsive
   ════════════════════════════════════════════════════════════════ */

/* Tablets and small laptops */
@media (max-width: 1024px) {
    .container { padding: 0 1rem; }
    .db-layout { grid-template-columns: 200px 1fr; }
}

/* Tablets portrait / large phones */
@media (max-width: 900px) {
    .db-layout { grid-template-columns: 1fr; }
    .db-sidebar { position: static; }
    .db-table-list {
        flex-direction: row;
        flex-wrap: wrap;
        max-height: none;
    }
}

/* Phones */
@media (max-width: 768px) {
    .navbar {
        padding: 0.5rem 0.75rem;
        gap: 0.35rem;
    }

    /* Nav turns into a horizontally scrollable strip — no wrap chaos */
    .nav-links {
        order: 3;
        width: 100%;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0.1rem;
        padding-bottom: 2px;
    }
    .nav-links::-webkit-scrollbar { display: none; }
    .nav-links li { flex-shrink: 0; }
    .nav-links a,
    .nav-dropdown-toggle {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
        white-space: nowrap;
    }

    .nav-brand-logo { height: 32px; }

    .nav-actions { gap: 0.4rem; }
    .btn-text { font-size: 0.82rem; padding: 0.35rem 0.45rem; }
    .icon-btn { min-height: 34px; padding: 0.3rem 0.5rem; }
    .lang-switch { min-height: 34px; }

    .container { margin: 1.25rem auto; padding: 0 0.75rem; }
    .card { padding: 1.15rem; border-radius: var(--radius); }
    .grid-stats { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }

    /* Prevent iOS zoom-on-focus by keeping inputs >= 16px on touch */
    .form-control { font-size: 16px; min-height: 44px; }
    .btn, .btn-outline { min-height: 44px; }
    .btn-sm { min-height: 36px !important; }

    th, td { padding: 0.6rem 0.7rem; }

    /* Modals slide up from the bottom like a sheet */
    .modal-overlay { padding: 0; align-items: flex-end; }
    .modal-box {
        max-width: 100%;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        max-height: 92vh;
        max-height: 92dvh;
        animation: sheetIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }
    .modal-actions { position: sticky; bottom: 0; background: var(--surface); }

    .pagination-bar { justify-content: center; }
    .pagination-info { width: 100%; text-align: center; }

    .nav-dropdown-menu {
        position: fixed;
        left: 0.75rem;
        right: 0.75rem;
        top: auto;
        min-width: 0;
    }
}

@keyframes sheetIn {
    from { opacity: 0; transform: translateY(40px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Small phones */
@media (max-width: 480px) {
    .grid-stats { grid-template-columns: 1fr; }
    .auth-card { padding: 1.6rem; }
    .card h2 { font-size: 1.2rem; }
    .page-header h2 { font-size: 1.25rem; }
    .stat-card { padding: 1.15rem; }
    .modal-box { padding: 1.25rem; }
    .db-tabs { width: 100%; }
    .db-tab { flex: 1; text-align: center; }
}
