/* =====================================================================
   FileVault — Master Stylesheet (clean rewrite)
   ===================================================================== */

/* ---- Design tokens ---- */
:root {
    --bg:            #f7f6f2;
    --surface:       #ffffff;
    --surface-2:     #f2f0eb;
    --ink:           #1a1a18;
    --ink-2:         #57564f;
    --ink-3:         #9a9890;
    --border:        #e2dfd6;
    --accent:        #1f3a34;
    --accent-soft:   #e6efec;
    --accent-hover:  #163028;
    --gold:          #a07828;
    --danger:        #923535;
    --danger-soft:   #faeaea;
    --warning:       #a07828;
    --warning-soft:  #fdf3e0;
    --success:       #2a6347;
    --success-soft:  #e4f0ea;
    --radius-s:  5px;
    --radius-m:  10px;
    --radius-l:  16px;
    --shadow-s:  0 1px 4px rgba(0,0,0,.06);
    --shadow-m:  0 4px 20px rgba(0,0,0,.09);
    --shadow-l:  0 12px 48px rgba(0,0,0,.18);
    --font-h:    Georgia, 'Iowan Old Style', serif;
    --font-b:    -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --nav-w:     240px;
    --bot-h:     64px;
}

/* ---- Dark theme ---- */
[data-theme="dark"] {
    --bg:           #0e0e0c;
    --surface:      #181816;
    --surface-2:    #222220;
    --ink:          #e6e4de;
    --ink-2:        #8a8880;
    --ink-3:        #58564e;
    --border:       #2c2c28;
    --accent:       #4a9e82;
    --accent-soft:  #162a22;
    --accent-hover: #3a8a6e;
    --gold:         #c9a050;
    --danger:       #c06060;
    --danger-soft:  #2a1212;
    --warning:      #c9a050;
    --warning-soft: #2a1e08;
    --success:      #4a9e82;
    --success-soft: #0e2a1e;
    --shadow-s:  0 1px 4px rgba(0,0,0,.3);
    --shadow-m:  0 4px 20px rgba(0,0,0,.4);
    --shadow-l:  0 12px 48px rgba(0,0,0,.6);
}

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

/* Smooth theme transitions — only on colour properties, not layout */
body, .sidebar, .bottom-nav, .file-card, .auth-card, .profile-section,
.profile-card, .stat-card, .user-card, .admin-file-card, .admin-panel-box,
.viewer, .upload-zone, .upload-queue li, .settings-card, .lb-box,
.pw-rules, .admin-quick-btn, .activity-list, .btn, input, select, textarea {
    transition: background-color .2s, border-color .2s, color .15s;
}

html { font-size: 16px; }
body {
    font-family: var(--font-b);
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}
h1,h2,h3,h4 { font-family: var(--font-h); font-weight: 500; letter-spacing: .01em; line-height: 1.25; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; }

/* =====================================================================
   BUTTONS
   ===================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 20px;
    border-radius: var(--radius-s);
    border: 1.5px solid transparent;
    font-size: .92rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
}
.btn:active { transform: scale(.98); }

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

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

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

.btn-sm  { min-height: 36px; padding: 0 14px; font-size: .82rem; }
.btn-xs  { min-height: 30px; padding: 0 10px; font-size: .76rem; }
.btn-icon-only { width: 44px; padding: 0; justify-content: center; }

/* Full-width button context */
.btn-block { display: flex; width: 100%; }

