/* ========================================================
   MDB Viewer — Premium Dark UI
   ======================================================== */

/* --- Tokens ---- */
:root {
    --bg-base: #0c0c0f;
    --bg-surface: #16161a;
    --bg-raised: #1e1e24;
    --bg-overlay: #26262e;
    --text: #ffffffde;
    --text-dim: #ffffff80;
    --text-muted: #ffffff40;
    --accent: #6c63ff;
    --accent-soft: #6c63ff22;
    --accent-glow: #6c63ff55;
    --green: #34d399;
    --green-soft: #34d39920;
    --red: #f87171;
    --amber: #fbbf24;
    --border: #ffffff0d;
    --border-light: #ffffff14;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --transition: .2s cubic-bezier(.4,0,.2,1);
    --sidebar-w: 280px;
}

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

/* Prevent autofill globally */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--bg-raised) inset !important;
    -webkit-text-fill-color: var(--text) !important;
    caret-color: var(--text);
}

body {
    font-family: var(--font);
    background: var(--bg-base);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* ---- App Layout ---- */
.app-layout {
    display: flex;
    height: calc(100vh - 36px);
    overflow: hidden;
}

/* ---- App Footer ---- */
.app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 24px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-muted);
    height: 36px;
    flex-shrink: 0;
}
.footer-left {
    display: flex;
    align-items: center;
    gap: 6px;
}
.footer-left i { color: var(--green); font-size: 12px; }
.footer-right {
    display: flex;
    align-items: center;
    gap: 10px;
}
.footer-right a {
    color: var(--text-muted);
    font-size: 16px;
    transition: color var(--transition);
    display: inline-flex;
    align-items: center;
}
.footer-right a:hover { color: #0a66c2; }

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    height: calc(100vh - 36px);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 56px;
    min-height: 56px;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 16px;
    box-shadow: 0 0 20px var(--accent-glow);
}

.logo-text {
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -.3px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
}

/* Responsive visibility */
.mobile-only { display: none; }
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: #000000aa;
    z-index: 150;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}
.sidebar-backdrop.active { display: block; }
@media (max-width: 768px) {
    .mobile-only { display: inline-flex; }
}

/* Upload Button */
.sidebar-upload { padding: 16px 16px 0; }

.upload-trigger {
    width: 100%;
    padding: 14px 16px;
    background: var(--accent-soft);
    border: 1px dashed var(--accent);
    border-radius: var(--radius-md);
    color: var(--accent);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-family: var(--font);
    transition: all var(--transition);
}
.upload-trigger i { font-size: 22px; margin-bottom: 2px; }
.upload-trigger span:first-of-type { font-weight: 600; font-size: 14px; }
.upload-trigger .upload-hint { font-size: 11px; color: var(--text-muted); }

.upload-trigger:hover {
    background: var(--accent);
    color: #fff;
    border-style: solid;
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--accent-glow);
}
.upload-trigger:hover .upload-hint { color: #ffffffaa; }

/* File Chip */
.sidebar-info { padding: 10px 16px 0; }
.file-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--green-soft);
    border: 1px solid #34d39930;
    border-radius: var(--radius-sm);
    color: var(--green);
    font-size: 12px;
    font-weight: 500;
}
.file-chip-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Sidebar Section */
.sidebar-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-top: 16px;
}

.sidebar-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
}

.count-badge {
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    min-width: 24px;
    text-align: center;
}

/* Sidebar Search */
.sidebar-search {
    margin: 0 16px 8px;
    position: relative;
}
.sidebar-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 12px;
}
.sidebar-search input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    background: var(--bg-raised);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    font-family: var(--font);
    outline: none;
    transition: border-color var(--transition);
}
.sidebar-search input::placeholder { color: var(--text-muted); }
.sidebar-search input:focus { border-color: var(--accent); }

/* Table List */
.table-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 16px;
}

.table-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
    border: 1px solid transparent;
    margin-bottom: 2px;
    text-decoration: none;
}

