/* ===== Reset + Variables ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-surface: #eff6ff;
  --success: #22c55e;
  --success-surface: #f0fdf4;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-surface: #fef2f2;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.08);
  --shadow: 0 4px 6px -1px rgba(0,0,0,.10), 0 2px 4px -2px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.10), 0 4px 6px -4px rgba(0,0,0,.05);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --border: #334155;
  --text: #f1f5f9;
  --text-2: #94a3b8;
  --text-3: #64748b;
  --primary-surface: rgba(59,130,246,.15);
  --success-surface: rgba(34,197,94,.12);
  --danger-surface: rgba(239,68,68,.12);
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

/* ===== Login Screen ===== */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #f0f9ff 0%, #eff6ff 50%, #fdf4ff 100%);
  position: relative;
}

.login-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 13px;
}
.login-links a { color: var(--primary); text-decoration: none; }
.login-links a:hover { text-decoration: underline; }
.login-links-sep { color: var(--text-2); }

.login-card-topbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.login-theme-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background .15s, color .15s;
  box-shadow: 0 1px 4px rgba(0,0,0,.12), 0 0 0 1px rgba(0,0,0,.04);
  flex-shrink: 0;
}
.login-theme-btn:hover { background: #f1f5f9; color: #0f172a; }
[data-theme="dark"] .login-theme-btn {
  background: rgba(255,255,255,.18);
  border-color: rgba(255,255,255,.30);
  color: #f1f5f9;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
[data-theme="dark"] .login-theme-btn:hover {
  background: rgba(255,255,255,.28);
}
[data-theme="dark"] .login-screen {
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 60%, #1e293b 100%);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 380px;
  max-width: calc(100vw - 40px);
  box-shadow: var(--shadow-lg);
  position: relative;
}

.login-logo {
  width: 64px;
  height: 64px;
  border-radius: var(--radius);
  background: var(--primary-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  color: var(--primary);
  margin: 0 auto 20px;
}

.login-card h1 {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 6px;
  color: var(--text);
}

.login-sub {
  font-size: 13px;
  color: var(--text-2);
  text-align: center;
  margin-bottom: 28px;
}

.login-card label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 6px;
}

.login-card input[type=text] {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
  margin-bottom: 16px;
}
.login-card input[type=text]:focus { border-color: var(--primary); }

.input-password-wrap {
  position: relative;
  margin-bottom: 20px;
}
.input-password-wrap input {
  width: 100%;
  height: 40px;
  padding: 0 42px 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.input-password-wrap input:focus { border-color: var(--primary); }

.btn-eye {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  padding: 0;
}
.btn-eye:hover { color: var(--text-2); }

.btn-full {
  width: 100%;
  height: 42px;
  justify-content: center;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
}

.login-error {
  margin-top: 12px;
  font-size: 13px;
  color: var(--danger);
  text-align: center;
  min-height: 1em;
}

/* ===== App Screen Layout ===== */
.app-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ===== Topbar ===== */
.topbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  flex-shrink: 0;
  z-index: 10;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 110px;
}

.brand-svg {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.3px;
}

.topbar-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.bucket-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
}
.bucket-pill i { font-size: 14px; color: var(--primary); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 110px;
  justify-content: flex-end;
}

.topbar-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background .15s, color .15s;
}
.topbar-icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
.btn-bandwidth-active { color: var(--primary) !important; }

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  margin-left: 4px;
  transition: opacity .15s;
}
.user-avatar:hover { opacity: .85; }

/* ===== Toolbar ===== */
.toolbar {
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
}

.breadcrumb {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
}
.breadcrumb a {
  color: var(--primary);
  cursor: pointer;
  text-decoration: none;
  padding: 2px 4px;
  border-radius: 4px;
}
.breadcrumb a:hover { background: var(--primary-surface); }
.breadcrumb .sep { color: var(--text-3); padding: 0 2px; }
.breadcrumb .current { color: var(--text); font-weight: 500; padding: 2px 4px; }

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

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-3);
  font-size: 15px;
  pointer-events: none;
}
.search-input {
  height: 34px;
  padding: 0 32px 0 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  width: 190px;
  outline: none;
  transition: border-color .15s, width .2s;
}
.search-input:focus { border-color: var(--primary); width: 230px; }
.search-input::placeholder { color: var(--text-3); }
.search-clear {
  position: absolute;
  right: 4px;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  padding: 0;
  font-size: 14px;
}
.search-clear:hover { background: var(--surface-2); color: var(--text-2); }

