/* ===================================================================
   Cloud RAID — File Manager UI
   =================================================================== */

/* --- CSS Custom Properties --- */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #161922;
    --bg-surface: #1c1f2e;
    --bg-surface-hover: #252839;
    --bg-elevated: #222640;
    --border: #2a2d3e;
    --border-light: #363a4f;

    --text-primary: #e8eaf0;
    --text-secondary: #9399b2;
    --text-muted: #6c7086;

    --accent: #9333ea;
    --accent-dim: #4c1d95;
    --accent-hover: #7e22ce;
    --success: #a6e3a1;
    --success-dim: #1e3a2f;
    --warning: #f9e2af;
    --warning-dim: #3a3020;
    --danger: #f38ba8;
    --danger-dim: #3a1e2f;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,.4);
    --shadow-lg: 0 8px 30px rgba(0,0,0,.5);

    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    --font-mono: 'SF Mono', 'Cascadia Code', 'JetBrains Mono', Consolas, monospace;

    --header-height: 56px;
    --sidebar-width: 380px;
    --nav-sidebar-width: 220px;
    --nav-sidebar-collapsed-width: 56px;
    --grid-card-min: 170px;
    --transition: .2s ease;
}

/* --- Catppuccin Latte (Light Theme) --- */
[data-theme="light"] {
    --bg-primary: #eff1f5;
    --bg-secondary: #e6e9ef;
    --bg-surface: #ccd0da;
    --bg-surface-hover: #bcc0cc;
    --bg-elevated: #dce0e8;
    --border: #bcc0cc;
    --border-light: #acb0be;

    --text-primary: #4c4f69;
    --text-secondary: #6c6f85;
    --text-muted: #9ca0b0;

    --accent: #7c3aed;
    --accent-dim: #c4b5fd;
    --accent-hover: #6d28d9;
    --success: #40a02b;
    --success-dim: #d7f0d0;
    --warning: #df8e1d;
    --warning-dim: #f5e6c8;
    --danger: #d20f39;
    --danger-dim: #f5d0d8;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,.1);
    --shadow-lg: 0 8px 30px rgba(0,0,0,.12);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
}

.sr-only { position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

select, select option { background: var(--bg-primary); color: var(--text-primary); }

button {
    font-family: inherit;
    font-size: inherit;
    border: none;
    cursor: pointer;
    background: none;
    color: inherit;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- Header --- */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}

.header__logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -.3px;
    color: var(--text-primary);
    text-decoration: none;
}

.header__logo i {
    width: 22px;
    height: 22px;
    color: var(--accent);
}

.header__logo-img {
    height: 28px;
    width: auto;
}

.header__logo-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

/* (Toolbar removed — navigation moved to left sidebar) */

/* --- Status Bar (bottom-right health indicator) --- */
.status-bar {
    position: fixed;
    bottom: 0;
    right: 0;
    z-index: 99;
    display: flex;
    align-items: center;
    padding: 4px 14px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px) 0 0 0;
    backdrop-filter: blur(12px);
}

/* --- Provider Strip --- */
.provider-strip {
    display: flex;
    align-items: center;
    gap: 10px;
}

.provider-strip__label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    font-weight: 500;
}

.provider-strip__dots {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* Provider chips (icon + optional storage bar) */
.provider-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    transition: color var(--transition);
    cursor: default;
}

.provider-chip__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
}

.provider-chip__bar {
    width: 32px;
    height: 4px;
    background: var(--bg-elevated);
    border-radius: 2px;
    overflow: hidden;
}

.provider-chip__fill {
    display: block;
    height: 100%;
    border-radius: 2px;
    transition: width .3s;
}

.provider-chip__fill--ok { background: var(--success); }
.provider-chip__fill--warning { background: var(--warning); }
.provider-chip__fill--danger { background: var(--danger); }

.provider-chip--ok { color: var(--success); }
.provider-chip--ok.provider-chip--dropbox { color: #0061fe; }
.provider-chip--ok.provider-chip--onedrive { color: #0078d4; }
.provider-chip--ok.provider-chip--google_drive { color: #34a853; }
.provider-chip--ok.provider-chip--s3 { color: #ff9900; }
.provider-chip--ok.provider-chip--azure { color: #0089d6; }
.provider-chip--ok.provider-chip--gcs { color: #4285f4; }
.provider-chip--ok.provider-chip--local { color: var(--success); }
.provider-chip--error { color: var(--danger); }
.provider-chip--unknown { color: var(--text-muted); }
.provider-chip--loading { color: var(--border-light); animation: pulse 1.5s infinite; }

@keyframes pulse {
    0%, 100% { opacity: .4; }
    50% { opacity: 1; }
}

/* Provider Icons */
.provider-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.provider-icon svg,
.provider-icon i { width: 100%; height: 100%; }
.provider-icon--sm { width: 12px; height: 12px; }
.provider-icon--lg { width: 20px; height: 20px; }

/* --- App Shell --- */
.app-shell {
    display: flex;
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
    position: relative;
}

/* --- Nav Sidebar (Global Navigation) --- */
.nav-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--nav-sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 80;
    transition: width .25s ease;
    overflow: hidden;
}

.nav-sidebar__links {
    padding: 10px 8px 0;
    flex-shrink: 0;
}

.nav-sidebar__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    margin-bottom: 2px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: color .15s, background .15s;
    white-space: nowrap;
    position: relative;
}

.nav-sidebar__item:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

.nav-sidebar__item i { width: 18px; height: 18px; flex-shrink: 0; }

.nav-sidebar__item--active {
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 8%, transparent);
    font-weight: 600;
}

.nav-sidebar__item--active::before {
    content: '';
    position: absolute;
    left: 0; top: 4px; bottom: 4px;
    width: 3px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.nav-sidebar__label { overflow: hidden; text-overflow: ellipsis; }

.nav-sidebar__section-label {
    display: block;
    padding: 4px 14px 2px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--text-muted);
    font-weight: 700;
}

.nav-sidebar__divider {
    margin: 6px 12px;
    border: none;
    border-top: 1px solid var(--border);
}

/* --- Admin Context Switcher --- */
.admin-ctx { padding: 4px 10px 6px; }
.admin-ctx__select {
    display: block;
    width: 100%;
    padding: 4px 6px;
    margin-bottom: 4px;
    font-size: 11px;
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    outline: none;
}
.admin-ctx__select:focus { border-color: var(--accent); }
.admin-ctx__select option { background: var(--bg-surface); color: var(--text-primary); }
.admin-ctx__badge {
    display: none;
    font-size: 9px;
    text-align: center;
    padding: 2px 4px;
    margin: 2px 10px 4px;
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: var(--radius-sm);
    font-weight: 600;
    letter-spacing: .3px;
}
body.admin-ctx-active .admin-ctx__badge { display: block; }
body.sidebar-collapsed .admin-ctx { display: none; }

/* --- Folder Tree Section (files page only) --- */
.nav-sidebar__folder-tree {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.nav-sidebar__tree-header {
    padding: 6px 14px;
    flex-shrink: 0;
}

.nav-sidebar__tree-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--text-muted);
    font-weight: 600;
}

.nav-sidebar__tree-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 0;
}

body:not(.files-page) .nav-sidebar__folder-tree { display: none; }

/* --- Sidebar Collapsed State --- */
body.sidebar-collapsed .nav-sidebar { width: var(--nav-sidebar-collapsed-width); }
body.sidebar-collapsed .nav-sidebar__links { padding: 10px 4px 0; }
body.sidebar-collapsed .nav-sidebar__item { justify-content: center; padding: 9px; gap: 0; }
body.sidebar-collapsed .nav-sidebar__label { display: none; }
body.sidebar-collapsed .nav-sidebar__section-label { display: none; }
body.sidebar-collapsed .nav-sidebar__item--active::before { left: 0; }
body.sidebar-collapsed .nav-sidebar__divider { margin: 6px 4px; }
body.sidebar-collapsed .nav-sidebar__folder-tree { display: none; }

/* --- Tree Nodes --- */
.tree-node {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px 5px 8px;
    cursor: pointer;
    border-radius: 0;
    transition: background var(--transition);
    white-space: nowrap;
    font-size: 13px;
    color: var(--text-secondary);
    user-select: none;
    position: relative;
}

.tree-node:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.tree-node--active {
    background: rgba(137,180,250,.08);
    color: var(--text-primary);
    font-weight: 500;
}

.tree-node--active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 2px;
    bottom: 2px;
    width: 2px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
}

