:root {
  --bg: #0b1120;
  --surface: #111827;
  --card: #161f33;
  --card-hover: #1c2841;
  --border: #24304a;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
}

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

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* === AUTH SCREEN === */
.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.auth-glow {
  position: absolute;
  width: 540px;
  height: 540px;
  background: radial-gradient(circle, rgba(59,130,246,.22), transparent 65%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -55%);
  pointer-events: none;
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 430px;
  background: rgba(22, 31, 51, .92);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
  justify-self: end;
}

.landing-grid {
  position: relative;
  width: 100%;
  max-width: 1060px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 430px);
  gap: 36px;
  align-items: center;
}

.landing-info { padding: 8px 4px; }
.landing-title { font-size: clamp(26px, 3.2vw, 36px); font-weight: 700; letter-spacing: -.02em; line-height: 1.2; margin-bottom: 12px; }
.landing-lead { font-size: 15px; color: var(--muted); margin-bottom: 24px; max-width: 540px; }

.how-list { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.how-item {
  display: flex; align-items: flex-start; gap: 14px;
  background: rgba(22, 31, 51, .72);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
}
.how-num {
  width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
  display: grid; place-items: center;
  background: rgba(59, 130, 246, .18);
  border: 1px solid rgba(59, 130, 246, .35);
  color: var(--accent); font-weight: 700; font-size: 13px;
}
.how-title { font-weight: 600; font-size: 14px; margin-bottom: 3px; color: var(--text); }
.how-desc { font-size: 13px; color: var(--muted); line-height: 1.45; }
.how-desc code {
  background: rgba(15, 23, 42, .8); border: 1px solid var(--border);
  padding: 1px 6px; border-radius: 5px; font-size: 12px; color: var(--accent);
}

.auth-card h2 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }

@media (max-width: 880px) {
  .landing-grid { grid-template-columns: 1fr; gap: 24px; }
  .auth-card { justify-self: stretch; max-width: 100%; }
}

.brand-row { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.brand-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  color: #fff; flex-shrink: 0;
}
.brand-icon.sm { width: 34px; height: 34px; border-radius: 10px; }
.brand-name { font-weight: 700; font-size: 17px; }
.brand-sub { font-size: 12px; color: var(--muted); }

.auth-card h1 { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.auth-hint { font-size: 14px; color: var(--muted); margin-bottom: 20px; }

.code-input {
  text-align: center;
  font-size: 26px !important;
  letter-spacing: 0.35em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
}

.dev-code {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 10px;
  border-radius: 6px;
  background: rgba(0,0,0,.35);
  color: #fde68a;
  font-size: 16px;
  letter-spacing: 0.2em;
}

/* === FORMS & BUTTONS === */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: #cbd5e1; font-weight: 500; }
.req { color: var(--danger); }

input, select, textarea {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.2);
}
input.is-invalid, select.is-invalid, textarea.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239,68,68,.18);
}
.field-err { font-size: 12px; color: #fca5a5; min-height: 0; }
.field-hint { font-size: 11px; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 10px;
  padding: 10px 16px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all .15s; font-family: inherit;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-full { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--card); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--card-hover); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: rgba(255,255,255,.04); }