.table-list-item:hover {
    background: var(--bg-raised);
    color: var(--text);
}

.table-list-item.active {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent-glow);
    font-weight: 600;
}

.table-list-item i {
    font-size: 11px;
    width: 16px;
    text-align: center;
    opacity: .6;
}

.table-list-item.active i { opacity: 1; }

.table-item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-item-index {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
    background: var(--bg-overlay);
    padding: 2px 6px;
    border-radius: 4px;
    min-width: 20px;
    text-align: center;
}

.empty-sidebar {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 32px;
    margin-bottom: 12px;
    opacity: .3;
}

.empty-sidebar p {
    font-size: 13px;
    margin: 0;
}

/* ---- Main Content ---- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* Top Bar */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    height: 56px;
    min-height: 56px;
    flex-shrink: 0;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.hamburger {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 18px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
}
.hamburger:hover { background: var(--bg-raised); color: var(--text); }

.page-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.page-title i { color: var(--text-muted); margin-right: 6px; font-size: 14px; }

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.action-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background: var(--bg-raised);
    color: var(--text-dim);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    transition: all var(--transition);
    line-height: 1;
    padding: 0;
}
.action-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
    transform: translateY(-1px);
}
.action-btn.export {
    border-color: var(--green-soft);
}
.action-btn.export:hover {
    border-color: var(--green);
    color: var(--green);
    background: var(--green-soft);
}

/* Content Area */
.content-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
}

/* ---- Welcome State ---- */
.welcome-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 100%;
    animation: fadeIn .6s ease;
}

.welcome-illustration {
    position: relative;
    margin-bottom: 32px;
}

.welcome-blob {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: blobPulse 4s ease-in-out infinite;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-xl);
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    display: grid;
    place-items: center;
    font-size: 32px;
    color: #fff;
    position: relative;
    box-shadow: 0 8px 32px var(--accent-glow);
}

.welcome-state h2 {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 8px;
    letter-spacing: -.5px;
}

.gradient-text {
    background: linear-gradient(135deg, var(--accent), #a78bfa, #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-sub {
    color: var(--text-dim);
    font-size: 15px;
    max-width: 440px;
    line-height: 1.6;
    margin-bottom: 20px;
}

/* Privacy Badge */
.privacy-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    background: var(--green-soft);
    border: 1px solid #34d39930;
    border-radius: 24px;
    color: var(--green);
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 32px;
}
.privacy-badge i { font-size: 14px; }

/* Feature Cards */
.feature-cards {
    display: flex;
    gap: 16px;
    margin-bottom: 36px;
    flex-wrap: wrap;
    justify-content: center;
}

.feature-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 24px 20px;
    width: 180px;
    text-align: center;
    transition: all var(--transition);
}
.feature-card:hover {
    border-color: var(--accent-glow);
    transform: translateY(-4px);
    box-shadow: 0 12px 40px #00000040;
}