.btn-toolbar {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn-toolbar:hover { background: var(--surface-2); }

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

.btn-toolbar-danger {
  color: var(--danger);
  border-color: var(--border);
}
.btn-toolbar-danger:hover { background: var(--danger-surface); border-color: var(--danger); }

.btn-invisible { display: none !important; }

/* ===== Stats Row ===== */
.stats-row {
  display: flex;
  gap: 14px;
  padding: 14px 20px;
  background: var(--bg);
  flex-shrink: 0;
}

.stat-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-icon-blue  { background: #eff6ff; color: #3b82f6; }
.stat-icon-amber { background: #fffbeb; color: #f59e0b; }
.stat-icon-green { background: #f0fdf4; color: #22c55e; }
[data-theme="dark"] .stat-icon-blue  { background: rgba(59,130,246,.15); }
[data-theme="dark"] .stat-icon-amber { background: rgba(245,158,11,.15); }
[data-theme="dark"] .stat-icon-green { background: rgba(34,197,94,.15); }

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 3px;
}

.stat-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.stat-storage-body {
  flex: 1;
  min-width: 0;
}

.stat-bar {
  margin-top: 8px;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.stat-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width .4s ease;
}

/* ===== File Area ===== */
.file-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 20px;
  background: var(--bg);
  position: relative;
  min-height: 0;
}

.drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(59,130,246,.07);
  border: 2px dashed var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
  border-radius: var(--radius);
}
.drop-overlay.active { opacity: 1; pointer-events: all; }
.drop-overlay > div { text-align: center; color: var(--primary); }
.drop-overlay i { font-size: 48px; display: block; margin-bottom: 12px; }
.drop-overlay p { font-size: 16px; font-weight: 500; }

/* ===== File Table ===== */
.file-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.file-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
}

.file-count-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: .6px;
}

.status-selected-label {
  font-size: 13px;
  color: var(--primary);
  font-weight: 500;
}

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

.file-table th {
  padding: 9px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .5px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
.file-table th.sortable { cursor: pointer; }
.file-table th.sortable:hover { color: var(--text-2); }

.file-table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--text);
}
.file-table tbody tr:last-child td { border-bottom: none; }
.file-table tbody tr:hover td { background: var(--primary-surface); }
.file-table tbody tr.selected td { background: var(--primary-surface); }

.col-check { width: 40px; padding-right: 0 !important; }
.col-name  { }
.col-size  { width: 110px; color: var(--text-2) !important; font-size: 13px; }
.col-date  { width: 148px; color: var(--text-2) !important; font-size: 13px; }
.col-actions { width: 100px; text-align: right; }

.sort-icon { font-size: 13px; color: var(--text-3); margin-left: 4px; }
.sort-icon.active { color: var(--primary); }