.btn-danger-ghost { background: transparent; color: #fca5a5; border-color: rgba(239,68,68,.3); }
.btn-danger-ghost:hover:not(:disabled) { background: rgba(239,68,68,.15); color: #fff; }

.alert { padding: 12px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 16px; }
.alert-danger { background: rgba(239,68,68,.14); border: 1px solid rgba(239,68,68,.35); color: #fecaca; }
.alert-warn { background: rgba(245,158,11,.14); border: 1px solid rgba(245,158,11,.35); color: #fde68a; }

/* === DASHBOARD LAYOUT === */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 24px;
  background: rgba(11, 17, 32, .88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topbar-title { font-weight: 700; font-size: 16px; margin-right: 8px; }

.tabs { display: flex; gap: 4px; background: var(--surface); padding: 4px; border-radius: 10px; border: 1px solid var(--border); }
.tab {
  background: transparent; border: none; color: var(--muted);
  padding: 6px 14px; border-radius: 8px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.tab.active { background: var(--primary); color: #fff; }
.tab:hover:not(.active) { color: var(--text); }

.smtp-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.smtp-pill.ok { background: rgba(34,197,94,.12); color: var(--ok); border: 1px solid rgba(34,197,94,.3); }
.smtp-pill.warn { background: rgba(245,158,11,.12); color: var(--warn); border: 1px solid rgba(245,158,11,.3); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.user-chip { display: flex; flex-direction: column; text-align: right; line-height: 1.2; }
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--muted); }

.container { max-width: 1180px; margin: 0 auto; padding: 28px 20px 60px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  margin-bottom: 22px; flex-wrap: wrap;
}
.page-head h2 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.muted { color: var(--muted); font-size: 14px; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* === KPI CARDS === */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px; margin-bottom: 24px;
}
.kpi-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.kpi-label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 6px; }
.kpi-val { font-size: 28px; font-weight: 700; }
.text-ok { color: var(--ok); }
.text-danger { color: var(--danger); }
.text-accent { color: var(--accent); }

/* === SITE CARDS === */
.sites-list { display: flex; flex-direction: column; gap: 14px; }
.empty-state {
  background: var(--card); border: 1px dashed var(--border);
  border-radius: var(--radius); padding: 48px 24px; text-align: center; color: var(--muted);
}

.site-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
  transition: border-color .15s;
}
.site-card:hover { border-color: #364769; }
.site-card.paused { opacity: .62; }

.site-top {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  flex-wrap: wrap; margin-bottom: 12px;
}
.site-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.status-orb { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.status-orb.up { background: var(--ok); box-shadow: 0 0 12px rgba(34,197,94,.65); }
.status-orb.down { background: var(--danger); box-shadow: 0 0 12px rgba(239,68,68,.65); }
.status-orb.unknown { background: var(--muted); }

.site-name { font-size: 16px; font-weight: 600; }
.site-url { font-size: 13px; color: var(--accent); text-decoration: none; word-break: break-all; }
.site-url:hover { text-decoration: underline; }

.site-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.site-meta {
  display: flex; gap: 18px; flex-wrap: wrap;
  font-size: 13px; color: var(--muted); margin-bottom: 12px;
}
.site-meta strong { color: var(--text); font-weight: 600; }

.site-error {
  font-size: 12px; color: #fca5a5;
  background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.25);
  border-radius: 8px; padding: 6px 10px; margin-bottom: 10px;
}

.sparkline { display: flex; gap: 4px; align-items: center; height: 22px; }
.spark-bar {
  flex: 1; max-width: 14px; height: 100%; border-radius: 3px;
  background: var(--border);
}
.spark-bar.up { background: var(--ok); }
.spark-bar.down { background: var(--danger); }

.badge {
  display: inline-flex; align-items: center; padding: 2px 9px;
  border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge-ok { background: rgba(34,197,94,.14); color: var(--ok); }
.badge-danger { background: rgba(239,68,68,.14); color: #fca5a5; }
.badge-muted { background: rgba(148,163,184,.14); color: var(--muted); }
.badge-accent { background: rgba(56,189,248,.14); color: var(--accent); }

/* === TABLE === */
.table-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow-x: auto;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; padding: 13px 14px; color: var(--muted);
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}
.data-table td { padding: 13px 14px; border-bottom: 1px solid rgba(36,48,74,.6); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.cell-main { font-weight: 600; color: var(--text); }
.cell-sub { font-size: 12px; color: var(--muted); }

/* === MODAL === */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(2, 6, 23, .72); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 16px; overflow-y: auto;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: 100%; max-width: 580px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 18px; padding: 24px;
  box-shadow: 0 24px 64px rgba(0,0,0,.55);
}
.modal.modal-wide { max-width: 960px; }

.logs-summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px; margin-bottom: 14px;
}
.logs-stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px;
}
.logs-stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.logs-stat-val { font-size: 18px; font-weight: 700; margin-top: 2px; }

.logs-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.logs-table-wrap {
  max-height: 440px; overflow: auto;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
.logs-table-wrap .data-table th { position: sticky; top: 0; background: var(--card); z-index: 2; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-head h3 { font-size: 19px; font-weight: 700; }
.icon-btn {
  background: transparent; border: none; color: var(--muted);
  font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.icon-btn:hover { background: rgba(255,255,255,.06); color: var(--text); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.span-2 { grid-column: span 2; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }

/* === TOAST === */
.toast-wrap { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1e293b; border: 1px solid var(--border); color: var(--text);
  padding: 12px 16px; border-radius: 10px; font-size: 13px;
  box-shadow: 0 12px 28px rgba(0,0,0,.4);
}
.toast.ok { border-left: 3px solid var(--ok); }
.toast.err { border-left: 3px solid var(--danger); }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
}