.feature-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: grid;
    place-items: center;
    font-size: 20px;
    margin: 0 auto 14px;
}
.feature-icon.upload { background: var(--accent-soft); color: var(--accent); }
.feature-icon.browse { background: var(--green-soft); color: var(--green); }
.feature-icon.export { background: #fbbf2420; color: var(--amber); }

.feature-card h4 {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 6px;
}
.feature-card p {
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.4;
    margin: 0;
}

/* ---- Buttons ---- */
.btn-glow {
    padding: 12px 28px;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-glow:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--accent-glow);
    filter: brightness(1.1);
}
.btn-glow:disabled {
    opacity: .4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-ghost {
    padding: 12px 24px;
    background: none;
    color: var(--text-dim);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-ghost:hover {
    background: var(--bg-raised);
    color: var(--text);
    border-color: var(--text-muted);
}

.btn-outline-glow {
    padding: 10px 22px;
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-outline-glow:hover {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 20px var(--accent-glow);
}

/* ---- Custom Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    background: #000000aa;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 20px;
    animation: fadeIn .2s ease;
}
.modal-overlay.show { display: flex; }

.modal-glass {
    width: 100%;
    max-width: 540px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    box-shadow: 0 24px 80px #00000080;
    animation: slideUp .3s ease;
    overflow: hidden;
}

.modal-glass-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.modal-glass-header h3 {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}
.modal-glass-header h3 i { color: var(--accent); }

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--bg-raised);
    color: var(--text-dim);
    display: grid;
    place-items: center;
    cursor: pointer;
    font-size: 16px;
    transition: all var(--transition);
}
.modal-close:hover { background: var(--red); color: #fff; }

.modal-glass-body { padding: 24px; }

/* Privacy Notice in Modal */
.privacy-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--green-soft);
    border: 1px solid #34d39930;
    border-radius: var(--radius-sm);
    color: var(--green);
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 16px;
}
.privacy-notice i { font-size: 13px; flex-shrink: 0; }
.modal-glass-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-lg);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all .3s ease;
    background: var(--bg-raised);
    position: relative;
}
.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.drop-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-lg);
    background: var(--accent-soft);
    color: var(--accent);
    display: grid;
    place-items: center;
    font-size: 26px;
    margin: 0 auto 16px;
    transition: transform .3s ease;
}
.drop-zone:hover .drop-icon { transform: translateY(-4px); }

.drop-zone h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}
.drop-zone p {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 16px;
}

/* File Selected State */
.file-selected {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.file-selected .file-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    background: var(--green-soft);
    color: var(--green);
    display: grid;
    place-items: center;
    font-size: 24px;
}
.file-selected h4 { font-size: 15px; font-weight: 600; }
.file-selected .file-size { color: var(--text-muted); font-size: 13px; }
.file-remove {
    padding: 6px 14px;
    background: none;
    border: 1px solid var(--red);
    color: var(--red);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.file-remove:hover { background: var(--red); color: #fff; }

/* Password Field */
.password-field {
    margin-top: 16px;
}
.password-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-dim);
}
.password-field label i { margin-right: 6px; }
.password-field .optional { font-weight: 400; color: var(--text-muted); font-size: 11px; }
.password-field input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-raised);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition);
}
.password-field input::placeholder { color: var(--text-muted); }
.password-field input:focus { border-color: var(--accent); }

/* Upload Progress */
.upload-progress {
    margin-top: 20px;
    text-align: center;
}
.progress-track {
    height: 4px;
    background: var(--bg-overlay);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}
.progress-fill {
    height: 100%;
    width: 60%;
    background: linear-gradient(90deg, var(--accent), #a78bfa);
    border-radius: 4px;
    animation: progressAnim 1.5s ease-in-out infinite;
}
.upload-progress p {
    color: var(--text-dim);
    font-size: 13px;
    margin: 0;
}
.upload-progress p i { margin-right: 6px; color: var(--accent); }

/* ---- Data Table ---- */
.table-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    animation: fadeIn .3s ease;
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 10px;
}

.table-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.stat-pill {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.stat-pill.rows { background: var(--accent-soft); color: var(--accent); }
.stat-pill.cols { background: var(--green-soft); color: var(--green); }
.stat-pill.filtered { background: #fbbf2420; color: var(--amber); }
.stat-pill i { font-size: 10px; }

/* Right-side controls: search + per-page */
.table-right-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Search box inside table toolbar */
.table-search-box {
    position: relative;
    display: flex;
    align-items: center;
}
.table-search-box > i {
    position: absolute;
    left: 10px;
    color: var(--text-muted);
    font-size: 12px;
    pointer-events: none;
}
.table-search-box input {
    width: 200px;
    padding: 7px 30px 7px 32px;
    background: var(--bg-raised);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    font-family: var(--font);
    outline: none;
    transition: all var(--transition);
}
.table-search-box input::placeholder { color: var(--text-muted); }
.table-search-box input:focus { border-color: var(--accent); width: 240px; }
/* Prevent browser autofill styling */
.table-search-box input:-webkit-autofill,
.table-search-box input:-webkit-autofill:hover,
.table-search-box input:-webkit-autofill:focus,
.sidebar-search input:-webkit-autofill,
.sidebar-search input:-webkit-autofill:hover,
.sidebar-search input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--bg-raised) inset !important;
    -webkit-text-fill-color: var(--text) !important;
    caret-color: var(--text);
    transition: background-color 5000s ease-in-out 0s;
}
.search-clear {
    position: absolute;
    right: 6px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    padding: 4px;
    border-radius: 4px;
    line-height: 1;
    transition: all var(--transition);
}
.search-clear:hover { color: var(--red); background: #f8717120; }

/* Per-page dropdown */
.per-page-control {
    display: flex;
    align-items: center;
    gap: 6px;
}
.per-page-control label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}
.per-page-control select {
    padding: 6px 10px;
    background: var(--bg-raised);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    font-family: var(--font);
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition);
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23ffffff60'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
}
.per-page-control select:focus { border-color: var(--accent); }

