:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --text: #111827;
  --muted: #667085;
  --border: #e5e7eb;
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-soft: #eef2ff;
  --success: #16a34a;
  --success-soft: #ecfdf3;
  --warning: #d97706;
  --warning-soft: #fff7ed;
  --danger: #dc2626;
  --danger-soft: #fff1f2;
  --info: #0284c7;
  --info-soft: #eff6ff;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 6px 24px rgba(15, 23, 42, 0.06);
  --radius: 14px;
  --sidebar-w: 252px;
  --gap: 20px;
  --content-pad: 28px;
}

/* ─── Reset ─── */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  margin: 0;
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 14px;
  letter-spacing: -0.006em;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--brand); text-decoration: none; }

/* ─── App Shell ─── */
.app { min-height: 100vh; display: flex; }

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-w);
  position: fixed;
  inset: 0 auto 0 0;
  background: #0f172a;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform .25s ease;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.sidebar::-webkit-scrollbar {
  display: none;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -1px;
  box-shadow: 0 6px 20px rgba(99,102,241,.3);
}
.brand strong { color: white; display: block; font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }
.brand span { font-size: 11px; color: #94a3b8; letter-spacing: 0; }

.nav-section { padding: 16px 12px 4px; }
.nav-label { padding: 0 10px 6px; font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: #526077; font-weight: 600; }
.nav-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  margin-bottom: 2px;
  text-align: left;
  transition: background .15s ease, color .15s ease;
  position: relative;
  font-size: 13px;
  font-weight: 500;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: white; }
.nav-item.active { background: linear-gradient(90deg, rgba(99,102,241,.22), rgba(124,58,237,.14)); color: white; font-weight: 600; }
.nav-item.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 4px; background: #818cf8; }
.nav-icon { width: 18px; height: 18px; display: inline-grid; place-items: center; flex: 0 0 auto; font-size: 15px; opacity: .85; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-badge { margin-left: auto; min-width: 22px; height: 19px; border-radius: 999px; display: grid; place-items: center; padding: 0 6px; background: rgba(255,255,255,.08); font-size: 10px; font-weight: 600; }

.sidebar-footer { margin-top: auto; padding: 14px 12px 18px; border-top: 1px solid rgba(255,255,255,.08); }
.workspace {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255,255,255,.05);
}
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: #312e81; color: #e0e7ff; font-size: 13px; }
.workspace strong { color: white; font-size: 13px; display: block; }
.workspace span { color: #94a3b8; font-size: 11px; }

/* ─── Main Content ─── */
.main { margin-left: var(--sidebar-w); width: calc(100% - var(--sidebar-w)); min-height: 100vh; }

/* ─── Topbar ─── */
.topbar {
  height: 60px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(16px) saturate(1.8);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--content-pad);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.mobile-menu { display: none; border: 0; background: transparent; padding: 8px; border-radius: 8px; font-size: 20px; }
.page-title { font-size: 16px; font-weight: 700; white-space: nowrap; letter-spacing: -0.02em; }
.search {
  width: min(360px, 38vw);
  position: relative;
}
.search input {
  width: 100%;
  height: 36px !important;
  min-height: 36px !important;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 36px 0 34px !important;
  background: var(--panel-2);
  outline: none;
  transition: .2s ease;
  font-size: 13px;
}
.search input:focus { border-color: #a5b4fc; box-shadow: 0 0 0 3px rgba(99,102,241,.1); background: #fff; }
.search-icon { position: absolute; left: 10px; top: 9px; width: 16px; color: #98a2b3; }
.shortcut { position: absolute; right: 8px; top: 7px; font-size: 10px; color: #b0b8c4; border: 1px solid var(--border); padding: 1px 5px; border-radius: 5px; background: var(--panel); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ─── Buttons ─── */
.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #475467;
  position: relative;
  transition: .15s ease;
  font-size: 15px;
}
.icon-btn:hover { background: var(--panel-2); }
.indicator { position: absolute; right: 7px; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: #ef4444; border: 2px solid white; }

.primary-btn, .secondary-btn, .ghost-btn, .danger-btn {
  border-radius: 9px;
  padding: 8px 16px;
  border: 1px solid transparent;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  font-size: 13px;
  transition: .15s ease;
  white-space: nowrap;
  letter-spacing: -0.006em;
}
.primary-btn { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: white; box-shadow: 0 1px 3px rgba(79,70,229,.2), 0 4px 12px rgba(79,70,229,.15); }
.primary-btn:hover { filter: brightness(1.04); transform: translateY(-1px); box-shadow: 0 2px 6px rgba(79,70,229,.25), 0 8px 20px rgba(79,70,229,.18); }
.secondary-btn { background: var(--panel); color: #344054; border-color: var(--border); box-shadow: 0 1px 2px rgba(16,24,40,.05); }
.secondary-btn:hover { background: var(--panel-2); }
.ghost-btn { background: transparent; color: #475467; border-color: transparent; }
.ghost-btn:hover { background: var(--panel-2); }
.danger-btn { background: var(--danger); color: white; }
.danger-btn:hover { filter: brightness(1.05); }

/* ─── Content Area ─── */
.content { padding: var(--content-pad); }
.view { display: none; }
.view.active {
  display: block;
  animation: smoothFadeIn 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

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

/* Apply transitions to layout blocks, cards, and dashboards on render */
.card,
.panel,
.table-card,
.settings-grid,
.setup-checklist,
.engine-ov-card,
.stats-grid,
.settings-section,
.form-grid,
.health-list {
  animation: tabContentSmooth 0.26s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Sidebar Nav Items Transition */
.nav-item {
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
}
.nav-item:hover {
  transform: translateX(3px);
  background: rgba(255, 255, 255, 0.08) !important;
  color: white !important;
}
.nav-item.active {
  transform: translateX(3px);
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.28), rgba(124, 58, 237, 0.2)) !important;
  color: white !important;
}

/* Engine Tab Button Transitions */
.engine-tabs button {
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
  border-radius: 8px;
}
.engine-tabs button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
.engine-tabs button:active {
  transform: scale(0.97);
}
.engine-tabs button.active {
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

/* Action Dropdown Menu enter animation */
@keyframes dropdownEnter {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(-4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
.action-dropdown-menu {
  animation: dropdownEnter 0.15s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}


/* ─── Hero Row ─── */
.hero-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.hero-row h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: -.025em; font-weight: 750; line-height: 1.2; }
.hero-row p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ─── Stats Grid ─── */
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  transition: .2s ease;
}
.stat-card:hover { box-shadow: 0 4px 16px rgba(15,23,42,.08); transform: translateY(-1px); }
.stat-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 15px; }
.stat-icon.purple { background: var(--brand-soft); color: var(--brand); }
.stat-icon.green { background: var(--success-soft); color: var(--success); }
.stat-icon.orange { background: var(--warning-soft); color: var(--warning); }
.stat-icon.blue { background: var(--info-soft); color: var(--info); }
.stat-value { font-size: 26px; font-weight: 750; letter-spacing: -.03em; }
.stat-foot { margin-top: 6px; display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.trend-up { color: var(--success); font-weight: 700; }
.trend-down { color: var(--danger); font-weight: 700; }

/* ─── Panels ─── */
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(320px, .9fr); gap: var(--gap); margin-bottom: var(--gap); }
.grid-equal { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-header { padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); }
.panel-title { font-weight: 700; font-size: 14px; letter-spacing: -0.01em; }
.panel-subtitle { font-size: 11px; color: var(--muted); margin-top: 2px; }
.panel-body { padding: 16px 20px; }

/* ─── Charts ─── */
.chart-wrap { height: 260px; position: relative; }
.chart-grid { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; }
.chart-grid span { border-top: 1px dashed #e5e7eb; }
.chart-labels { position: absolute; left: 0; right: 0; bottom: -4px; display: grid; grid-template-columns: repeat(7,1fr); color: #98a2b3; font-size: 10px; text-align: center; }
.line-svg { position: absolute; inset: 12px 12px 28px 12px; width: calc(100% - 24px); height: calc(100% - 40px); overflow: visible; }
.legend { display: flex; gap: 16px; align-items: center; font-size: 11px; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 5px; }

/* ─── Health List ─── */
.health-list { display: grid; gap: 8px; }
.health-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; transition: .15s ease; }
.health-item:hover { border-color: #c7d2fe; }
.health-left { display: flex; align-items: center; gap: 10px; }
.health-status { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.health-status.ok { background: var(--success); box-shadow: 0 0 0 4px rgba(22,163,74,.1); }
.health-status.warn { background: var(--warning); box-shadow: 0 0 0 4px rgba(217,119,6,.1); }
.health-status.error { background: var(--danger); box-shadow: 0 0 0 4px rgba(220,38,38,.1); }
.health-item strong { font-size: 13px; display: block; }
.health-item span { color: var(--muted); font-size: 11px; }
.health-value { font-size: 12px; font-weight: 600; color: #344054; white-space: nowrap; }

/* ─── Activity List ─── */
.activity-list { display: grid; }
.activity { display: grid; grid-template-columns: 32px 1fr auto; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: start; }
.activity:last-child { border-bottom: 0; }
.activity-icon { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--panel-2); color: #475467; font-size: 13px; }
.activity strong { font-size: 13px; }
.activity p { margin: 2px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.activity time { font-size: 11px; color: #98a2b3; white-space: nowrap; }

/* ─── Toolbar ─── */
.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar-left, .toolbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-input, #searchBox {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 11px center;
  background-size: 15px;
  padding: 0 12px 0 34px;
  outline: none;
  color: #344054;
  font-size: 13px;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.filter-input { min-width: 220px; }
.filter-input:focus, #searchBox:focus {
  border-color: #a5b4fc;
  box-shadow: 0 0 0 3px rgba(99,102,241,.1);
  background-color: #fff;
}
.filter-select {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  padding: 0 12px;
  outline: none;
  color: #344054;
  font-size: 13px;
  transition: .2s ease;
  cursor: pointer;
}
.filter-select:focus {
  border-color: #a5b4fc;
  box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}

/* ─── Tables ─── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 880px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: #667085; background: #f8fafc; padding: 10px 16px; border-bottom: 1px solid var(--border); font-weight: 600; white-space: nowrap; }
td { padding: 11px 16px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: #f8faff; }
tbody tr:last-child td { border-bottom: none; }
.row-main { display: flex; align-items: center; gap: 10px; }
.mini-avatar { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: #eef2ff; color: var(--brand); font-size: 11px; font-weight: 800; flex-shrink: 0; }
.row-title { font-weight: 600; color: #101828; font-size: 13px; }
.row-sub { font-size: 11px; color: #98a2b3; margin-top: 1px; }

/* ─── Badges ─── */
.badge { display: inline-flex; align-items: center; gap: 5px; min-height: 22px; border-radius: 999px; padding: 2px 9px; font-size: 11px; font-weight: 600; white-space: nowrap; letter-spacing: 0; }
.badge.green { background: var(--success-soft); color: var(--success); }
.badge.orange { background: var(--warning-soft); color: var(--warning); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.blue { background: var(--info-soft); color: var(--info); }
.badge.purple { background: var(--brand-soft); color: var(--brand); }
.badge.gray { background: #f2f4f7; color: #475467; }

/* ─── Progress ─── */
.progress { width: 100px; height: 6px; background: #eef2f6; border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }

/* ─── Kebab Menu ─── */
.kebab { border: 0; background: transparent; width: 32px; height: 32px; border-radius: 8px; color: #667085; font-size: 15px; transition: .15s ease; }
.kebab:hover { background: #f2f4f7; }

/* ─── Mailbox Cards ─── */
.mailbox-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: var(--gap); }
.mailbox-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); transition: .2s ease; }
.mailbox-card:hover { box-shadow: 0 4px 16px rgba(15,23,42,.08); transform: translateY(-1px); }
.mailbox-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.mailbox-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mailbox-logo { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: #fff1f2; color: #dc2626; font-weight: 800; font-size: 13px; flex-shrink: 0; }
.mailbox-id strong { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.mailbox-id span { color: var(--muted); font-size: 11px; }
.toggle { width: 40px; height: 22px; border-radius: 999px; background: #d0d5dd; position: relative; transition: .2s; border: 0; flex-shrink: 0; }
.toggle::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: white; top: 3px; left: 3px; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.toggle.on { background: var(--success); }
.toggle.on::after { transform: translateX(18px); }
.mailbox-metrics { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-bottom: 14px; }
.metric { background: var(--panel-2); border-radius: 9px; padding: 10px; }
.metric strong { font-size: 14px; display: block; font-weight: 700; }
.metric span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.meter { height: 5px; border-radius: 999px; background: #eef2f6; overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: inherit; background: var(--success); }
.mailbox-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 11px; color: var(--muted); }

/* ─── Reply Cards ─── */
.reply-list { display: grid; gap: 12px; }
.reply-card { border: 1px solid var(--border); border-radius: 14px; padding: 16px; display: grid; grid-template-columns: 46px 1fr auto; gap: 12px; background: white; transition: .2s; }
.reply-card:hover { border-color: #c7d2fe; box-shadow: 0 8px 24px rgba(79,70,229,.08); }
.reply-avatar { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: #ecfeff; color: #0f766e; font-weight: 800; font-size: 14px; }
.reply-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.reply-head strong { font-size: 13px; }
.reply-sub { color: var(--muted); font-size: 11px; margin-top: 2px; }
.reply-text { margin-top: 10px; color: #344054; font-size: 13px; line-height: 1.55; }
.reply-meta { text-align: right; min-width: 130px; }
.reply-meta time { color: #98a2b3; font-size: 11px; display: block; margin-bottom: 8px; }

/* ─── Settings Layout ─── */
.settings-layout { display: grid; grid-template-columns: 230px 1fr; gap: 18px; }
.settings-menu { background: white; border: 1px solid var(--border); border-radius: 14px; padding: 8px; height: fit-content; }
.settings-tab { width: 100%; border: 0; background: transparent; text-align: left; padding: 11px 12px; border-radius: 9px; color: #475467; font-weight: 600; margin-bottom: 3px; font-size: 13px; transition: .15s ease; }
.settings-tab:hover { background: var(--panel-2); }
.settings-tab.active { background: var(--brand-soft); color: var(--brand); }
.settings-pane { display: none; }
.settings-pane.active { display: block; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.modal-form { display: grid; gap: 18px; margin-top: 18px; }
.field { display: grid; gap: 7px; }
.field label { font-size: 12px; font-weight: 700; color: #344054; }
.field small { color: #98a2b3; }
.field input, .field select, .field textarea { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; outline: none; background: white; font-size: 13px; transition: .2s ease; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #a5b4fc; box-shadow: 0 0 0 3px rgba(99,102,241,.08); }
.field.full { grid-column: 1 / -1; }
.settings-section { padding-bottom: 22px; margin-bottom: 22px; border-bottom: 1px solid var(--border); }
.settings-section:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.settings-section h3 { margin: 0 0 6px; font-size: 16px; }
.settings-section > p { margin: 0 0 16px; color: var(--muted); font-size: 12px; }

/* ─── Empty States ─── */
.empty-state { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.empty-icon { width: 48px; height: 48px; border-radius: 14px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin: 0 auto 12px; font-size: 20px; }

/* ─── Modals ─── */
.modal-backdrop, .drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.48);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  z-index: 100;
}
.modal-backdrop.open, .drawer-backdrop.open { opacity: 1; visibility: visible; }
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.48);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: grid;
  place-items: center;
}
.modal.hidden {
  display: none !important;
}
.modal-card {
  position: relative;
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 80px);
  background: white;
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(15,23,42,.28);
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
}
.modal-header, .modal-footer { padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-header { border-bottom: 1px solid var(--border); }
.modal-footer { border-top: 1px solid var(--border); justify-content: flex-end; gap: 8px; }
.modal-body { padding: 20px; max-height: 60vh; overflow-y: auto; }
.close-btn { border: 0; background: #f2f4f7; border-radius: 9px; width: 34px; height: 34px; color: #667085; font-size: 16px; transition: .15s ease; }
.close-btn:hover { background: #e5e7eb; }
.modal-card .close-btn { position: absolute; right: 18px; top: 18px; z-index: 50; }

/* ─── Drawer ─── */
.drawer {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(520px, 100vw);
  background: white;
  transform: translateX(100%);
  box-shadow: -20px 0 60px rgba(15,23,42,.18);
  display: flex;
  flex-direction: column;
}
.drawer-backdrop.open .drawer { transform: none; }
.drawer-header { padding: 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; }
.profile-card { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 14px; background: linear-gradient(135deg, #f8fafc, #eef2ff); margin-bottom: 18px; }
.profile-avatar { width: 54px; height: 54px; border-radius: 15px; display: grid; place-items: center; background: white; color: var(--brand); font-weight: 800; box-shadow: var(--shadow); font-size: 18px; }
.detail-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.detail { border: 1px solid var(--border); border-radius: 11px; padding: 12px; }
.detail span { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: #98a2b3; margin-bottom: 4px; }
.detail strong { font-size: 13px; }
.timeline { margin-top: 18px; }
.timeline-item { position: relative; padding: 0 0 18px 28px; }
.timeline-item::before { content: ""; position: absolute; left: 8px; top: 9px; bottom: -4px; width: 1px; background: var(--border); }
.timeline-item:last-child::before { display: none; }
.timeline-dot { position: absolute; left: 3px; top: 4px; width: 11px; height: 11px; border-radius: 50%; background: var(--brand); border: 3px solid #eef2ff; }
.timeline-item strong { font-size: 12px; }
.timeline-item p { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

/* ─── Toast ─── */
.toast-stack { position: fixed; right: 22px; bottom: 22px; display: grid; gap: 10px; z-index: 300; }
.toast { min-width: 280px; max-width: 360px; background: #101828; color: white; border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); transform: translateY(12px); opacity: 0; animation: toastIn .25s forwards; }
.toast strong { display: block; font-size: 13px; }
.toast span { color: #cbd5e1; font-size: 11px; display: block; margin-top: 3px; }
@keyframes toastIn { to { transform: none; opacity: 1; } }

/* ─── Command Palette ─── */
.command {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.42);
  backdrop-filter: blur(5px);
  z-index: 200;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}
.command.open { display: flex; }
.command-box { width: min(620px, calc(100vw - 32px)); background: white; border-radius: 16px; box-shadow: 0 30px 80px rgba(15,23,42,.3); overflow: hidden; }
.command-input { width: 100%; border: 0; border-bottom: 1px solid var(--border); padding: 18px; outline: none; font-size: 15px; }
.command-results { padding: 8px; max-height: 360px; overflow: auto; }
.command-item { width: 100%; border: 0; background: transparent; padding: 12px; border-radius: 10px; display: flex; align-items: center; justify-content: space-between; text-align: left; font-size: 13px; transition: .12s ease; }
.command-item:hover { background: var(--brand-soft); }
.command-item span { color: var(--muted); font-size: 11px; }

/* ─── UI-Only Staging Banner ─── */
.staging-banner {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  border-bottom: 1px solid #f59e0b;
}

/* ─── Dark Mode ─── */
body.dark {
  --bg: #0b1220;
  --panel: #111827;
  --panel-2: #182133;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --border: #1e293b;
  --shadow: 0 1px 3px rgba(0,0,0,.2), 0 6px 24px rgba(0,0,0,.15);
  --brand-soft: rgba(99,102,241,.14);
  --success-soft: rgba(22,163,74,.12);
  --warning-soft: rgba(217,119,6,.12);
  --danger-soft: rgba(220,38,38,.12);
  --info-soft: rgba(2,132,199,.12);
}
body.dark .topbar { background: rgba(17,24,39,.92); backdrop-filter: blur(16px) saturate(1.5); }
body.dark .panel,
body.dark .stat-card,
body.dark .mailbox-card,
body.dark .reply-card,
body.dark .settings-menu,
body.dark .modal-card,
body.dark .drawer,
body.dark .command-box { background: var(--panel); }
body.dark .modal { background: rgba(15, 23, 42, 0.6); }
body.dark .search input,
body.dark .icon-btn,
body.dark .secondary-btn,
body.dark .filter-select,
body.dark .field input,
body.dark .field select,
body.dark .field textarea { background: var(--panel-2); color: var(--text); border-color: var(--border); }
body.dark .filter-input, body.dark #searchBox {
  background: var(--panel-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 11px center;
  background-size: 15px;
  color: var(--text);
  border-color: var(--border);
}
body.dark th { background: #0f1729; }
body.dark tbody tr:hover { background: rgba(99,102,241,.04); }
body.dark .row-title,
body.dark .health-value,
body.dark .reply-text { color: var(--text); }
body.dark .metric,
body.dark .activity-icon,
body.dark .close-btn,
body.dark .kebab:hover { background: var(--panel-2); }
body.dark .staging-banner { background: linear-gradient(135deg, #451a03, #78350f); color: #fde68a; border-color: #92400e; }
body.dark .toast { background: #1e293b; }
body.dark .profile-card { background: linear-gradient(135deg, #1e293b, rgba(99,102,241,.1)); }

/* ─── Legacy Compatibility ─── */
/* These ensure the existing Advanced pages (prospector, templates, etc.) still render */
.shell { display: flex; min-height: 100vh; }
.error-screen { padding: 40px; text-align: center; }
.error-screen h1 { font-size: 24px; margin-bottom: 12px; }
.error-screen p { color: var(--muted); }

/* Legacy card, pill, mode-ribbon for Advanced pages */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 0; margin-bottom: var(--gap); box-shadow: var(--shadow); overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--border); margin-bottom: 0; }
.card-head h2 { font-size: 14px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.table-tools { display: flex; align-items: center; gap: 8px; }
.btn { border-radius: 8px; padding: 7px 14px; border: 1px solid transparent; font-weight: 600; font-size: 13px; cursor: pointer; transition: .15s ease; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.primary { background: var(--brand); color: white; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.secondary { background: white; border-color: var(--border); color: #344054; }
.btn.danger { background: var(--danger); color: white; }
.mode-ribbon { display: flex; gap: 8px; padding: 8px 20px; background: var(--panel-2); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.mode-badge { font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 6px; text-transform: uppercase; letter-spacing: .06em; }
.mode-badge.good { background: var(--success-soft); color: var(--success); }
.mode-badge.warn { background: var(--warning-soft); color: var(--warning); }
.mode-badge.neutral { background: #f2f4f7; color: #475467; }
.mode-badge.indigo { background: var(--brand-soft); color: var(--brand); }

/* Legacy pill utility */
.pill { display: inline-flex; align-items: center; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill.good { background: var(--success-soft); color: var(--success); }
.pill.warn { background: var(--warning-soft); color: var(--warning); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.indigo { background: var(--brand-soft); color: var(--brand); }

/* Legacy nav for backward compat */
.nav { flex: 1; overflow-y: auto; padding: 8px 12px; }
.nav button { width: 100%; border: 0; background: transparent; color: #cbd5e1; text-align: left; padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 2px; transition: .15s ease; }
.nav button:hover { background: rgba(255,255,255,.07); color: white; }
.nav button.active { background: rgba(99,102,241,.28); color: white; }
.subnav { padding-left: 18px; }
.subnav button { font-size: 12px; padding: 6px 10px; }
.profile { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); }
.profile span { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: #312e81; color: #e0e7ff; font-size: 12px; }
.profile strong { color: white; font-size: 13px; display: block; }
.profile small { color: #94a3b8; font-size: 11px; }

/* Legacy page header */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.page-header h1 { font-size: 22px; margin: 0 0 4px; }
.page-header p { margin: 0; color: var(--muted); font-size: 13px; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Legacy engine-tabs */
.engine-tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.engine-tabs button { border: 1px solid var(--border); background: white; border-radius: 8px; padding: 8px 14px; font-size: 12px; font-weight: 600; transition: .15s ease; }
.engine-tabs button.active { background: var(--brand); color: white; border-color: var(--brand); }
.engine-badge { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.engine-badge.good { background: var(--success-soft); color: var(--success); }
.engine-badge.warn { background: var(--warning-soft); color: var(--warning); }
.engine-badge.indigo { background: var(--brand-soft); color: var(--brand); }

/* Legacy toast-host */
.toast-host { position: fixed; top: 16px; right: 16px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }

/* ─── Responsive ─── */
@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .mailbox-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; width: 100%; }
  .mobile-menu { display: grid; place-items: center; }
  .search { display: none; }
  .content { padding: 20px 16px; }
  .hero-row { flex-direction: column; }
  .mailbox-grid, .grid-equal { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-menu { display: flex; overflow-x: auto; gap: 4px; }
  .settings-tab { white-space: nowrap; width: auto; }
}
@media (max-width: 560px) {
  .stats-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 14px; }
  .page-title { font-size: 16px; }
  .topbar-actions .primary-btn { display: none; }
  .hero-row h1 { font-size: 24px; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .reply-card { grid-template-columns: 42px 1fr; }
  .reply-meta { grid-column: 2; text-align: left; }
}

/* ─── UI V2 Corrections ─── */
.hidden { display: none !important; }

.dashboard-table {
  min-width: 100% !important;
}

button[disabled], .primary-btn[disabled], .secondary-btn[disabled], .btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed !important;
  pointer-events: none;
  filter: none !important;
  transform: none !important;
  box-shadow: none !important;
}

.staging-banner {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  border-bottom: 1px solid #f59e0b;
  word-break: break-word;
  white-space: normal;
}

/* ─── Engine Overview Cards ─── */
.engine-overview { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--gap); margin-bottom: 24px; }
.engine-ov-card {
  background: var(--bg-card, var(--panel)); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column;
  justify-content: space-between; border: 1px solid var(--line, var(--border)); border-left: 4px solid var(--engine-accent);
  transition: box-shadow .2s, transform .2s; box-shadow: var(--shadow);
}
.engine-ov-card:hover { box-shadow: 0 4px 16px rgba(15,23,42,.08); transform: translateY(-1px); }
.engine-ov-card.buying  { --engine-accent: #22c55e; }
.engine-ov-card.selling { --engine-accent: #6366f1; }
.engine-ov-card.domains { --engine-accent: #f59e0b; }
.engine-ov-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.engine-ov-head strong { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }
.engine-ov-head strong .ov-icon { margin-right: 6px; }
.engine-ov-card.buying  .engine-ov-head strong { color: #16a34a; }
.engine-ov-card.selling .engine-ov-head strong { color: #6366f1; }
.engine-ov-card.domains .engine-ov-head strong { color: #b45309; }
.engine-ov-tag { font-size: 10px; font-weight: 600; padding: 2px 9px; border-radius: 20px; text-transform: uppercase; letter-spacing: .03em; }
.engine-ov-card.buying  .engine-ov-tag { background: #dcfce7; color: #15803d; }
.engine-ov-card.selling .engine-ov-tag { background: #e0e7ff; color: #4338ca; }
.engine-ov-card.domains .engine-ov-tag { background: #fef3c7; color: #92400e; }
.engine-ov-desc { font-size: 13px; color: var(--text-sub, #64748b); line-height: 1.5; margin-bottom: 12px; }
.engine-ov-stats { display: flex; gap: 18px; font-size: 12px; color: var(--text-sub, #64748b); margin-bottom: 14px; font-weight: 500; }
.engine-ov-stats strong { color: var(--text, #1e293b); font-weight: 700; }
.engine-ov-btn {
  width: 100%; padding: 9px 0; border: none; border-radius: 8px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: filter .15s, box-shadow .15s; justify-content: center; display: flex; align-items: center;
}
.engine-ov-card.buying  .engine-ov-btn { background: #22c55e; color: #fff; }
.engine-ov-card.selling .engine-ov-btn { background: #6366f1; color: #fff; }
.engine-ov-card.domains .engine-ov-btn { background: #f59e0b; color: #fff; }
.engine-ov-btn:hover { filter: brightness(1.08); box-shadow: 0 2px 8px rgba(0,0,0,.1); }

/* ─── Action Center & Checklist ─── */
.action-center { margin-bottom: 24px; }
.action-center .panel-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; }
.ac-alert {
  display: flex; gap: 12px; padding: 14px 16px; border-radius: 10px; margin-bottom: 14px; align-items: flex-start;
}
.ac-alert.ok   { background: #f0fdf4; border: 1px solid #bbf7d0; }
.ac-alert.warn { background: #fff7ed; border: 1px solid #fed7aa; }
.ac-alert.err  { background: #fef2f2; border: 1px solid #fecaca; }
.ac-alert .ac-icon { font-size: 20px; flex-shrink: 0; line-height: 1; }
.ac-alert .ac-title { font-size: 14px; font-weight: 700; display: block; }
.ac-alert.ok   .ac-title { color: #15803d; }
.ac-alert.warn .ac-title { color: #c2410c; }
.ac-alert.err  .ac-title { color: #b91c1c; }
.ac-alert .ac-detail { font-size: 12px; color: var(--text-sub, #64748b); margin-top: 2px; }
.setup-checklist { padding-top: 14px; border-top: 1px solid var(--line, #e5e7eb); }
.setup-checklist strong { display: block; font-size: 13px; margin-bottom: 8px; }
.checklist-items { display: flex; flex-direction: column; gap: 6px; }
.checklist-item { font-size: 12.5px; display: flex; align-items: center; gap: 8px; }
.checklist-item .ck-icon { font-size: 15px; flex-shrink: 0; }
.checklist-item a { color: var(--accent, #6366f1); text-decoration: none; font-weight: 500; }
.checklist-item a:hover { text-decoration: underline; }

/* Dark mode overrides for engine cards + action center */
body.dark .engine-ov-card { background: var(--bg-card); border-color: var(--line); }
body.dark .engine-ov-desc, body.dark .engine-ov-stats { color: var(--text-sub); }
body.dark .engine-ov-stats strong { color: var(--text); }
body.dark .ac-alert.ok   { background: rgba(34,197,94,.08); border-color: rgba(34,197,94,.25); }
body.dark .ac-alert.warn { background: rgba(245,158,11,.08); border-color: rgba(245,158,11,.25); }
body.dark .ac-alert.err  { background: rgba(239,68,68,.08);  border-color: rgba(239,68,68,.25); }
body.dark .setup-checklist { border-color: var(--line); }

/* Dark mode overrides for legacy components */
.btn.light { background: #f8fafc; border-color: var(--border); color: #344054; border: 1px solid var(--border); }
.btn.light:hover { background: #f1f5f9; }
body.dark .btn.light { background: var(--panel-2); border-color: var(--border); color: var(--text); }
body.dark .btn.light:hover { background: #1f2937; }

body.dark .btn.secondary { background: var(--panel-2); border-color: var(--border); color: var(--text); }
body.dark .btn.secondary:hover { background: #1f2937; }

body.dark .engine-tabs button { background: var(--panel-2); color: var(--text); border-color: var(--border); }
body.dark .engine-tabs button.active { background: var(--brand); color: white; border-color: var(--brand); }

/* ─── Login Page ─── */
.login-container {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-card .brand {
  border-bottom: 0;
  padding: 0;
  display: block;
}
.login-error {
  margin-top: 16px;
  padding: 10px 12px;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid rgba(220,38,38,.1);
}

/* ─── Templates Page Layout ─── */
.template-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  margin-top: 16px;
  margin-bottom: 24px;
}
.template-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px !important;
  max-height: 540px;
  overflow-y: auto;
}
.template-list button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  text-align: left;
  transition: all .2s ease;
}
.template-list button:hover {
  background: var(--bg);
}
.template-list button.active {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.template-list button strong {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.template-list button small {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
}
.editor-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
body.dark .template-list button.active {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--brand);
}

/* ─── Engine Card Embedded Metrics ─── */
.engine-ov-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 14px;
  margin-bottom: 14px;
  padding: 10px;
  background: rgba(241, 245, 249, 0.5);
  border-radius: 10px;
  border: 1px solid rgba(226, 232, 240, 0.6);
}
body.dark .engine-ov-metrics {
  background: rgba(15, 23, 42, 0.3);
  border-color: rgba(51, 65, 85, 0.4);
}
.ov-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4px 2px;
}
.ov-metric-val {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.ov-metric-lbl {
  font-size: 9px;
  color: var(--muted);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
  line-height: 1.1;
}

/* ─── Pagination Bar ─── */
.pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}
.pagination .btn {
  font-size: 12px;
  padding: 4px 12px;
  min-height: 28px;
}

/* ─── Empty table state ─── */
td .empty { padding: 32px 16px; text-align: center; color: var(--muted); font-size: 13px; }

/* ─── Form Elements ─── */
.card > h2 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
  color: var(--text);
}

.modal-form {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field > span {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="search"],
input:not([type]),
textarea,
select {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.5;
  transition: border-color .15s ease, box-shadow .15s ease;
  outline: none;
  min-height: 40px;
}
input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
input:not([type]):focus,
textarea:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
input::placeholder,
textarea::placeholder {
  color: #94a3b8;
}
textarea {
  resize: vertical;
  min-height: 80px;
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

/* File input */
input[type="file"] {
  padding: 8px 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  min-height: 40px;
}
input[type="file"]:hover {
  border-color: var(--brand);
  background: rgba(79, 70, 229, 0.03);
}
input[type="file"]::file-selector-button {
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-right: 10px;
  transition: background .15s ease;
}
input[type="file"]::file-selector-button:hover {
  background: var(--bg);
}

/* Custom Checkboxes */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px !important;
  height: 18px;
  min-height: 18px !important;
  border: 2px solid var(--border);
  border-radius: 5px;
  background: var(--panel);
  cursor: pointer;
  transition: all .15s ease;
  position: relative;
  flex-shrink: 0;
}
input[type="checkbox"]:checked {
  background: var(--brand);
  border-color: var(--brand);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 11px 11px;
}
input[type="checkbox"]:hover {
  border-color: var(--brand);
}

/* Password Toggle Wrapper */
.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}
.password-wrapper input {
  padding-right: 40px !important;
}
.password-toggle-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  opacity: 0.65;
  transition: opacity 0.15s ease;
  user-select: none;
}
.password-toggle-btn:hover {
  opacity: 1;
}

/* Card with forms — add inner padding */
.card > .modal-form {
  padding: 22px;
}

/* Prospector buttons row */
.card .btn.primary {
  min-height: 44px;
  font-size: 14px;
  border-radius: 10px;
}

/* Execution Status panel refinements */
.settings-grid .card {
  overflow: visible;
}

/* ─── Dark Mode: Form Elements ─── */
body.dark input[type="text"],
body.dark input[type="number"],
body.dark input[type="email"],
body.dark input[type="password"],
body.dark input[type="url"],
body.dark input[type="search"],
body.dark input:not([type]),
body.dark textarea,
body.dark select {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}
body.dark input[type="text"]:focus,
body.dark input[type="number"]:focus,
body.dark input[type="email"]:focus,
body.dark input[type="password"]:focus,
body.dark input[type="url"]:focus,
body.dark input[type="search"]:focus,
body.dark input:not([type]):focus,
body.dark textarea:focus,
body.dark select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
body.dark input::placeholder,
body.dark textarea::placeholder {
  color: #475569;
}
body.dark select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}
body.dark input[type="file"] {
  background: #0f172a;
  border-color: #334155;
  color: #94a3b8;
}
body.dark input[type="file"]::file-selector-button {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}
body.dark input[type="checkbox"] {
  background: #0f172a;
  border-color: #475569;
}
body.dark .field > span {
  color: #e2e8f0;
}
body.dark .card > h2 {
  border-color: #1e293b;
  color: #e2e8f0;
}

/* ─── Integration Cards ─── */
.integration-cards {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 14px;
}
.integration-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.integration-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.integration-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.integration-desc {
  font-size: 13px;
  color: var(--muted);
  margin-top: 0;
  margin-bottom: 16px;
  line-height: 1.5;
}
.integration-desc a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 500;
}
.integration-desc a:hover {
  text-decoration: underline;
}
.health-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.health-status.ok {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}
.health-status.warn {
  background: var(--warning);
  box-shadow: 0 0 8px var(--warning);
}

/* Dark mode integrations */
body.dark .integration-card {
  background: var(--panel);
  border-color: var(--border);
}

/* ─── Table card structure ─── */
.table-card .table-wrap { padding: 0; min-height: 180px; }
.table-card table { min-width: 100%; }

/* ─── Action Dropdown Menu ─── */
.action-dropdown-menu {
  background: var(--panel, #ffffff);
  border: 1px solid var(--border, #e2e8f0);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  overflow: hidden;
  z-index: 9999;
}

body.dark .action-dropdown-menu {
  background: var(--panel, #1e293b);
  border-color: var(--border, #334155);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

.action-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text, #1e293b);
  text-decoration: none !important;
  transition: background 0.15s ease;
  cursor: pointer;
}

.action-menu-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

body.dark .action-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.action-menu-item.danger {
  color: #ef4444 !important;
}

.action-menu-item.danger:hover {
  background: rgba(239, 68, 68, 0.1) !important;
}

/* ─── Settings Horizontal Tabs & Subtabs ─── */
.settings-tab-bar {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.settings-tab-horizontal {
  border: 0;
  background: transparent;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: -1px;
}
.settings-tab-horizontal:hover {
  color: var(--text);
  border-bottom-color: var(--border);
}
.settings-tab-horizontal.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.settings-subtab-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}
.settings-subtab {
  border: 0;
  background: transparent;
  padding: 6px 14px;
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.settings-subtab:hover {
  background: var(--panel-2);
  color: var(--text);
}
.settings-subtab.active {
  background: var(--brand-soft);
  color: var(--brand);
}

.settings-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 900px) {
  .settings-split {
    grid-template-columns: 1fr;
  }
}

.credential-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
}

.credential-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

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


