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

:root {
  --sidebar-w: 220px;
  --sidebar-bg: #1a1a2e;
  --sidebar-text: #a0aec0;
  --sidebar-text-active: #ffffff;
  --sidebar-active-bg: rgba(255,255,255,0.08);
  --sidebar-hover-bg: rgba(255,255,255,0.05);
  --sidebar-accent: #4299e1;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1a202c;
  --text-muted: #718096;
  --text-sm: #4a5568;
  --accent: #3182ce;
  --accent-hover: #2b6cb0;
  --danger: #e53e3e;
  --success: #38a169;
  --warning: #d69e2e;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

/* --- Themes --------------------------------------------- */
[data-theme="dark"] {
  --sidebar-bg: #0a0a14;
  --sidebar-text: #8892a4;
  --sidebar-text-active: #e2e8f0;
  --sidebar-active-bg: rgba(255,255,255,0.1);
  --sidebar-hover-bg: rgba(255,255,255,0.06);
  --sidebar-accent: #60a5fa;
  --bg: #0f172a;
  --surface: #1e293b;
  --border: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-sm: #cbd5e1;
  --accent: #60a5fa;
  --accent-hover: #3b82f6;
}
[data-theme="sunrise"] {
  --sidebar-bg: #7c2d12;
  --sidebar-text: #fed7aa;
  --sidebar-text-active: #fff7ed;
  --sidebar-active-bg: rgba(255,255,255,0.12);
  --sidebar-hover-bg: rgba(255,255,255,0.07);
  --sidebar-accent: #fb923c;
  --bg: #fff7ed;
  --surface: #ffffff;
  --border: #fed7aa;
  --text: #431407;
  --text-muted: #9a3412;
  --text-sm: #7c2d12;
  --accent: #ea580c;
  --accent-hover: #c2410c;
}
[data-theme="forest"] {
  --sidebar-bg: #14532d;
  --sidebar-text: #bbf7d0;
  --sidebar-text-active: #f0fdf4;
  --sidebar-active-bg: rgba(255,255,255,0.1);
  --sidebar-hover-bg: rgba(255,255,255,0.06);
  --sidebar-accent: #4ade80;
  --bg: #f0fdf4;
  --surface: #ffffff;
  --border: #bbf7d0;
  --text: #14532d;
  --text-muted: #166534;
  --text-sm: #15803d;
  --accent: #16a34a;
  --accent-hover: #15803d;
}
[data-theme="ocean"] {
  --sidebar-bg: #164e63;
  --sidebar-text: #a5f3fc;
  --sidebar-text-active: #ecfeff;
  --sidebar-active-bg: rgba(255,255,255,0.1);
  --sidebar-hover-bg: rgba(255,255,255,0.06);
  --sidebar-accent: #22d3ee;
  --bg: #ecfeff;
  --surface: #ffffff;
  --border: #a5f3fc;
  --text: #164e63;
  --text-muted: #0e7490;
  --text-sm: #0891b2;
  --accent: #0891b2;
  --accent-hover: #0e7490;
}
[data-theme="purple"] {
  --sidebar-bg: #3b0764;
  --sidebar-text: #e9d5ff;
  --sidebar-text-active: #faf5ff;
  --sidebar-active-bg: rgba(255,255,255,0.1);
  --sidebar-hover-bg: rgba(255,255,255,0.06);
  --sidebar-accent: #c084fc;
  --bg: #faf5ff;
  --surface: #ffffff;
  --border: #e9d5ff;
  --text: #3b0764;
  --text-muted: #7e22ce;
  --text-sm: #6b21a8;
  --accent: #9333ea;
  --accent-hover: #7e22ce;
}
[data-theme="rose"] {
  --sidebar-bg: #881337;
  --sidebar-text: #fecdd3;
  --sidebar-text-active: #fff1f2;
  --sidebar-active-bg: rgba(255,255,255,0.1);
  --sidebar-hover-bg: rgba(255,255,255,0.06);
  --sidebar-accent: #fb7185;
  --bg: #fff1f2;
  --surface: #ffffff;
  --border: #fecdd3;
  --text: #881337;
  --text-muted: #be123c;
  --text-sm: #9f1239;
  --accent: #e11d48;
  --accent-hover: #be123c;
}
[data-theme="orange"] {
  --sidebar-bg: #431407;
  --sidebar-text: #fed7aa;
  --sidebar-text-active: #fff7ed;
  --sidebar-active-bg: rgba(255,255,255,0.1);
  --sidebar-hover-bg: rgba(255,255,255,0.06);
  --sidebar-accent: #fb923c;
  --bg: #fff7ed;
  --surface: #ffffff;
  --border: #fed7aa;
  --text: #1c1917;
  --text-muted: #78350f;
  --text-sm: #92400e;
  --accent: #f97316;
  --accent-hover: #ea580c;
}
[data-theme="graphite"] {
  --sidebar-bg: #111827;
  --sidebar-text: #9ca3af;
  --sidebar-text-active: #f9fafb;
  --sidebar-active-bg: rgba(255,255,255,0.08);
  --sidebar-hover-bg: rgba(255,255,255,0.04);
  --sidebar-accent: #9ca3af;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --border: #d1d5db;
  --text: #111827;
  --text-muted: #6b7280;
  --text-sm: #374151;
  --accent: #374151;
  --accent-hover: #1f2937;
}
[data-theme="sapphire"] {
  --sidebar-bg: #1e1b4b;
  --sidebar-text: #c7d2fe;
  --sidebar-text-active: #eef2ff;
  --sidebar-active-bg: rgba(255,255,255,0.1);
  --sidebar-hover-bg: rgba(255,255,255,0.06);
  --sidebar-accent: #818cf8;
  --bg: #eef2ff;
  --surface: #ffffff;
  --border: #c7d2fe;
  --text: #1e1b4b;
  --text-muted: #4338ca;
  --text-sm: #3730a3;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
}
[data-theme="contrast"] {
  --sidebar-bg: #000000;
  --sidebar-text: #e5e5e5;
  --sidebar-text-active: #ffff00;
  --sidebar-active-bg: rgba(255,255,0,0.15);
  --sidebar-hover-bg: rgba(255,255,255,0.08);
  --sidebar-accent: #ffff00;
  --bg: #ffffff;
  --surface: #ffffff;
  --border: #000000;
  --text: #000000;
  --text-muted: #333333;
  --text-sm: #1a1a1a;
  --accent: #0000cc;
  --accent-hover: #000099;
}

body {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

button, input, select {
  font: inherit;
}

/* --- App shell: sidebar + main -------------------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --------------------------------------------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  color: var(--sidebar-text-active);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.brand-icon {
  width: 22px;
  height: 22px;
  color: var(--sidebar-accent);
  flex-shrink: 0;
}

.nav-list {
  list-style: none;
  padding: 8px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 18px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 0;
  transition: background 150ms, color 150ms;
  text-align: left;
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-text-active);
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
  border-left: 3px solid var(--sidebar-accent);
  padding-left: 15px;
}

.nav-section-label {
  padding: 16px 18px 4px;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.3);
  font-weight: 600;
}

/* --- Main content area ----------------------------------- */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 28px 32px;
  overflow-y: auto;
}

/* --- Views ----------------------------------------------- */
.view { display: block; }
.view.hidden { display: none; }

/* --- Page header ----------------------------------------- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.page-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

/* --- Stats grid ------------------------------------------ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  box-shadow: var(--shadow-sm);
}

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-value {
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.stat-value--sm {
  font-size: 18px;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 20px;
  height: 20px;
}

.stat-icon--blue { background: #ebf8ff; color: #3182ce; }
.stat-icon--green { background: #f0fff4; color: #38a169; }
.stat-icon--red { background: #fff5f5; color: #e53e3e; }

/* --- Card ------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 20px;
}

.card-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

/* --- Buttons --------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  transition: opacity 150ms, background 150ms, transform 120ms;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.55; cursor: wait; }
.btn:not(:disabled):hover { opacity: 0.88; }
.btn:not(:disabled):active { transform: scale(0.97); }

.btn--primary {
  background: var(--accent);
  color: #fff;
}
.btn--primary:not(:disabled):hover { background: var(--accent-hover); opacity: 1; }

.btn--secondary {
  background: #edf2f7;
  color: var(--text-sm);
}

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn--danger {
  background: #fff0f0;
  color: var(--danger);
  border: 1px solid #fecaca;
}
.btn--danger:not(:disabled):hover { background: #fee2e2; opacity: 1; }

.btn--sm { padding: 5px 11px; font-size: 12.5px; }

/* --- Table ----------------------------------------------- */
.table-wrap { overflow-x: auto; }

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

.data-table th,
.data-table td {
  padding: 11px 20px;
  text-align: left;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-weight: 600;
  color: var(--text-muted);
  background: #fafbfc;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafbfc; }

.empty-row {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 20px !important;
}

/* --- Status badges --------------------------------------- */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.status-badge--ok,
.status-badge--completed { background: #c6f6d5; color: #22543d; }
.status-badge--partial,
.status-badge--completed-with-errors { background: #fefcbf; color: #744210; }
.status-badge--error { background: #fed7d7; color: #742a2a; }
.status-badge--running { background: #bee3f8; color: #2a4365; }

/* --- Profiles layout ------------------------------------- */
.profiles-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  align-items: start;
}

/* --- Profile form ---------------------------------------- */
.profile-form {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.form-field {
  display: grid;
  gap: 6px;
}

.form-field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sm);
}

.form-field input[type='text'],
.form-fieldset input[type='text'] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 150ms;
}

.form-field input:focus {
  outline: none;
  border-color: var(--accent);
}

.form-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.form-fieldset legend {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sm);
  padding: 0 4px;
}

.radio-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.radio-card {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fafbfc;
  cursor: pointer;
}

.radio-card span {
  font-weight: 600;
  font-size: 13px;
}

.radio-card small {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* --- Container picker ------------------------------------ */
.container-picker {
  display: grid;
  gap: 8px;
}

.picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.picker-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sm);
}

.container-options {
  display: grid;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
}

.container-option {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
}

.container-option:hover { background: #f7faff; }

.container-option strong {
  display: block;
  font-size: 13px;
}

.container-option small {
  font-size: 11.5px;
  color: var(--text-muted);
}

.state {
  font-size: 11px;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  text-transform: uppercase;
}

.state.running { color: var(--success); }
.state.exited, .state.created { color: var(--text-muted); }

/* --- Form actions ---------------------------------------- */
.form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* --- Profiles list --------------------------------------- */
.profiles-list {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.profile-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  background: #fafbfc;
  display: grid;
  gap: 10px;
}

.profile-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.profile-card h3 {
  font-size: 14px;
  font-weight: 600;
}

.profile-card p {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.profile-card code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  color: var(--text-sm);
  display: inline-block;
  margin-top: 2px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  background: #ebf4ff;
  color: #2b6cb0;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 500;
}

.card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.run-actions {
  display: grid;
  gap: 6px;
}

.mode-picker {
  display: grid;
  gap: 4px;
}

.mode-picker span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
}

.mode-select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  padding: 6px 8px;
  font-size: 13px;
}

