:root {
  --bg: #0f172a;
  --card: #111827;
  --accent: #06b6d4;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --border: #1f2937;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 20% 20%, #0b3b4c, #0f172a 30%), radial-gradient(circle at 80% 0%, #1f2937, #0f172a 35%), var(--bg);
  color: var(--text);
  min-height: 100vh;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; letter-spacing: 0.5px; }
nav a {
  color: var(--muted);
  margin-right: 12px;
  text-decoration: none;
}
nav a:hover { color: var(--text); }
nav button { margin-left: 8px; }
main { padding: 24px; max-width: 1200px; margin: 0 auto; display: grid; gap: 16px; }
.tabs {
  display: flex;
  gap: 12px;
  flex-wrap: nowrap;
  overflow-x: auto;
}
.tabs button {
  background: #0c1422;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
}
.tabs button.active {
  border-color: var(--accent);
  background: radial-gradient(circle at 30% 20%, rgba(56,189,248,0.25), transparent 55%), #020617;
}
.tabs::-webkit-scrollbar { height: 6px; }
.tabs::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
.tabs button:hover { border-color: var(--accent); }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.25);
}
h2, h3, h4 { margin-top: 0; }
label { display: block; margin: 8px 0; font-size: 0.95rem; }
input, select, button, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  font-size: 0.95rem;
}
button {
  background: linear-gradient(120deg, #0ea5e9, #06b6d4);
  border: none;
  color: #0b1220;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
button:hover { transform: translateY(-1px); box-shadow: 0 10px 25px rgba(6,182,212,0.25); }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
button.danger {
  background: #ef4444;
  color: #fee2e2;
  border-color: #b91c1c;
}
button.danger:hover {
  box-shadow: 0 10px 25px rgba(248,113,113,0.35);
}
.muted { color: var(--muted); font-size: 0.9rem; }
.muted.smaller { font-size: 0.8rem; }
.status { margin-top: 8px; min-height: 18px; }
.list { list-style: none; padding: 0; margin: 8px 0; max-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.list li { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: none; }
.list small { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.pending-card { border: 1px solid var(--border); padding: 12px; border-radius: 10px; background: #0c1422; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.column { background: #0c1422; border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
table { width: 100%; border-collapse: collapse; margin-top: 8px; }
table th, table td { border: 1px solid var(--border); padding: 8px; font-size: 0.9rem; }
table th { background: #0c1422; }
.hidden { display: none !important; }
.inline { display: flex; align-items: center; gap: 8px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.dot.green { background: #22c55e; }
.dot.yellow { background: #eab308; }
.dot.red { background: #ef4444; }

/* Domain layout */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; background: #0c1422; border-bottom: 1px solid var(--border); }
.topbar .brand { font-weight: 700; cursor: pointer; font-size: 1.05rem; }
.topbar .topbar-actions { display: flex; gap: 12px; align-items: center; }
.domain-switcher-wrapper input {
  min-width: 220px;
  max-width: 320px;
}
.layout { display: grid; grid-template-columns: minmax(180px, 220px) minmax(0, 1fr); min-height: calc(100vh - 70px); width: 100%; max-width: 100vw; }
.layout, .content { width: 100%; }
.sidebar { border-right: 1px solid var(--border); background: #0c1422; padding: 12px; }
.side-link { width: 100%; text-align: left; padding: 9px 12px; border: 1px solid var(--border); background: #0f172a; color: var(--text); border-radius: 8px; margin-bottom: 8px; }
.side-link.active { border-color: var(--accent); }
.content { padding: 18px; display: grid; gap: 14px; min-width: 0; width: 100%; }
.dns-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.search-group {
  display: flex;
  gap: 6px;
  align-items: center;
  flex: 1 1 260px;
}
.dns-toolbar .search-group input[type="search"],
.dns-toolbar .search-group input {
  width: 100%;
}
.dns-toolbar button,
#user-domain-add {
  width: auto;
  flex: 0 0 auto;
  white-space: nowrap;
}
.table-wrapper { width: 100%; max-width: 100%; overflow-x: auto; }
.dns-table { width: 100%; max-width: 100%; border-collapse: collapse; table-layout: auto; }
.dns-table th, .dns-table td {
  font-size: 0.82rem;
  padding: 6px;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.dns-table .truncate {
  display: inline;
  white-space: normal;
}
.expand-row td { background: #0c1422; }
.expand-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }
.expand-fields textarea { width: 100%; min-height: 80px; resize: vertical; }
.dns-table tbody tr:nth-child(odd) { background: #0c1422; }
.dns-table th { background: #0c1422; position: sticky; top: 0; }
.ghost.small { padding: 6px 8px; font-size: 0.85rem; }
.expand-actions {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: 8px;
  width: 100%;
}
.expand-actions > .inline {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.expand-actions > .inline button {
  width: auto;
  flex-shrink: 0;
}

.cloud-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  margin-right: 6px;
  font-size: 14px;
  background: #1f2937;
  color: #6b7280;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.cloud-icon.on {
  background: #f97316;
  color: #111827;
}
.cloud-icon.off {
  background: #1f2937;
  color: #6b7280;
}

#pending-dns-wrapper {
  margin-bottom: 50px;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
  gap: 16px;
  margin-top: 12px;
}
.score-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.score-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 20%, rgba(148,163,184,0.35), transparent 55%), #020617;
  border: 3px solid var(--border);
}
.score-circle.good { border-color: #22c55e; box-shadow: 0 0 0 1px rgba(34,197,94,0.3); }
.score-circle.warn { border-color: #eab308; box-shadow: 0 0 0 1px rgba(234,179,8,0.3); }
.score-circle.bad { border-color: #ef4444; box-shadow: 0 0 0 1px rgba(239,68,68,0.3); }
#score-value { font-size: 2.2rem; font-weight: 700; }
.alerts-card { max-height: 260px; overflow-y: auto; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  margin-right: 6px;
}
.badge.high { background: rgba(239,68,68,0.15); color: #fecaca; }
.badge.medium { background: rgba(234,179,8,0.15); color: #fef3c7; }
.badge.low { background: rgba(56,189,248,0.15); color: #e0f2fe; }
.badge.info { background: rgba(148,163,184,0.18); color: #e5e7eb; }

.expiring-card {
  max-height: none;
  overflow: visible;
}
#lowsec-list {
  max-height: none;
  overflow: visible;
}

/* Client home low-security section */
#client-lowsec-heading {
  margin-top: 24px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
#client-lowsec-list {
  max-height: none;
  overflow: visible;
}
#home-pending {
  margin-top: 24px;
  margin-bottom: 48px;
}
#lowsec-heading {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

/* Client TOTP setup */
.totp-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr);
  gap: 16px;
  align-items: flex-start;
  margin-top: 12px;
}
.totp-steps {
  margin: 0 0 12px 20px;
  padding: 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.totp-steps li + li {
  margin-top: 4px;
}
.totp-qr {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: #020617;
  padding: 12px;
  min-height: 180px;
}
.totp-qr img {
  width: 180px;
  height: 180px;
  object-fit: contain;
}

/* Admin home stats */
.stats-circle {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 20%, rgba(148,163,184,0.35), transparent 55%), #020617;
  border: 3px solid var(--border);
}
.stats-circle.good { border-color: #22c55e; box-shadow: 0 0 0 1px rgba(34,197,94,0.3); }
.stats-circle.mixed { border-color: #eab308; box-shadow: 0 0 0 1px rgba(234,179,8,0.3); }
.stats-circle.bad { border-color: #ef4444; box-shadow: 0 0 0 1px rgba(239,68,68,0.3); }
#stats-total { font-size: 2rem; font-weight: 700; }

.registration-card { margin-top: 16px; }
.registration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px 16px;
  margin-bottom: 8px;
  font-size: 0.9rem;
}
.whois-block pre {
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.lock-indicator { display: inline-flex; align-items: center; gap: 4px; }
.lock-icon.locked { color: #22c55e; }
.lock-icon.unlocked { color: #ef4444; }

.history-pre {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
}

#history-timeline .timeline-item {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
#history-timeline .timeline-item.active {
  background: #0c1422;
  border-left: 2px solid var(--accent);
}

.history-row {
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  align-items: flex-start;
}
#history-timeline {
  max-height: 360px;
  overflow-y: auto;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15,23,42,0.75);
}
.modal-content {
  position: relative;
  background: #020617;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

/* User domain assignments list */
#user-domain-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
#user-domain-list li strong {
  flex: 1 1 auto;
}
#user-domain-list li button {
  width: auto;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .row { grid-template-columns: 1fr; }
  main { padding: 16px; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
  .totp-layout {
    grid-template-columns: 1fr;
  }
}
