/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --c-bg:       #f1f5f9;
  --c-surface:  #ffffff;
  --c-border:   #e2e8f0;
  --c-text:     #0f172a;
  --c-muted:    #64748b;
  --c-primary:  #4f46e5;
  --c-primary-h:#4338ca;
  --c-ok:       #10b981;
  --c-ok-bg:    #d1fae5;
  --c-warn:     #d97706;
  --c-warn-bg:  #fef3c7;
  --c-err:      #ef4444;
  --c-err-bg:   #fee2e2;
  --c-code:     #f1f5f9;
  --radius:     10px;
  --shadow:     0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 16px rgba(0,0,0,.08);
  --sidebar-w:  240px;
  --topbar-h:   56px;
}

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

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.6;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── App layout (sidebar + main) ────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: #0f172a;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
  overflow-y: auto;
}

.sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.25rem 0;
}

.sidebar__logo {
  font-weight: 800;
  font-size: 1.15rem;
  color: #fff;
  letter-spacing: -.4px;
  text-decoration: none;
}
.sidebar__logo:hover { color: #a5b4fc; text-decoration: none; }

.sidebar__close {
  display: none;
  background: none; border: none;
  color: #64748b; cursor: pointer; font-size: 1.2rem; padding: .25rem;
  line-height: 1;
}

.sidebar__section-label {
  font-size: .67rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #334155;
  padding: 1.5rem 1.25rem .4rem;
}

.sidebar__nav {
  flex: 1;
  padding: .75rem .75rem 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar__item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .6rem .75rem;
  border-radius: 8px;
  color: #94a3b8;
  font-size: .9rem;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.sidebar__item:hover {
  background: rgba(255,255,255,.07);
  color: #e2e8f0;
  text-decoration: none;
}
.sidebar__item--active {
  background: rgba(79,70,229,.18);
  color: #a5b4fc;
  font-weight: 600;
}
.sidebar__item--active:hover {
  background: rgba(79,70,229,.22);
  color: #a5b4fc;
}
.sidebar__icon {
  width: 17px; height: 17px;
  flex-shrink: 0; opacity: .8;
}
.sidebar__item--active .sidebar__icon { opacity: 1; }

.sidebar__divider {
  height: 1px;
  background: #1e293b;
  margin: .75rem .75rem;
}

.sidebar__footer {
  padding: 1rem .75rem 1.25rem;
  border-top: 1px solid #1e293b;
  margin-top: auto;
}
.sidebar__user-email {
  font-size: .78rem;
  color: #64748b;
  padding: .4rem .75rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}
.sidebar__logout {
  display: flex; align-items: center; gap: .7rem;
  padding: .5rem .75rem;
  border-radius: 8px;
  color: #64748b; font-size: .875rem;
  text-decoration: none;
  transition: background .15s, color .15s;
  margin-top: .25rem;
}
.sidebar__logout:hover {
  background: rgba(239,68,68,.12);
  color: #fca5a5;
  text-decoration: none;
}

/* ── Mobile topbar ──────────────────────────────────────── */
.topbar {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: #0f172a;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 90;
}
.topbar__logo {
  font-weight: 800; font-size: 1.1rem; color: #fff; text-decoration: none;
}
.topbar__burger {
  background: none; border: none;
  color: #94a3b8; cursor: pointer; padding: .4rem; font-size: 1.3rem; line-height: 1;
}

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}
.sidebar-overlay.show { display: block; }

/* ── App main ───────────────────────────────────────────── */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
}

.app-content {
  padding: 2rem 2.5rem;
  max-width: 900px;
}

/* ── Auth split layout ──────────────────────────────────── */
.auth-body {
  min-height: 100vh;
  display: flex;
}

.auth-split {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

.auth-panel {
  display: flex;
  flex-direction: column;
}

.auth-panel--dark {
  width: 42%;
  background: #0f172a;
  color: #fff;
  padding: 3rem;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.auth-panel--dark::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 30% 40%, rgba(79,70,229,.35) 0%, transparent 65%);
  pointer-events: none;
}