/* =====================================================================
   BADGES & CHIPS
   ===================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .02em;
    white-space: nowrap;
}
.badge-success  { background: var(--success-soft);  color: var(--success); }
.badge-warning  { background: var(--warning-soft);  color: var(--warning); }
.badge-danger   { background: var(--danger-soft);   color: var(--danger);  }
.badge-neutral  { background: var(--surface-2);     color: var(--ink-2);   }
.badge-role     { background: #eef0f7; color: #3a3d5c; }
[data-theme="dark"] .badge-role { background: #1a1a2e; color: #9090cc; }

.chip {
    display: inline-flex;
    align-items: center;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1.5px solid var(--border);
    font-size: .82rem;
    color: var(--ink-2);
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
}
.chip:hover    { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip-active   { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* =====================================================================
   ALERTS
   ===================================================================== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-s);
    border: 1px solid;
    font-size: .88rem;
    margin-bottom: 16px;
    line-height: 1.5;
}
.alert-success { background: var(--success-soft); color: var(--success); border-color: #b8dcc8; }
.alert-error   { background: var(--danger-soft);  color: var(--danger);  border-color: #e0b8b8; }
.alert-info    { background: var(--accent-soft);  color: var(--accent);  border-color: var(--border); }
[data-theme="dark"] .alert-success { border-color: #1a3a28; }
[data-theme="dark"] .alert-error   { border-color: #3a1818; }

/* =====================================================================
   ICONS
   ===================================================================== */
.icon {
    width: 20px; height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}
.icon-sm  { width: 16px; height: 16px; }
.icon-lg  { width: 28px; height: 28px; }
.icon-xl  { width: 40px; height: 40px; }

/* =====================================================================
   FORMS — base
   ===================================================================== */
.form-group {
    margin-bottom: 16px;
}
.form-label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: 6px;
}
.form-input, .form-select {
    display: block;
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-s);
    font-size: .95rem;
    font-family: var(--font-b);
    background: var(--surface);
    color: var(--ink);
    min-height: 44px;
    outline: none;
    appearance: none;
}
.form-input:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,58,52,.1); }
.form-input::placeholder { color: var(--ink-3); }

/* Legacy form selectors still used by some pages */
form label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: 16px;
}
form input[type="text"],
form input[type="email"],
form input[type="password"],
form input[type="number"],
form select {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-s);
    font-size: .95rem;
    font-family: var(--font-b);
    background: var(--surface);
    color: var(--ink);
    min-height: 44px;
    outline: none;
    appearance: none;
}
form input:focus, form select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,58,52,.1); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: .88rem; }
.checkbox-row input[type="checkbox"] { width: auto; margin: 0; min-height: auto; }

/* =====================================================================
   PASSWORD FIELD — eye toggle + hint button
   ===================================================================== */
.password-field-wrap {
    position: relative;
    display: flex;
    align-items: center;
    margin-top: 6px;
}
/* Input inside the wrap */
.password-field-wrap input {
    margin-top: 0;
    padding-right: 76px;
    flex: 1;
    min-width: 0;
    width: 100%;
}
/* No hint button variant */
.password-field-wrap.no-hint input { padding-right: 44px; }

.pw-toggle {
    position: absolute;
    right: 38px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--ink-3);
    display: flex;
    align-items: center;
    line-height: 0;
    border-radius: var(--radius-s);
    z-index: 2;
}
.pw-toggle:hover { color: var(--accent); }
.pw-toggle .icon { width: 18px; height: 18px; stroke-width: 1.8; }
.password-field-wrap.no-hint .pw-toggle { right: 10px; }

.pw-hint-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px; height: 22px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--surface-2);
    color: var(--ink-2);
    font-size: .72rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    line-height: 1;
}
.pw-hint-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Password rules tooltip */
.pw-rules {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0; right: 0;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-m);
    padding: 14px 16px;
    box-shadow: var(--shadow-m);
    z-index: 200;
    font-size: .82rem;
}
.pw-rules-visible { display: block; }
.pw-rules-title {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ink-3);
    margin-bottom: 10px;
}
.pw-rules ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.pw-rules li { display: flex; align-items: center; gap: 8px; }
.rule-icon { font-size: .82rem; width: 16px; text-align: center; flex-shrink: 0; }
.rule-pass { color: var(--success); }
.rule-fail { color: var(--ink-2); }
.rule-pass .rule-icon { color: var(--success); font-weight: 700; }
.rule-fail .rule-icon { color: var(--danger); }

.pw-confirm-msg { display: block; font-size: .78rem; margin-top: 6px; min-height: 1em; }
.pw-confirm-ok   { color: var(--success); }
.pw-confirm-fail { color: var(--danger); }

