/* ========== CSS VARIABLES ========== */
:root {
  --primary: #6366f1;
  --primary-rgb: 99, 102, 241;
  --secondary: #22d3ee;
  --secondary-rgb: 34, 211, 238;
  --radius: 16px;
  --radius-sm: 10px;
  --section-gap: 28px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg-base: #0b0d13;
  --bg-surface: #12141c;
  --bg-card: #181a24;
  --bg-card-hover: #1e2030;
  --text-primary: #f0f0f5;
  --text-secondary: #8b8fa3;
  --text-tertiary: #7a7e93;
  --border: rgba(255,255,255,0.05);
  --border-hover: rgba(255,255,255,0.1);
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --noise-opacity: 0.03;
  --chart-grid: rgba(255,255,255,0.05);
  --row-alt: rgba(255,255,255,0.02);
  /* Legacy aliases for JS compatibility */
  --bg: #0b0d13;
  --card: #181a24;
  --card-hover: #1e2030;
  --text: #f0f0f5;
  --text-dim: #8b8fa3;
  --text-muted: #5a5e73;
  --chart-text: #5a5e73;
  --blue: var(--primary);
  --blue-light: #818cf8;
  --green: #22c55e;
  --orange: #f59e0b;
  --red: #ef4444;
  --mini-bar-bg: #12141c;
}

[data-theme="light"] {
  --bg-base: #f3f4f8;
  --bg-surface: #eaebf0;
  --bg-card: #ffffff;
  --bg-card-hover: #f8f8fb;
  --text-primary: #1a1c2b;
  --text-secondary: #6b6f85;
  --text-tertiary: #9b9fb3;
  --border: rgba(0,0,0,0.06);
  --border-hover: rgba(0,0,0,0.12);
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
  --noise-opacity: 0.015;
  --chart-grid: rgba(0,0,0,0.06);
  --row-alt: rgba(0,0,0,0.02);
  /* Legacy aliases for JS compatibility */
  --bg: #f3f4f8;
  --card: #ffffff;
  --card-hover: #f8f8fb;
  --text: #1a1c2b;
  --text-dim: #6b6f85;
  --text-muted: #9b9fb3;
  --chart-text: #9b9fb3;
  --blue: var(--primary);
  --blue-light: #818cf8;
  --green: #16a34a;
  --orange: #d97706;
  --red: #dc2626;
  --mini-bar-bg: #eaebf0;
}

/* ========== RESET & BASE ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
*:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

body {
  font-family: 'DM Sans', -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}

/* Noise texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  opacity: var(--noise-opacity);
  pointer-events: none;
  z-index: 9999;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px;
}

.mono { font-family: 'JetBrains Mono', monospace; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 60px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.card:hover { border-color: var(--border-hover); }

.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 16px;
}

/* ========== HEADER ========== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: background var(--transition), border-color var(--transition);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: relative;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo svg { width: 18px; height: 18px; fill: white; }
.logo-text {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 10px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
.transfer-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  max-width: 40vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
  flex-shrink: 0;
}
.status-dot.paused { background: #f59e0b; box-shadow: 0 0 8px rgba(245, 158, 11, 0.5); }
.status-dot.error { background: #ef4444; box-shadow: 0 0 8px rgba(239, 68, 68, 0.5); }
.status-dot.complete { background: var(--secondary); box-shadow: 0 0 8px rgba(var(--secondary-rgb), 0.5); }
.status-dot.active { animation: pulse 2s infinite; }
.wall-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-tertiary);
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px rgba(34,197,94,0.5); }
  50% { opacity: 0.6; box-shadow: 0 0 16px rgba(34,197,94,0); }
}
@keyframes ctaGlow {
  0%, 100% { box-shadow: 0 4px 14px rgba(var(--primary-rgb),0.3); }
  50% { box-shadow: 0 4px 24px rgba(var(--primary-rgb),0.6), 0 0 40px rgba(var(--primary-rgb),0.15); }
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.btn-icon {
  padding: 7px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
}
.btn-icon:hover { border-color: var(--border-hover); color: var(--text-primary); background: var(--bg-card); }
.btn-icon svg { width: 18px; height: 18px; }

.session-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-tertiary);
}
.schedule-badge {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  font-family: var(--mono);
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.2);
}


/* ========== BIG PROGRESS ========== */
.progress-section {
  padding: 40px 36px 36px;
  margin-top: var(--section-gap);
  text-align: center;
}
.progress-percentage {
  font-family: 'JetBrains Mono', monospace;
  font-size: 72px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.progress-bar-container {
  margin: 24px auto 20px;
  max-width: 600px;
  position: relative;
}
.progress-bar-track {
  height: 8px;
  border-radius: 4px;
  background: var(--bg-surface);
  overflow: hidden;
  position: relative;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 2s ease;
  position: relative;
  min-width: 4px;
}
.progress-bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 4px;
  background: linear-gradient(90deg, transparent 60%, rgba(255,255,255,0.3));
  animation: shimmer 2s infinite;
}
@keyframes shimmer {
  0% { opacity: 0.3; }
  50% { opacity: 0.8; }
  100% { opacity: 0.3; }
}
.progress-glow {
  position: absolute;
  bottom: -6px;
  left: 0;
  height: 16px;
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(var(--primary-rgb),0.3), rgba(var(--secondary-rgb),0.3));
  filter: blur(12px);
  transition: width 2s ease;
  pointer-events: none;
}
.progress-meta {
  display: flex;
  justify-content: center;
  gap: 32px;
  color: var(--text-secondary);
  font-size: 14px;
}
.progress-meta span { display: flex; align-items: center; gap: 6px; }
.progress-meta .val { color: var(--text-primary); font-family: 'JetBrains Mono', monospace; font-weight: 500; }
.progress-sub-bars {
  display: flex;
  gap: 16px;
  margin-top: 20px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}
