:root {
  --bg: #f5f6fb;
  --sidebar-bg: #ffffff;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --line: #e7e9f4;
  --line-strong: #d7dbec;
  --text: #14162b;
  --muted: #6b7280;
  --accent: #6366f1;
  --accent-2: #4f46e5;
  --accent-soft: #eef0ff;
  --accent-soft-strong: #e0e3ff;
  --cyan: #06b6d4;
  --ok: #10b981;
  --ok-soft: #ecfdf5;
  --ok-line: #a7f3d0;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --danger: #e11d48;
  --danger-soft: #fef2f2;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 28px rgba(15, 23, 42, 0.06);
  /* Shared by .topbar and the sidebar brand block so the logo can never hang
     below the header's bottom border, whatever size is configured. */
  --topbar-h: 58px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(15, 23, 42, 0.14); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(15, 23, 42, 0.24); background-clip: content-box; }

.aurora { display: none; }

.app { display: flex; min-height: 100vh; }
.app[hidden] { display: none; }

/* ---------- Sidebar ---------- */

.sidebar {
  width: 268px;
  flex-shrink: 0;
  padding: 0 16px 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-right: 1px solid var(--line);
  background: var(--sidebar-bg);
  position: sticky;
  top: 0;
  height: 100vh;
}

/* Fixed-height brand bar that mirrors the topbar, so its bottom border lines up
   with the header's. overflow:hidden + max-height on the image mean an oversized
   logo scales down instead of pushing past that line. */
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-h);
  box-sizing: border-box;
  flex-shrink: 0;
  overflow: hidden;
  margin: 0 -16px;
  padding:
    var(--brand-pad-t, 0px)
    calc(22px + var(--brand-pad-r, 0px))
    0
    calc(22px + var(--brand-pad-l, 0px));
  border-bottom: 1px solid var(--line);
}

.logo img { max-height: 100%; max-width: 100%; object-fit: contain; display: block; }
.logo .logo-text { min-width: 0; }
.logo .logo-title, .logo .logo-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.logo-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 18px rgba(99, 102, 241, 0.35);
  flex-shrink: 0;
}

.logo-text { display: flex; flex-direction: column; line-height: 1.25; }
.logo-title { font-weight: 800; font-size: 1rem; letter-spacing: -0.01em; }
.logo-sub { font-size: 0.72rem; color: var(--muted); }