/* =====================================================================
   LAYOUT — auth pages (login, register, forgot, reset)
   ===================================================================== */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: var(--bg);
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-l);
    box-shadow: var(--shadow-m);
    padding: 40px 32px 36px;
}
@media (max-width: 480px) {
    .auth-card { padding: 32px 20px 28px; border-radius: var(--radius-m); }
}
.auth-brand { font-family: var(--font-h); font-size: 1.6rem; text-align: center; margin-bottom: 4px; }
.auth-subtitle { text-align: center; color: var(--ink-2); font-size: .9rem; margin-bottom: 28px; }
.auth-footer { text-align: center; margin-top: 20px; font-size: .85rem; color: var(--ink-2); }
.auth-footer a { color: var(--accent); font-weight: 600; }

/* Make primary/secondary buttons full-width inside auth cards */
.auth-card .btn-primary,
.auth-card .btn-secondary { display: flex; width: 100%; justify-content: center; margin-top: 10px; }

/* Legacy .brand class */
.brand { font-family: var(--font-h); font-size: 1.6rem; text-align: center; }

/* =====================================================================
   LAYOUT — app shell (logged-in pages)
   ===================================================================== */
.app-shell { min-height: 100vh; background: var(--bg); }

/* Sidebar — desktop */
.sidebar {
    display: none;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--nav-w);
    background: var(--surface);
    border-right: 1.5px solid var(--border);
    flex-direction: column;
    padding: 0 12px 20px;
    z-index: 100;
    overflow-y: auto;
}
.sidebar-brand {
    font-family: var(--font-h);
    font-size: 1.2rem;
    padding: 24px 12px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
    color: var(--ink);
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 12px;
    border-radius: var(--radius-s);
    color: var(--ink-2);
    font-size: .9rem;
    margin-bottom: 2px;
    cursor: pointer;
    text-decoration: none;
}
.nav-item:hover, .nav-item.active {
    background: var(--accent-soft);
    color: var(--accent);
}
.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }

/* Theme toggle button in sidebar */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-s);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--ink-2);
    font-size: .88rem;
    cursor: pointer;
    margin-bottom: 6px;
    font-family: var(--font-b);
}
.theme-toggle:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* Sun/Moon swap */
.icon-sun  { display: none; }
.icon-moon { display: block; }
[data-theme="dark"] .icon-sun  { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* Bottom nav — mobile */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bot-h);
    background: var(--surface);
    border-top: 1.5px solid var(--border);
    display: flex;
    align-items: stretch;
    z-index: 100;
}
.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: .65rem;
    color: var(--ink-3);
    text-decoration: none;
    padding: 8px 4px;
    min-height: 44px;
}
.bottom-nav-item.active { color: var(--accent); }
.bottom-nav-item .icon { width: 22px; height: 22px; }

/* Bottom theme toggle */
.bottom-theme-toggle {
    flex: 0 0 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: .65rem;
    color: var(--ink-3);
    background: none;
    border: none;
    border-left: 1px solid var(--border);
    cursor: pointer;
    padding: 8px 4px;
    font-family: var(--font-b);
    min-height: 44px;
}
.bottom-theme-toggle .icon { width: 22px; height: 22px; }
.bottom-theme-toggle:hover { color: var(--accent); }

/* Main content area */
.content {
    padding: 20px 16px calc(var(--bot-h) + 28px);
    max-width: 980px;
    margin: 0 auto;
    overflow-x: hidden;
}
.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.content-header h1 { font-size: 1.35rem; }

/* Desktop overrides */
@media (min-width: 768px) {
    .sidebar   { display: flex; }
    .bottom-nav { display: none; }
    .content { margin-left: var(--nav-w); padding: 36px 40px 40px; max-width: 1140px; }
}

/* Utility */
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: .88rem; }
.back-link:hover { color: var(--accent); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: 8px; }

/* =====================================================================
   STORAGE METER
   ===================================================================== */
.storage-meter { margin-bottom: 20px; }
.storage-meter-bar {
    height: 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    overflow: hidden;
}
.storage-meter-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
    transition: width .5s ease;
}
.storage-meter-label { font-size: .78rem; color: var(--ink-2); margin-top: 6px; }

/* =====================================================================
   FILTER ROW
   ===================================================================== */
