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

:root {
  --bg:       #0d0f18;
  --surface:  #161929;
  --surface2: #1e2235;
  --surface3: #252a3d;
  --border:   #2c3050;
  --border2:  #373d5c;
  --text:     #e4e6f0;
  --muted:    #7c82a0;
  --accent:   #6c63ff;
  --accent-h: #5a52e0;
  --accent-l: #1a1840;
  --ok:       #2ecc71;
  --warn:     #f59e0b;
  --danger:   #ef4444;
  --radius:   10px;
}

html { font-size: 14px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Navbar ─────────────────────────────────────────────────── */
.navbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 24px;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.brand { font-weight: 800; font-size: 17px; color: var(--accent); text-decoration: none; margin-right: 12px; }
.nav-links { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.nav-links a {
  color: var(--muted);
  text-decoration: none;
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  transition: color .15s, background .15s;
}
.nav-links a:hover   { color: var(--text); background: var(--surface2); }
.nav-links a.highlight { color: var(--accent); background: var(--accent-l); }

/* ── Layout ──────────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 28px 24px; }

.page-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 20px; font-weight: 700; }
.page-header a  { color: var(--muted); text-decoration: none; font-size: 13px; }

.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card > h2 {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ── Stats ───────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 28px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
}
.stat-num   { font-size: 30px; font-weight: 800; }
.stat-label { color: var(--muted); font-size: 11px; margin-top: 4px; text-transform: uppercase; letter-spacing: .05em; }
.stat-new .stat-num { color: var(--warn); }
.stat-won .stat-num { color: var(--ok); }

/* ── Table ───────────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table th {
  background: var(--surface2);
  color: var(--muted);
  font-weight: 700;
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}
.table td { padding: 10px 14px; border-top: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.table tr:hover td { background: var(--surface2); }
.table a { color: var(--accent); text-decoration: none; }
.empty { text-align: center; color: var(--muted); padding: 48px !important; font-size: 13px; }

/* ── Badges & tags ───────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.badge-ok   { background: #0a2018; border-color: #153a22; color: #4ade80; }
.badge-warn { background: #1e1608; border-color: #2e2010; color: #fbbf24; }

.tag {
  display: inline-block;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 7px;
  font-size: 11px;
  color: var(--muted);
}

.score      { font-weight: 700; font-size: 13px; }
.score-high { color: var(--ok); }
.score-mid  { color: var(--warn); }
.score-low  { color: var(--muted); }

.status {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.status-new        { background: #0a1a2e; color: #64b5f6; border-color: #152840; }
.status-qualified  { background: #0a2018; color: #66bb6a; border-color: #153a22; }
.status-replied    { background: #0a2025; color: #4db6ac; border-color: #153530; }
.status-won        { background: #0a2018; color: var(--ok); border-color: #153a22; }
.status-lost,
.status-spam       { background: #200a0a; color: var(--danger); border-color: #3a1515; }
.status-quote_sent { background: #1e1608; color: var(--warn); border-color: #2e2010; }
.status-archived   { background: var(--surface2); color: var(--muted); border-color: var(--border); }

/* ── Filters ─────────────────────────────────────────────────── */
.filter-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.filter-btn {
  padding: 5px 13px;
  border-radius: 20px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  transition: all .15s;
}
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.filter-btn:hover  { color: var(--text); border-color: var(--border2); }

/* ── Form elements ───────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }

.form-group > label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.form-hint { font-size: 11px; color: var(--muted); line-height: 1.4; }
.form-hint a { color: var(--accent); }

.form-input {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px #6c63ff1a;
}
.form-input::placeholder { color: var(--muted); opacity: .5; }
textarea.form-input      { resize: vertical; min-height: 80px; }
select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237c82a0' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}
.form-input[readonly] { opacity: .55; cursor: default; }

.copy-row { display: flex; gap: 8px; align-items: stretch; }
.copy-row .form-input { flex: 1; min-width: 0; }

.inline-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-form select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  font-family: inherit;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 7px;
  border: 1.5px solid transparent;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  font-family: inherit;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn-primary   { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-h); border-color: var(--accent-h); }
.btn-secondary { background: var(--surface2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface3); border-color: var(--border2); }
.btn-danger    { background: #200a0a; color: var(--danger); border-color: #3a1515; }
.btn-danger:hover { background: #2e1010; }
.btn-sm  { padding: 4px 10px; font-size: 11px; }
.btn-lg  { padding: 11px 22px; font-size: 14px; }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert { padding: 11px 16px; border-radius: 7px; font-size: 13px; border: 1px solid transparent; }
.alert-success { background: #0a2018; border-color: #153a22; color: #4ade80; }
.alert-error   { background: #200a0a; border-color: #3a1515; color: #f87171; }
.alert-warn    { background: #1e1608; border-color: #2e2010; color: #fbbf24; }

/* ── Toggle switch ───────────────────────────────────────────── */
.toggle-switch { position: relative; display: inline-block; width: 42px; height: 22px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--surface3);
  border: 1.5px solid var(--border2);
  border-radius: 22px;
  cursor: pointer;
  transition: all .2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  left: 3px; top: 50%;
  transform: translateY(-50%);
  background: var(--muted);
  border-radius: 50%;
  transition: transform .2s, background .2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent-l); border-color: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translate(20px, -50%); background: var(--accent); }