.nav-list { display: flex; flex-direction: column; gap: 3px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 11px;
  color: #3f4457;
  font-size: 0.885rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  background: transparent;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: #f4f5fb; color: var(--text); }

.nav-item.current {
  background: var(--accent-soft);
  color: var(--accent-2);
}

.nav-icon { width: 20px; height: 20px; flex-shrink: 0; display: grid; place-items: center; color: inherit; }
.nav-item.current .nav-icon { color: var(--accent-2); }

.help-card {
  margin-top: auto;
  background: linear-gradient(180deg, var(--accent-soft), #ffffff);
  border: 1px solid var(--accent-soft-strong);
  border-radius: 16px;
  padding: 18px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.help-illustration { width: 64px; height: 64px; margin-bottom: 6px; }
.help-card h4 { font-size: 0.9rem; font-weight: 700; }
.help-card p { font-size: 0.76rem; color: var(--muted); margin-top: 2px; margin-bottom: 12px; line-height: 1.4; }

.help-card .btn { width: 100%; justify-content: center; }

/* ---------- Topbar ---------- */

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 32px;
  min-height: var(--topbar-h);
  box-sizing: border-box;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-size: 1.08rem; font-weight: 800; letter-spacing: -0.01em; }

.step-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 99px;
  background: #f1f2f8;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

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

.run-status { display: none; align-items: center; gap: 10px; }
.run-status.show { display: flex; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: #f8f9fc;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.chip.mono { font-family: "JetBrains Mono", ui-monospace, monospace; letter-spacing: 0.02em; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }

.chip.running { color: var(--accent-2); border-color: rgba(99, 102, 241, 0.3); background: var(--accent-soft); }
.chip.running .dot { background: var(--accent); animation: pulse 1.6s infinite; }
.chip.done { color: var(--ok); border-color: var(--ok-line); background: var(--ok-soft); }
.chip.done .dot { background: var(--ok); }
.chip.error { color: var(--danger); border-color: #fecdd3; background: var(--danger-soft); }
.chip.error .dot { background: var(--danger); }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(99, 102, 241, 0); }
  100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

.icon-btn {
  width: 33px;
  height: 33px;
  display: inline-grid;
  place-items: center;
  background: #f8f9fc;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.icon-btn:hover { color: var(--text); background: #eef0f7; border-color: var(--line-strong); }

.icon-btn .badge-dot {
  position: absolute;
  top: 6px;
  right: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--panel);
}

.theme-sun { display: none; }
html[data-theme="light"] .theme-sun { display: block; }
html[data-theme="light"] .theme-moon { display: none; }
html:not([data-theme="dark"]) .theme-sun { display: block; }
html:not([data-theme="dark"]) .theme-moon { display: none; }

.profile-wrap { position: relative; }

.avatar-btn {
  width: 33px;
  height: 33px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.avatar-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-btn.lg { width: 44px; height: 44px; font-size: 1.05rem; cursor: default; }
.avatar-btn.xl { width: 72px; height: 72px; font-size: 1.7rem; cursor: default; flex-shrink: 0; }

.profile-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: 250px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 8px;
  z-index: 50;
}

.profile-menu-head {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}

.profile-menu-name { font-weight: 700; font-size: 0.88rem; }
.profile-menu-email { font-size: 0.76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 170px; }

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
}

.menu-item:hover { background: #f1f2f8; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  background: #14162b;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 11px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.28);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Main content ---------- */

main { padding: 22px 32px 26px; max-width: 1500px; width: 100%; }

.panel { display: none; }
.panel.active { display: block; animation: fadeUp 0.3s cubic-bezier(0.2, 0.7, 0.3, 1); }

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

.hero-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }
.hero-copy h2 { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; }
.hero-copy .desc { color: var(--muted); font-size: 0.88rem; margin-top: 4px; }

.gradient-text {
  background: linear-gradient(135deg, var(--accent), #a855f7);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-aside { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.hero-illustration { width: 110px; height: 60px; flex-shrink: 0; }

.credentials-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--ok-soft);
  border: 1px solid var(--ok-line);
  border-radius: 13px;
  padding: 10px 16px;
  max-width: 320px;
}

.credentials-card .icon-badge { width: 30px; height: 30px; background: #fff; border-color: var(--ok-line); color: var(--ok); flex-shrink: 0; }
.credentials-card strong { display: block; font-size: 0.8rem; font-weight: 700; color: #065f46; }
.credentials-card span { font-size: 0.72rem; color: #0f7a5c; line-height: 1.3; }

.panel-head { margin-bottom: 26px; }
h2 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; }
.desc { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }
h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 16px; letter-spacing: -0.01em; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 16px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s;
}

.card:hover { border-color: var(--line-strong); }

.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.card-head h3 { margin: 0; }
.card-sub { font-size: 0.76rem; color: var(--muted); }

.icon-badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: #f8f9fc;
  flex-shrink: 0;
}

.icon-badge.src { color: var(--accent-2); background: var(--accent-soft); border-color: var(--accent-soft-strong); }
.icon-badge.dst { color: #059669; background: var(--ok-soft); border-color: var(--ok-line); }
.icon-badge.folders { color: #0891b2; background: #ecfeff; border-color: #a5f3fc; }

.field { margin-bottom: 13px; }

.field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="date"],
select,
input:not([type]) {
  width: 100%;
  padding: 10px 14px;
  background: #f8f9fc;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.16s, box-shadow 0.16s, background 0.16s;
}

input::placeholder { color: #9aa0b4; }

input:focus, select:focus {
  outline: none;
  background: #fff;
  border-color: rgba(99, 102, 241, 0.6);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.13);
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.field-row { display: flex; gap: 14px; align-items: flex-end; }
.field-row .field { flex: 1; margin-bottom: 16px; }
.field-row .field.grow { flex: 1; }

/* Field prefix icons: wraps only the input (never the label), so
   top:50% centers on the input's own height, not label+input combined. */
.input-icon { position: relative; }
.input-icon .prefix-icon {
  position: absolute;
  z-index: 1;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: #9aa0b4;
  pointer-events: none;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1;
}
.input-icon input { padding-left: 36px; }
.input-icon .input-wrap input { padding-right: 44px; }

.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; }
.switch.compact { padding-bottom: 13px; }

.switch input { position: absolute; opacity: 0; width: 0; height: 0; }

.switch .track {
  position: relative;
  width: 44px;
  height: 25px;
  border-radius: 99px;
  background: #e2e5f1;
  border: 1px solid var(--line);
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}

.switch .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.3, 1);
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.25);
}

.switch input:checked + .track { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; }
.switch input:checked + .track .knob { transform: translateX(19px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.22); }