.tree-node--drag-over {
    background: rgba(137,180,250,.15);
    outline: 1px dashed var(--accent);
    outline-offset: -1px;
}

.tree-node__toggle {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform .15s ease;
    padding: 0;
}

.tree-node__toggle i { width: 14px; height: 14px; }

.tree-node__toggle--open {
    transform: rotate(90deg);
}

.tree-node__spacer {
    width: 16px;
    flex-shrink: 0;
}

.tree-node__icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--warning);
}

.tree-node--root .tree-node__icon {
    color: var(--text-muted);
}

.tree-node__name {
    overflow: hidden;
    text-overflow: ellipsis;
}

.main {
    flex: 1;
    padding: 24px 32px;
    margin-left: var(--nav-sidebar-width);
    transition: margin-right var(--transition), margin-left .25s ease;
    max-width: 100%;
    overflow-x: hidden;
}

body.sidebar-collapsed .main {
    margin-left: var(--nav-sidebar-collapsed-width);
}

body.no-sidebar .main {
    margin-left: 0;
    margin-right: auto;
    max-width: 100%;
}

body.detail-open .main {
    margin-right: var(--sidebar-width);
}

/* --- Upload Zone --- */
.upload-zone {
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-lg);
    padding: 32px;
    text-align: center;
    transition: all var(--transition);
    cursor: pointer;
    margin-bottom: 24px;
    background: var(--bg-secondary);
}

.upload-zone:hover,
.upload-zone--active {
    border-color: var(--accent);
    background: rgba(137,180,250,.04);
}

.upload-zone--active {
    box-shadow: inset 0 0 40px rgba(137,180,250,.06);
}

.upload-zone__icon {
    width: 40px;
    height: 40px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.upload-zone:hover .upload-zone__icon,
.upload-zone--active .upload-zone__icon {
    color: var(--accent);
}

.upload-zone__text {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 4px;
}

.upload-zone__buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.upload-zone__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    transition: all var(--transition);
}
.upload-zone__btn i { width: 18px; height: 18px; }
.upload-zone__btn:hover {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}

.upload-zone__progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.upload-zone__progress[hidden] {
    display: none;
}

.upload-progress { width: 100%; max-width: 420px; }

.upload-progress__bar {
    width: 100%;
    height: 6px;
    background: var(--bg-elevated);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.upload-progress__fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width .25s ease;
}

.upload-progress__text {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 0;
    text-align: center;
}

.upload-progress__detail {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin: 0;
    text-align: center;
    font-family: var(--font-mono);
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --- Download Progress Overlay --- */
.download-progress-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,.45);
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(2px);
}
.download-progress-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px 36px;
    min-width: 340px;
    box-shadow: 0 8px 32px rgba(0,0,0,.3);
}
.download-progress-title {
    display: flex; align-items: center; gap: 8px;
    font-weight: 600; font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 16px;
}
.download-progress-title svg { width: 18px; height: 18px; color: var(--accent); }
.download-progress-bar-track {
    width: 100%; height: 6px;
    background: var(--bg-elevated);
    border-radius: 3px; overflow: hidden;
    margin-bottom: 10px;
}
.download-progress-bar-fill {
    height: 100%; width: 0%;
    background: var(--accent);
    border-radius: 3px;
    transition: width .2s ease;
}
.download-progress-text {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: center;
    font-family: var(--font-mono);
}

/* --- Breadcrumb --- */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    margin-bottom: 8px;
    font-size: 13px;
    flex-wrap: wrap;
}

.breadcrumb__item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    text-decoration: none;
}

.breadcrumb__item:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

.breadcrumb__item--active {
    color: var(--text-primary);
    font-weight: 500;
}

.breadcrumb__icon { width: 14px; height: 14px; }

.breadcrumb__sep {
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
}

.breadcrumb__sep i { width: 14px; height: 14px; }

/* --- Toolbar --- */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 0 4px;
}

.toolbar__count {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.toolbar__actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
    border: none;
    cursor: pointer;
}

.btn i { width: 16px; height: 16px; }

.btn--ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn--ghost:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.btn--primary {
    background: var(--accent);
    color: var(--bg-primary);
}

.btn--primary:hover {
    background: var(--accent-hover);
}

.view-toggle {
    display: flex;
    gap: 2px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.view-toggle__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 28px;
    border-radius: 4px;
    color: var(--text-muted);
    transition: all var(--transition);
}

.view-toggle__btn:hover { color: var(--text-secondary); }

.view-toggle__btn--active {
    background: var(--bg-elevated);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.view-toggle__btn i { width: 16px; height: 16px; }

/* --- File Browser --- */
.file-browser { min-height: 200px; }

/* Grid / List visibility controlled by data-view attribute */
[data-view="grid"] .file-grid { display: grid; }
[data-view="grid"] .file-list { display: none; }
[data-view="list"] .file-grid { display: none; }
[data-view="list"] .file-list { display: block; }

/* --- File Grid --- */
.file-grid {
    grid-template-columns: repeat(auto-fill, minmax(var(--grid-card-min), 1fr));
    gap: 12px;
}

/* --- File Card --- */
.file-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px 16px 14px;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    position: relative;
}

.file-card:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.file-card--selected {
    border-color: var(--accent);
    background: rgba(137,180,250,.06);
}

.file-card__icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.file-card__icon i { width: 36px; height: 36px; }

.file-card__name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-card__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.file-card__size { color: var(--text-muted); }

.file-card__time {
    font-size: 11px;
    color: var(--text-muted);
}

/* File card / row action menu button */
.file-card__menu {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition);
}

.file-card:hover .file-card__menu { opacity: 1; }
.file-card__menu:hover { background: var(--bg-elevated); color: var(--accent); }
.file-card__menu i { width: 16px; height: 16px; }

.file-action-menu {
    background: none;
    border: none;
    cursor: pointer;
}

/* --- Folder Card --- */
.file-card--folder {
    border-style: dashed;
    border-color: var(--border);
}

.file-card--folder:hover {
    border-style: solid;
    border-color: var(--accent-dim);
}

.file-card__icon--folder {
    color: var(--warning);
}

.file-card__icon--folder i { width: 36px; height: 36px; }

/* --- Folder Row --- */
.file-row--folder .file-row__name i {
    color: var(--warning);
}

.file-row__item-count {
    font-size: 12px;
    color: var(--text-muted);
}

/* --- File List --- */
.file-list__header,
.file-row {
    display: grid;
    grid-template-columns: 1fr 90px 120px 80px 36px 80px 120px 40px;
    align-items: center;
    padding: 10px 16px;
    gap: 10px;
}

.file-list__header {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 0;
}

.file-list__filters {
    display: grid;
    grid-template-columns: 1fr 90px 120px 80px 36px 80px 120px 40px;
    align-items: center;
    padding: 6px 12px;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2px;
}

.file-list__filter {
    width: 100%;
    padding: 3px 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.75rem;
    outline: none;
    box-sizing: border-box;
}
.file-list__filter:focus { border-color: var(--accent); }
.file-list__filter::placeholder { color: var(--text-muted); font-size: 0.7rem; }
select.file-list__filter { cursor: pointer; }

.file-row {
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
    border: 1px solid transparent;
}

.file-row:hover {
    background: var(--bg-surface-hover);
}

.file-row--selected {
    background: rgba(137,180,250,.06);
    border-color: var(--accent-dim);
}

.file-row__name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    min-width: 0;
}