.auth-panel--light {
  flex: 1;
  background: var(--c-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
}

.auth-brand-logo {
  font-weight: 800; font-size: 1.4rem; color: #fff;
  text-decoration: none; display: inline-block; margin-bottom: 3rem;
}
.auth-brand-logo:hover { color: #a5b4fc; text-decoration: none; }

.auth-brand-title {
  font-size: 1.75rem; font-weight: 800;
  line-height: 1.25; margin-bottom: 1.75rem;
  letter-spacing: -.4px; position: relative;
}

.auth-brand-features {
  list-style: none;
  display: flex; flex-direction: column; gap: .75rem;
  position: relative;
}
.auth-brand-features li {
  display: flex; align-items: center; gap: .75rem;
  color: #94a3b8; font-size: .9rem;
}
.auth-brand-features li::before {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  background: #4f46e5; flex-shrink: 0;
}

.auth-form-wrap {
  width: 100%; max-width: 380px;
}

.auth-back {
  display: inline-block;
  font-size: .8rem; color: var(--c-muted);
  margin-bottom: 2.25rem;
  text-decoration: none;
}
.auth-back:hover { color: var(--c-primary); text-decoration: none; }

.auth-title {
  font-size: 1.5rem; font-weight: 800;
  margin-bottom: 1.5rem; letter-spacing: -.3px;
}

.auth-switch {
  margin-top: 1.25rem;
  font-size: .875rem; color: var(--c-muted); text-align: center;
}

/* ── Page head ──────────────────────────────────────────── */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1rem;
}
.page-head h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.3px; }