.switch-text { font-size: 0.86rem; font-weight: 600; display: flex; flex-direction: column; }
.switch-sub { font-size: 0.72rem; color: var(--muted); font-weight: 500; }

.switches { display: flex; gap: 34px; flex-wrap: wrap; }

.test-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.test-status { font-size: 0.78rem; color: var(--muted); }
.test-status.ok { color: var(--ok); }
.test-status.err { color: var(--danger); }
.test-status.busy { color: var(--warn); }

.folder-card { margin-bottom: 20px; }

.folder-toolbar { display: flex; gap: 10px; margin-bottom: 14px; }
.folder-toolbar input { flex: 1; }

.folder-list {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8f9fc;
  padding: 6px;
}

.folder-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.14s;
}

.folder-row:hover { background: #eef0f7; }

.folder-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.folder-name {
  flex: 1;
  font-size: 0.85rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #334155;
}

.folder-meta { font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.folder-tag {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid #a5f3fc;
  color: #0891b2;
}

.folder-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  gap: 12px;
  flex-wrap: wrap;
}

.dim { color: var(--muted); font-size: 0.78rem; }

.input-wrap { position: relative; }
.input-wrap input { padding-right: 46px; }

.reveal-btn {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  border-radius: 9px;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.reveal-btn:hover { color: var(--text); background: #eef0f7; }
.reveal-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3); }
.reveal-btn .eye-closed { display: none; }
.reveal-btn.revealed .eye-open { display: none; }
.reveal-btn.revealed .eye-closed { display: block; }

.panel-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 10px; }
.panel-actions.split { justify-content: space-between; }

.btn {
  padding: 11px 26px;
  border: none;
  border-radius: 11px;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s, opacity 0.15s, border-color 0.15s;
}

.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 22px rgba(99, 102, 241, 0.3);
}

.btn.primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 14px 28px rgba(99, 102, 241, 0.4); }

.btn.ghost {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}

.btn.ghost:hover:not(:disabled) { background: #f4f5fb; border-color: var(--line-strong); }

.btn.outline {
  background: #fff;
  color: var(--accent-2);
  border: 1px solid var(--accent-soft-strong);
}

.btn.outline:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }

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