/* Row number column */
.row-num-header, .row-num {
    color: var(--text-muted) !important;
    font-size: 11px;
    text-align: center;
    width: 50px;
    min-width: 50px;
    max-width: 50px;
    font-variant-numeric: tabular-nums;
}
.row-num { font-weight: 500; }

.table-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}
.table-controls label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}
.table-controls input[type="number"] {
    width: 70px;
    padding: 6px 10px;
    background: var(--bg-raised);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    font-family: var(--font);
    outline: none;
    text-align: center;
}
.table-controls input[type="number"]:focus { border-color: var(--accent); }

.table-controls .apply-btn {
    padding: 6px 12px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-glow);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
}
.table-controls .apply-btn:hover {
    background: var(--accent);
    color: #fff;
}

.table-scroll {
    overflow-x: auto;
}

/* The actual table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead th {
    background: var(--bg-raised);
    color: var(--text-dim);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 2;
    white-space: nowrap;
}

.data-table thead th.sortable {
    cursor: pointer;
    user-select: none;
    transition: color var(--transition);
}
.data-table thead th.sortable:hover {
    color: var(--accent);
}
.sort-idle { font-size: 9px; opacity: .3; margin-left: 4px; }
.sort-active { font-size: 10px; color: var(--accent); margin-left: 4px; }

.data-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
.data-table tbody tr:nth-child(even) { background: #ffffff03; }
.data-table tbody tr:hover { background: var(--bg-raised); }
.data-table tbody tr:last-child { border-bottom: none; }

.data-table tbody td {
    padding: 10px 16px;
    color: var(--text-dim);
    white-space: nowrap;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table td .null-val {
    color: var(--text-muted);
    font-style: italic;
    font-size: 11px;
}

.table-footer-info {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}
.table-footer-info i { color: var(--accent); }

/* ---- Pagination ---- */
.table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 12px;
    background: var(--bg-raised);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.page-info {
    font-size: 13px;
    color: var(--text-dim);
}
.page-info strong { color: var(--text); font-weight: 600; }
.page-info .from-total { color: var(--text-muted); font-size: 12px; margin-left: 4px; }

.page-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background: var(--bg-surface);
    color: var(--text-dim);
    display: grid;
    place-items: center;
    cursor: pointer;
    font-size: 12px;
    transition: all var(--transition);
}
.page-btn:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}
.page-btn:disabled {
    opacity: .3;
    cursor: not-allowed;
}

.page-numbers {
    display: flex;
    gap: 2px;
    margin: 0 4px;
}

.page-num {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: none;
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all var(--transition);
}
.page-num:hover {
    background: var(--bg-overlay);
    color: var(--text);
}
.page-num.active {
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    border-color: var(--accent);
    box-shadow: 0 2px 10px var(--accent-glow);
}

.page-jump {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
    font-size: 12px;
    color: var(--text-muted);
}
.page-jump input {
    width: 48px;
    padding: 5px 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    font-family: var(--font);
    outline: none;
    text-align: center;
}
.page-jump input:focus { border-color: var(--accent); }

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    gap: 16px;
}
.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-light);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
.loading-state p { color: var(--text-dim); font-size: 14px; margin: 0; }

