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

:root {
  --blue:    #2563eb;
  --blue-h:  #1d4ed8;
  --green:   #16a34a;
  --red:     #dc2626;
  --bg:      #f1f5f9;
  --card:    #ffffff;
  --border:  #e2e8f0;
  --text:    #1e293b;
  --muted:   #64748b;
  --radius:  10px;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Nav ── */
nav {
  background: var(--blue);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  box-shadow: 0 2px 8px rgba(37,99,235,.25);
}
nav .brand {
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  letter-spacing: .02em;
}
nav .nav-links { display: flex; gap: 4px; align-items: center; }
nav a.nav-link {
  color: rgba(255,255,255,.8);
  text-decoration: none;
  font-size: .875rem;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
nav a.nav-link:hover,
nav a.nav-link.active { background: rgba(255,255,255,.15); color: #fff; }
nav button.logout {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  font-size: .875rem;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s;
}
nav button.logout:hover { background: rgba(255,255,255,.25); }

/* ── Layout ── */
main { max-width: 680px; margin: 40px auto; padding: 0 16px; }

/* ── Card ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.card + .card { margin-top: 20px; }

h1 { font-size: 1.25rem; font-weight: 700; margin-bottom: 4px; }
.subtitle { color: var(--muted); font-size: .875rem; margin-bottom: 24px; }
h2 { font-size: 1rem; font-weight: 600; margin-bottom: 16px; }

/* ── Form elements ── */
label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .9rem;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.field { margin-bottom: 16px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-h); }
.btn-primary:disabled { background: #93c5fd; cursor: not-allowed; transform: none; }
.btn-full { width: 100%; }

/* ── Checkboxes / provider list ── */
.providers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}
.provider-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  user-select: none;
}
.provider-item:hover { border-color: #93c5fd; background: #eff6ff; }
.provider-item.checked { border-color: var(--blue); background: #eff6ff; }
.provider-item input[type="checkbox"] { display: none; }
.provider-dot {
  width: 10px; height: 10px;
  border: 2px solid var(--border);
  border-radius: 3px;
  flex-shrink: 0;
  transition: background .15s, border-color .15s;
}
.provider-item.checked .provider-dot { background: var(--blue); border-color: var(--blue); }
.provider-label { font-size: .875rem; font-weight: 500; }

/* ── SMTP Accordion ── */
.smtp-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}
.smtp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #f8fafc;
  cursor: pointer;
  font-weight: 600;
  font-size: .9rem;
  user-select: none;
  transition: background .15s;
}
.smtp-header:hover { background: #f1f5f9; }
.smtp-header .status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
}
.smtp-header .status-dot.configured { background: var(--green); }
.smtp-header .chevron { color: var(--muted); font-size: .75rem; transition: transform .2s; }
.smtp-header.open .chevron { transform: rotate(180deg); }
.smtp-body {
  display: none;
  padding: 16px;
  border-top: 1px solid var(--border);
  background: #fff;
}
.smtp-body.open { display: block; }
.smtp-grid {
  display: grid;
  grid-template-columns: 1fr 100px;
  gap: 12px;
}
.smtp-grid .field { margin-bottom: 0; }

/* ── Results ── */
#results { margin-top: 20px; }
.result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: .9rem;
}
.result-item.success { background: #f0fdf4; border: 1px solid #bbf7d0; }
.result-item.error   { background: #fef2f2; border: 1px solid #fecaca; }
.result-icon { font-size: 1rem; flex-shrink: 0; }
.result-label { font-weight: 600; min-width: 70px; }
.result-msg { color: var(--muted); font-size: .825rem; }
.result-msg.err-msg { color: var(--red); }

/* ── Login page ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
  text-align: center;
}
.login-icon { font-size: 2.5rem; margin-bottom: 16px; }
.login-card h1 { font-size: 1.3rem; margin-bottom: 6px; }
.login-card .subtitle { margin-bottom: 24px; }
.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--red);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: .85rem;
  margin-top: 12px;
  display: none;
}
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: #1e293b;
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: .875rem;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  z-index: 1000;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.success { background: var(--green); }
#toast.error   { background: var(--red); }

/* ── Responsive ── */
@media (max-width: 480px) {
  main { margin: 20px auto; }
  .card { padding: 20px; }
  .providers { grid-template-columns: 1fr 1fr; }
}