.btn.sm { padding: 8px 16px; font-size: 0.8rem; border-radius: 10px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.progress-card { border-color: var(--accent-soft-strong); }

.stage-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.stage-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.stage-label { font-weight: 600; font-size: 0.95rem; }

.stage-pct {
  font-size: 1.1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

.spinner.hidden { display: none; }
.spinner.done { animation: none; border-color: var(--ok); border-top-color: var(--ok); }

@keyframes spin { to { transform: rotate(360deg); } }

.progress-bar {
  height: 10px;
  border-radius: 99px;
  background: #eceef7;
  border: 1px solid var(--line);
  overflow: hidden;
  margin-bottom: 22px;
}

.progress-fill {
  position: relative;
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  transition: width 0.45s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.progress-fill.running::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  animation: shimmer 1.6s linear infinite;
}

@keyframes shimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }

.stat-box {
  background: #f8f9fc;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 12px;
  text-align: center;
  transition: transform 0.18s, border-color 0.18s;
}

.stat-box:hover { transform: translateY(-2px); }
.stat-box.accent { border-color: var(--accent-soft-strong); }
.stat-box.warn { border-color: #fde68a; }
.stat-box.danger { border-color: #fecdd3; }

.stat-val { display: block; font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat-box.accent .stat-val { color: var(--accent-2); }
.stat-box.warn .stat-val { color: var(--warn); }
.stat-box.danger .stat-val { color: var(--danger); }

.stat-lbl {
  display: block;
  margin-top: 5px;
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.log-card { padding: 20px; }

.log-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.log-header h3 { margin: 0; }

.log-console {
  height: 320px;
  overflow-y: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #f8f9fc;
  padding: 12px 14px;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.76rem;
  line-height: 1.6;
}

.log-line {
  padding: 1px 0 1px 10px;
  border-left: 2px solid transparent;
  white-space: pre-wrap;
  word-break: break-word;
  color: #475569;
  animation: logIn 0.2s ease;
}

@keyframes logIn { from { opacity: 0; } to { opacity: 1; } }

.log-line.ok { color: #047857; border-color: rgba(16, 185, 129, 0.45); }
.log-line.warn { color: #92400e; border-color: rgba(217, 119, 6, 0.4); }
.log-line.error { color: #be123c; border-color: rgba(225, 29, 72, 0.45); background: rgba(225, 29, 72, 0.05); }
.log-line.info { color: #4338ca; border-color: rgba(99, 102, 241, 0.4); }

.result-card { border-width: 1px; }

.result-card.ok { background: linear-gradient(180deg, var(--ok-soft), #ffffff); border-color: var(--ok-line); }
.result-card.err { background: linear-gradient(180deg, var(--danger-soft), #ffffff); border-color: #fecdd3; }

.result-title { display: flex; align-items: center; gap: 12px; font-size: 1.15rem; font-weight: 800; margin-bottom: 6px; }
.result-msg { color: var(--muted); font-size: 0.85rem; margin-bottom: 18px; }

.result-icon { width: 34px; height: 34px; flex-shrink: 0; }
.result-icon circle { stroke-dasharray: 160; stroke-dashoffset: 160; animation: draw 0.6s ease forwards; }
.result-icon path { stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw 0.4s ease 0.35s forwards; }

@keyframes draw { to { stroke-dashoffset: 0; } }

.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.result-item {
  background: #f8f9fc;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 10px;
  text-align: center;
}

.result-item .val { display: block; font-size: 1.2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.result-item .lbl { display: block; font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 3px; font-weight: 600; }

.dry-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 99px;
  background: var(--warn-soft);
  border: 1px solid #fde68a;
  color: var(--warn);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.4);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop[hidden] { display: none; }

.modal { max-width: 460px; width: 100%; margin: 0; max-height: calc(100vh - 40px); overflow-y: auto; }

.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-head h3 { margin: 0; }

.avatar-edit { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.avatar-edit-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.avatar-edit-actions .dim { width: 100%; }

.modal-status { font-size: 0.82rem; min-height: 1.2em; margin: 4px 0 6px; }
.modal-status.ok { color: var(--ok); }
.modal-status.err { color: var(--danger); }

@media (max-width: 1080px) {
  .grid-2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .hero-row { flex-direction: column; }
}

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { position: static; height: auto; width: 100%; }
  .help-card { display: none; }
  .topbar { padding: 14px 18px; }
  main { padding: 22px 18px 48px; }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Dark theme ---------- */

html[data-theme="dark"] {
  --bg: #07070c;
  --sidebar-bg: rgba(23, 23, 32, 0.85);
  --panel: rgba(23, 23, 32, 0.72);
  --panel-strong: #1c1c28;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f4f4f8;
  --muted: #9a9aae;
  --accent: #7c5cff;
  --accent-2: #5b8cff;
  --accent-soft: rgba(124, 92, 255, 0.14);
  --accent-soft-strong: rgba(124, 92, 255, 0.35);
  --cyan: #22d3ee;
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.12);
  --ok-line: rgba(52, 211, 153, 0.35);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.12);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] .aurora {
  display: block;
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: radial-gradient(circle at 15% 0%, #14112a 0%, var(--bg) 45%);
}

html[data-theme="dark"] .blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  animation: drift 22s ease-in-out infinite alternate;
}

html[data-theme="dark"] .blob.b1 { width: 520px; height: 520px; background: #6d28d9; top: -160px; left: -120px; }
html[data-theme="dark"] .blob.b2 { width: 460px; height: 460px; background: #0e7490; top: 30%; right: -180px; animation-duration: 28s; }
html[data-theme="dark"] .blob.b3 { width: 400px; height: 400px; background: #be185d; bottom: -180px; left: 30%; opacity: 0.32; animation-duration: 34s; }

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(60px, -40px, 0) scale(1.12); }
}

html[data-theme="dark"] .sidebar { border-right: 1px solid var(--line); backdrop-filter: blur(18px); }
html[data-theme="dark"] .topbar { background: rgba(9, 9, 14, 0.6); backdrop-filter: blur(16px); }
html[data-theme="dark"] .card { backdrop-filter: blur(14px); }
html[data-theme="dark"] .nav-item { color: var(--muted); }
html[data-theme="dark"] .nav-item:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }
html[data-theme="dark"] .nav-item.current { background: var(--accent-soft); color: #cbd5ff; }
html[data-theme="dark"] .help-card { background: linear-gradient(180deg, rgba(124, 92, 255, 0.14), rgba(23, 23, 32, 0.4)); border-color: var(--accent-soft-strong); }
html[data-theme="dark"] .credentials-card { background: rgba(52, 211, 153, 0.1); border-color: var(--ok-line); }
html[data-theme="dark"] .credentials-card strong { color: #86efac; }
html[data-theme="dark"] .credentials-card span { color: #a7f3d0; }
html[data-theme="dark"] .credentials-card .icon-badge { background: rgba(255, 255, 255, 0.05); }

html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] select,
html[data-theme="dark"] input:not([type]) {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line);
  color: var(--text);
}

html[data-theme="dark"] input::placeholder { color: rgba(255, 255, 255, 0.28); }
html[data-theme="dark"] input:focus, html[data-theme="dark"] select:focus { background: rgba(124, 92, 255, 0.07); }
html[data-theme="dark"] .field-icon .prefix-icon { color: var(--muted); }

html[data-theme="dark"] .switch .track { background: rgba(255, 255, 255, 0.12); }
html[data-theme="dark"] .btn.ghost { background: rgba(255, 255, 255, 0.04); }
html[data-theme="dark"] .btn.ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.09); }
html[data-theme="dark"] .btn.outline { background: transparent; color: #cbd5ff; }
html[data-theme="dark"] .btn.outline:hover:not(:disabled) { background: var(--accent-soft); }

html[data-theme="dark"] .chip { background: rgba(255, 255, 255, 0.04); }
html[data-theme="dark"] .step-badge { background: rgba(255, 255, 255, 0.06); }
html[data-theme="dark"] .icon-btn { background: rgba(255, 255, 255, 0.04); }
html[data-theme="dark"] .icon-btn:hover { background: rgba(255, 255, 255, 0.09); }
html[data-theme="dark"] .icon-btn .badge-dot { border-color: var(--panel-strong); }

html[data-theme="dark"] .avatar-btn { border: 1px solid var(--line-strong); }
html[data-theme="dark"] .profile-menu { background: var(--panel-strong); border-color: var(--line-strong); backdrop-filter: blur(14px); }
html[data-theme="dark"] .menu-item:hover { background: rgba(255, 255, 255, 0.07); }
html[data-theme="dark"] .menu-item.danger:hover { background: rgba(251, 113, 133, 0.12); }
html[data-theme="dark"] .reveal-btn:hover { background: rgba(255, 255, 255, 0.08); }

html[data-theme="dark"] .stage-pct { background: linear-gradient(135deg, #a5b4fc, var(--cyan)); -webkit-background-clip: text; background-clip: text; color: transparent; }
html[data-theme="dark"] .spinner { border-color: rgba(255, 255, 255, 0.15); }
html[data-theme="dark"] .progress-bar { background: rgba(255, 255, 255, 0.07); }
html[data-theme="dark"] .stat-box { background: rgba(0, 0, 0, 0.28); }
html[data-theme="dark"] .stat-box.accent .stat-val { color: #a5b4fc; }

html[data-theme="dark"] .folder-list { background: rgba(0, 0, 0, 0.22); }
html[data-theme="dark"] .folder-row:hover { background: rgba(255, 255, 255, 0.05); }
html[data-theme="dark"] .folder-name { color: inherit; }

html[data-theme="dark"] .log-console { background: rgba(0, 0, 0, 0.42); border-color: var(--line); }
html[data-theme="dark"] .log-line { color: #b9b9c9; }
html[data-theme="dark"] .log-line.ok { color: #86efac; }
html[data-theme="dark"] .log-line.warn { color: #fcd34d; }
html[data-theme="dark"] .log-line.error { color: #fda4af; }
html[data-theme="dark"] .log-line.info { color: #a5b4fc; }

html[data-theme="dark"] .result-item { background: rgba(0, 0, 0, 0.3); }
html[data-theme="dark"] .modal-backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(4px); }

html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); background-clip: content-box; border: 3px solid transparent; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.22); background-clip: content-box; border: 3px solid transparent; }

/* ==========================================================================
   Views, tables, tabs and admin components
   ========================================================================== */

.view { display: none; }
.view.active { display: block; animation: fadeUp 0.3s cubic-bezier(0.2, 0.7, 0.3, 1); }

.nav-bottom { margin-top: auto; }
.sidebar .help-card + .nav-bottom { margin-top: 16px; }

/* ------------------------------------------------------------- sign-in */

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card { max-width: 400px; width: 100%; }

.login-card .card-head { margin-bottom: 18px; }

/* The brand block is centred on the sign-in screens.
   The markup is rendered by the server and has two shapes — a name (optionally
   beside a mark) or a logo image — so both are handled here rather than in the
   template. .card-head is already a flex row, so centring its main axis centres
   whichever shape it holds; text-align carries into the name and tagline.
   The logo image is inline in the light theme but display:block in the dark
   one, so it needs the auto margins as well to stay centred in both. */
.login-card .card-head { justify-content: center; text-align: center; }
.login-card .card-head > div:not(.logo-mark) { justify-content: center; }
.login-card .card-head .brand-img { margin-left: auto; margin-right: auto; }

/* Both theme variants are in the DOM; CSS picks the one that matches. */
.brand-img.dark { display: none; }
html[data-theme="dark"] .has-dark .brand-img.light { display: none; }
html[data-theme="dark"] .has-dark .brand-img.dark { display: block; }

.oauth-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }

.oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel-strong);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.oauth-btn:hover { background: var(--panel-2); border-color: var(--line-strong); }
.oauth-btn.disabled { opacity: 0.45; pointer-events: none; }

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 14px;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.form-row-right { display: flex; justify-content: flex-end; margin: -4px 0 2px; }

.text-link {
  color: var(--accent-2);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
}
.text-link:hover { text-decoration: underline; }

.alt-link {
  margin-top: 14px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}
.alt-link a { color: var(--accent-2); font-weight: 600; text-decoration: none; }
.alt-link a:hover { text-decoration: underline; }

.login-card .grid-2 { gap: 12px; margin-bottom: 0; }

/* -------------------------------------------------------- form messages */

.form-error, .form-ok {
  font-size: 0.83rem;
  font-weight: 600;
  padding: 9px 13px;
  border-radius: 10px;
  margin-bottom: 12px;
}
.form-error { color: var(--danger); background: var(--danger-soft); border: 1px solid #fecdd3; }
.form-ok { color: var(--ok); background: var(--ok-soft); border: 1px solid var(--ok-line); }
.form-error[hidden], .form-ok[hidden] { display: none; }

/* --------------------------------------------------------- notifications */

.notif-wrap { position: relative; }

.notif-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: 340px;
  max-height: 420px;
  display: flex;
  flex-direction: column;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 50;
  overflow: hidden;
}

.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent-2);
  font-size: 0.76rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
}
.link-btn:hover { text-decoration: underline; }

.notif-list { overflow-y: auto; }

.notif-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid transparent;
}
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--accent-soft); }
.notif-item.level-success { border-left-color: var(--ok); }
.notif-item.level-warning { border-left-color: var(--warn); }
.notif-item.level-info { border-left-color: var(--accent); }

.notif-title { font-size: 0.85rem; font-weight: 700; }
.notif-msg { font-size: 0.79rem; color: var(--muted); margin-top: 2px; line-height: 1.45; }
.notif-time { font-size: 0.7rem; color: var(--muted); margin-top: 6px; }
.notif-empty { padding: 26px 14px; text-align: center; color: var(--muted); font-size: 0.82rem; }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }

.data-table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  white-space: nowrap;
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafbff; }
html[data-theme="dark"] .data-table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }

.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table .actions-col { text-align: right; white-space: nowrap; }

.cell-sub { font-size: 0.73rem; color: var(--muted); margin-top: 2px; }

.user-cell { display: flex; align-items: center; gap: 10px; }

.avatar-btn.sm { width: 30px; height: 30px; font-size: 0.75rem; cursor: default; flex-shrink: 0; }

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: capitalize;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}
.status-badge.completed { color: var(--ok); background: var(--ok-soft); border-color: var(--ok-line); }
.status-badge.failed { color: var(--danger); background: var(--danger-soft); border-color: #fecdd3; }
.status-badge.aborted { color: var(--warn); background: var(--warn-soft); border-color: #fde68a; }
.status-badge.role-admin { color: var(--accent-2); background: var(--accent-soft); border-color: var(--accent-soft-strong); }
.status-badge.role-user { color: var(--muted); background: #f1f2f8; border-color: var(--line); }
html[data-theme="dark"] .status-badge.role-user { background: rgba(255, 255, 255, 0.06); }

.row-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }

.inline-search {
  width: auto !important;
  min-width: 200px;
  padding: 8px 12px !important;
  font-size: 0.82rem !important;
}

.empty-state {
  text-align: center;
  padding: 34px 20px;
  color: var(--muted);
}
.empty-state svg { color: var(--line-strong); margin-bottom: 10px; }
.empty-state p { font-size: 0.86rem; }
.empty-state[hidden] { display: none; }

.icon-btn.sm { width: 28px; height: 28px; border-radius: 8px; }

/* ------------------------------------------------------------------ tabs */

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #f1f2f8;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 20px;
  width: fit-content;
}
html[data-theme="dark"] .tabs { background: rgba(255, 255, 255, 0.05); }

.tab {
  padding: 8px 20px;
  border: none;
  background: transparent;
  border-radius: 9px;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--panel); color: var(--accent-2); box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08); }

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeUp 0.25s ease; }

/* ------------------------------------------------------ branding editor */

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 900px) { .grid-3 { grid-template-columns: 1fr; } }

.upload-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.upload-preview {
  width: 58px;
  height: 44px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #f8f9fc;
  font-size: 0.68rem;
  color: var(--muted);
  overflow: hidden;
  flex-shrink: 0;
}
html[data-theme="dark"] .upload-preview { background: rgba(255, 255, 255, 0.04); }
.upload-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }

.color-row { display: flex; gap: 8px; align-items: center; }

.color-row input[type="color"] {
  width: 46px;
  height: 40px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  cursor: pointer;
  flex-shrink: 0;
}

.hex-input { font-family: "JetBrains Mono", ui-monospace, monospace; text-transform: lowercase; }

.radio-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 99px;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--panel);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.radio-pill input { accent-color: var(--accent); cursor: pointer; }
.radio-pill:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-2);
}