/* --- Restore block --------------------------------------- */
.restore-block {
  display: grid;
  gap: 8px;
}

.restore-block h4 {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.backup-history {
  display: grid;
  gap: 6px;
}

.backup-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition: background 150ms;
}

.backup-item:hover { background: #f7faff; }

.backup-item strong {
  display: block;
  font-size: 13px;
}

.backup-item small {
  font-size: 12px;
  color: var(--text-muted);
}

.backup-item em {
  font-style: normal;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  font-size: 13px;
}

.backup-error {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--danger);
}

/* --- Run progress ---------------------------------------- */
.run-progress { display: grid; }
.run-progress.hidden { display: none; }

.progress-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  background: #f0f7ff;
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.progress-header,
.progress-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}

.progress-header small,
.progress-label-row { color: var(--text-muted); }

.progress-block { display: grid; gap: 5px; }

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(49,130,206,0.15);
  overflow: hidden;
}

.progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #63b3ed, #3182ce);
  transition: width 220ms ease;
}

.current-file {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-log {
  max-height: 120px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 6px 8px;
  display: grid;
  gap: 3px;
}

.progress-log small {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* --- Badge ----------------------------------------------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  font-family: 'IBM Plex Mono', monospace;
  background: #ebf4ff;
  color: #2b6cb0;
}

.badge--accent {
  background: #ebf4ff;
  color: #2b6cb0;
}

.badge--full {
  background: #e6ffed;
  color: #276749;
}

.badge--incremental {
  background: #fef3c7;
  color: #92400e;
}

/* --- Incremental backup row ------------------------------ */
.incremental-row td:first-child {
  padding-left: 28px;
  color: var(--text-muted);
  font-size: 13px;
}

.incremental-row {
  background: rgba(0,0,0,0.015);
}

/* --- Empty states ---------------------------------------- */
.empty-state {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
}

.empty-inline {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* --- Servers grid ---------------------------------------- */
.servers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.server-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 8px;
}

.server-card h3 { font-size: 14px; font-weight: 600; }
.server-card small { font-size: 12.5px; color: var(--text-muted); }

/* --- Backups view ---------------------------------------- */
#backupsViewList { display: grid; gap: 16px; }

/* --- Toast ----------------------------------------------- */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  font-size: 13.5px;
  z-index: 100;
}

