:root {
  color-scheme: dark;
  --bg: #07111f;
  --card: rgba(15, 23, 42, 0.86);
  --card-border: rgba(148, 163, 184, 0.18);
  --text: #e5eefc;
  --muted: #92a3ba;
  --primary: #38bdf8;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --surface: rgba(30, 41, 59, 0.72);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.24), transparent 34rem),
    radial-gradient(circle at 80% 20%, rgba(99, 102, 241, 0.18), transparent 26rem),
    var(--bg);
  color: var(--text);
}

button, input, select { font: inherit; }
button {
  border: 0;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(28px, env(safe-area-inset-bottom));
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 4px 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, p { margin: 0; }

h1 {
  font-size: clamp(28px, 8vw, 42px);
  line-height: 1.05;
  word-break: break-word;
}

main {
  display: grid;
  gap: 14px;
}

.card {
  border: 1px solid var(--card-border);
  border-radius: 24px;
  background: var(--card);
  padding: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(18px);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.section-title h2 { font-size: 18px; }

.hstack {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--primary);
  color: #000;
  font-size: 12px;
  font-weight: 700;
}

.icon-button-sm {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--card-border);
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-button-sm.ghost { background: transparent; box-shadow: none; }

.server-list { display: grid; gap: 8px; }

.list-placeholder {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 24px 0;
}

.server-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.62);
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  user-select: none;
}

.server-item:active { background: rgba(15, 23, 42, 0.9); }
.server-item.active { box-shadow: inset 0 0 0 1.5px var(--primary); }

.server-item .dot {
  width: 10px; height: 10px;
  border-radius: 50%; flex-shrink: 0;
  background: var(--muted);
}
.server-item .dot.online  { background: var(--success); }
.server-item .dot.offline { background: var(--danger); }

.server-item .info { flex: 1; min-width: 0; }
.server-item .info strong {
  display: block;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.server-item .info small { color: var(--muted); font-size: 12px; }

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

.server-item .actions button {
  width: 34px; height: 34px;
  border-radius: 10px;
  font-size: 15px;
  background: rgba(255,255,255,0.06);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.server-item .actions .delete-btn { color: var(--danger); }

.form-card[hidden] { display: none; }

.status-card { padding: 16px; }

.status-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 16px;
}

.status-topline > div {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 18px currentColor;
}
.status-dot.online  { background: var(--success); color: var(--success); }
.status-dot.offline { background: var(--danger);  color: var(--danger); }
.status-dot.busy    { background: var(--warning); color: var(--warning); }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  min-width: 0;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.66);
  padding: 14px;
}

.metric span, .metric small, .section-title > span, dt {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 20px;
  word-break: break-word;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.action {
  min-height: 46px;
  border-radius: 15px;
  font-weight: 700;
  background: var(--surface);
}
.action.success { background: rgba(34,197,94,0.18); color: #86efac; }
.action.warning { background: rgba(245,158,11,0.18); color: #fcd34d; }
.action.danger  { background: rgba(239,68,68,0.18); color: #fca5a5; }
.action.ghost   { box-shadow: inset 0 0 0 1px rgba(239,68,68,0.32); }

.detail-list { display: grid; gap: 12px; margin: 0; }
.detail-list div { display: grid; gap: 5px; }
dd { margin: 0; overflow-wrap: anywhere; }

.field { display: grid; gap: 8px; margin-top: 12px; }
.field:first-child { margin-top: 0; }
.field span { color: var(--muted); font-size: 13px; }

input, select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--card-border);
  border-radius: 15px;
  background: rgba(15,23,42,0.82);
  color: var(--text);
  padding: 0 14px;
  outline: none;
}

input:focus, select:focus {
  border-color: rgba(56,189,248,0.72);
  box-shadow: 0 0 0 4px rgba(56,189,248,0.12);
}

.primary { background: linear-gradient(135deg, #38bdf8, #6366f1); }
.secondary, .link-button { background: var(--surface); }
.link-button { min-height: 38px; padding: 0 12px; color: var(--primary); }

.settings-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.settings-actions button { flex: 1; }

.snapshot-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(15,23,42,0.62);
}
.snapshot-item + .snapshot-item { margin-top: 8px; }
.snapshot-item small { color: var(--muted); }

.mini-danger {
  min-height: 36px;
  padding: 0 10px;
  border-radius: 12px;
  background: rgba(239,68,68,0.18);
  color: #fca5a5;
}

.list-empty, pre { color: var(--muted); margin: 0; }
pre { white-space: pre-wrap; word-break: break-word; font-size: 13px; }

#toast {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 10;
  min-height: 48px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: rgba(2,6,23,0.94);
  color: var(--text);
  padding: 12px 16px;
  text-align: center;
  box-shadow: 0 18px 40px rgba(0,0,0,0.36);
}
#toast.show { display: flex; }

@media (min-width: 680px) {
  .metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .details-card .detail-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
