/* ═══════════════════════════════════════════════════════════════════════════
   FamilyCloud — Premium Dark UI
   ══════════════════════════════════════════════════════════════════════════ */

/* ─── Design Tokens ──────────────────────────────────────────────────────── */
:root {
  --bg-base:        #080c14;
  --bg-surface:     #0d1421;
  --bg-elevated:    #121929;
  --bg-card:        rgba(255,255,255,0.038);
  --bg-card-hover:  rgba(255,255,255,0.065);
  --bg-input:       rgba(255,255,255,0.05);

  --border:         rgba(255,255,255,0.08);
  --border-focus:   rgba(124,58,237,0.6);
  --border-hover:   rgba(124,58,237,0.35);

  --accent:         #7c3aed;
  --accent-bright:  #8b5cf6;
  --accent-hover:   #6d28d9;
  --accent-glow:    rgba(124,58,237,0.25);
  --accent-subtle:  rgba(124,58,237,0.12);

  --teal:           #14b8a6;
  --teal-subtle:    rgba(20,184,166,0.12);
  --emerald:        #10b981;
  --emerald-subtle: rgba(16,185,129,0.12);
  --amber:          #f59e0b;
  --amber-subtle:   rgba(245,158,11,0.12);
  --blue:           #3b82f6;
  --blue-subtle:    rgba(59,130,246,0.12);
  --rose:           #f43f5e;
  --rose-subtle:    rgba(244,63,94,0.12);
  --violet:         #8b5cf6;
  --violet-subtle:  rgba(139,92,246,0.12);
  --orange:         #f97316;
  --orange-subtle:  rgba(249,115,22,0.12);

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #475569;
  --text-accent:    #a78bfa;

  --danger:         #ef4444;
  --danger-hover:   #dc2626;
  --danger-subtle:  rgba(239,68,68,0.12);
  --success:        #22c55e;

  --sidebar-w:      240px;
  --topbar-h:       60px;
  --radius-sm:      8px;
  --radius:         12px;
  --radius-lg:      18px;
  --radius-xl:      24px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
  --shadow:     0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:  0 12px 40px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 30px rgba(124,58,237,0.2);

  --ease:  cubic-bezier(0.25,0.46,0.45,0.94);
  --speed: 200ms;
}

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

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }
input, select { font: inherit; }
a { color: var(--accent-bright); }
::selection { background: var(--accent); color: #fff; }

.hidden { display: none !important; }

/* ─── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ─── LOGIN SCREEN ───────────────────────────────────────────────────────── */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-base);
  z-index: 9999;
  overflow: hidden;
}