.file-row__name i { width: 18px; height: 18px; color: var(--text-secondary); flex-shrink: 0; }
.file-row__name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* File icon colors by type */
.ficon--file-text   { color: #3b82f6; }  /* blue – documents */
.ficon--image       { color: #ec4899; }  /* pink – images */
.ficon--film        { color: #f43f5e; }  /* rose – video */
.ficon--music       { color: #f97316; }  /* orange – audio */
.ficon--archive     { color: #a78bfa; }  /* violet – archives */
.ficon--file-code   { color: #22c55e; }  /* green – code */
.ficon--table       { color: #10b981; }  /* emerald – spreadsheets */
.ficon--presentation{ color: #f59e0b; }  /* amber – presentations */
.ficon--braces      { color: #facc15; }  /* yellow – data/config */
.ficon--database    { color: #06b6d4; }  /* cyan – databases */
.ficon--cog         { color: #8b5cf6; }  /* purple – executables */
.ficon--file        { color: var(--text-secondary); }  /* default */

.file-row__providers, .file-card__providers {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    overflow: hidden;
}
.file-provider-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
}
.file-provider-icon--dropbox { color: #0061fe; }
.file-provider-icon--onedrive { color: #0078d4; }
.file-provider-icon--google_drive { color: #34a853; }
.file-provider-icon--s3 { color: #ff9900; }
.file-provider-icon--azure { color: #0089d6; }
.file-provider-icon--gcs { color: #4285f4; }
.file-provider-icon--local { color: var(--text-muted); }
.provider-icon--xs { width: 14px; height: 14px; }
.provider-icon--xs svg, .provider-icon--xs i { width: 14px; height: 14px; }

.file-row__category { font-size: 12px; }
.badge--category {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}
.file-row__size { color: var(--text-secondary); font-size: 13px; }
.file-row__compressed { display: flex; align-items: center; justify-content: center; }
.file-row__compressed-icon { width: 16px; height: 16px; }
.file-row__compressed-icon--yes { color: #89b4fa; }
.file-row__compressed-icon--no { color: var(--text-muted); opacity: 0.3; width: 14px; height: 14px; }
.file-card__compressed-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    color: #89b4fa;
    display: flex;
    align-items: center;
}
.file-card__compressed-badge i { width: 14px; height: 14px; }
.file-row__time { color: var(--text-muted); font-size: 13px; }

.file-row__action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: all var(--transition);
}

.file-row__action:hover {
    background: var(--bg-elevated);
    color: var(--accent);
}

.file-row__action i { width: 16px; height: 16px; }

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .3px;
    text-transform: capitalize;
}

.badge--available {
    color: var(--success);
    background: var(--success-dim);
}

.badge--processing {
    color: var(--warning);
    background: var(--warning-dim);
}

.badge--failed {
    color: var(--danger);
    background: var(--danger-dim);
}

/* --- Detail Panel --- */
.detail-panel {
    position: fixed;
    top: var(--header-height);
    right: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform .25s ease;
    z-index: 90;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.detail-panel--open {
    transform: translateX(0);
}

.detail-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.detail-panel__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.detail-panel__close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: all var(--transition);
}

.detail-panel__close:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.detail-panel__close i { width: 18px; height: 18px; }

.detail-panel__body {
    padding: 20px;
    flex: 1;
}

/* Detail content sections */
.detail-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 16px 0 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.detail-hero__icon {
    width: 56px;
    height: 56px;
    margin-bottom: 12px;
}

.detail-hero__name {
    font-size: 15px;
    font-weight: 600;
    word-break: break-all;
    margin-bottom: 4px;
}

.detail-hero__size {
    font-size: 13px;
    color: var(--text-muted);
}

/* Detail panel tabs */
.detail-tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.detail-tabs__btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 0;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.detail-tabs__btn i { width: 14px; height: 14px; }

.detail-tabs__btn:hover { color: var(--text-primary); }

.detail-tabs__btn--active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Chunk mini-map in detail panel */
.detail-chunk-map {
    width: 100%;
    height: 220px;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-primary);
    margin-bottom: 12px;
}

.detail-chunk-map .leaflet-container {
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
}

.detail-chunk-map-legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.detail-chunk-map-legend__item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.detail-chunk-map-legend__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.detail-chunk-map-legend__count {
    margin-left: auto;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 12px;
}

/* Hop list in chunk map tab */
.detail-chunk-map-hops {
    margin-top: 12px;
}

.detail-hops-trace {
    margin-bottom: 10px;
}

.detail-hops-trace__header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.detail-hops-trace__meta {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}

.detail-hops-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.detail-hop-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    background: var(--bg-surface);
    font-size: 11px;
    color: var(--text-muted);
    font-family: monospace;
}

.detail-hop-row--geo {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.detail-hop-row__num {
    width: 18px;
    text-align: right;
    flex-shrink: 0;
    opacity: 0.5;
}

.detail-hop-row__ip {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-hop-row__rtt {
    width: 55px;
    text-align: right;
    flex-shrink: 0;
}

.detail-hop-row__loc {
    font-size: 10px;
    color: var(--accent);
    flex-shrink: 0;
}

.detail-hops-empty {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    padding: 12px 0;
}

.detail-section {
    margin-bottom: 20px;
}

.detail-section__title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 10px;
}

.detail-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-meta__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.detail-meta__label { color: var(--text-muted); }
.detail-meta__value { color: var(--text-primary); font-weight: 500; }

.detail-meta__value--encrypted {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--success);
}

.detail-meta__value--encrypted i { width: 14px; height: 14px; }

/* Chunk Distribution Visualization */
.chunk-viz {
    display: flex;
    gap: 6px;
    align-items: flex-end;
    padding: 8px 0 4px;
}

.chunk-viz__column {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.chunk-viz__bar-bg {
    width: 100%;
    height: 70px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
}

.chunk-viz__bar-fill {
    position: absolute;
    bottom: 0;
    width: 100%;
    background: linear-gradient(to top, var(--accent-dim), var(--accent));
    border-radius: var(--radius-sm);
    transition: height .4s ease;
}

.chunk-viz__label {
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    display: inline-flex;
    align-items: center;
    gap: 2px;
    white-space: nowrap;
}

.chunk-viz__count {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.chunk-summary {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    padding: 8px 0;
    line-height: 1.6;
}

.chunk-summary strong { color: var(--text-secondary); font-weight: 600; }

/* Detail action buttons */
.detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.detail-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
    padding: 9px 10px;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    font-family: var(--font-sans);
    white-space: nowrap;
    overflow: hidden;
}

.detail-action:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.detail-action--primary {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: transparent;
}

.detail-action--primary:hover {
    background: rgba(137,180,250,.2);
    color: var(--accent-hover);
}

.detail-action--danger:hover {
    background: var(--danger-dim);
    color: var(--danger);
    border-color: transparent;
}

.detail-action i { width: 14px; height: 14px; }

/* Detail loading spinner */
.detail-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 0;
}

.detail-loading__spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-light);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

/* --- Empty State --- */
.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    text-align: center;
}

.empty-state__icon {
    width: 56px;
    height: 56px;
    margin-bottom: 16px;
    opacity: .4;
}

.empty-state p {
    font-size: 14px;
}

/* --- Toast Notifications --- */
.toast-container {
    position: fixed;
    bottom: 40px;
    right: 24px;
    z-index: 400;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    color: var(--text-primary);
    pointer-events: auto;
    animation: slideIn .3s ease;
    max-width: 360px;
}

.toast--success { border-left: 3px solid var(--success); }
.toast--error { border-left: 3px solid var(--danger); }
.toast--info { border-left: 3px solid var(--accent); }

.toast i { width: 18px; height: 18px; flex-shrink: 0; }
.toast--success i { color: var(--success); }
.toast--error i { color: var(--danger); }
.toast--info i { color: var(--accent); }

.toast--fade-out {
    animation: slideOut .3s ease forwards;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0,0,0,.6);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-overlay[hidden] { display: none; }

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 400px;
    max-width: 90vw;
    animation: modalIn .2s ease;
}

@keyframes modalIn {
    from { transform: scale(.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal__title {
    font-size: 15px;
    font-weight: 600;
}

.modal__close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: all var(--transition);
}

.modal__close:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.modal__close i { width: 18px; height: 18px; }

.modal__body {
    padding: 20px;
}

.modal__input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition);
}

.modal__input:focus {
    border-color: var(--accent);
}

.modal__input::placeholder { color: var(--text-muted); }

.modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px 16px;
}

/* --- Context Menu --- */
.context-menu {
    position: fixed;
    z-index: 400;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    padding: 4px;
    animation: modalIn .15s ease;
}

.context-menu__item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    text-align: left;
}

.context-menu__item:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.context-menu__item i { width: 16px; height: 16px; }

.context-menu__item--danger { color: var(--danger); }
.context-menu__item--danger:hover { background: var(--danger-dim); color: var(--danger); }

.context-menu__divider {
    margin: 4px 0;
    border: none;
    border-top: 1px solid var(--border);
}

/* --- Move Modal Tree --- */
.move-tree {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
}

.move-tree .tree-node {
    border-radius: var(--radius-sm);
    margin: 1px 4px;
}

.move-tree .tree-node--selected {
    background: rgba(137,180,250,.12);
    color: var(--accent);
}

/* --- File dragging --- */
.file-card[draggable="true"],
.file-row[draggable="true"] {
    cursor: grab;
}

.file-card[draggable="true"]:active,
.file-row[draggable="true"]:active {
    cursor: grabbing;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .header { padding: 0 12px; }
    .header__logo-text { display: none; }

    .status-bar { display: none; }

    .header__right { gap: 8px; }

    /* Compact user menu trigger — hide name text, keep tier badge icon */
    .user-menu__trigger > span:not(.header-tier-badge) { display: none; }
    .user-menu__trigger { padding: 6px 8px; }

    .nav-sidebar { display: none; }
    .main { margin-left: 0 !important; padding: 16px; }

    body.detail-open .main { margin-right: 0; }

    .detail-panel {
        width: 100%;
        left: 0;
    }

    .file-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 8px;
    }

    .file-card { padding: 14px 10px 10px; }
    .file-card__icon { width: 36px; height: 36px; }
    .file-card__icon i { width: 28px; height: 28px; }

    .file-list__header,
    .file-list__filters,
    .file-row {
        grid-template-columns: 1fr 80px 40px;
    }

    .file-row__category,
    .file-row__providers,
    .file-row__compressed,
    .file-row__status,
    .file-row__time,
    .file-list__header span:nth-child(2),
    .file-list__header span:nth-child(3),
    .file-list__header span:nth-child(5),
    .file-list__header span:nth-child(6),
    .file-list__header span:nth-child(7),
    .file-list__filters span:nth-child(2),
    .file-list__filters span:nth-child(3),
    .file-list__filters span:nth-child(5),
    .file-list__filters span:nth-child(6),
    .file-list__filters span:nth-child(7) { display: none; }

    .toast-container { right: 12px; bottom: 12px; left: 12px; }
    .toast { max-width: none; }

    /* Audit log table: horizontal scroll on mobile */
    .admin-table-wrap { overflow-x: auto; }
    .audit-table { min-width: 600px; }

    /* Provider cards: stack actions below on mobile */
    .provider-card {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .provider-card__header {
        flex-basis: calc(100% - 50px); /* checkbox + gap */
    }
    .provider-card__actions {
        margin-left: auto;
    }

    /* Settings/admin pages full width */
    .admin-page, .settings-page { padding: 16px; }
}

@media (max-width: 480px) {
    .view-toggle { display: none; }
    [data-view="grid"] .file-grid { display: none; }
    [data-view="grid"] .file-list { display: block; }
}

/* ===================================================================
   Auth Pages (login, setup)
   =================================================================== */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 40px 32px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-align: center;
}

.auth-card__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    color: var(--accent);
}

.auth-card__icon svg { width: 28px; height: 28px; }

.auth-card__logo-img {
    height: 64px;
    width: auto;
}

.auth-card__title {
    margin: 0 0 6px;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
}

.auth-card__subtitle {
    margin: 0 0 24px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-card__error {
    margin-bottom: 16px;
    padding: 10px 14px;
    background: var(--danger-dim);
    border: 1px solid var(--danger);
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-size: 0.85rem;
}

.auth-card__success {
    margin-bottom: 16px;
    padding: 12px 14px;
    background: rgba(166,227,161,.08);
    border: 1px solid var(--success);
    border-radius: var(--radius-sm);
    color: var(--success);
    font-size: 0.9rem;
    line-height: 1.5;
}

.auth-form {
    text-align: left;
}

.auth-form__label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.auth-form__input {
    display: block;
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
    box-sizing: border-box;
}

.auth-form__input:focus { border-color: var(--accent); }

.auth-form__submit {
    display: block;
    width: 100%;
    padding: 12px;
    margin-top: 8px;
    background: var(--accent);
    color: var(--bg-primary);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.auth-form__submit:hover { background: var(--accent-hover); }

.auth-card__link {
    margin-top: 16px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.auth-card__link a {
    color: var(--accent);
    text-decoration: none;
}
.auth-card__link a:hover {
    text-decoration: underline;
}

/* ===================================================================
   User Menu
   =================================================================== */

.header__right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-menu {
    position: relative;
}

.user-menu__trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s;
}

.user-menu__trigger:hover { background: var(--bg-surface-hover); }
.user-menu__trigger svg { width: 16px; height: 16px; }
.user-menu__chevron { width: 14px !important; height: 14px !important; color: var(--text-muted); }

/* Header tier badge */
.header-tier-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}
.header-tier-badge i { width: 12px; height: 12px; }
.header-tier-badge__label { white-space: nowrap; }
.header-tier-badge--free {
    background: var(--bg-elevated);
    color: var(--text-muted);
}
.header-tier-badge--pro {
    background: rgba(250, 204, 21, 0.15);
    color: #facc15;
}
.header-tier-badge--premium {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
}
.header-tier-badge--enterprise {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}
@media (max-width: 768px) {
    .header-tier-badge__label { display: none; }
    .header-tier-badge { padding: 2px 4px; }
}

.user-menu__dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    min-width: 180px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 200;
    overflow: hidden;
}

.user-menu__dropdown.open { display: block; }

.user-menu__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 0.85rem;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s;
}

.user-menu__item:hover { background: var(--bg-surface-hover); }
.user-menu__item svg { width: 16px; height: 16px; color: var(--text-secondary); }
.user-menu__item--form { padding: 0; margin: 0; }

.user-menu__logout {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    background: none;
    border: none;
    color: var(--danger);
    font-size: 0.85rem;
    cursor: pointer;
    font-family: inherit;
}

.user-menu__logout:hover { background: var(--bg-surface-hover); }
.user-menu__logout svg { width: 16px; height: 16px; }

.user-menu__divider {
    margin: 4px 0;
    border: none;
    border-top: 1px solid var(--border);
}

/* ===================================================================
   Settings & Admin Pages
   =================================================================== */

.admin-page, .settings-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

.admin-page__header, .settings-page__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.admin-page__header h2, .settings-page__header h2 {
    margin: 0;
    font-size: 1.3rem;
    color: var(--text-primary);
}

.admin-section {
    margin-bottom: 32px;
}

.admin-section h3 {
    margin: 0 0 12px;
    font-size: 1rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.admin-table th {
    text-align: left;
    padding: 10px 12px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.admin-table td {
    padding: 10px 12px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
}

.admin-loading, .admin-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
}

.invite-code {
    padding: 2px 6px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-family: monospace;
    font-size: 0.8rem;
    word-break: break-all;
}

.provider-selection-counter {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    background: var(--bg-surface);
}
.provider-selection-counter--ok {
    color: var(--success);
    border-color: rgba(166,227,161,.3);
}
.provider-selection-counter--warning {
    color: var(--warning);
    border-color: rgba(249,226,175,.3);
}

.provider-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.provider-card__checkbox-wrap {
    margin-right: 12px;
    display: flex;
    align-items: center;
}
.provider-card__checkbox-wrap input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.provider-card__header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    flex-wrap: wrap;
}

.provider-card__actions {
    flex-shrink: 0;
}

.provider-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin: 16px 0 8px;
}
.provider-section-title:first-child { margin-top: 0; }
.provider-section-hint {
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    color: var(--text-muted);
    font-size: 11px;
}

.provider-card__name { font-weight: 600; color: var(--text-primary); }
.provider-card__actions { display: flex; gap: 6px; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}

.btn:hover { background: var(--bg-surface-hover); }
.btn svg { width: 16px; height: 16px; }

.btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-primary);
}

.btn--primary:hover { background: var(--accent-hover); }

.btn--danger {
    color: var(--danger);
    border-color: var(--danger);
    background: transparent;
}

.btn--danger:hover { background: var(--danger-dim); }

.btn--sm { padding: 5px 10px; font-size: 0.8rem; }

.badge--owner { background: var(--accent-dim); color: var(--accent); }
.badge--guest { background: var(--bg-elevated); color: var(--text-secondary); }
.badge--available { background: var(--success-dim); color: var(--success); }
.badge--used { background: var(--bg-elevated); color: var(--text-muted); }
.badge--info { background: rgba(137,180,250,.12); color: var(--accent); }
.badge--warning { background: rgba(249,226,175,.12); color: var(--warning); }
.badge--muted { background: var(--bg-elevated); color: var(--text-secondary); }
.badge--local { background: #2d3040; color: #a0a8d0; }
.badge--s3 { background: #2a2f1e; color: #c4d97f; }
.badge--gcs { background: #1e2f3a; color: #7fc4d9; }
.badge--azure { background: #1e2a3a; color: #7fa8d9; }
.badge--accent { background: var(--accent-dim); color: var(--accent); }

/* --- Settings Page --- */
.settings { max-width: 640px; margin: 0 auto; padding: 24px; }
.settings__title { margin: 0 0 24px; font-size: 1.3rem; color: var(--text-primary); }

.settings__section { margin-bottom: 28px; }
.settings__section-title {
    display: flex; align-items: center; gap: 8px;
    margin: 0 0 12px; font-size: 0.8rem; font-weight: 600;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em;
}
.settings__section-title svg { width: 14px; height: 14px; }

.settings__group {
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius-md); overflow: hidden;
}

.settings__row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; gap: 12px;
}
.settings__row + .settings__row { border-top: 1px solid var(--border); }

.settings__row-label {
    display: flex; align-items: center; gap: 10px;
    color: var(--text-primary); font-size: 0.875rem;
}
.settings__row-label svg { width: 16px; height: 16px; color: var(--text-secondary); }

.settings__row-control {
    display: flex; align-items: center; gap: 8px;
}

.settings__link {
    font-size: 0.8rem; color: var(--accent); text-decoration: none;
}
.settings__link:hover { text-decoration: underline; }

.form-select {
    padding: 5px 10px; background: var(--bg-secondary); color: var(--text-primary);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.825rem; cursor: pointer;
}

.settings__inline-form {
    padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.settings__inline-actions { display: flex; gap: 8px; }
.settings__error { color: var(--danger); font-size: 0.8rem; }
.settings__success { color: var(--success); font-size: 0.8rem; }

/* ===================================================================
   Modal (reusable)
   =================================================================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
}

.modal {
    width: 100%;
    max-width: 480px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal__header h3 { margin: 0; font-size: 1rem; color: var(--text-primary); }

.modal__close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}

.modal__close:hover { color: var(--text-primary); }
.modal__close svg { width: 18px; height: 18px; }

.modal__body { padding: 20px; }

.modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

/* --- OAuth Connect --- */
.oauth-connect__hint {
    color: var(--text-secondary);
    font-size: 13px;
    margin: 12px 0 16px;
    line-height: 1.5;
}

.oauth-connect__btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    font-size: 14px;
}

.oauth-connect__btn i { width: 16px; height: 16px; }

.badge--connected {
    background: var(--success-dim);
    color: var(--success);
}

.badge--onedrive { background: rgba(0,120,215,.15); color: #0078d7; }
.badge--google_drive { background: rgba(66,133,244,.15); color: #4285f4; }
.badge--dropbox { background: rgba(0,97,255,.15); color: #0061ff; }

/* ===================================================================
   Audit Log
   =================================================================== */

/* -- Geo Map -- */
.audit-map-wrap {
    margin-bottom: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-surface);
}

.audit-map-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.audit-map-header__title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
}

.audit-map {
    height: 280px;
    width: 100%;
    background: var(--bg-primary);
}

/* Leaflet popup override for dark theme */
.audit-map-popup .leaflet-popup-content-wrapper {
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    color: var(--text-primary);
}

.audit-map-popup .leaflet-popup-tip {
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
}

/* -- Column Filters -- */
.audit-filter-row th {
    padding: 4px 6px 8px;
    border-bottom: 1px solid var(--border);
}

.audit-col-filter {
    width: 100%;
    padding: 4px 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.72rem;
    outline: none;
    transition: border-color var(--transition);
    box-sizing: border-box;
}

.audit-col-filter:focus { border-color: var(--accent); }
.audit-col-filter::placeholder { color: var(--text-muted); font-size: 0.7rem; }

.audit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.audit-header h2 {
    margin: 0;
    font-size: 1.3rem;
    color: var(--text-primary);
}

.audit-header__controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.audit-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.audit-select {
    padding: 6px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.8rem;
    outline: none;
    cursor: pointer;
}

.audit-select:focus { border-color: var(--accent); }

.audit-total {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.audit-time { white-space: nowrap; font-size: 0.8rem; color: var(--text-muted); }
.audit-details { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.8rem; color: var(--text-secondary); }
.audit-ip { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted); }

/* Event type badges */
.badge--auth { background: rgba(137,180,250,.12); color: var(--accent); }
.badge--file { background: rgba(166,227,161,.12); color: var(--success); }
.badge--folder { background: rgba(249,226,175,.12); color: var(--warning); }
.badge--provider { background: rgba(0,120,215,.12); color: #7fc4d9; }
.badge--subscription { background: rgba(203,166,247,.12); color: #cba6f7; }
.badge--admin { background: rgba(243,139,168,.12); color: var(--danger); }

/* Status badges */
.badge--success { background: var(--success-dim); color: var(--success); }
.badge--failure { background: var(--danger-dim); color: var(--danger); }

/* Clickable audit rows */
.audit-table tbody .audit-row { cursor: pointer; transition: background .15s; }
.audit-table tbody .audit-row:hover { background: var(--bg-surface-hover); }
.audit-method { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted); }
.audit-client { font-size: 0.75rem; color: var(--text-secondary); white-space: nowrap; }
.audit-geo { font-size: 0.75rem; color: var(--text-secondary); white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }

/* Detail overlay */
.audit-overlay {
    position: fixed; inset: 0; z-index: 900;
    background: rgba(0,0,0,.55); display: flex;
    align-items: center; justify-content: center;
}
.audit-detail-panel {
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius-md); width: 540px; max-width: 95vw;
    max-height: 80vh; overflow-y: auto;
}
.audit-detail-panel__header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.audit-detail-panel__header h3 { margin: 0; font-size: 1rem; }
.audit-detail-panel__body { padding: 16px 20px; }

.audit-dl { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; font-size: 0.85rem; }
.audit-dl dt { color: var(--text-muted); font-weight: 500; }
.audit-dl dd { margin: 0; word-break: break-all; }
.audit-dl code { font-family: var(--font-mono); font-size: 0.8em; background: var(--bg-elevated); padding: 1px 4px; border-radius: 3px; }
.audit-ua { font-size: 0.75rem; max-width: 360px; word-break: break-all; color: var(--text-muted); }
.audit-diff { font-family: var(--font-mono); font-size: 0.75rem; background: var(--bg-elevated); padding: 8px; border-radius: var(--radius-sm); white-space: pre-wrap; max-height: 200px; overflow-y: auto; }

/* --- Dashboard --- */
.dashboard { padding: 24px; max-width: 1200px; margin: 0 auto; }
.dashboard__title { font-size: 1.5rem; font-weight: 700; margin-bottom: 24px; color: var(--text-primary); }

.dashboard__stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color var(--transition);
}
.stat-card:hover { border-color: var(--accent); }
.stat-card--loading { align-items: center; justify-content: center; min-height: 100px; }
.stat-card__icon { color: var(--accent); }
.stat-card__icon svg { width: 22px; height: 22px; }
.stat-card__value { font-size: 1.75rem; font-weight: 700; color: var(--text-primary); line-height: 1.1; }
.stat-card__label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.stat-card__sub { font-size: 0.85rem; color: var(--text-secondary); }

.stat-card__bar { width: 100%; height: 8px; background: var(--bg-elevated); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.stat-card__bar-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .4s ease; }

.dashboard__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 28px;
}
@media (max-width: 900px) {
    .dashboard__grid { grid-template-columns: 1fr; }
}

.dashboard__section { margin-bottom: 8px; }
.dashboard__section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}
.dashboard__section-title svg { width: 18px; height: 18px; color: var(--accent); }

.provider-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.provider-card__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.provider-card__dot--ok { background: var(--success); }
.provider-card__dot--error { background: var(--danger); }
.provider-card__name { font-weight: 600; color: var(--text-primary); flex: 1; }
.provider-card__type { font-size: 0.8rem; color: var(--text-muted); }
.provider-card__status { font-size: 0.8rem; font-weight: 600; }
.provider-card__status--ok { color: var(--success); }
.provider-card__status--error { color: var(--danger); }

.provider-card__quota { width: 100%; margin-top: 4px; }
.provider-card__quota-bar { height: 4px; background: var(--bg-elevated); border-radius: 2px; overflow: hidden; }
.provider-card__quota-fill { height: 100%; background: var(--accent); border-radius: 2px; }
.provider-card__quota-text { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

.activity-list { list-style: none; }
.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-item__icon { color: var(--accent); flex-shrink: 0; width: 20px; text-align: center; }
.activity-item__icon svg, .activity-item__icon i { width: 16px; height: 16px; }
.activity-item__text { flex: 1; min-width: 0; font-size: 0.875rem; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-item__detail { color: var(--text-secondary); }
.activity-item__time { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; min-width: 90px; text-align: right; }
.activity-item__status { font-size: 0.7rem; font-weight: 600; padding: 2px 6px; border-radius: 4px; white-space: nowrap; }
.activity-item__status--success { background: var(--success-dim); color: var(--success); }
.activity-item__status--failure { background: var(--danger-dim); color: var(--danger); }

.activity-more { display: inline-block; margin-top: 12px; font-size: 0.85rem; color: var(--accent); }
.activity-more:hover { color: var(--accent-hover); }

.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: border-color var(--transition), background var(--transition);
    cursor: pointer;
}
.quick-action:hover { border-color: var(--accent); background: var(--bg-surface-hover); color: var(--text-primary); }
.quick-action svg { width: 24px; height: 24px; color: var(--accent); }

.dash-loading { padding: 20px; color: var(--text-muted); font-size: 0.85rem; }
.dash-empty { padding: 16px; color: var(--text-muted); font-size: 0.85rem; font-style: italic; }

/* --- Provider Health Legend + Chart --- */
.provider-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.provider-legend__item { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; }
.provider-legend__dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.provider-legend__dot--ok { background: var(--success, #40a02b); }
.provider-legend__dot--error { background: var(--danger, #d20f39); }
.provider-legend__name { font-weight: 600; }
.provider-legend__type { color: var(--text-muted); font-size: 0.75rem; }
.provider-legend__latency {
    font-family: var(--font-mono, monospace); font-size: 0.72rem;
    color: var(--accent-dim); background: var(--bg-surface); padding: 1px 5px; border-radius: 3px;
}
.provider-legend__status { font-weight: 600; font-size: 0.75rem; }
.provider-legend__status--ok { color: var(--success, #40a02b); }
.provider-legend__status--error { color: var(--danger, #d20f39); }

.dashboard__chart-container { min-height: 300px; position: relative; display: flex; align-items: center; justify-content: center; }
.dashboard__chart-container canvas { width: 100% !important; max-height: 300px !important; }

/* --- Heartbeat History Modal --- */
.heartbeat-stats {
    display: flex; gap: 20px; justify-content: center; padding: 12px 0;
}
.heartbeat-stat { text-align: center; }
.heartbeat-stat__value {
    display: block; font-size: 1.5rem; font-weight: 700; color: var(--text-primary);
}
.heartbeat-stat__label {
    display: block; font-size: 0.75rem; color: var(--text-muted);
}

.heartbeat-sparkline {
    display: flex; gap: 2px; flex-wrap: wrap; padding: 12px 0; justify-content: center;
}
.heartbeat-dot {
    width: 8px; height: 8px; border-radius: 50%;
    display: inline-block; cursor: help; transition: transform 0.1s;
}
.heartbeat-dot:hover { transform: scale(1.5); }
.heartbeat-dot--ok { background: var(--success); }
.heartbeat-dot--error { background: var(--danger); }

/* --- Activity Map --- */
.dashboard__map {
    min-height: 280px; border-radius: var(--radius-sm);
    overflow: hidden; border: 1px solid var(--border);
    background: var(--bg-surface);
}
.dashboard__map .leaflet-container { height: 280px; width: 100%; }

/* --- Activity Heatmap --- */
.dashboard__heatmap { padding: 8px 0; }
.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(13, 1fr);
    grid-template-rows: repeat(7, 1fr);
    grid-auto-flow: column;
    gap: 3px;
}
.heatmap-cell {
    aspect-ratio: 1; border-radius: 2px;
    min-width: 0; min-height: 0;
}
.heatmap-cell--0 { background: var(--bg-surface); }
.heatmap-cell--1 { background: color-mix(in srgb, var(--success) 25%, var(--bg-surface)); }
.heatmap-cell--2 { background: color-mix(in srgb, var(--success) 50%, var(--bg-surface)); }
.heatmap-cell--3 { background: color-mix(in srgb, var(--success) 75%, var(--bg-surface)); }
.heatmap-cell--4 { background: var(--success); }

.heatmap-legend {
    display: flex; align-items: center; gap: 4px;
    justify-content: flex-end; margin-top: 8px;
}
.heatmap-legend .heatmap-cell { width: 12px; height: 12px; aspect-ratio: auto; }
.heatmap-legend__label { font-size: 0.7rem; color: var(--text-muted); }

.dashboard__section-sub {
    font-size: 0.75rem; font-weight: 400; color: var(--text-muted); margin-left: 8px;
}

/* --- Analytics Page --- */

.analytics-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
}

.analytics-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0;
}

.analytics-time-select {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    min-width: 160px;
}

.analytics-timeline-chart {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    min-height: 280px;
    position: relative;
}
.analytics-timeline-chart canvas {
    width: 100% !important;
    height: 280px !important;
}

/* Horizontal bar rows */
.analytics-bars {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 8px 0;
}

.analytics-bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.analytics-bar-label {
    width: 90px;
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
    flex-shrink: 0;
}

.analytics-bar-track {
    flex: 1;
    height: 24px;
    background: var(--bg-elevated);
    border-radius: 6px;
    overflow: hidden;
}

.analytics-bar-track--sm {
    height: 8px;
    margin-top: 4px;
}

.analytics-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.4s ease;
}

.analytics-bar-value {
    width: 100px;
    text-align: right;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

/* Analytics tables */
.analytics-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.analytics-table th {
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

.analytics-table td {
    padding: 10px 12px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
}

.analytics-table tbody tr:hover {
    background: var(--bg-surface-hover);
}

.analytics-table__file {
    display: flex;
    align-items: center;
    gap: 8px;
}

.analytics-table__file i,
.analytics-table__file svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.analytics-table__size-cell {
    min-width: 120px;
}

.analytics-table__providers {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

/* Duplicates + Tips cards */
.analytics-card-body {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
}

.analytics-badge {
    display: inline-block;
    background: color-mix(in srgb, var(--warning) 15%, transparent);
    color: var(--warning);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
    margin-bottom: 8px;
}

.analytics-savings {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 8px 0 16px;
}

.analytics-tips {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px 20px;
}

.analytics-tips ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.analytics-tips li {
    padding: 8px 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
}

.analytics-tips li:last-child {
    border-bottom: none;
}

.analytics-tips li::before {
    content: '\2022';
    color: var(--accent);
    font-weight: bold;
    margin-right: 8px;
}

@media (max-width: 900px) {
    .analytics-header { flex-direction: column; gap: 12px; }
}

/* --- Subscription Page --- */

.sub-header { text-align: center; margin-bottom: 2rem; }
.sub-header h2 { font-size: 1.75rem; margin: 0 0 .25rem; }
.sub-header p { color: var(--text-secondary); margin: 0; font-size: .95rem; }

/* Current Plan Card */
.sub-current {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem 2rem;
    margin-bottom: 2rem;
}
.sub-current__title {
    display: flex; align-items: center; gap: .75rem;
    font-size: 1.25rem; font-weight: 600; margin-bottom: 1.25rem;
}
.sub-current__badge {
    display: inline-flex; align-items: center;
    padding: 3px 10px; border-radius: 20px;
    font-size: .75rem; font-weight: 600;
    background: var(--success-dim); color: var(--success);
}
.sub-current__stats {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.sub-stat {
    display: flex; align-items: flex-start; gap: .75rem;
}
.sub-stat i { width: 18px; height: 18px; color: var(--text-secondary); flex-shrink: 0; margin-top: 2px; }
.sub-stat__label { font-size: .8rem; color: var(--text-secondary); margin-bottom: 2px; }
.sub-stat__value { font-size: .9rem; font-weight: 500; color: var(--text-primary); }

/* Pricing Cards Grid */
.sub-plans {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}
.sub-plan {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex; flex-direction: column;
    position: relative;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.sub-plan:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-md);
}
.sub-plan--current {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent), var(--shadow-md);
}
.sub-plan--popular::before {
    content: 'Popular';
    position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
    background: var(--accent); color: #fff;
    font-size: .7rem; font-weight: 600;
    padding: 2px 12px; border-radius: 10px;
}
.sub-plan__name { font-size: 1.25rem; font-weight: 600; margin-bottom: .75rem; }
.sub-plan__price { font-size: 2.25rem; font-weight: 700; margin-bottom: 1.25rem; }
.sub-plan__price span { font-size: .9rem; font-weight: 400; color: var(--text-secondary); }
.sub-plan__features {
    list-style: none; padding: 0; margin: 0 0 1.5rem;
    flex: 1;
}
.sub-plan__features li {
    display: flex; align-items: center; gap: .5rem;
    font-size: .85rem; color: var(--text-secondary);
    padding: .35rem 0;
}
.sub-plan__features li i { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }

.sub-plan__btn {
    display: block; width: 100%; padding: .6rem 1rem;
    border-radius: var(--radius-md);
    font-size: .875rem; font-weight: 600;
    text-align: center; cursor: pointer;
    border: 1px solid var(--border);
    background: transparent; color: var(--text-primary);
    transition: all var(--transition);
}
.sub-plan__btn:hover { background: var(--bg-surface-hover); }
.sub-plan__btn--primary {
    background: var(--accent); border-color: var(--accent); color: #fff;
}
.sub-plan__btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.sub-plan__btn--current {
    background: var(--bg-surface); border-color: var(--border-light);
    color: var(--text-secondary); cursor: default; pointer-events: none;
}

/* Billing Alert */
.sub-alert {
    border-radius: var(--radius-md); padding: .75rem 1rem;
    margin-bottom: 1rem; font-size: .85rem;
    display: flex; align-items: center; gap: .5rem;
}
.sub-alert--danger { background: var(--danger-dim); border: 1px solid var(--danger); color: var(--danger); }
.sub-alert--warning { background: var(--warning-dim); border: 1px solid var(--warning); color: var(--warning); }
.sub-alert i { width: 16px; height: 16px; flex-shrink: 0; }

/* Manage Billing Button */
.sub-billing-actions {
    display: flex; gap: .5rem; margin-bottom: 2rem;
}

/* Feature Comparison Table */
.sub-comparison {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem 2rem;
}
.sub-comparison h3 { margin: 0 0 .25rem; font-size: 1.15rem; }
.sub-comparison p { margin: 0 0 1rem; font-size: .85rem; color: var(--text-secondary); }
.sub-comparison table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.sub-comparison th,
.sub-comparison td {
    padding: .6rem .75rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
}
.sub-comparison th:first-child,
.sub-comparison td:first-child { text-align: left; }
.sub-comparison th {
    font-weight: 600; font-size: .8rem; text-transform: uppercase;
    letter-spacing: .3px; color: var(--text-secondary);
    background: var(--bg-surface);
}
.sub-comparison .sub-col-current {
    background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.sub-comparison th.sub-col-current {
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    color: var(--accent);
}

/* Responsive */
@media (max-width: 1024px) {
    .sub-plans { grid-template-columns: repeat(2, 1fr); }
    .sub-current__stats { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .sub-plans { grid-template-columns: 1fr; }
}

/* ============================================================
   SEARCH BAR (header)
   ============================================================ */
.header__left {
    flex: 1;
    min-width: 0;
}
/* --- Admin "View as" badge (header top-right) --- */
.ctx-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    white-space: nowrap;
}
.ctx-badge svg { width: 16px; height: 16px; color: var(--accent); }
.ctx-badge__close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 15px;
    cursor: pointer;
    padding: 0 0 0 2px;
    margin-left: 2px;
    line-height: 1;
    transition: color .15s;
}
.ctx-badge__close:hover { color: var(--text-primary); }
.header__search {
    flex: 0 1 420px;
    position: relative;
}
.header__right {
    flex: 1;
    min-width: 0;
    justify-content: flex-end;
}
.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 12px;
    height: 36px;
    transition: border-color .15s;
}
.search-bar:focus-within {
    border-color: var(--accent);
}
.search-bar__icon {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.search-bar__input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: .875rem;
    min-width: 0;
}
.search-bar__input::placeholder {
    color: var(--text-secondary);
}
.search-bar__kbd {
    font-size: .7rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-family: monospace;
    line-height: 1;
}

/* Search results dropdown */
.search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    max-height: 360px;
    overflow-y: auto;
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.search-results__list {
    padding: 4px;
}
.search-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-primary);
    text-decoration: none;
    transition: background .1s;
}
.search-result-item:hover,
.search-result-item--active {
    background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.search-result-item__icon {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.search-result-item__name {
    flex: 1;
    font-size: .875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.search-result-item__size {
    font-size: .75rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.search-results__empty {
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: .875rem;
}
.search-results__loading {
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: .875rem;
}

/* ============================================================
   BARRISTA CHAT FAB + PANEL
   ============================================================ */
.barrista-fab {
    position: fixed;
    bottom: 44px;
    right: 24px;
    z-index: 150;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 16px rgba(0,0,0,.3);
    transition: transform .15s, box-shadow .15s;
}
.barrista-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0,0,0,.4);
}
.barrista-fab i,
.barrista-fab svg {
    width: 24px;
    height: 24px;
}

.barrista-panel {
    position: fixed;
    bottom: 88px;
    right: 24px;
    z-index: 160;
    width: 380px;
    height: 520px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 40px rgba(0,0,0,.35);
    overflow: hidden;
}

.barrista-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
}
.barrista-panel__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: .95rem;
    color: var(--text-primary);
}
.barrista-panel__title i,
.barrista-panel__title svg {
    width: 18px;
    height: 18px;
    color: var(--accent);
}
.barrista-panel__close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
    border-radius: 4px;
}
.barrista-panel__close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.barrista-panel__close i,
.barrista-panel__close svg {
    width: 16px;
    height: 16px;
}

.barrista-panel__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.barrista-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: .875rem;
    line-height: 1.5;
    word-wrap: break-word;
}
.barrista-msg p { margin: 0 0 6px; }
.barrista-msg p:last-child { margin-bottom: 0; }
.barrista-msg ul { margin: 4px 0 0; padding-left: 18px; }
.barrista-msg li { margin-bottom: 2px; }

.barrista-msg--assistant {
    align-self: flex-start;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}
.barrista-msg--user {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.barrista-msg--loading {
    align-self: flex-start;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-style: italic;
}

.barrista-msg__files {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.barrista-msg__file {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .8rem;
    color: var(--accent);
    cursor: pointer;
    padding: 3px 8px;
    border-radius: 4px;
    background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.barrista-msg__file:hover {
    background: color-mix(in srgb, var(--accent) 16%, transparent);
}
.barrista-msg__file i,
.barrista-msg__file svg {
    width: 12px;
    height: 12px;
}

.barrista-panel__input {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-primary);
}
.barrista-panel__input input {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: .875rem;
    outline: none;
}
.barrista-panel__input input:focus {
    border-color: var(--accent);
}
.barrista-panel__mic {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: all .2s;
}
.barrista-panel__mic:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}
.barrista-panel__mic--active {
    color: #fff;
    background: var(--danger);
    border-color: var(--danger);
    animation: barrista-pulse 1.5s infinite;
}
.barrista-panel__mic i,
.barrista-panel__mic svg {
    width: 16px;
    height: 16px;
}
@keyframes barrista-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(243, 139, 168, .4); }
    50% { box-shadow: 0 0 0 6px rgba(243, 139, 168, 0); }
}
.barrista-panel__send {
    background: var(--accent);
    border: none;
    border-radius: 8px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity .15s;
}
.barrista-panel__send:hover {
    opacity: .85;
}
.barrista-panel__send i,
.barrista-panel__send svg {
    width: 16px;
    height: 16px;
}

/* Mobile responsive */
@media (max-width: 640px) {
    .header__search { flex: 0 1 200px; }
    .search-bar__kbd { display: none; }
    .barrista-panel {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: 80px;
        height: 60vh;
    }
    .barrista-fab {
        bottom: 16px;
        right: 16px;
    }
}


/* --- Data Map --- */

.data-map {
    position: relative;
    height: calc(100vh - 56px);
    margin: -24px -32px;
    display: flex;
    flex-direction: column;
    isolation: isolate;
    z-index: 0;
}

.data-map__container {
    flex: 1;
    min-height: 0;
    background: var(--bg-primary);
}

.data-map__container .leaflet-container {
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
}

.data-map__stats {
    position: absolute;
    bottom: 16px;
    left: 16px;
    z-index: 800;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    min-width: 200px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.data-map__stats-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 12px;
    color: var(--text-primary);
}

.data-map__stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.data-map__stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px;
    background: var(--bg-elevated);
    border-radius: 8px;
}

.data-map__stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent);
}

