:root {
  --bg: #0a0d14;
  --bg-soft: #0f1420;
  --card: #131926;
  --card-2: #171f30;
  --line: #222c40;
  --line-2: #2d3a55;
  --text: #e7ecff;
  --muted: #8a95b0;
  --muted-2: #5f6b85;
  --accent: #7c5cff;
  --accent-2: #4fd1c5;
  --accent-glow: rgba(124, 92, 255, .28);
  --ok: #3ddc97;
  --warn: #ffbe55;
  --bad: #ff6b6b;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 24px 60px rgba(0, 0, 0, .45);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(124, 92, 255, .14), transparent 60%),
    radial-gradient(900px 520px at 100% 0%, rgba(79, 209, 197, .09), transparent 55%),
    var(--bg);
  min-height: 100vh;
}

body.app::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, .022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .022) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(#000 0%, transparent 75%);
  z-index: 0;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }

code, .mono { font-family: var(--mono); font-size: 12.5px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ------------------------------------------------------------ top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 14px 26px;
  background: rgba(10, 13, 20, .78);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -.01em;
  white-space: nowrap;
}

.brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 4px var(--accent-glow), 0 0 18px var(--accent);
}

.brand.big { font-size: 26px; margin-bottom: 18px; }
.brand.big .dot { width: 14px; height: 14px; }

.tag {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--accent-2);
  border: 1px solid rgba(79, 209, 197, .35);
  border-radius: 999px;
  padding: 2px 8px;
}

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

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 550;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: color .15s, background .15s;
}

.tab:hover { color: var(--text); background: rgba(255, 255, 255, .05); text-decoration: none; }
.tab.active { color: var(--text); background: rgba(124, 92, 255, .18); box-shadow: inset 0 0 0 1px rgba(124, 92, 255, .35); }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* ------------------------------------------------------------- layout */

.page {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  padding: 26px 26px 64px;
}

.section-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 16px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 18px; }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.services-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.card {
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .03) inset;
}

.card + .card, .grid + .grid, .card + .grid, .grid + .card { margin-top: 16px; }
.grid .card + .card { margin-top: 0; }

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

.stat {
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}

.stat::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: .45;
}

.stat .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--muted); }
.stat .sub { margin-top: 6px; font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; margin: 0 -6px; }

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

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

td {
  padding: 10px;
  border-bottom: 1px solid rgba(34, 44, 64, .55);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255, 255, 255, .022); }

.empty {
  padding: 26px 10px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ------------------------------------------------------------ controls */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}

.btn:hover { background: rgba(255, 255, 255, .08); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), #5f7dff);
  box-shadow: 0 8px 24px rgba(124, 92, 255, .28);
}

.btn.primary:hover { background: linear-gradient(135deg, #8b6dff, #6a86ff); }

.btn.danger { color: var(--bad); border-color: rgba(255, 107, 107, .35); background: rgba(255, 107, 107, .08); }
.btn.danger:hover { background: rgba(255, 107, 107, .16); }

.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: rgba(255, 255, 255, .06); }

.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn.block { width: 100%; padding: 11px 14px; }

label { display: block; font-size: 12px; color: var(--muted); font-weight: 550; }
label > input, label > select, label > textarea { margin-top: 6px; }

input, select, textarea {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line-2);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea { min-height: 92px; resize: vertical; font-family: var(--mono); font-size: 12.5px; }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }

.form { display: grid; gap: 16px; }
.form .cols { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form .cols.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13px; margin-top: 24px; }

.hint { display: block; margin-top: 5px; font-size: 11.5px; color: var(--muted-2); font-weight: 400; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.toolbar .spacer { flex: 1; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }

/* --------------------------------------------------------------- chips */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(124, 92, 255, .13);
  border: 1px solid rgba(124, 92, 255, .3);
  color: #cbc2ff;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11.5px;
  font-weight: 550;
  white-space: nowrap;
}