.filter-row {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    margin-bottom: 16px;
    scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }

/* =====================================================================
   FILE GRID & CARDS
   ===================================================================== */
.file-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
    min-width: 0;
}
@media (max-width: 360px) { .file-grid { grid-template-columns: 1fr; } }
@media (min-width: 768px) { .file-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; } }

.file-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-m);
    padding: 12px;
    display: block;
    position: relative;
    min-width: 0;
    overflow: hidden;
    cursor: pointer;
    text-decoration: none;
    text-align: left;
    font-family: var(--font-b);
    width: 100%;
    color: var(--ink);
}
.file-card:hover { border-color: var(--accent); box-shadow: var(--shadow-s); }

.file-card-thumb {
    height: 88px;
    border-radius: var(--radius-s);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .72rem;
    letter-spacing: .06em;
    background: var(--accent-soft);
    color: var(--accent);
    margin-bottom: 10px;
    overflow: hidden;
}
.file-type-videos { background: #f5ead6; color: var(--gold); }
.file-type-zip    { background: #ede8f4; color: #5a3870; }
.file-type-other  { background: var(--surface-2); color: var(--ink-3); }
[data-theme="dark"] .file-type-videos { background: #2a1e08; color: var(--gold); }
[data-theme="dark"] .file-type-zip    { background: #1e1428; color: #a080d0; }
[data-theme="dark"] .file-type-other  { background: var(--surface-2); color: var(--ink-3); }

.file-card-body {}
.file-card-name { font-size: .84rem; font-weight: 600; margin: 0 0 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.file-card-meta { font-size: .72rem; color: var(--ink-2); }
.file-card-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; }

.file-card-flagged { border-color: #d4aa50; background: #fefaea; }
[data-theme="dark"] .file-card-flagged { border-color: #5a3f0a; background: #1e1608; }

.icon-btn {
    width: 30px; height: 30px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink-2);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: .85rem;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--ink-3);
    font-size: .92rem;
}

/* =====================================================================
   UPLOAD PAGE
   ===================================================================== */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-m);
    background: var(--surface);
    padding: 52px 24px;
    text-align: center;
    cursor: pointer;
    margin-bottom: 20px;
    transition: border-color .2s, background .2s;
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.upload-zone p { color: var(--ink-2); margin-top: 10px; }
.upload-zone-sub { font-size: .8rem; color: var(--ink-3); margin-top: 4px !important; }

.upload-queue { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.upload-queue li {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-s);
    padding: 14px;
}
.upload-file-name {
    font-size: .86rem;
    font-weight: 600;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink);
}
.progress-bar {
    height: 6px;
    border-radius: 999px;
    background: var(--accent-soft);
    overflow: hidden;
    margin-bottom: 6px;
}
.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 999px;
}
.progress-fill-done  { background: var(--success); }
.progress-fill-error { background: var(--danger); }
.upload-progress-row { display: flex; justify-content: space-between; align-items: center; }
.upload-status { font-size: .74rem; color: var(--ink-3); }
.upload-status.upload-done { color: var(--success); }
.upload-status.error       { color: var(--danger);  }
.upload-pct { font-size: .74rem; font-weight: 700; color: var(--ink-2); }

/* =====================================================================
   VIEWER PAGE
   ===================================================================== */
.viewer-page { padding-bottom: calc(var(--bot-h) + 80px); }

.viewer-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}
.viewer-header .back-link {
    width: 40px; height: 40px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--surface);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    color: var(--ink-2);
}
.viewer-header .back-link:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.viewer-title {
    flex: 1;
    font-size: .92rem;
    font-weight: 600;
    font-family: var(--font-b);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.viewer-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.viewer-wrap .viewer { flex: 1; min-width: 0; margin-bottom: 0; }

.viewer {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-m);
    padding: 16px;
    text-align: center;
    margin-bottom: 16px;
}
.viewer-image { max-width: 100%; border-radius: var(--radius-s); }
.viewer-video { width: 100%; border-radius: var(--radius-s); }
.viewer-text  { text-align: left; white-space: pre-wrap; font-family: monospace; font-size: .84rem; max-height: 60vh; overflow: auto; }
.viewer-pdf   { width: 100%; height: 68vh; border: none; display: block; }
.viewer-fallback { padding: 48px 0; color: var(--ink-2); display: flex; flex-direction: column; align-items: center; gap: 16px; }

