:root {
  --bg: #f8fafc;
  --bg-elevated: #ffffff;
  --sidebar: #0f172a;
  --sidebar-hover: #1e293b;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --primary: #0d9488;
  --primary-hover: #0f766e;
  --primary-soft: #ccfbf1;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning-soft: #fef3c7;
  --warning-text: #92400e;
  --success-soft: #d1fae5;
  --success-text: #065f46;
  --error-soft: #fee2e2;
  --error-text: #991b1b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgb(15 23 42 / 6%), 0 4px 16px rgb(15 23 42 / 4%);
  --radius: 14px;
  --radius-sm: 8px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.ico {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--sidebar);
  color: #e2e8f0;
  padding: 24px 18px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-icon { border-radius: 8px; }

.brand {
  font-size: 1.05rem;
  font-weight: 700;
  color: #5eead4;
  letter-spacing: -0.02em;
}

.sub {
  font-size: 11px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar nav { flex: 1; }

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #cbd5e1;
  text-decoration: none;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.sidebar nav a:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; }

.sidebar-status {
  font-size: 12px;
  color: var(--text-light);
  padding: 12px 14px;
  background: rgb(255 255 255 / 4%);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.healthy { background: #22c55e; box-shadow: 0 0 8px #22c55e88; }
.status-dot.other { background: #f59e0b; }
.status-dot.loading { background: #64748b; animation: pulse 1.2s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.sidebar .ext {
  border-top: 1px solid #334155;
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar .ext a {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #5eead4;
  text-decoration: none;
  font-size: 13px;
}

.sidebar .ext a.muted { color: var(--text-light); }
.sidebar .ext a:hover { color: #99f6e4; }

/* Main */
.main {
  flex: 1;
  padding: 28px 32px 48px;
  max-width: 1200px;
  min-width: 0;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.page-header h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.page-header p { margin: 6px 0 0; color: var(--text-muted); font-size: 14px; }

.breadcrumb {
  font-size: 13px;
  margin: 0 0 4px;
  color: var(--text-muted);
}

.breadcrumb a { color: var(--primary); text-decoration: none; }

.header-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline; }

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
}

.stat:hover { transform: translateY(-1px); }

.stat .num {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.stat .num.sm { font-size: 1rem; font-family: var(--mono); }

.stat .lbl {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
  font-weight: 600;
}

.skeleton-stat .num { color: var(--text-light); }

/* Tabs */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  width: fit-content;
  flex-wrap: wrap;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 0;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}

.tab:hover { color: var(--text); background: var(--bg); }
.tab.active { background: var(--primary); color: #fff; }

.tab-panel { display: none; animation: fadeIn 0.2s ease; }
.tab-panel.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* Cards */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.card h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.card .hint {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 16px;
}

.chip {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--primary-soft);
  color: var(--primary-hover);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Forms */
label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input, select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 14px;
  font-family: inherit;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(13 148 136 / 15%);
}

.search-input {
  max-width: 220px;
  margin: 0;
  padding: 8px 12px;
  font-size: 13px;
}

.form-compact input:last-of-type { margin-bottom: 14px; }

.pw-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.pw-row input { margin: 0; flex: 1; min-width: 100px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: #fff;
  border: 0;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn:hover { background: var(--primary-hover); }
.btn:active { transform: scale(0.98); }
.btn.secondary { background: #475569; }
.btn.danger { background: var(--danger); }
.btn.ghost {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.ghost:hover { background: var(--bg); border-color: #cbd5e1; }
.btn.sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; margin-top: 4px; }

/* Flash & Toast */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
  border: 1px solid transparent;
}

.flash.success { background: var(--success-soft); color: var(--success-text); border-color: #a7f3d0; }
.flash.error { background: var(--error-soft); color: var(--error-text); border-color: #fecaca; }
.flash.warning { background: var(--warning-soft); color: var(--warning-text); border-color: #fde68a; }

#toast-root {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--sidebar);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 20%);
  animation: slideIn 0.25s ease;
  pointer-events: auto;
  max-width: 360px;
}

.toast.success { border-left: 4px solid #22c55e; }
.toast.error { border-left: 4px solid #ef4444; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: none; }
}

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -4px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  white-space: nowrap;
}

td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: 0; }
tr:hover td { background: #f8fafc; }

.loading-cell {
  color: var(--text-muted);
  text-align: center;
  padding: 32px !important;
}

code {
  font-family: var(--mono);
  font-size: 12px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
}

/* Badges */
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
}

.badge.ok { background: var(--success-soft); color: var(--success-text); }
.badge.warn { background: var(--warning-soft); color: var(--warning-text); }
.badge.err { background: var(--error-soft); color: var(--error-text); }

.type-badge {
  display: inline-block;
  font-weight: 700;
  font-size: 12px;
  color: var(--primary);
}

.type-note {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Domain list */
.domain-list { list-style: none; padding: 0; margin: 0; }

.domain-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.domain-list li:last-child { border-bottom: 0; }
.domain-list .empty { color: var(--text-muted); font-size: 14px; }

.domain-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.domain-info a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  font-size: 15px;
}

.domain-info a:hover { text-decoration: underline; }

.domain-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
}

.domain-actions { display: flex; gap: 6px; flex-shrink: 0; }

.skeleton-line { color: var(--text-light); }

/* Account actions */
.actions-cell { min-width: 280px; }

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.actions-row form { display: inline-flex; gap: 4px; align-items: center; margin: 0; }
.actions-row input[type="password"],
.actions-row input[type="text"] {
  width: 110px;
  margin: 0;
  padding: 6px 8px;
  font-size: 12px;
}

.usage-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 4px;
  max-width: 120px;
  overflow: hidden;
}

.usage-bar span {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
}

.alias-tags { display: flex; flex-wrap: wrap; gap: 4px; }

.alias-tag {
  font-size: 11px;
  padding: 2px 8px;
  background: #f1f5f9;
  border-radius: 12px;
  color: var(--text-muted);
}

/* Client settings */
.client-settings {
  font-size: 13px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.client-settings.empty-state { color: var(--text-muted); text-align: center; }

.client-settings dl {
  margin: 0;
  display: grid;
  gap: 10px;
}

.client-settings dt {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.client-settings dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* DNS */
.dns-table .val {
  word-break: break-all;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
}

.card-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

/* Activity */
.activity-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.activity-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.activity-list li:last-child { border-bottom: 0; }

.activity-list time { color: var(--text-muted); font-family: var(--mono); font-size: 12px; }
.activity-list .act { font-weight: 600; color: var(--primary); }
.activity-list .detail { color: var(--text-muted); }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(15 23 42 / 50%);
  z-index: 8000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgb(0 0 0 / 25%);
}

.modal h3 { margin: 0 0 16px; font-size: 1.1rem; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #0f172a 0%, #134e4a 50%, #0f172a 100%);
}

.login-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 20%, rgb(20 184 166 / 20%), transparent 50%);
}

.login-card {
  position: relative;
  background: #fff;
  border-radius: 20px;
  padding: 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 64px rgb(0 0 0 / 35%);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.login-brand h1 {
  margin: 0;
  font-size: 1.4rem;
  color: var(--primary);
  letter-spacing: -0.03em;
}

.login-brand .sub {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
}

.login-form label { margin-top: 4px; }
.login-footer {
  margin-top: 24px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

.login-footer a { color: var(--primary); }

/* Responsive */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 16px;
  }
  .brand-row { margin-bottom: 0; }
  .sidebar nav { display: flex; flex: none; }
  .sidebar-status { margin: 0; }
  .sidebar .ext { border: 0; padding: 0; flex-direction: row; margin-left: auto; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: 1fr; }
  .main { padding: 20px 16px 40px; }
  .tabs { width: 100%; }
  .tab { flex: 1; justify-content: center; }
}

@media (max-width: 500px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .actions-cell { min-width: auto; }
}