.range-value { color: var(--accent-2); font-weight: 700; font-variant-numeric: tabular-nums; }

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  padding: 0;
  background: transparent;
  border: none;
}

textarea {
  width: 100%;
  padding: 10px 14px;
  background: #f8f9fc;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.16s, box-shadow 0.16s, background 0.16s;
}
textarea:focus {
  outline: none;
  background: #fff;
  border-color: rgba(99, 102, 241, 0.6);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.13);
}
html[data-theme="dark"] textarea { background: rgba(255, 255, 255, 0.04); }
html[data-theme="dark"] textarea:focus { background: rgba(124, 92, 255, 0.07); }

/* ------------------------------------------------------- sent messages */

.sent-list { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; }

.sent-item {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 11px;
  background: #f8f9fc;
}
html[data-theme="dark"] .sent-item { background: rgba(255, 255, 255, 0.03); }
.sent-item.level-success { border-left-color: var(--ok); }
.sent-item.level-warning { border-left-color: var(--warn); }

.sent-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 0.87rem; }
.sent-msg { font-size: 0.8rem; color: var(--muted); margin: 4px 0 6px; line-height: 1.45; }

/* ------------------------------------------------------------- profile */

.profile-card { max-width: 720px; }

/* A class rule with `display` beats the UA [hidden] rule, so anything toggled
   via the hidden attribute needs its own escape hatch. Same trap that once
   left the admin shell painted behind the sign-in card. */