.sub-bar-wrap { flex: 1; }
.sub-bar-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.sub-bar-label span { color: var(--text-primary); font-weight: 500; font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.sub-track { height: 6px; background: var(--bg-surface); border-radius: 3px; overflow: hidden; }
.sub-fill { height: 100%; border-radius: 3px; transition: width 2s ease; }
.sub-fill.files { background: linear-gradient(90deg, var(--primary), rgba(var(--primary-rgb),0.7)); }
.sub-fill.checks { background: linear-gradient(90deg, var(--secondary), rgba(var(--secondary-rgb),0.7)); }
.session-note { font-size: 12px; color: var(--text-tertiary); margin-top: 8px; font-family: 'JetBrains Mono', monospace; }
.finish-time {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  padding: 6px 16px;
  background: rgba(var(--primary-rgb), 0.06);
  border-radius: 8px;
  display: inline-block;
}

/* ========== CONTROL BAR ========== */
#controlBar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  margin-bottom: 0;
  flex-wrap: wrap;
}
.ctrl-btn {
  padding: 7px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-card);
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ctrl-btn:hover { background: var(--bg-card-hover); border-color: var(--border-hover); color: var(--text-primary); }
.ctrl-btn:active { transform: scale(0.97); }
.ctrl-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.ctrl-btn.pause { color: #f87171; border-color: rgba(248,113,113,0.2); }
.ctrl-btn.pause:hover { color: #fca5a5; border-color: rgba(248,113,113,0.4); background: rgba(248,113,113,0.08); }
.ctrl-btn.resume { color: #34d399; border-color: rgba(52,211,153,0.2); }
.ctrl-btn.resume:hover { color: #6ee7b7; border-color: rgba(52,211,153,0.4); background: rgba(52,211,153,0.08); }
.ctrl-btn .spinner {
  display: inline-block; width: 10px; height: 10px; border: 2px solid currentColor;
  border-top-color: transparent; border-radius: 50%; animation: spin 0.6s linear infinite;
  margin-right: 4px; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
.ctrl-select {
  padding: 7px 12px;
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--body);
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.ctrl-select:hover {
  border-color: var(--border-hover);
  background: var(--bg-hover);
}


/* ========== STATS GRID ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: var(--section-gap);
}
.stat-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.stat-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.stat-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon.primary { background: rgba(var(--primary-rgb), 0.12); color: var(--primary); }
.stat-icon.secondary { background: rgba(var(--secondary-rgb), 0.12); color: var(--secondary); }
.stat-icon svg { width: 16px; height: 16px; }
.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.stat-sub {
  font-size: 12px;
  color: var(--text-tertiary);
}
/* Legacy color classes used by JS */
.stat-value.green, .stat-value.blue, .stat-value.purple, .stat-value.cyan { color: var(--text-primary) !important; }
.stat-value.orange, .stat-value.yellow, .stat-value.pink { color: var(--text-primary) !important; }
.stat-value.red { color: var(--red) !important; }

/* ========== SESSION TIMELINE ========== */
.timeline-section {
  margin-top: var(--section-gap);
  padding: 24px;
}
/* ========== SESSION TIMELINE (used by JS) ========== */
.timeline { position: relative; }
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot { display: none; }
.tl-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.tl-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.tl-time { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-secondary); }
.tl-stats { font-size: 12px; color: var(--text-secondary); line-height: 1.6; }
.tl-stats span { color: var(--text-primary); font-weight: 500; font-family: 'JetBrains Mono', monospace; }
.tl-pause { position: relative; padding-bottom: 16px; }
.tl-pause-inner {
  background: rgba(245,158,11,0.05); border: 1px dashed rgba(245,158,11,0.2);
  border-radius: var(--radius-sm); padding: 8px 12px; font-size: 12px; color: var(--orange);
}

/* ========== CHARTS ========== */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: var(--section-gap);
}
.chart-card {
  padding: 24px;
}
.chart-card-full {
  margin-top: var(--section-gap);
  padding: 24px;
}
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.chart-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.chart-container {
  position: relative;
  height: 200px;
  overflow: hidden;
}
.chart-svg { width: 100%; height: 100%; }

/* ========== ACTIVE TRANSFERS ========== */
.active-section {
  margin-top: var(--section-gap);
  padding: 24px;
}
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.section-header h3 {
  font-size: 13px; font-weight: 600; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.transfer-count {
  font-size: 12px; color: var(--primary);
  background: rgba(var(--primary-rgb),0.1); padding: 2px 10px; border-radius: 10px;
  font-family: 'JetBrains Mono', monospace;
}
/* ========== ACTIVE TRANSFER ITEMS ========== */
.transfer-item {
  display: grid; grid-template-columns: 1fr 140px 50px 90px 80px;
  align-items: center; gap: 12px; padding: 12px 12px;
  border-radius: var(--radius-sm); margin-bottom: 2px;
  font-size: 13px; transition: background var(--transition);
}
.transfer-item:nth-child(odd) { background: var(--row-alt); }
.transfer-item:hover { background: rgba(var(--primary-rgb),0.04); }
.transfer-item .fname {
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mini-bar { height: 4px; background: var(--bg-surface); border-radius: 2px; overflow: hidden; }
.mini-fill {
  height: 100%; border-radius: 2px; transition: width 2s ease;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
}
.transfer-item .tpct {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; font-weight: 600; color: #22c55e; text-align: right;
}
.transfer-item .tspeed {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; color: var(--secondary); text-align: right;
}
.transfer-item .teta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; color: var(--text-secondary); text-align: right;
}

/* ========== BOTTOM ROW ========== */
.bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: var(--section-gap);
  align-items: start;
}
.completed-section { padding: 24px; min-width: 0; overflow: hidden; }
/* ========== RECENT FILES ========== */
.recent-file {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border-radius: var(--radius-sm);
}
.recent-file:nth-child(odd) { background: var(--row-alt); }
.recent-file .rf-name {
  font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; margin-right: 12px;
}
.recent-file .rf-time {
  font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-tertiary); white-space: nowrap;
}
.recent-file .rf-ext { font-size: 11px; padding: 1px 6px; border-radius: 4px; margin-left: 8px; white-space: nowrap; }

.filetypes-section { padding: 24px; min-width: 0; overflow: hidden; }
/* ========== FILE TYPES ========== */
.types-grid { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.type-badge {
  display: grid; grid-template-columns: 56px 1fr 52px; align-items: center; gap: 8px; padding: 0;
  border-radius: 0; background: none; font-size: 13px;
}
.type-badge .type-name {
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  color: var(--text-secondary); text-align: right;
}
.type-badge .type-count {
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  color: var(--text-tertiary); text-align: right;
}
.type-bar {
  height: 20px; border-radius: 4px;
  min-width: 8px; transition: width 0.5s ease;
}

/* ========== ERROR ========== */
.error-section {
  background: rgba(239,68,68,0.05); border: 1px solid rgba(239,68,68,0.15);
  border-radius: var(--radius); padding: 16px 24px; margin-top: var(--section-gap); display: none;
}
.error-section.show { display: block; }
.error-section h3 {
  font-size: 13px; font-weight: 600; color: var(--red);
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px;
}
.error-item {
  font-size: 12px; color: var(--red); padding: 4px 0;
  font-family: 'JetBrains Mono', monospace;
  word-break: break-all;
}

/* ========== DAILY CHART ========== */
.daily-chart-section {
  margin-top: var(--section-gap);
  padding: 24px;
  display: none;
}

/* ========== FOOTER ========== */
.footer {
  margin-top: var(--section-gap);
  padding: 20px 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
  border-top: 1px solid var(--border);
}
.footer a { color: var(--primary); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* ========== TOAST ========== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 20px; font-size: 13px;
  color: var(--text-primary); z-index: 200; opacity: 0; transition: opacity 0.3s;
  pointer-events: none; box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; }

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ========== LOADING PULSE ========== */
.loading-pulse {
  animation: loadingPulse 1.5s ease-in-out infinite;
}
@keyframes loadingPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-row, .bottom-row { grid-template-columns: 1fr; }
  .header-center { position: static; transform: none; }
  .header-inner { flex-wrap: wrap; }
  .progress-percentage { font-size: 48px; }
  .transfer-item { grid-template-columns: 1fr 80px 40px 60px; gap: 6px; padding: 8px 6px; }
  .transfer-item .teta { display: none; }
  .progress-sub-bars { flex-direction: column; }
}