/* Empty Table State */
.empty-table {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: var(--text-muted);
}
.empty-table i { font-size: 40px; margin-bottom: 16px; opacity: .3; }
.empty-table h4 { font-size: 16px; font-weight: 600; color: var(--text-dim); margin-bottom: 4px; }
.empty-table p { font-size: 13px; margin: 0; }

/* ---- Toast Notifications ---- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px #00000060;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    animation: slideIn .3s ease;
    min-width: 280px;
    max-width: 420px;
}
.toast-item.error { border-color: var(--red); }
.toast-item.error i { color: var(--red); }
.toast-item.success { border-color: var(--green); }
.toast-item.success i { color: var(--green); }

.toast-dismiss {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 6px;
    font-size: 14px;
}
.toast-dismiss:hover { color: var(--text); }

/* ---- Animations ---- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

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

@keyframes blobPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: .5; }
    50% { transform: translate(-50%, -50%) scale(1.3); opacity: .8; }
}

@keyframes progressAnim {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(0); }
    100% { transform: translateX(100%); }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-overlay); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- Responsive ---- */

/* Tablet & Mobile */
@media (max-width: 768px) {
    :root { --sidebar-w: 280px; }

    /* Sidebar: off-canvas overlay on mobile */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        height: 100dvh;
        transform: translateX(-100%);
        z-index: 200;
        overflow-y: auto;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px #00000060;
    }

    /* Main content fills viewport on mobile */
    .app-layout { height: calc(100vh - 32px); height: calc(100dvh - 32px); }
    .main-content { min-height: 0; }

    /* Top bar */
    .top-bar { padding: 0 12px; height: 50px; min-height: 50px; }
    .page-title { font-size: 14px; }
    .page-title i { font-size: 12px; margin-right: 4px; }

    /* Action buttons: smaller on mobile */
    .action-btn { width: 34px; height: 34px; font-size: 13px; }
    .top-bar-actions { gap: 5px; }

    /* Content */
    .content-area { padding: 12px; }

    /* Welcome state */
    .welcome-state { min-height: 100%; padding: 16px 0; justify-content: center; }
    .welcome-state h2 { font-size: 22px; margin-bottom: 4px; }
    .welcome-sub { font-size: 13px; padding: 0 8px; margin-bottom: 12px; }
    .welcome-icon { width: 56px; height: 56px; font-size: 24px; }
    .welcome-blob { width: 90px; height: 90px; }
    .welcome-illustration { margin-bottom: 14px; }
    .privacy-badge { font-size: 11px; padding: 6px 14px; margin-bottom: 14px; }

    /* Feature cards: stack vertically on mobile */
    .feature-cards {
        flex-direction: column;
        align-items: center;
        gap: 8px;
        margin-bottom: 16px;
        width: 100%;
        padding: 0 16px;
    }
    .feature-cards::-webkit-scrollbar { display: none; }
    .feature-card {
        width: 100%;
        max-width: 280px;
        padding: 16px 14px;
    }
    .feature-icon { width: 40px; height: 40px; font-size: 18px; margin-bottom: 10px; }
    .feature-card h4 { font-size: 13px; }
    .feature-card p { font-size: 11px; }

    .btn-glow { padding: 10px 22px; font-size: 13px; }

    /* Table toolbar */
    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
        padding: 10px 12px;
        gap: 8px;
    }
    .table-stats { gap: 6px; }
    .stat-pill { font-size: 11px; padding: 3px 10px; }

    .table-right-controls {
        flex-direction: column;
        gap: 8px;
    }
    .table-search-box { width: 100%; }
    .table-search-box input { width: 100%; }
    .table-search-box input:focus { width: 100%; }
    .per-page-control { justify-content: space-between; }

    /* Table: better mobile scroll */
    .table-scroll { -webkit-overflow-scrolling: touch; }
    .data-table thead th { padding: 10px 12px; font-size: 10px; letter-spacing: .5px; }
    .data-table tbody td { padding: 8px 12px; font-size: 12px; max-width: 200px; }
    .row-num-header, .row-num { width: 36px; min-width: 36px; max-width: 36px; font-size: 10px; }

    /* Pagination */
    .table-pagination {
        flex-direction: column;
        align-items: stretch;
        padding: 10px 12px;
        gap: 8px;
    }
    .page-info { font-size: 12px; text-align: center; }
    .page-controls { flex-wrap: wrap; justify-content: center; }
    .page-btn { width: 30px; height: 30px; font-size: 11px; }
    .page-num { width: 30px; height: 30px; font-size: 12px; }
    .page-jump { margin-left: 0; justify-content: center; }

    /* Modal */
    .modal-overlay { padding: 12px; }
    .modal-glass { border-radius: var(--radius-lg); }
    .modal-glass-header { padding: 16px; }
    .modal-glass-header h3 { font-size: 16px; }
    .modal-glass-body { padding: 16px; }
    .modal-glass-footer { padding: 12px 16px; }
    .drop-zone { padding: 28px 16px; }
    .drop-icon { width: 52px; height: 52px; font-size: 22px; }
    .drop-zone h4 { font-size: 15px; }

    /* Footer */
    .app-footer { font-size: 10px; padding: 6px 12px; height: 32px; }
    .footer-left span { display: none; }

    /* Toasts */
    .toast-container { top: 10px; right: 10px; left: 10px; }
    .toast-item { min-width: auto; font-size: 12px; padding: 10px 14px; }
}