.login-bg-orbs { position: absolute; inset: 0; pointer-events: none; }
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  animation: float 8s ease-in-out infinite;
}
.orb-1 { width: 500px; height: 500px; top: -150px; left: -100px;
  background: radial-gradient(circle, #7c3aed, transparent 70%); animation-delay: 0s; }
.orb-2 { width: 400px; height: 400px; bottom: -100px; right: -80px;
  background: radial-gradient(circle, #4f46e5, transparent 70%); animation-delay: 3s; }
.orb-3 { width: 300px; height: 300px; top: 30%; left: 50%;
  background: radial-gradient(circle, #14b8a6, transparent 70%); animation-delay: 5s; opacity: 0.2; }

@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-20px) scale(1.04); }
}

.login-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 420px; margin: 16px;
  background: rgba(13,20,33,0.85);
  backdrop-filter: blur(24px) saturate(1.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 44px 40px 36px;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  animation: slideUp 0.5s var(--ease) both;
}

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

.login-logo {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-bottom: 10px;
}
.login-logo-icon {
  width: 80px; height: 80px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 18px;
  overflow: hidden;
  flex-shrink: 0;
}
.login-logo-text { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
.logo-family { color: var(--text-primary); }
.logo-cloud  { color: var(--accent-bright); }

.login-subtitle {
  color: var(--text-secondary); font-size: 13px; margin-bottom: 32px;
  margin-top: 4px; text-align: center;
}

.login-form { display: flex; flex-direction: column; gap: 16px; }

.field-group { display: flex; flex-direction: column; gap: 7px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.6px; }
.field-input-wrap { position: relative; display: flex; align-items: center; }
.field-icon { position: absolute; left: 13px; font-size: 16px; pointer-events: none; }
.field-input {
  width: 100%;
  padding: 12px 44px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
  outline: none;
}
.field-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.18);
}
.field-input::placeholder { color: var(--text-muted); }
.field-toggle {
  position: absolute; right: 12px;
  background: none; border: none;
  font-size: 16px; cursor: pointer;
  color: var(--text-muted);
  transition: color var(--speed);
}
.field-toggle:hover { color: var(--text-secondary); }

.login-error {
  background: var(--danger-subtle);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-sm);
  color: #fca5a5;
  font-size: 13px; padding: 10px 14px;
  text-align: center;
  animation: shake 0.3s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.login-footer {
  text-align: center; color: var(--text-muted); font-size: 12px;
  margin-top: 20px;
}

/* ─── BUTTONS ────────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 22px;
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  color: #fff; font-weight: 600; font-size: 14px;
  border-radius: var(--radius-sm);
  border: none; cursor: pointer;
  transition: opacity var(--speed), transform var(--speed), box-shadow var(--speed);
  box-shadow: 0 4px 14px rgba(124,58,237,0.35);
  user-select: none;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(124,58,237,0.45); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-full { width: 100%; }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px;
  background: var(--bg-card); color: var(--text-secondary);
  font-weight: 500; font-size: 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--speed), color var(--speed);
}
.btn-secondary:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px;
  background: var(--danger); color: #fff;
  font-weight: 600; font-size: 14px;
  border: none; border-radius: var(--radius-sm); cursor: pointer;
  transition: background var(--speed);
}
.btn-danger:hover { background: var(--danger-hover); }

.btn-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 16px;
  transition: background var(--speed), color var(--speed), border-color var(--speed);
}
.btn-icon:hover { background: var(--bg-card-hover); color: var(--text-primary); border-color: var(--border-hover); }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── APP LAYOUT ─────────────────────────────────────────────────────────── */
.app {
  display: flex; flex-direction: column;
  height: 100vh; overflow: hidden;
}

/* ─── TOPBAR ─────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: rgba(8,12,20,0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: relative; z-index: 100;
  flex-shrink: 0;
}

.topbar-left {
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}

.sidebar-toggle {
  display: none; flex-direction: column; gap: 4px;
  width: 32px; height: 32px; padding: 6px; justify-content: center;
  background: none; border: none; cursor: pointer; border-radius: 6px;
}
.sidebar-toggle span {
  display: block; height: 2px; background: var(--text-secondary);
  border-radius: 2px; transition: all 0.2s;
  width: 100%;
}

.topbar-logo { display: flex; align-items: center; gap: 7px; font-size: 17px; font-weight: 700; }
.logo-icon-sm {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  border-radius: 8px;
}
.logo-text-sm .logo-family { color: var(--text-primary); }
.logo-text-sm .logo-cloud  { color: var(--accent-bright); }

/* Breadcrumbs */
.breadcrumb-nav {
  flex: 1; display: flex; align-items: center; gap: 0;
  overflow: hidden; min-width: 0;
}
.breadcrumb-item {
  display: flex; align-items: center; gap: 0;
  font-size: 13px; color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  max-width: 160px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  padding: 4px 8px; border-radius: 6px;
  transition: background var(--speed), color var(--speed);
}
.breadcrumb-item:hover { background: var(--bg-card); color: var(--text-primary); }
.breadcrumb-item.active { color: var(--text-primary); font-weight: 600; cursor: default; }
.breadcrumb-item.active:hover { background: none; }
.breadcrumb-sep { color: var(--text-muted); font-size: 16px; flex-shrink: 0; padding: 0 2px; }

.topbar-right {
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}

.search-wrap {
  position: relative; display: flex; align-items: center;
}
.search-icon { position: absolute; left: 10px; font-size: 14px; pointer-events: none; }
.search-input {
  width: 200px; padding: 8px 12px 8px 32px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 13px;
  outline: none;
  transition: border-color var(--speed), width var(--speed), box-shadow var(--speed);
}
.search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.14);
  width: 250px;
}
.search-input::placeholder { color: var(--text-muted); }

.view-toggle { display: flex; gap: 2px; }
.view-btn {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  font-size: 16px; border-radius: 6px; color: var(--text-muted);
  transition: background var(--speed), color var(--speed);
}
.view-btn:hover { background: var(--bg-card); color: var(--text-secondary); }
.view-btn.active { background: var(--accent-subtle); color: var(--accent-bright); }

.btn-upload {
  padding: 8px 16px; font-size: 13px;
  box-shadow: 0 2px 8px rgba(124,58,237,0.3);
}

/* ─── APP BODY ───────────────────────────────────────────────────────────── */
.app-body {
  display: flex; flex: 1; overflow: hidden;
}