.data-map__stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-map__legend {
    display: flex;
    gap: 12px;
    margin-top: 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.data-map__legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.data-map__legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.data-map__legend-dot--upload {
    background: #89b4fa;
}

.data-map__legend-dot--download {
    background: #a6e3a1;
}

/* Provider legend */
.data-map__provider-legend {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.data-map__provider-legend:empty {
    display: none;
}

.data-map__provider-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.data-map__provider-legend-count {
    margin-left: auto;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.72rem;
}

/* Sidebar */
.data-map__sidebar {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 340px;
    z-index: 1001;
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.data-map__sidebar[hidden] {
    display: none;
}

.data-map__sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.data-map__sidebar-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.data-map__sidebar-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}
.data-map__sidebar-close:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.data-map__sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.data-map__sidebar-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.data-map__sidebar-stat {
    background: var(--bg-elevated);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.data-map__sidebar-metric {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.data-map__sidebar-section {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 16px 0 8px;
}

.data-map__sidebar-empty {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.data-map__trace-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.data-map__trace-item {
    background: var(--bg-elevated);
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: border-color 0.15s;
}
.data-map__trace-item:hover {
    border-color: var(--border);
}
.data-map__trace-item--active {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.data-map__trace-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}
.data-map__trace-row + .data-map__trace-row {
    margin-top: 4px;
}
.data-map__trace-row time {
    margin-left: auto;
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Trace line animation */
.trace-line {
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Hop marker dots */
.data-map__hop {
    transition: r 0.15s;
}

/* Badge additions for upload/download */
.badge--upload {
    background: rgba(137, 180, 250, 0.15);
    color: #89b4fa;
}
.badge--download {
    background: rgba(166, 227, 161, 0.15);
    color: #a6e3a1;
}

/* ---- Metadata tab ---- */
.detail-metadata {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--border);
    border-radius: 6px;
    overflow: hidden;
    margin-top: 8px;
}
.detail-metadata__row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--bg-surface);
    font-size: 12px;
}
.detail-metadata__key {
    color: var(--text-muted);
    min-width: 100px;
    flex-shrink: 0;
    font-weight: 500;
}
.detail-metadata__value {
    color: var(--text-primary);
    word-break: break-word;
}
.detail-metadata__gps-map {
    height: 160px;
    border-radius: 6px;
    margin-top: 8px;
    border: 1px solid var(--border);
}
.badge--compressed {
    background: rgba(137, 180, 250, 0.15);
    color: #89b4fa;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

/* ---- Share modal ---- */
.share-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.share-modal {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 24px;
}
.share-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.share-modal__title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}
.share-modal__close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}
.share-modal__tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.share-modal__tab {
    flex: 1;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.share-modal__tab--active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.share-modal__field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}
.share-modal__label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}
.share-modal__input {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
}
.share-modal__input:focus {
    border-color: var(--accent);
}
.share-modal__row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.share-modal__checkbox {
    accent-color: var(--accent);
}
.share-modal__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    margin-top: 8px;
}
.share-modal__btn:hover {
    background: var(--accent-hover);
}
.share-modal__link-result {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    margin-top: 12px;
}
.share-modal__link-url {
    flex: 1;
    font-size: 12px;
    color: var(--text-primary);
    font-family: monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.share-modal__copy-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px;
    color: var(--text-primary);
    cursor: pointer;
    white-space: nowrap;
}
.share-modal__existing {
    margin-top: 16px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}
.share-modal__existing-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.share-modal__share-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 12px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}
.share-modal__share-item:last-child {
    border-bottom: none;
}
.share-modal__revoke-btn {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 11px;
    margin-left: auto;
    padding: 2px 6px;
}
.badge--shared {
    background: rgba(203, 166, 247, 0.15);
    color: #cba6f7;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
}
/* Shared with me sidebar */
.shared-with-me__list {
    max-height: 200px;
    overflow-y: auto;
    padding: 0 8px 8px;
}
.shared-with-me__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .15s;
}
.shared-with-me__item:hover {
    background: var(--bg-surface-hover);
}
.shared-with-me__icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--text-muted);
}
.shared-with-me__info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.shared-with-me__name {
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.shared-with-me__meta {
    font-size: 10px;
    color: var(--text-muted);
}
/* Share existing items */
.share-existing-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}
.share-existing-item:last-child { border-bottom: none; }
.share-existing-item__info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    flex: 1;
    min-width: 0;
}
.share-existing-item__icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: var(--text-muted);
}
.share-existing-item__revoke {
    padding: 2px 4px !important;
    color: var(--danger) !important;
    opacity: 0.6;
}
.share-existing-item__revoke:hover { opacity: 1; }