.step-badge[hidden] { display: none; }
.notif-menu[hidden] { display: none; }
.avatar-btn img[hidden] { display: none; }
.run-status[hidden] { display: none; }

/* -------------------------------------------- notification menu footer */

.notif-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: #fafbff;
}
html[data-theme="dark"] .notif-foot { background: rgba(255, 255, 255, 0.03); }

/* ------------------------------------------------ notifications page */

.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.page-size { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--muted); }

.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: #f1f2f8;
  border: 1px solid var(--line);
  border-radius: 10px;
}
html[data-theme="dark"] .seg { background: rgba(255, 255, 255, 0.05); }

.seg button {
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--panel); color: var(--accent-2); box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08); }

.notif-feed { display: flex; flex-direction: column; gap: 10px; }

.notif-row {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  background: var(--panel);
}
.notif-row.unread { background: var(--accent-soft); }
.notif-row.level-success { border-left-color: var(--ok); }
.notif-row.level-warning { border-left-color: var(--warn); }

.notif-row .notif-body { flex: 1; min-width: 0; }
.notif-row .notif-title { font-size: 0.9rem; }
.notif-row .notif-msg { font-size: 0.84rem; }
.notif-row .notif-time { white-space: nowrap; }

.unread-pill {
  align-self: flex-start;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-2);
  background: var(--panel);
  border: 1px solid var(--accent-soft-strong);
  border-radius: 99px;
  padding: 2px 9px;
}