/* Small phones */
@media (max-width: 420px) {
    :root { --sidebar-w: 260px; }

    .top-bar { padding: 0 8px; height: 46px; min-height: 46px; }
    .page-title { font-size: 13px; max-width: 140px; }
    .action-btn { width: 30px; height: 30px; font-size: 12px; }
    .top-bar-actions { gap: 3px; }

    .sidebar-header { height: 46px; min-height: 46px; padding: 0 14px; }
    .logo-icon { width: 30px; height: 30px; font-size: 14px; }
    .logo-text { font-size: 16px; }

    .content-area { padding: 8px; }
    .welcome-state h2 { font-size: 19px; }
    .welcome-sub { font-size: 12px; }
    .welcome-icon { width: 56px; height: 56px; font-size: 22px; }
    .privacy-badge { font-size: 10px; padding: 5px 10px; gap: 5px; }
    .privacy-badge i { font-size: 12px; }

    .feature-cards { gap: 8px; padding: 0 8px; }
    .feature-card { max-width: 260px; padding: 14px 10px; }
    .feature-icon { width: 36px; height: 36px; font-size: 16px; }
    .feature-card h4 { font-size: 12px; }
    .feature-card p { font-size: 10px; }

    .btn-glow { padding: 9px 18px; font-size: 12px; gap: 6px; }

    .table-toolbar { padding: 8px 10px; }
    .stat-pill { font-size: 10px; padding: 2px 8px; }

    .data-table thead th { padding: 8px 8px; font-size: 9px; }
    .data-table tbody td { padding: 7px 8px; font-size: 11px; max-width: 150px; }
    .row-num-header, .row-num { width: 30px; min-width: 30px; max-width: 30px; }

    .table-pagination { padding: 8px 10px; }
    .page-btn { width: 28px; height: 28px; }
    .page-num { width: 28px; height: 28px; font-size: 11px; }

    .modal-overlay { padding: 8px; }
    .modal-glass-header h3 { font-size: 15px; gap: 8px; }
    .modal-glass-body { padding: 12px; }
    .drop-zone { padding: 20px 12px; }
    .drop-icon { width: 44px; height: 44px; font-size: 20px; }
    .drop-zone h4 { font-size: 14px; }
    .drop-zone p { font-size: 12px; }

    .app-footer { height: 28px; padding: 4px 8px; font-size: 9px; }
    .app-layout { height: calc(100vh - 28px); }
}