/* Responsive */
@media (max-width: 768px) {
    .data-map {
        margin: -16px;
    }
    .data-map__sidebar {
        width: 100%;
    }
    .data-map__stats {
        right: 8px;
        top: 8px;
        min-width: 160px;
        padding: 10px;
    }
    .share-modal {
        max-width: 100%;
    }
}

/* =====================================================================
   Table Sort & Filter — Reusable
   ===================================================================== */

/* Sortable headers */
.sortable-th {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
    white-space: nowrap;
}
.sortable-th:hover {
    color: var(--text-primary);
}
.sort-indicator {
    font-size: 0.65em;
    margin-left: 2px;
    color: var(--accent);
    vertical-align: middle;
}
.sorted-asc,
.sorted-desc {
    color: var(--accent) !important;
}

/* Filter row for <table> elements */
.tbl-filter-row th {
    padding: 4px 6px !important;
    border-bottom: 1px solid var(--border) !important;
}
.tbl-col-filter {
    width: 100%;
    padding: 3px 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.75rem;
    outline: none;
    box-sizing: border-box;
    font-weight: normal;
    text-transform: none;
    letter-spacing: normal;
}
.tbl-col-filter:focus {
    border-color: var(--accent);
}
.tbl-col-filter::placeholder {
    color: var(--text-muted);
    font-size: 0.7rem;
}

/* File list header sort (div-based grid) */
.file-list__header .sortable-th {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}