/* ================================================ admin settings additions */

.req { color: var(--danger); font-weight: 700; }

/* The dark-variant preview sits on a dark plate so a white logo is visible. */
.upload-preview.dark-preview { background: #1b1d2b; border-color: #2a2d3f; }
html[data-theme="dark"] .upload-preview.dark-preview { background: #101220; }

.size-row { margin-bottom: 16px; }
.size-row .field { margin-bottom: 0; }

.switch-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.switch-row input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row input { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.78rem; }

.panel-actions .spacer { flex: 1; }
.btn.ghost.danger-text { color: var(--danger); border-color: #f4c3cd; }
.btn.ghost.danger-text:hover { background: var(--danger-soft); }
html[data-theme="dark"] .btn.ghost.danger-text { border-color: rgba(244, 63, 94, 0.4); }

.empty-cell { text-align: center; color: var(--muted); padding: 26px 12px !important; font-size: 0.85rem; }

/* ------------------------------------------------------- template picker */

.tpl-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }

.tpl-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-strong);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.tpl-card:hover { border-color: var(--line-strong); }
.tpl-card.current { border-color: var(--accent); background: var(--accent-soft); }
.tpl-card-title { font-size: 0.85rem; font-weight: 700; color: var(--text); }
.tpl-card-when { font-size: 0.74rem; color: var(--muted); line-height: 1.4; }

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

.var-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.74rem;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--accent-2);
  cursor: pointer;
}
.var-chip:hover { border-color: var(--accent); background: var(--accent-soft); }