.chip.gray { background: rgba(255, 255, 255, .05); border-color: var(--line-2); color: var(--muted); }
.chip.ok { background: rgba(61, 220, 151, .12); border-color: rgba(61, 220, 151, .32); color: var(--ok); }
.chip.bad { background: rgba(255, 107, 107, .12); border-color: rgba(255, 107, 107, .32); color: var(--bad); }
.chip.warn { background: rgba(255, 190, 85, .12); border-color: rgba(255, 190, 85, .32); color: var(--warn); }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 2px 9px;
}

.pill.live { color: var(--ok); border-color: rgba(61, 220, 151, .35); }
.pill.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.pill.dead { color: var(--bad); border-color: rgba(255, 107, 107, .35); }

/* --------------------------------------------------------------- picks */

.picks {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 7px;
  max-height: 190px;
  overflow-y: auto;
  padding: 4px;
}

.pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: border-color .12s, background .12s, color .12s;
}

.pick input { display: none; }
.pick:has(input:checked) {
  color: var(--text);
  border-color: rgba(124, 92, 255, .55);
  background: rgba(124, 92, 255, .14);
}

/* -------------------------------------------------------------- modal */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 18px;
  background: rgba(4, 6, 11, .68);
  backdrop-filter: blur(6px);
  overflow-y: auto;
  animation: fade .14s ease-out;
}

.modal {
  width: 100%;
  max-width: 560px;
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: pop .16s ease-out;
}

.modal.wide { max-width: 760px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-body { padding: 18px; max-height: 68vh; overflow-y: auto; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}

.x {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.x:hover { color: var(--text); }

/* -------------------------------------------------------------- toast */

#toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 36px));
}

.toast {
  background: #1a2131;
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--accent);
  border-radius: 9px;
  padding: 11px 14px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: slide .18s ease-out;
}

.toast.ok { border-left-color: var(--ok); }
.toast.bad { border-left-color: var(--bad); }
.toast.warn { border-left-color: var(--warn); }

/* --------------------------------------------------------------- auth */

body.auth { display: grid; place-items: center; min-height: 100vh; }

.auth-wrap {
  width: 100%;
  max-width: 380px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.auth-card { width: 100%; padding: 24px; box-shadow: var(--shadow); }
.auth-card h1 { margin-bottom: 4px; }
.auth-card p { margin: 0 0 18px; }
.auth-card label { margin-bottom: 14px; font-size: 12.5px; }
.auth-card .btn { margin-top: 4px; }

.error {
  background: rgba(255, 107, 107, .1);
  border: 1px solid rgba(255, 107, 107, .35);
  color: #ffb3b3;
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 12.5px;
  margin-bottom: 12px;
}

/* ---------------------------------------------------------------- misc */

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 9px 14px; font-size: 13px; }
.kv .k { color: var(--muted); }
.kv .v { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }

.copy-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
}

.copy-row code { flex: 1; word-break: break-all; }
.copy-row .btn { padding: 4px 9px; font-size: 11.5px; }

.code-block {
  background: var(--bg-soft);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #b9c6e6;
  margin: 0;
}

.steps { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.steps li { margin-bottom: 7px; }
.steps li::marker { color: var(--accent); }

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 12px; font-size: 12.5px; color: var(--muted); }

.badge-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: var(--muted-2); }
.badge-dot.on { background: var(--ok); box-shadow: 0 0 7px var(--ok); }

.row-actions { display: flex; gap: 5px; justify-content: flex-end; }

.hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.hero p { margin: 4px 0 0; color: var(--muted); }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes slide { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }

@media (max-width: 980px) {
  .two, .three { grid-template-columns: 1fr; }
  .form .cols, .form .cols.three { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 10px 16px; padding: 12px 16px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .top-actions { margin-left: auto; }
  .page { padding: 18px 16px 48px; }
  .stat .value { font-size: 22px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv .k { margin-top: 8px; }
}

@media (max-width: 560px) {
  .hero { align-items: flex-start; }
  .btn.sm { padding: 5px 8px; }
  .who { display: none; }
  .modal-body { max-height: 74vh; }
}