.toast.error {
  background: #fff5f5;
  border-color: #feb2b2;
  color: var(--danger);
}

.hidden { display: none !important; }

/* --- Sidebar footer / logout ----------------------------- */
.sidebar-footer {
  margin-top: auto;
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.sidebar-logout {
  width: 100%;
  justify-content: center;
  color: var(--sidebar-text);
}
.sidebar-logout:hover { color: #fff; }

/* --- Login overlay --------------------------------------- */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 15, 30, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px 36px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.login-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 12px;
  margin-bottom: 4px;
}
.login-card h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}
.login-card p {
  font-size: 0.875rem;
  color: var(--text-muted);
}
.login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 8px;
}
.login-error {
  font-size: 0.8rem;
  color: var(--danger);
  text-align: center;
}
.btn--full { width: 100%; justify-content: center; }

/* --- Settings view --------------------------------------- */
.settings-card {
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.settings-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.settings-section h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.settings-section p {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.settings-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  max-width: 280px;
}
.settings-select:focus { outline: 2px solid var(--accent); }
.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text);
}
.toggle-label input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.auth-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* --- About view ------------------------------------------ */
.about-card {
  max-width: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}
.about-logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.about-logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
  border-radius: 16px;
}
.about-logo-wrap h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}
.about-description {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 480px;
  line-height: 1.6;
}
.about-version-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
  max-width: 380px;
}
.about-version-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.about-version-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.about-version-item strong {
  font-size: 1.1rem;
  color: var(--text);
}
.about-update-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.about-update-status {
  font-size: 0.875rem;
  color: var(--text-muted);
}
.about-changelog {
  width: 100%;
  text-align: left;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.about-changelog h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}
