/* ── Variables ─────────────────────────────────────────────── */
:root {
  --sidebar-bg: #1a1f2e;
  --sidebar-hover: #252c3f;
  --sidebar-active: #4361ee;
  --sidebar-text: #a8b2d8;
  --sidebar-text-active: #fff;
  --sidebar-width: 240px;

  --bg: #f0f2f8;
  --card-bg: #ffffff;
  --text: #1e2a45;
  --text-muted: #6b7a99;
  --border: #e2e8f0;

  --accent: #4361ee;
  --accent-hover: #3451d1;
  --success: #2ec4b6;
  --warning: #f77f00;
  --danger: #e63946;
  --info: #4895ef;

  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
       font-size: 14px; color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; }

/* ── Layout ────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s;
}
.sidebar-logo {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-logo h1 { font-size: 15px; color: #fff; font-weight: 700; letter-spacing: .02em; }
.sidebar-logo span { font-size: 11px; color: var(--sidebar-text); }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  cursor: pointer;
  border-radius: 0;
  transition: background .15s, color .15s;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: var(--sidebar-text-active); }
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-footer {
  padding: 12px 18px;
  border-top: 1px solid rgba(255,255,255,.06);
  font-size: 12px;
  color: var(--sidebar-text);
}
.sidebar-footer .user { color: #fff; font-weight: 600; font-size: 13px; }
.btn-logout {
  margin-top: 8px;
  background: none; border: 1px solid rgba(255,255,255,.15);
  color: var(--sidebar-text);
  padding: 6px 12px; border-radius: var(--radius);
  font-size: 12px; width: 100%; text-align: center;
  transition: background .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.08); color: #fff; }

/* ── Main content ──────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky; top: 0; z-index: 50;
}
.topbar h2 { font-size: 17px; font-weight: 600; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }
.content { padding: 24px 28px; flex: 1; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-header h3 { font-size: 14px; font-weight: 600; }
.card-body { padding: 20px; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 18px 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.stat-card .label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.stat-card .value { font-size: 26px; font-weight: 700; color: var(--text); }
.stat-card .sub { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* ── Tables ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
     color: var(--text-muted); background: #f8fafc; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 14px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; border: none;
  transition: opacity .15s, background .15s;
  white-space: nowrap;
}
.btn:hover { opacity: .88; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-info    { background: var(--info); color: #fff; }
.btn-ghost   { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); background: #f8fafc; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 9px; border-radius: 99px;
  font-size: 11px; font-weight: 600; letter-spacing: .03em;
}
.badge-ok      { background: #dcfce7; color: #15803d; }
.badge-warn    { background: #fef3c7; color: #92400e; }
.badge-missing { background: #fee2e2; color: #991b1b; }
.badge-active  { background: #dcfce7; color: #15803d; }
.badge-inactive{ background: #f1f5f9; color: #64748b; }
.badge-superadmin { background: #ede9fe; color: #5b21b6; }
.badge-operador   { background: #e0f2fe; color: #075985; }

/* ── DNS Semaphore ─────────────────────────────────────────── */
.dns-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.dns-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  box-shadow: var(--shadow);
}
.dns-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.dns-domain { font-size: 14px; font-weight: 700; }
.dns-ready  { font-size: 12px; }
.dns-checks { display: flex; flex-direction: column; gap: 8px; }
.dns-check {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 12px;
}
.dns-check .check-icon { font-size: 14px; flex-shrink: 0; line-height: 1.4; }
.dns-check .check-body { flex: 1; }
.dns-check .check-label { font-weight: 600; }
.dns-check .check-value { color: var(--text-muted); font-size: 11px; word-break: break-all; }
.dns-check .check-hint  { color: var(--danger); font-size: 11px; }
.dns-actions { margin-top: 12px; display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Progress bar ──────────────────────────────────────────── */
.progress { background: #e2e8f0; border-radius: 99px; height: 6px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 99px; background: var(--accent);
                transition: width .3s; }
.progress-bar.warn { background: var(--warning); }
.progress-bar.danger { background: var(--danger); }

/* ── Forms / Modals ────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal {
  background: var(--card-bg);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  width: 440px; max-width: 95vw;
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 15px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--text-muted);
               line-height: 1; padding: 2px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border);
                display: flex; gap: 8px; justify-content: flex-end; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600;
                    color: var(--text-muted); margin-bottom: 5px; text-transform: uppercase; }
.form-control {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; color: var(--text); background: #fff;
  transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--accent);
                      box-shadow: 0 0 0 3px rgba(67,97,238,.12); }
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7a99'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; appearance: none; }

/* ── Toast ─────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 999;
}
.toast {
  padding: 12px 18px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn .2s ease;
  max-width: 340px;
}
.toast-success { background: #dcfce7; color: #15803d; border-left: 4px solid var(--success); }
.toast-error   { background: #fee2e2; color: #991b1b; border-left: 4px solid var(--danger); }
.toast-info    { background: #e0f2fe; color: #075985; border-left: 4px solid var(--info); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; }
                     to   { transform: translateX(0);    opacity: 1; } }

/* ── Section groups ────────────────────────────────────────── */
.section { display: none; }
.section.active { display: block; }

/* ── Domain section header ─────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.section-header h2 { font-size: 18px; font-weight: 700; }

/* ── Storage bars ──────────────────────────────────────────── */
.storage-domain { margin-bottom: 20px; }
.storage-domain-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.storage-domain-name { font-weight: 700; font-size: 14px; }
.storage-domain-meta { font-size: 12px; color: var(--text-muted); }

/* ── Loading spinner ───────────────────────────────────────── */
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row td { text-align: center; padding: 32px; color: var(--text-muted); }

/* ── Empty state ───────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 36px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Collapsible domain groups ─────────────────────────────── */
.domain-group { margin-bottom: 4px; }
.domain-group-header {
  background: #f8fafc; padding: 8px 14px;
  font-weight: 700; font-size: 12px; letter-spacing: .04em;
  color: var(--text-muted); text-transform: uppercase;
  cursor: pointer; display: flex; align-items: center; gap: 6px;
  border-bottom: 1px solid var(--border);
}
.domain-group-header:hover { background: #eef2f7; }

/* ── Login page ────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--sidebar-bg) 0%, #2d3561 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-box {
  background: #fff; border-radius: 12px;
  padding: 40px; width: 380px; max-width: 95vw;
  box-shadow: var(--shadow-lg);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 20px; font-weight: 800; color: var(--text); }
.login-logo p  { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.login-error { background: #fee2e2; color: #991b1b; padding: 10px 14px;
               border-radius: var(--radius); font-size: 13px; margin-bottom: 14px; }