/* ─── SIDEBAR ────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 0;
  overflow-y: auto; overflow-x: hidden;
  padding: 12px 0 20px;
  transition: transform var(--speed) var(--ease), width var(--speed) var(--ease);
}

.sidebar-section {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.sidebar-section:last-of-type { border-bottom: none; }

.sidebar-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-muted); padding: 4px 8px 8px;
}

.sidebar-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 9px 8px;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
  color: var(--text-secondary);
  transition: background var(--speed), color var(--speed);
  text-align: left;
}
.sidebar-item:hover { background: var(--bg-card); color: var(--text-primary); }
.sidebar-item.active { background: var(--accent-subtle); color: var(--accent-bright); }
.si-icon { font-size: 16px; flex-shrink: 0; }
.sidebar-item-action { color: var(--text-muted); }
.sidebar-item-action:hover { color: var(--text-primary); }

.sidebar-actions { padding-top: 8px; }

/* Storage Stats Card */
.stats-card {
  margin: 12px; flex-shrink: 0;
  background: linear-gradient(135deg, rgba(124,58,237,0.08), rgba(79,70,229,0.05));
  border: 1px solid rgba(124,58,237,0.2);
  border-radius: var(--radius);
  padding: 14px;
}
.stats-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.stats-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); }
.stats-refresh {
  font-size: 14px; color: var(--text-muted);
  padding: 2px; border-radius: 4px;
  transition: color var(--speed), transform var(--speed);
}
.stats-refresh:hover { color: var(--accent-bright); transform: rotate(90deg); }
.stats-refresh.spinning { animation: spin 1s linear infinite; }

.stats-total { font-size: 22px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.5px; }
.stats-count { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }

.stats-bars { display: flex; flex-direction: column; gap: 7px; }
.stats-bar-item { display: flex; flex-direction: column; gap: 4px; }
.stats-bar-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-secondary); }
.stats-bar-name { font-weight: 500; }
.stats-bar-track { height: 4px; background: rgba(255,255,255,0.08); border-radius: 99px; overflow: hidden; }
.stats-bar-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
  transition: width 0.6s var(--ease);
  min-width: 4px;
}
.stats-bar-fill.fill-archive { background: linear-gradient(90deg, var(--amber), #fbbf24); }
.stats-bar-fill.fill-photos  { background: linear-gradient(90deg, var(--emerald), #34d399); }
.stats-bar-fill.fill-videos  { background: linear-gradient(90deg, var(--violet), #a78bfa); }
.stats-bar-fill.fill-documents { background: linear-gradient(90deg, var(--blue), #60a5fa); }

/* ─── MAIN CONTENT ───────────────────────────────────────────────────────── */
.main-content {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; position: relative;
}

/* Drop overlay */
.drop-overlay {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8,12,20,0.88);
  backdrop-filter: blur(8px);
  border: 2px dashed var(--accent);
  border-radius: var(--radius-lg);
  margin: 12px;
  pointer-events: none; opacity: 0;
  transition: opacity 0.2s;
}
.drop-overlay.active { opacity: 1; pointer-events: all; }
.drop-overlay-inner { text-align: center; }
.drop-overlay-icon {
  font-size: 52px; display: block; margin-bottom: 12px;
  animation: bounce 1s ease-in-out infinite;
  color: var(--accent-bright);
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.drop-overlay-text { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.drop-overlay-sub { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }

/* Content toolbar */
.content-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.item-count { font-size: 12px; color: var(--text-muted); }
.sort-select {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-secondary); font-size: 12px;
  padding: 5px 10px; outline: none; cursor: pointer;
  transition: border-color var(--speed);
}
.sort-select:hover { border-color: var(--border-hover); }
.sort-select:focus { border-color: var(--border-focus); }

/* File container */
.file-container {
  flex: 1; overflow-y: auto; padding: 20px;
}

/* Loading state */
.loading-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; height: 200px; color: var(--text-muted); font-size: 14px;
}
.loader-ring {
  width: 36px; height: 36px;
  border: 3px solid rgba(255,255,255,0.08);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Empty state */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 60px 20px; text-align: center; color: var(--text-muted);
}
.empty-icon { font-size: 48px; opacity: 0.5; }
.empty-title { font-size: 17px; font-weight: 600; color: var(--text-secondary); }
.empty-sub { font-size: 13px; max-width: 260px; }
.empty-actions { margin-top: 8px; display: flex; gap: 10px; }

/* ─── FILE GRID ──────────────────────────────────────────────────────────── */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.file-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden; cursor: pointer;
  transition: background var(--speed), border-color var(--speed), transform var(--speed), box-shadow var(--speed);
  animation: cardIn 0.25s var(--ease) both;
  user-select: none;
}
@keyframes cardIn {
  from { opacity: 0; transform: scale(0.95) translateY(4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.file-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow), var(--shadow-glow);
}
.file-card.selected {
  border-color: var(--accent);
  background: var(--accent-subtle);
  box-shadow: 0 0 0 2px rgba(124,58,237,0.25);
}

/* Folder card */
.file-card.folder-card {
  background: rgba(124,58,237,0.06);
  border-color: rgba(124,58,237,0.2);
}
.file-card.folder-card:hover {
  background: rgba(124,58,237,0.12);
  border-color: rgba(124,58,237,0.4);
}

.card-thumb {
  width: 100%; aspect-ratio: 4/3;
  display: flex; align-items: center; justify-content: center;
  font-size: 42px; position: relative; overflow: hidden;
  background: rgba(0,0,0,0.2);
}
.card-thumb img {
  width: 100%; height: 100%;
  object-fit: cover; position: absolute; inset: 0;
  transition: opacity 0.3s;
}
.card-thumb img.loading { opacity: 0; }
.card-thumb img.loaded { opacity: 1; }
.card-thumb-icon {
  font-size: 44px; line-height: 1;
  opacity: 0.85;
}

.archive-badge {
  position: absolute; top: 6px; right: 6px;
  background: var(--amber-subtle); border: 1px solid rgba(245,158,11,0.3);
  color: var(--amber); font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 99px; text-transform: uppercase; letter-spacing: 0.5px;
}

.card-info {
  padding: 10px 12px;
}
.card-name {
  font-size: 13px; font-weight: 500; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 3px;
}
.card-meta {
  font-size: 11px; color: var(--text-muted);
  display: flex; justify-content: space-between;
}

.card-actions {
  position: absolute; top: 6px; right: 6px;
  display: flex; gap: 4px;
  opacity: 0; transition: opacity var(--speed);
}
.file-card:hover .card-actions { opacity: 1; }
.card-actions .card-action-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8,12,20,0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 6px; font-size: 14px;
  transition: background var(--speed), border-color var(--speed);
}
.card-actions .card-action-btn:hover { background: var(--bg-elevated); border-color: var(--border-hover); }

/* ─── FILE LIST ──────────────────────────────────────────────────────────── */
.file-list { display: flex; flex-direction: column; gap: 2px; }

.file-row {
  display: grid;
  grid-template-columns: 40px 1fr 100px 140px 36px;
  gap: 12px; align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer; user-select: none;
  border: 1px solid transparent;
  transition: background var(--speed), border-color var(--speed);
  animation: cardIn 0.2s var(--ease) both;
}
.file-row:hover { background: var(--bg-card); border-color: var(--border); }
.file-row.selected { background: var(--accent-subtle); border-color: var(--accent); }

.row-icon { font-size: 24px; text-align: center; }
.row-name { font-size: 13px; font-weight: 500; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-size { font-size: 12px; color: var(--text-muted); text-align: right; }
.row-date { font-size: 12px; color: var(--text-muted); }
.row-actions {
  display: flex; gap: 4px; opacity: 0;
  transition: opacity var(--speed);
}
.file-row:hover .row-actions { opacity: 1; }

.list-header {
  display: grid;
  grid-template-columns: 40px 1fr 100px 140px 36px;
  gap: 12px; padding: 6px 12px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border); margin-bottom: 4px;
}

/* ─── UPLOAD PANEL ───────────────────────────────────────────────────────── */
.upload-panel {
  position: fixed; bottom: 20px; right: 20px; z-index: 200;
  width: 340px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(20px) scale(0.97); opacity: 0;
  pointer-events: none;
  transition: transform 0.25s var(--ease), opacity 0.25s var(--ease);
}
.upload-panel.visible { transform: translateY(0) scale(1); opacity: 1; pointer-events: all; }

.upload-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}
.upload-panel-title { font-size: 13px; font-weight: 600; }
.upload-panel-close {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 14px; border-radius: 4px;
  transition: color var(--speed), background var(--speed);
}
.upload-panel-close:hover { color: var(--text-primary); background: var(--bg-card); }

.upload-panel-list {
  max-height: 280px; overflow-y: auto;
  padding: 8px;
  display: flex; flex-direction: column; gap: 4px;
}

.upload-item {
  padding: 10px 12px;
  background: var(--bg-card); border-radius: var(--radius-sm);
  display: flex; flex-direction: column; gap: 6px;
}
.upload-item-header { display: flex; align-items: center; gap: 8px; }
.upload-item-icon { font-size: 18px; flex-shrink: 0; }
.upload-item-name { font-size: 12px; font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item-status { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.upload-item-status.done   { color: var(--success); }
.upload-item-status.error  { color: var(--danger); }

.upload-progress-track { height: 3px; background: rgba(255,255,255,0.08); border-radius: 99px; overflow: hidden; }
.upload-progress-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
  transition: width 0.2s;
}
.upload-progress-fill.done { background: var(--success); }
.upload-progress-fill.error { background: var(--danger); }

/* ─── MODALS ─────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s var(--ease) both;
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 0;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 14px; border-radius: 6px;
  transition: color var(--speed), background var(--speed);
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-card); }

.modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.modal-text { font-size: 14px; color: var(--text-secondary); line-height: 1.6; }
.modal-hint {
  font-size: 12px; color: var(--text-muted);
  background: var(--bg-card); border-radius: var(--radius-sm);
  padding: 10px 12px; border-left: 3px solid var(--accent);
}
.modal-body .field-input { padding-left: 14px; }

.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 12px 20px 18px;
}

/* ─── CONTEXT MENU ───────────────────────────────────────────────────────── */
.context-menu {
  position: fixed; z-index: 2000;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 5px;
  min-width: 170px;
  animation: slideUp 0.1s ease both;
}
.ctx-item {
  display: block; width: 100%;
  padding: 9px 12px; text-align: left;
  font-size: 13px; font-weight: 500; color: var(--text-secondary);
  border-radius: 7px;
  transition: background var(--speed), color var(--speed);
}
.ctx-item:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.ctx-item.ctx-danger { color: var(--danger); }
.ctx-item.ctx-danger:hover { background: var(--danger-subtle); color: var(--danger); }
.ctx-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ─── TOAST STACK ────────────────────────────────────────────────────────── */
.toast-stack {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  z-index: 3000; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; align-items: center;
}

.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 99px;
  box-shadow: var(--shadow);
  font-size: 13px; font-weight: 500; color: var(--text-primary);
  animation: toastIn 0.25s var(--ease) both;
  white-space: nowrap;
}
.toast.success { border-color: rgba(34,197,94,0.3); }
.toast.error   { border-color: rgba(239,68,68,0.3); color: #fca5a5; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(-8px) scale(0.96); }
}

/* ─── RESPONSIVE / MOBILE ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }

  .sidebar-toggle { display: flex; }
  .sidebar {
    position: fixed; left: 0; top: var(--topbar-h); bottom: 0; z-index: 90;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-backdrop {
    display: none; position: fixed; inset: 0; top: var(--topbar-h);
    background: rgba(0,0,0,0.5); z-index: 89;
  }
  .sidebar-backdrop.visible { display: block; }

  .search-input { width: 140px; }
  .search-input:focus { width: 160px; }

  .file-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
  .file-container { padding: 14px; }

  .upload-panel { bottom: 0; right: 0; left: 0; width: auto; border-radius: var(--radius) var(--radius) 0 0; }

  .topbar-logo .logo-text-sm { display: none; }

  .file-row { grid-template-columns: 36px 1fr 80px 36px; }
  .row-date { display: none; }
}

@media (max-width: 480px) {
  .login-card { padding: 32px 24px 28px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .btn-upload span { display: none; }
  .view-toggle { display: none; }
}

/* ─── Color theme per file type ──────────────────────────────────────────── */
.type-image     { --type-color: var(--teal);    --type-bg: var(--teal-subtle); }
.type-video     { --type-color: var(--violet);  --type-bg: var(--violet-subtle); }
.type-audio     { --type-color: var(--amber);   --type-bg: var(--amber-subtle); }
.type-document  { --type-color: var(--blue);    --type-bg: var(--blue-subtle); }
.type-spreadsheet { --type-color: var(--emerald); --type-bg: var(--emerald-subtle); }
.type-presentation { --type-color: var(--orange); --type-bg: var(--orange-subtle); }
.type-archive   { --type-color: var(--amber);   --type-bg: var(--amber-subtle); }
.type-text      { --type-color: #94a3b8;        --type-bg: rgba(148,163,184,0.1); }
.type-code      { --type-color: #6366f1;        --type-bg: rgba(99,102,241,0.1); }
.type-unknown   { --type-color: #94a3b8;        --type-bg: rgba(148,163,184,0.08); }

.card-thumb { background: var(--type-bg); }