.viewer-arrow {
    display: none;
    width: 44px; height: 44px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--ink);
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    box-shadow: var(--shadow-s);
}
.viewer-arrow svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.viewer-arrow:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.viewer-arrow-disabled { opacity: .3; pointer-events: none; }
@media (min-width: 600px) { .viewer-arrow { display: flex; } }

.viewer-counter { text-align: center; font-size: .78rem; color: var(--ink-3); margin: 6px 0 14px; }

.file-meta {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-m);
    padding: 16px;
    margin-bottom: 16px;
}
.file-meta-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 16px;
    font-size: .84rem;
}
.file-meta-label { font-weight: 600; color: var(--ink-2); white-space: nowrap; }

.viewer-mobile-nav { display: flex; gap: 10px; margin-top: 12px; }
.viewer-mobile-nav .btn { flex: 1; justify-content: center; }
.viewer-nav-disabled { opacity: .35; pointer-events: none; }
@media (min-width: 600px) { .viewer-mobile-nav { display: none; } }

/* =====================================================================
   PROFILE PAGE
   ===================================================================== */
.profile-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-m);
    padding: 20px;
    margin-bottom: 20px;
}
.profile-avatar {
    width: 54px; height: 54px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-family: var(--font-h);
    font-size: 1.4rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.profile-name  { font-size: .96rem; font-weight: 600; margin-bottom: 2px; }
.profile-email { font-size: .82rem; color: var(--ink-2); margin-bottom: 2px; }
.profile-role  { font-size: .74rem; color: var(--ink-3); }

.profile-section {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-m);
    padding: 20px;
    margin-bottom: 14px;
}
.profile-section h2 { font-size: 1rem; margin-bottom: 6px; }
.section-hint {
    font-size: .8rem;
    color: var(--ink-2);
    margin: 0 0 14px;
    line-height: 1.55;
}
.form-section { max-width: 400px; }
.form-section .btn { display: flex; width: 100%; margin-top: 8px; }
.form-section form label:last-of-type { margin-bottom: 0; }

.pending-notice {
    margin-top: 12px;
    font-size: .82rem;
    color: var(--warning);
    background: var(--warning-soft);
    border: 1px solid #e8c870;
    border-radius: var(--radius-s);
    padding: 10px 14px;
}
[data-theme="dark"] .pending-notice { border-color: #5a3f10; }

/* =====================================================================
   DASHBOARD HEADER ACTIONS
   ===================================================================== */
.btn-icon-only { width: 44px; min-height: 44px; padding: 0; }

/* =====================================================================
   ADMIN — OVERVIEW PAGE
   ===================================================================== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
@media (min-width: 600px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }

.stat-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-m);
    padding: 18px 16px;
}
.stat-card-alert .stat-value { color: var(--warning); }
.stat-value { display: block; font-family: var(--font-h); font-size: 1.6rem; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: .74rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }

.admin-quick-nav { display: flex; gap: 10px; margin-bottom: 20px; }
.admin-quick-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 18px 10px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-m);
    font-size: .82rem;
    font-weight: 600;
    color: var(--ink);
    text-align: center;
    cursor: pointer;
    text-decoration: none;
}
.admin-quick-btn:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.admin-quick-btn .icon { width: 24px; height: 24px; }

.admin-panel-box {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-m);
    margin-bottom: 16px;
    overflow: hidden;
}
.admin-panel-heading {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--ink-3);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.activity-list { display: flex; flex-direction: column; }
.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-thumb {
    width: 40px; height: 40px;
    border-radius: var(--radius-s);
    display: flex; align-items: center; justify-content: center;
    font-size: .65rem;
    font-weight: 700;
    background: var(--accent-soft);
    color: var(--accent);
    flex-shrink: 0;
    letter-spacing: .04em;
}
.activity-info { flex: 1; min-width: 0; }
.activity-name { font-size: .86rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 2px; }
.activity-meta { font-size: .72rem; color: var(--ink-3); display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }

/* =====================================================================
   ADMIN — USER CARDS
   ===================================================================== */
.user-card-list { display: flex; flex-direction: column; gap: 10px; }
.user-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-m);
    padding: 16px;
}
.user-card-top { margin-bottom: 12px; }
.user-card-info { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.user-card-name { font-weight: 700; font-size: .92rem; }
.user-card-meta { font-size: .76rem; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 12px; }
.user-card-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-icon { display: inline-flex; align-items: center; gap: 5px; }
.btn-icon .icon { width: 14px; height: 14px; }

@media (min-width: 600px) {
    .user-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
    .user-card-info { margin-bottom: 0; }
}

/* Inline forms in user cards */
.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.quota-input  { width: 80px; padding: 6px 8px; border: 1.5px solid var(--border); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); font-size: .82rem; min-height: 34px; outline: none; }
.quota-input:focus { border-color: var(--accent); }