/* ── Card ───────────────────────────────────────────────── */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}
.card--disabled { opacity: .45; pointer-events: none; }
.card__title {
  font-size: 1rem; font-weight: 700; margin-bottom: 1rem;
  display: flex; align-items: center; gap: .5rem;
  color: var(--c-text);
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1.1rem; border-radius: 8px; font-size: .9rem;
  font-weight: 600; cursor: pointer; border: none; white-space: nowrap;
  transition: background .15s, opacity .15s, box-shadow .15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn--primary {
  background: var(--c-primary); color: #fff;
  box-shadow: 0 1px 3px rgba(79,70,229,.3);
}
.btn--primary:hover { background: var(--c-primary-h); color: #fff; }
.btn--ghost {
  background: transparent; color: var(--c-text);
  border: 1px solid var(--c-border);
}
.btn--ghost:hover { background: var(--c-bg); }
.btn--danger { background: var(--c-err); color: #fff; }
.btn--danger:hover { background: #dc2626; color: #fff; }
.btn--sm { padding: .35rem .8rem; font-size: .8rem; }
.btn--full { width: 100%; justify-content: center; }

/* ── Forms ──────────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: 1rem; }
.form--inline { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }

.field { display: flex; flex-direction: column; gap: .35rem; }
.field--grow { flex: 1; min-width: 180px; }
.field--sm { width: 120px; }

label { font-size: .8rem; font-weight: 600; color: var(--c-muted); }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"] {
  width: 100%; padding: .55rem .8rem;
  border: 1.5px solid var(--c-border); border-radius: 8px;
  font-size: .95rem; background: var(--c-surface);
  color: var(--c-text);
  transition: border-color .15s, box-shadow .15s;
}
input:focus {
  outline: none; border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}

.field__hint { font-size: .75rem; color: var(--c-muted); }

.input-group { display: flex; align-items: center; }
.input-group input { border-radius: 8px 0 0 8px; }
.input-group__sep {
  padding: .55rem .8rem; background: var(--c-bg);
  border: 1.5px solid var(--c-border); border-left: none;
  border-radius: 0 8px 8px 0; font-size: .85rem; color: var(--c-muted);
  white-space: nowrap;
}

/* ── Alerts ─────────────────────────────────────────────── */
.alert {
  padding: .8rem 1rem; border-radius: 8px;
  margin-bottom: 1.25rem; font-size: .9rem;
  display: flex; align-items: flex-start; gap: .5rem;
}
.alert--ok   { background: var(--c-ok-bg);   color: #065f46; border: 1px solid #a7f3d0; }
.alert--err  { background: var(--c-err-bg);  color: #991b1b; border: 1px solid #fca5a5; }
.alert--warn { background: var(--c-warn-bg); color: #92400e; border: 1px solid #fcd34d; }

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: .2rem .65rem; border-radius: 20px;
  font-size: .72rem; font-weight: 700; letter-spacing: .02em;
}
.badge--ok   { background: var(--c-ok-bg);   color: #065f46; }
.badge--warn { background: var(--c-warn-bg); color: #92400e; }
.badge--err  { background: var(--c-err-bg);  color: #991b1b; }

/* ── Step number ────────────────────────────────────────── */
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--c-primary); color: #fff;
  font-size: .72rem; font-weight: 800; flex-shrink: 0;
}

/* ── DNS record ─────────────────────────────────────────── */
.dns-record {
  background: #f8fafc; border: 1px solid var(--c-border);
  border-radius: 8px; padding: .75rem 1rem; margin-top: .75rem;
}
.dns-record__row {
  display: flex; align-items: flex-start; gap: 1rem;
  padding: .3rem 0; border-bottom: 1px solid var(--c-border);
  font-size: .875rem;
}
.dns-record__row:last-child { border-bottom: none; }
.dns-record__label {
  width: 80px; flex-shrink: 0; color: var(--c-muted); font-size: .78rem; padding-top: .05em;
}
code {
  font-family: 'JetBrains Mono', 'Fira Code', Menlo, monospace;
  font-size: .8rem; word-break: break-all;
}
.copyable {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: 5px; padding: .15rem .45rem;
  transition: background .15s; user-select: all; cursor: pointer;
}
.copyable:hover { background: #eef2ff; border-color: #c7d2fe; }
.copyable--long { display: block; margin-top: .25rem; word-break: break-all; }

/* ── DNS status ─────────────────────────────────────────── */
.dns-status { margin-top: .5rem; }
.dns-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.dns-table td { padding: .5rem .75rem; border-bottom: 1px solid var(--c-border); }
.dns-table__label { font-weight: 700; width: 80px; }

/* ── Domain list ────────────────────────────────────────── */
.domain-list { display: flex; flex-direction: column; gap: .75rem; }
.domain-card {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius); padding: 1rem 1.25rem;
  box-shadow: var(--shadow); color: var(--c-text);
  transition: border-color .15s, box-shadow .15s;
}
.domain-card:hover {
  border-color: var(--c-primary);
  box-shadow: var(--shadow-md);
  text-decoration: none; color: var(--c-text);
}
.domain-card__name { font-weight: 700; }

/* ── Table ──────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th, .table td {
  padding: .65rem .75rem; text-align: left;
  border-bottom: 1px solid var(--c-border);
}
.table th { color: var(--c-muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.table tr:last-child td { border-bottom: none; }

/* ── Misc ───────────────────────────────────────────────── */
.empty { text-align: center; padding: 4rem 1rem; color: var(--c-muted); }
.empty p { margin-bottom: 1rem; font-size: 1rem; }
.text-muted { color: var(--c-muted); font-size: .875rem; }
.ml-auto { margin-left: auto; }

/* ── Admin stat cards ───────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1rem;
}
.stat-card {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius); padding: 1.5rem;
  box-shadow: var(--shadow);
}
.stat-card__val {
  font-size: 2.25rem; font-weight: 800; color: var(--c-primary);
  line-height: 1; margin-bottom: .4rem; letter-spacing: -.05em;
}
.stat-card__label { font-size: .82rem; color: var(--c-muted); }

/* ── Code inputs (verify) ───────────────────────────────── */
.code-inputs {
  display: flex; justify-content: center; gap: .75rem; margin-bottom: 1.25rem;
}
.code-input {
  width: 58px; height: 68px; text-align: center; font-size: 1.8rem;
  font-weight: 700; font-family: monospace;
  border: 2px solid var(--c-border); border-radius: 12px;
  background: var(--c-bg); color: var(--c-text);
  transition: border-color .15s, box-shadow .15s;
  caret-color: transparent;
}
.code-input:focus {
  outline: none; border-color: var(--c-primary);
  box-shadow: 0 0 0 4px rgba(79,70,229,.14);
  background: var(--c-surface);
}
.code-input:not(:placeholder-shown) {
  border-color: var(--c-primary); background: var(--c-surface);
}

.btn-link {
  background: none; border: none; color: var(--c-primary); cursor: pointer;
  font-size: inherit; padding: 0; text-decoration: underline;
}
.btn-link:hover { opacity: .8; }

/* ── DKIM tabs ──────────────────────────────────────────── */
.dkim-tabs { display: flex; gap: .5rem; margin-bottom: .5rem; }
.dkim-tab {
  padding: .3rem .8rem; border-radius: 6px; font-size: .8rem;
  border: 1.5px solid var(--c-border); background: var(--c-bg);
  cursor: pointer; color: var(--c-muted); font-weight: 500;
}
.dkim-tab--active { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }

/* ── Domain actions ─────────────────────────────────────── */
.domain-actions {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: .5rem; padding-top: 1rem;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .topbar { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    top: 0;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar__close { display: block; }
  .app-main { margin-left: 0; padding-top: var(--topbar-h); }
  .app-content { padding: 1.25rem; }

  .auth-split { flex-direction: column; }
  .auth-panel--dark { width: 100%; padding: 2rem 1.5rem; justify-content: flex-start; }
  .auth-brand-title { font-size: 1.35rem; margin-bottom: 0; }
  .auth-brand-features { display: none; }
  .auth-brand-logo { margin-bottom: 1rem; }
  .auth-panel--light { padding: 2rem 1.5rem; }
}