.changelog-content h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  margin: 10px 0 6px;
}
.changelog-content ul {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.changelog-content li {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.changelog-content h5.changelog-section {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 8px 0 4px;
}
.changelog-loading {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}
.about-author {
  margin-top: 1.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

/* --- Modal ----------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
}

#profileFormModal {
  z-index: 60;
}

#volumePickerModal {
  z-index: 70;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
}

.modal-card {
  position: relative;
  width: min(580px, calc(100vw - 24px));
  max-height: min(80vh, 600px);
  overflow: auto;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  padding: 20px;
  display: grid;
  gap: 12px;
}

.modal-card--wide {
  width: min(720px, calc(100vw - 24px));
  max-height: min(90vh, 800px);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.modal-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.modal-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.modal-options {
  display: grid;
  gap: 6px;
}

.modal-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fafbfc;
  cursor: pointer;
}

.modal-option strong { font-size: 13px; display: block; }
.modal-option small { font-size: 12px; color: var(--text-muted); }

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

.volume-blocked { opacity: 0.5; cursor: not-allowed; }

/* --- Dir Input Group ------------------------------------- */
.dir-input-group {
  display: flex;
  gap: 6px;
  align-items: center;
}

.dir-input-group input {
  flex: 1;
  min-width: 0;
}

.dir-browse-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
}

/* --- Dir Browser Modal ----------------------------------- */
#dirBrowserModal {
  z-index: 80;
}

.dir-browser-card {
  width: min(520px, calc(100vw - 24px));
  max-height: min(75vh, 560px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dir-browser-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
  min-height: 34px;
}

.dir-browser-current-path {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--text);
  word-break: break-all;
}

.dir-browser-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 120px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.dir-browser-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: background 0.1s;
  user-select: none;
}

.dir-browser-item:hover {
  background: var(--bg);
}

.dir-browser-item--up {
  color: var(--text-muted);
  font-style: italic;
}

.dir-browser-item svg {
  flex-shrink: 0;
  color: var(--accent, #3b82f6);
}

.dir-browser-item--up svg {
  color: var(--text-muted);
}

.dir-browser-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px 0;
}

/* --- Responsive ------------------------------------------ */
@media (max-width: 900px) {
  :root { --sidebar-w: 60px; }
  .sidebar-brand span,
  .nav-item span,
  .nav-section-label { display: none; }
  .nav-item { justify-content: center; padding: 10px; }
  .nav-item.active { padding-left: 10px; border-left-width: 3px; }
  .main-content { padding: 20px 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .profiles-layout { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
}