/* =====================================================================
   ADMIN — FILE CARDS (browse all files)
   ===================================================================== */
.admin-file-list { display: flex; flex-direction: column; gap: 10px; }
.admin-file-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-m);
    padding: 14px;
}
.admin-file-flagged { border-color: #d4aa50; background: #fefaea; }
[data-theme="dark"] .admin-file-flagged { border-color: #5a3f0a; background: #1e1608; }

.admin-file-top { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.admin-file-thumb {
    width: 52px; height: 52px;
    border-radius: var(--radius-s);
    display: flex; align-items: center; justify-content: center;
    font-size: .68rem; font-weight: 700; letter-spacing: .04em;
    background: var(--accent-soft); color: var(--accent);
    flex-shrink: 0; overflow: hidden;
}
.admin-file-info { flex: 1; min-width: 0; }
.admin-file-name { font-size: .88rem; font-weight: 600; margin: 0 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-file-name a { color: var(--accent); }
.admin-file-meta { font-size: .74rem; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.admin-file-flag-reason { font-size: .74rem; color: var(--warning); margin-top: 4px; }
.badge-type { background: var(--accent-soft); color: var(--accent); padding: 2px 7px; border-radius: 999px; font-size: .66rem; font-weight: 700; }

.admin-file-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; border-top: 1px solid var(--border); padding-top: 10px; }
.admin-flag-form { display: flex; gap: 6px; align-items: center; flex: 1; min-width: 0; }
.flag-reason-input { flex: 1; min-width: 0; padding: 7px 10px; font-size: .82rem; border: 1.5px solid var(--border); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); min-height: 36px; outline: none; }
.flag-reason-input:focus { border-color: var(--accent); }

/* Admin search form */
.admin-search-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.admin-search-form input, .admin-search-form select {
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-s);
    min-height: 44px;
    font-size: .9rem;
    background: var(--surface);
    color: var(--ink);
    outline: none;
    font-family: var(--font-b);
    width: 100%;
}
.admin-search-form input:focus, .admin-search-form select:focus { border-color: var(--accent); }
.admin-search-form .btn { width: 100%; }
@media (min-width: 600px) {
    .admin-search-form { flex-direction: row; }
    .admin-search-form input { flex: 1; width: auto; }
    .admin-search-form select { width: auto; }
    .admin-search-form .btn { width: auto; }
}

/* =====================================================================
   SETTINGS PAGE
   ===================================================================== */
.settings-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-m);
    margin-bottom: 14px;
    overflow: hidden;
}
.settings-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 20px;
    background: var(--accent-soft);
    border-bottom: 1px solid var(--border);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--accent);
}
.settings-card-header .icon { width: 16px; height: 16px; flex-shrink: 0; }

.settings-field {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}
.settings-field:last-child { border-bottom: none; }
.settings-field-toggle {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.settings-field-label label {
    font-size: .9rem;
    font-weight: 600;
    display: block;
    margin-bottom: 3px;
    color: var(--ink);
}
.settings-hint { font-size: .76rem; color: var(--ink-3); line-height: 1.5; margin: 0; }
.settings-field-input { display: flex; flex-direction: column; gap: 6px; }

.settings-input {
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-s);
    font-size: .92rem;
    font-family: var(--font-b);
    background: var(--surface);
    color: var(--ink);
    min-height: 44px;
    outline: none;
    width: 100%;
    max-width: 340px;
}
.settings-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,58,52,.08); }