.tpl-frame {
  width: 100%;
  height: 420px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f5f6fb;
}

#tpl-editor[hidden], #tpl-preview-card[hidden] { display: none; }

.user-cell .cell-sub { font-size: 0.73rem; color: var(--muted); }

/* Inline hints inside a label must not change its line box, or the inputs in a
   two-column row stop lining up. */
.field label .dim,
.field label .req {
  font-size: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  vertical-align: baseline;
}
.field label .dim { font-weight: 500; text-transform: none; letter-spacing: 0.02em; }

.card > .desc { margin: -8px 0 16px; }
.card > .desc code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em; }
#tpl-when { margin: -10px 0 16px; }

/* ========================================================== rich text editor */

.rte {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  overflow: hidden;
}
.rte:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.rte-bar {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-strong);
}

.rte-btn {
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 28px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.82rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.rte-btn:hover { background: var(--panel-2); color: var(--text); }
.rte-btn.active { background: var(--accent-soft); color: var(--accent-2); border-color: var(--accent-soft-strong); }
html[data-theme="dark"] .rte-btn:hover { background: rgba(255, 255, 255, 0.07); }

.rte-block {
  /* The global rule stretches every select to 100%; the toolbar needs it inline. */
  width: auto;
  flex: 0 0 auto;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

.rte-sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
.rte-grow { flex: 1; }
.rte-source { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.rte-body {
  min-height: 210px;
  max-height: 460px;
  overflow-y: auto;
  padding: 14px 16px;
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text);
  outline: none;
}
.rte-body[hidden] { display: none; }
.rte-body:empty::before { content: "Write the email body…"; color: var(--muted); }

/* The editor previews the email's own typography, not the admin panel's. */
.rte-body p { margin: 0 0 12px; }
.rte-body h1 { font-size: 1.2rem; font-weight: 700; margin: 0 0 10px; }
.rte-body h2 { font-size: 1.05rem; font-weight: 700; margin: 0 0 10px; }
.rte-body h3 { font-size: 0.95rem; font-weight: 700; margin: 0 0 10px; }
.rte-body ul, .rte-body ol { margin: 0 0 12px; padding-left: 22px; }
.rte-body li { margin-bottom: 5px; }
.rte-body blockquote {
  margin: 0 0 12px;
  padding: 6px 14px;
  border-left: 3px solid var(--line-strong);
  color: var(--muted);
}
.rte-body a { color: var(--accent-2); text-decoration: underline; }
.rte-body > *:last-child { margin-bottom: 0; }

.rte-html {
  display: block;
  width: 100%;
  min-height: 210px;
  padding: 14px 16px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  resize: vertical;
}
.rte-html:focus { outline: none; box-shadow: none; }
.rte-html[hidden] { display: none; }

/* ------------------------------------------------- rich editor: images */

/* Matches the inline styles the mailer applies, so the editor shows what sends. */
.rte-body img { display: block; max-width: 100%; height: auto; margin: 0 0 12px; border-radius: 6px; }
.rte-body img.rte-img-selected { outline: 2px solid var(--accent); outline-offset: 2px; }

.rte-imgbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  background: var(--panel-strong);
  font-size: 0.78rem;
}
.rte-imgbar[hidden] { display: none; }
.rte-imgbar-label { font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.rte-imgbar-field {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-weight: 600;
}
.rte-imgbar-field input {
  width: 84px;
  height: 30px;
  padding: 0 9px;
  font-size: 0.8rem;
  border-radius: 8px;
}
.rte-imgbar-alt { flex: 1; min-width: 180px; }
.rte-imgbar-alt input { width: 100%; }