/* ── Services pills ──────────────────────────────────────────── */
.services-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.service-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  transition: all .15s;
  user-select: none;
}
.service-toggle input { display: none; }
.service-toggle:hover  { border-color: var(--border2); color: var(--text); }
.service-toggle.active { border-color: var(--accent); background: var(--accent-l); color: var(--text); }

/* ── Settings tabs ───────────────────────────────────────────── */
.settings-tabs { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 20px; }
.stab {
  padding: 7px 14px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  transition: all .15s;
  font-family: inherit;
}
.stab:hover  { border-color: var(--border2); color: var(--text); }
.stab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.stab-panel  { display: none; }
.stab-panel.active { display: block; }

/* ── Info box ────────────────────────────────────────────────── */
.info-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 12px 14px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 12px;
  line-height: 1.5;
}
.info-box code { font-size: 11px; color: var(--text); word-break: break-all; }

/* ── SMTP test ───────────────────────────────────────────────── */
#smtpTestResult { font-size: 12px; padding: 6px 10px; border-radius: 6px; }
#smtpTestResult.ok  { background: #0a2018; border: 1px solid #153a22; color: #4ade80; }
#smtpTestResult.err { background: #200a0a; border: 1px solid #3a1515; color: #f87171; }

/* ── Notifications rows ──────────────────────────────────────── */
.notif-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.notif-row:last-child { border-bottom: none; }
.notif-row strong { font-size: 13px; color: var(--text); display: block; }
.notif-row p { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ── Service profiles accordion ──────────────────────────────── */
.sp-accordion {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
  transition: border-color .15s;
}
.sp-accordion:hover { border-color: var(--border2); }
.sp-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  background: var(--surface);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  transition: background .15s;
  font-family: inherit;
}
.sp-header:hover { background: var(--surface2); }
.sp-current-name {
  margin-left: auto;
  margin-right: 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-l);
  padding: 2px 10px;
  border-radius: 20px;
  border: 1px solid #2e2a60;
}
.sp-chevron { color: var(--muted); font-size: 11px; }
.sp-current-name ~ .sp-chevron { margin-left: 0; }
.sp-body {
  padding: 20px;
  background: var(--surface2);
  border-top: 1.5px solid var(--border);
}
.sp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.sp-grid .form-group { margin-bottom: 0; }
.sp-full { grid-column: 1 / -1; }

/* ── Bulk bar ────────────────────────────────────────────────── */
.bulk-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.bulk-bar.visible { display: flex; }
.bulk-bar span { color: var(--muted); font-size: 13px; }

/* ── Log entries ─────────────────────────────────────────────── */
.log-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.log-entry:last-child { border-bottom: none; }
.log-entry small { color: var(--muted); min-width: 130px; flex-shrink: 0; }

.raw-msg {
  background: var(--surface2);
  border-radius: 6px;
  padding: 12px;
  white-space: pre-wrap;
  font-size: 12px;
  color: var(--muted);
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
}

.message { padding: 10px 12px; border-radius: 7px; margin-bottom: 8px; }
.message-in  { background: var(--surface2); border-left: 3px solid var(--accent); }
.message-out { background: #0a2018; border-left: 3px solid var(--ok); }
.message small { color: var(--muted); display: block; margin-bottom: 4px; font-size: 11px; }

/* ── Login ───────────────────────────────────────────────────── */
.login-box { max-width: 360px; margin: 80px auto; padding: 32px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); }
.login-title { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.login-sub   { color: var(--muted); margin-bottom: 28px; font-size: 13px; }
.login-input {
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 7px;
  font-size: 14px;
  margin-bottom: 14px;
  font-family: inherit;
  transition: border-color .15s;
}
.login-input:focus { outline: none; border-color: var(--accent); }
.btn-block { width: 100%; padding: 12px; font-size: 14px; justify-content: center; }

/* ── Pagination ──────────────────────────────────────────────── */
.pagination {
  display: flex; gap: 16px; align-items: center;
  margin-top: 20px; justify-content: center;
  color: var(--muted); font-size: 13px;
}
.pagination a { color: var(--accent); text-decoration: none; }

/* ── Misc ────────────────────────────────────────────────────── */
details summary { cursor: pointer; color: var(--muted); font-size: 12px; margin-top: 8px; }
details ul { margin-top: 8px; padding-left: 16px; color: var(--muted); font-size: 12px; }

h2 { font-size: 17px; margin-bottom: 14px; font-weight: 700; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .two-cols   { grid-template-columns: 1fr; }
  .sp-grid    { grid-template-columns: 1fr; }
  .container  { padding: 16px; }
}