.settings-quota-wrap { display: flex; align-items: center; gap: 10px; }
.settings-quota-label { font-size: .86rem; color: var(--ink-2); }
.settings-quota-gb { color: var(--accent); font-size: .78rem; margin-left: 4px; }

.settings-actions { margin-top: 4px; padding-bottom: 4px; }
.settings-actions .btn { gap: 8px; }
.settings-actions .btn .icon { width: 16px; height: 16px; }

@media (min-width: 640px) {
    .settings-field { flex-direction: row; align-items: flex-start; gap: 24px; }
    .settings-field-toggle { align-items: center; }
    .settings-field-label { flex: 1; }
    .settings-field-input { flex: 1; }
    .settings-input { max-width: 100%; }
}

/* Theme radio picker */
.theme-option-group { display: flex; gap: 10px; flex-wrap: wrap; }
.theme-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius-s);
    cursor: pointer;
    font-size: .86rem;
    font-weight: 500;
    min-height: 44px;
    color: var(--ink);
    user-select: none;
}
.theme-option input[type="radio"] { display: none; }
.theme-option:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.theme-option-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.theme-option .icon { width: 16px; height: 16px; }

/* Toggle switch */
.toggle-switch { position: relative; display: inline-block; width: 48px; height: 28px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 999px;
    cursor: pointer;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px; height: 20px;
    left: 4px; top: 4px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
    box-shadow: var(--shadow-s);
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* =====================================================================
   LIGHTBOX (admin user-files inline viewer)
   ===================================================================== */
.lb-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.88);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    backdrop-filter: blur(6px);
}
.lb-box {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-m);
    width: 100%;
    max-width: 900px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-l);
}
.lb-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--surface-2);
}
.lb-title { flex: 1; font-size: .86rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-header-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.lb-close {
    width: 32px; height: 32px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: transparent;
    cursor: pointer;
    font-size: .88rem;
    color: var(--ink-2);
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
}
.lb-close:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.lb-media {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #080808;
    min-height: 180px;
}
.lb-img   { max-width: 100%; max-height: 62vh; object-fit: contain; display: block; }
.lb-video { max-width: 100%; max-height: 62vh; display: block; }
.lb-pdf   { width: 100%; height: 62vh; border: none; display: block; }
.lb-fallback { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 40px 20px; color: var(--ink-2); }
.lb-fallback-icon {
    width: 72px; height: 72px;
    border-radius: var(--radius-m);
    display: flex; align-items: center; justify-content: center;
    font-size: .9rem; font-weight: 700;
    background: var(--accent-soft); color: var(--accent);
}
.lb-footer {
    border-top: 1px solid var(--border);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
    flex-wrap: wrap;
    background: var(--surface-2);
}
.lb-meta { display: flex; gap: 12px; font-size: .74rem; color: var(--ink-3); flex-wrap: wrap; align-items: center; }
.lb-nav  { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.lb-arrow {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--ink);
}
.lb-arrow svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lb-arrow:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.lb-arrow:disabled { opacity: .3; cursor: not-allowed; }
.lb-counter { font-size: .78rem; color: var(--ink-3); min-width: 52px; text-align: center; }

/* =====================================================================
   MISCELLANEOUS UTILITIES
   ===================================================================== */
.admin-panel { margin-bottom: 20px; }

/* Old .admin-panel h2 used in some pages */
.admin-panel h2 {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--ink-3);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.action-cell { display: flex; gap: 6px; flex-wrap: wrap; }
.row-flagged { background: #fefaea; }
[data-theme="dark"] .row-flagged { background: #1e1608; }

/* 404 page, generic centered layout */
.auth-page .auth-card p { color: var(--ink-2); }

/* Ensure selects in forms have a consistent look */
select { cursor: pointer; }