.file-name {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.file-name-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== File Type Circles ===== */
.ftype-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.ftype-folder  { background: #f59e0b; font-size: 16px; }
.ftype-pdf     { background: #ef4444; }
.ftype-img     { background: #f59e0b; }
.ftype-sheet   { background: #16a34a; }
.ftype-doc     { background: #2563eb; }
.ftype-zip     { background: #7c3aed; }
.ftype-db      { background: #0ea5e9; }
.ftype-default { background: #64748b; }

/* ===== File Type Badges ===== */
.ftype-badge {
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.ftype-badge-pdf     { background: #fef2f2; color: #dc2626; }
.ftype-badge-img     { background: #fffbeb; color: #b45309; }
.ftype-badge-sheet   { background: #f0fdf4; color: #15803d; }
.ftype-badge-doc     { background: #eff6ff; color: #1d4ed8; }
.ftype-badge-zip     { background: #f5f3ff; color: #6d28d9; }
.ftype-badge-db      { background: #f0f9ff; color: #0369a1; }
.ftype-badge-default { background: var(--surface-2); color: var(--text-2); }

[data-theme="dark"] .ftype-badge-pdf     { background: rgba(239,68,68,.15);   color: #f87171; }
[data-theme="dark"] .ftype-badge-img     { background: rgba(245,158,11,.15);  color: #fbbf24; }
[data-theme="dark"] .ftype-badge-sheet   { background: rgba(22,163,74,.15);   color: #4ade80; }
[data-theme="dark"] .ftype-badge-doc     { background: rgba(37,99,235,.15);   color: #60a5fa; }
[data-theme="dark"] .ftype-badge-zip     { background: rgba(124,58,237,.15);  color: #a78bfa; }
[data-theme="dark"] .ftype-badge-db      { background: rgba(14,165,233,.15);  color: #38bdf8; }
[data-theme="dark"] .ftype-badge-default { background: rgba(100,116,139,.15); color: var(--text-2); }

/* ===== Drop Zone Hint ===== */
.drop-zone-hint {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  color: var(--text-3);
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: border-color .15s, color .15s;
}
.drop-zone-hint i { font-size: 26px; }
.drop-zone-hint span { font-size: 13px; }
.drop-zone-hint:hover { border-color: var(--primary); color: var(--primary); }

/* ===== Empty / Loading States ===== */
.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-3);
}
.empty-state i { font-size: 40px; display: block; margin-bottom: 12px; }
.empty-state p { font-size: 15px; font-weight: 500; color: var(--text-2); }
.empty-state span { font-size: 13px; display: block; margin-top: 4px; }

.search-empty { padding: 40px !important; text-align: center; color: var(--text-2); }

/* ===== Statusbar ===== */
.statusbar {
  height: 30px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  font-size: 12px;
  color: var(--text-2);
  flex-shrink: 0;
}

.status-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(34,197,94,.2);
}

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

.status-size { color: var(--text-3); }

/* ===== Row Actions ===== */
.row-action {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background .12s, color .12s;
}
.row-action:hover { background: var(--surface-2); color: var(--text-2); }

.row-action-danger {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background .12s, color .12s;
}
.row-action-danger:hover { background: var(--danger-surface); color: var(--danger); }

/* ===== Upload / Download Panels ===== */
.upload-panel {
  position: fixed;
  bottom: 46px;
  right: 20px;
  width: 340px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 100;
}
#download-panel { right: 376px; }

@media (max-width: 780px) {
  #download-panel { right: 20px; bottom: 420px; }
}

.upload-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.panel-timer {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-3);
  margin-left: 6px;
}

.upload-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.upload-item:last-child { border-bottom: none; }

.upload-item-name {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text);
}
.upload-item-name > span:first-of-type {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-item-size {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
}

.progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 4px;
}
.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  width: 0%;
  transition: width .15s;
}
.progress-bar.done  { background: var(--success); }
.progress-bar.error { background: var(--danger); }

.upload-item-status {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
}
.upload-pct   { font-weight: 500; color: var(--text-2); }
.upload-speed { color: var(--text-3); }

.item-cancel-btn {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  padding: 0;
  transition: background .12s, color .12s;
}
.item-cancel-btn:hover { background: var(--danger-surface); color: var(--danger); }
.item-cancel-btn:disabled { opacity: .35; cursor: default; }

.btn-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  padding: 0;
  transition: background .12s;
}
.btn-icon:hover { background: var(--surface-2); }

/* ===== Row Menu ===== */
.row-menu {
  position: fixed;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  min-width: 164px;
  overflow: hidden;
}
.row-menu-item {
  width: 100%;
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: none;
  border: none;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background .1s;
}
.row-menu-item:hover { background: var(--surface-2); }

/* ===== Dialogs ===== */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  backdrop-filter: blur(2px);
}

.dialog {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 420px;
  max-width: calc(100vw - 40px);
  box-shadow: var(--shadow-lg);
}
.dialog-wide { width: 520px; }

.dialog h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.dialog input[type=text] {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
  margin-bottom: 16px;
}
.dialog input[type=text]:focus { border-color: var(--primary); }

.dialog-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 6px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.confirm-message {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ===== Buttons ===== */
.btn-ghost {
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
.btn-ghost:hover { background: var(--surface-2); }

.btn-primary {
  height: 36px;
  padding: 0 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .15s;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-danger-solid {
  height: 36px;
  padding: 0 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--danger);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .15s;
}
.btn-danger-solid:hover { background: var(--danger-hover); }

/* ===== Folder Picker ===== */
.folder-picker {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  overflow: hidden;
}

.picker-nav {
  padding: 8px 12px;
  background: var(--surface-2);
  font-size: 12px;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}

.picker-list {
  max-height: 180px;
  overflow-y: auto;
}

.picker-item {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background .1s;
}
.picker-item:hover { background: var(--surface-2); }
.picker-item-up { color: var(--text-3); }
.picker-selected { background: var(--primary-surface); color: var(--primary); }

.picker-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

/* ===== Bandwidth Panel ===== */
.bandwidth-panel {
  position: fixed;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  width: 240px;
}

.bandwidth-panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.bandwidth-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.bandwidth-input {
  flex: 1;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.bandwidth-input:focus { border-color: var(--primary); }

.bandwidth-unit { font-size: 12px; color: var(--text-3); }
.bandwidth-hint { font-size: 11px; color: var(--text-3); margin-bottom: 12px; }

.bandwidth-save {
  width: 100%;
  justify-content: center;
  height: 34px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  z-index: 500;
  white-space: nowrap;
  box-shadow: var(--shadow);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.success { background: #166534; color: #fff; }
.toast.error   { background: #991b1b; color: #fff; }

/* ===== Preview Modal ===== */
.preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.87);
  z-index: 400;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.preview-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.1);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background .15s;
}
.preview-close:hover { background: rgba(255,255,255,.22); }

.preview-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 60px 20px 20px;
  min-height: 0;
}

.preview-img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.preview-pdf {
  width: 900px;
  max-width: calc(100vw - 40px);
  height: calc(100vh - 160px);
  border: none;
  border-radius: var(--radius-sm);
}

.preview-loading {
  color: rgba(255,255,255,.6);
  font-size: 36px;
}

.preview-footer {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(0,0,0,.5);
  width: 100%;
}

.preview-name {
  color: #fff;
  font-size: 14px;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preview-dl-btn { text-decoration: none; }

/* ===== Misc ===== */
.icon-folder { color: #f59e0b; }

@keyframes _ti-spin { to { transform: rotate(360deg); } }
.ti-spin { animation: _ti-spin 1s linear infinite; display: inline-block; }
