:root {
  --bg-top: #242b59;
  --bg-bottom: #05060d;
  --panel: rgba(255, 255, 255, 0.05);
  --border: rgba(255, 255, 255, 0.1);
  --text: #e9ebf8;
  --muted: #9aa1c6;
  --accent: #8a63d2;
  --accent-strong: #6b45b8;
  --good: #34d399;
  --warn: #fbbf24;
  --info: #60a5fa;
  --bad: #f87171;
  --radius: 16px;
  --gutter: 16px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: dark; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--text); background: #05060d;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; line-height: 1.45;
}
body::before { content: ""; position: fixed; inset: 0; z-index: -1; background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom) 85%); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.muted { color: var(--muted); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.88em; }

.wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 max(var(--gutter), env(safe-area-inset-left)); }
.topbar { padding: 16px 0; border-bottom: 1px solid var(--border); background: rgba(0, 0, 0, 0.2); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; font-size: 1.25rem; font-weight: 650; }
main.wrap { padding-top: 20px; padding-bottom: calc(40px + env(safe-area-inset-bottom)); }

/* buttons & fields */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border: 1px solid var(--border); border-radius: 12px; background: rgba(255, 255, 255, 0.06); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; transition: background-color 0.15s;
}
.btn:hover { background: rgba(255, 255, 255, 0.12); }
.btn:focus-visible, input:focus-visible, .chip-link:focus-visible { outline: 3px solid rgba(138, 99, 210, 0.6); outline-offset: 2px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent-strong); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #7a52c9; }
.btn-secondary { background: rgba(138, 99, 210, 0.18); border-color: rgba(138, 99, 210, 0.5); }
.btn-ghost { background: transparent; }
.btn-danger { background: #b4232c; border-color: #ef4444; color: #fff; }
.btn-danger:hover:not([disabled]) { background: #cf2b36; }
.btn-block { width: 100%; }
.btn-small { min-height: 40px; padding: 0 14px; font-size: 0.9rem; }

.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 16px; }
.field-label { color: var(--muted); font-size: 0.74rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; }
.hint { color: var(--muted); font-size: 0.82rem; }
input {
  width: 100%; height: 48px; padding: 0 14px; border: 1px solid var(--border); border-radius: 12px;
  background: rgba(255, 255, 255, 0.06); color: var(--text); font: inherit; font-size: 16px;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(138, 99, 210, 0.35); }
input::placeholder { color: rgba(154, 161, 198, 0.6); }
.suffix-input { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 12px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.suffix-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(138, 99, 210, 0.35); }
.suffix-input input { border: 0; border-radius: 0; background: transparent; box-shadow: none; min-width: 0; }
.suffix { display: grid; place-items: center; padding: 0 12px; color: var(--muted); font-size: 0.9rem; white-space: nowrap; background: rgba(0, 0, 0, 0.2); }
.form-error { margin: 0 0 14px; padding: 10px 12px; border: 1px solid rgba(248, 113, 113, 0.5); border-radius: 10px; background: rgba(248, 113, 113, 0.12); color: #fecaca; font-size: 0.92rem; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px var(--gutter); }
.login-card { width: 100%; max-width: 380px; padding: 28px 24px; border: 1px solid var(--border); border-radius: 20px; background: var(--panel); backdrop-filter: blur(8px); text-align: center; }
.login-card h1 { margin: 12px 0 4px; font-size: 1.5rem; }
.login-card .muted { margin: 0 0 20px; }
.login-card .field { text-align: left; }
.login-logo { display: block; margin: 0 auto; }

/* dashboard */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
.tile { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.tile-label { color: var(--muted); font-size: 0.72rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; }
.tile strong { font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.toolbar h2 { font-size: 1.25rem; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.banner { margin-bottom: 16px; padding: 14px 16px; border: 1px solid rgba(251, 191, 36, 0.45); border-radius: 14px; background: rgba(251, 191, 36, 0.1); font-size: 0.95rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.card { display: flex; flex-direction: column; gap: 14px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-title { margin: 0; font-size: 1.15rem; overflow-wrap: anywhere; }
.card-title a { color: #fff; text-decoration: none; }
.card-title a:hover { text-decoration: underline; }
.card-host { margin: 2px 0 0; color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; border: 1px solid; font-size: 0.74rem; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip-live { color: var(--good); border-color: rgba(52, 211, 153, 0.5); background: rgba(52, 211, 153, 0.1); }
.chip-needs-dns { color: var(--warn); border-color: rgba(251, 191, 36, 0.5); background: rgba(251, 191, 36, 0.1); }
.chip-needs-cert { color: var(--info); border-color: rgba(96, 165, 250, 0.5); background: rgba(96, 165, 250, 0.1); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 0; }
.facts div { min-width: 0; }
.facts dt { color: var(--muted); font-size: 0.7rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; }
.facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.facts .wide { grid-column: 1 / -1; }
.help { margin: 0; padding: 10px 12px; border-radius: 10px; background: rgba(0, 0, 0, 0.25); color: var(--muted); font-size: 0.88rem; }
.help b, .help code { color: var(--text); }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.card-actions .btn { flex: 1 1 auto; }
.empty { padding: 28px; border: 1px dashed var(--border); border-radius: var(--radius); text-align: center; color: var(--muted); }

/* dialogs */
dialog { width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 1px solid var(--border); border-radius: 20px; background: #161a38; color: var(--text); overflow: auto; }
dialog::backdrop { background: rgba(2, 3, 10, 0.7); backdrop-filter: blur(3px); }
dialog form { padding: 22px; }
dialog h3 { margin-bottom: 6px; font-size: 1.25rem; }
dialog .muted { margin: 0 0 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.warning { margin: 14px 0 18px; padding: 12px 14px; border: 1px solid rgba(248, 113, 113, 0.5); border-radius: 12px; background: rgba(248, 113, 113, 0.1); font-size: 0.95rem; }
.warning strong { display: block; margin-bottom: 2px; color: #fecaca; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 20; transform: translateX(-50%); width: min(560px, calc(100vw - 24px)); padding: 14px 16px; border: 1px solid var(--border); border-radius: 14px; background: #1d2247; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); font-size: 0.95rem; }
.toast.ok { border-color: rgba(52, 211, 153, 0.6); }
.toast.err { border-color: rgba(248, 113, 113, 0.7); }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, 0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  :root { --gutter: 14px; }
  .tiles { gap: 8px; }
  .tile { padding: 12px; }
  .tile strong { font-size: 1.4rem; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions .btn { flex: 1 1 100%; }
  .grid { grid-template-columns: 1fr; }
  /* dialogs become bottom sheets on phones */
  dialog { width: 100%; max-width: none; margin: auto 0 0; border-radius: 20px 20px 0 0; border-bottom: 0; }
  dialog form { padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.btn-danger-outline { border-color: rgba(248, 113, 113, 0.5); color: #fecaca; background: rgba(248, 113, 113, 0.08); }
.btn-danger-outline:hover:not([disabled]) { background: rgba(248, 113, 113, 0.2); }
