/* Anubis ICMP Monitor — dark dashboard theme */

:root {
  --bg: #0b0c0e;
  --panel: #15181d;
  --panel-2: #1b1f25;
  --panel-3: #22272f;
  --border: #272c34;
  --border-strong: #343b45;
  --text: #e7eaee;
  --dim: #99a2ae;
  --faint: #6b7481;
  --green: #73bf69;
  --green-dim: rgba(115, 191, 105, 0.16);
  --red: #f2495c;
  --red-dim: rgba(242, 73, 92, 0.14);
  --orange: #ff9830;
  --orange-dim: rgba(255, 152, 48, 0.14);
  --blue: #5794f2;
  --blue-dim: rgba(87, 148, 242, 0.15);
  --gold: #e8b45a;
  --gold-dim: rgba(232, 180, 90, 0.14);
  --primary: #3d71d9;
  --radius: 12px;
  --radius-sm: 8px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(900px 520px at 12% -12%, rgba(232, 180, 90, 0.07), transparent 70%),
    radial-gradient(760px 420px at 96% -6%, rgba(87, 148, 242, 0.08), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1, h2, p, dl, dd { margin: 0; }

button, input, select { font: inherit; color: inherit; }

code {
  font-family: var(--mono);
  font-size: 0.92em;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.hidden { display: none !important; }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 58px;
  padding: 0 clamp(16px, 4vw, 40px);
  background: rgba(11, 12, 14, 0.84);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-logo {
  display: block;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  flex: none;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.brand-accent {
  color: var(--gold);
  margin-left: 3px;
  margin-right: 3px;
  font-weight: 600;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 14px;
}

.admin-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--dim);
  font-size: 12px;
  text-decoration: none;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.admin-link:hover {
  color: var(--gold);
  border-color: rgba(232, 180, 90, 0.3);
  background: var(--gold-dim);
}

.api-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 11px 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  font-size: 12px;
  color: var(--dim);
  white-space: nowrap;
}

.api-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--orange);
  flex: none;
}

.api-status.online {
  color: var(--green);
  border-color: rgba(115, 191, 105, 0.32);
  background: rgba(115, 191, 105, 0.08);
}
.api-status.online .api-dot {
  background: var(--green);
  box-shadow: 0 0 8px rgba(115, 191, 105, 0.8);
}

.api-status.offline {
  color: var(--red);
  border-color: rgba(242, 73, 92, 0.34);
  background: rgba(242, 73, 92, 0.08);
}
.api-status.offline .api-dot {
  background: var(--red);
  box-shadow: 0 0 8px rgba(242, 73, 92, 0.8);
}

.topbar-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
}

.clock {
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--dim);
  letter-spacing: 0.02em;
}

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

.page {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px clamp(16px, 4vw, 40px) 40px;
}

.page-admin { max-width: 1180px; }

.panel {
  background: linear-gradient(180deg, #171b21, #14171c);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02) inset, 0 10px 28px rgba(0, 0, 0, 0.22);
}

/* ---------- intro / toolbar ---------- */

.intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 18px;
}

.intro-text h1 {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.intro-text p {
  margin-top: 3px;
  max-width: 720px;
  font-size: 12.5px;
  color: var(--faint);
}

.intro-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  flex: none;
}

.refresh-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--faint);
  white-space: nowrap;
}

.refresh-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 7px rgba(115, 191, 105, 0.7);
  animation: pulse 2s ease-in-out infinite;
}

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

/* ---------- forms ---------- */

.add-form {
  display: flex;
  gap: 10px;
  padding: 0 6px;
}

.input-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  pointer-events: none;
}

#host-input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #0f1216;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#host-input::placeholder { color: #565f6b; }

#host-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(232, 180, 90, 0.16);
}

.hint {
  margin: 8px 8px 0;
  font-size: 11.5px;
  color: var(--faint);
}

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

.field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  white-space: nowrap;
}

.select {
  height: 36px;
  padding: 0 30px 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--panel-3);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2399a2ae' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.select:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.select-sm {
  height: 30px;
  padding: 0 26px 0 8px;
  font-size: 12px;
  background-position: right 8px center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--panel-3);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.btn:hover { background: #2a3038; border-color: #414a56; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.btn:disabled {
  opacity: 0.55;
  cursor: progress;
}

.btn-primary {
  background: linear-gradient(180deg, #4a82e6, #3d71d9);
  border-color: #4a82e6;
  color: #fff;
  font-weight: 600;
  padding: 0 18px;
}

.btn-primary:hover {
  background: linear-gradient(180deg, #5b8eea, #4677dd);
  border-color: #5b8eea;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--dim);
}

.btn-ghost:hover { background: var(--panel-3); color: var(--text); border-color: transparent; }

.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }

.btn-block { width: 100%; }

.btn-icon { flex: none; }

.btn-danger {
  color: #ffb3bb;
  border-color: rgba(242, 73, 92, 0.28);
  background: rgba(242, 73, 92, 0.08);
}

.btn-danger:hover {
  color: #fff;
  background: rgba(242, 73, 92, 0.22);
  border-color: rgba(242, 73, 92, 0.55);
}

.btn-danger.armed {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

/* ---------- banner ---------- */

.banner {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 152, 48, 0.35);
  background: linear-gradient(180deg, rgba(255, 152, 48, 0.12), rgba(255, 152, 48, 0.06));
  color: #ffd9ac;
  font-size: 13px;
}

.banner strong { color: var(--orange); }
.banner-body { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.banner code { color: #ffe4c4; background: rgba(0, 0, 0, 0.25); }

/* ---------- summary tiles ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  min-height: 96px;
  justify-content: center;
}

.tile-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--faint);
}

.tile-value {
  font-size: 30px;
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.tile-value.green { color: var(--green); }
.tile-value.red { color: var(--red); }
.tile-value.blue { color: var(--blue); }
.tile-value.warn { color: var(--orange); }
.tile-value.empty { color: var(--faint); }

.tile-sub {
  font-size: 11.5px;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- targets ---------- */

.targets-panel { padding: 6px 10px 12px; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 6px;
  flex-wrap: wrap;
}

.panel-head h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim);
}

.panel-head-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.muted { font-size: 11.5px; color: var(--faint); }

.target-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.target {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(90px, 1fr) 84px 84px 100px;
  grid-template-areas: "identity spark ms loss uptime";
  align-items: center;
  gap: 6px 16px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.target:hover { background: var(--panel-2); border-color: var(--border); }

.target.is-selected {
  background: var(--panel-2);
  border-color: rgba(87, 148, 242, 0.42);
}

.target.is-down {
  background: linear-gradient(90deg, rgba(242, 73, 92, 0.08), transparent 46%);
}

.target.is-off { opacity: 0.55; }
.target.is-off.is-selected { opacity: 1; }

.target-identity {
  grid-area: identity;
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding: 2px 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.target-identity:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 6px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
  background: var(--faint);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.03);
}

.status-dot.ok {
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-dim), 0 0 10px rgba(115, 191, 105, 0.45);
}

.status-dot.down {
  background: var(--red);
  box-shadow: 0 0 0 3px var(--red-dim), 0 0 10px rgba(242, 73, 92, 0.45);
}

.status-dot.pending {
  background: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-dim);
  animation: pulse 1.5s ease-in-out infinite;
}

.status-dot.off { background: #4d5662; box-shadow: none; }

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

.identity-text { min-width: 0; display: flex; flex-direction: column; }

.host {
  font-family: var(--mono);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.host-meta {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spark {
  grid-area: spark;
  position: relative;
  height: 42px;
  min-width: 0;
}

.spark canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.metric.ms { grid-area: ms; }
.metric.loss { grid-area: loss; }
.metric.uptime { grid-area: uptime; }

.metric-value {
  display: flex;
  align-items: baseline;
  gap: 2px;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.metric-value .unit {
  font-size: 10px;
  font-weight: 500;
  color: var(--faint);
}

.metric-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  white-space: nowrap;
}

.metric-value .warn { color: var(--orange); }
.metric-value .bad { color: var(--red); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover { background: var(--panel-3); color: var(--text); border-color: var(--border); }
.icon-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }

/* ---------- empty state ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 6px 4px 4px;
  padding: 38px 20px;
  text-align: center;
  color: var(--faint);
  border: 1px dashed var(--border);
  border-radius: 10px;
}

.empty svg { color: var(--faint); opacity: 0.8; }

.empty-title {
  margin-top: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--dim);
}

.empty-text {
  max-width: 460px;
  margin-bottom: 6px;
  font-size: 12.5px;
  color: var(--faint);
}

/* ---------- detail ---------- */

.detail {
  grid-column: 1 / -1;
  min-width: 0;
  margin-top: 2px;
  padding: 12px 2px 2px;
  border-top: 1px solid var(--border);
}

.detail .panel-head { padding: 0 0 6px; flex-wrap: nowrap; }

.detail-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.detail-heading h2 {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.detail-ip {
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.range-group {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #101317;
}

.range-btn {
  height: 24px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--faint);
  font-size: 11px;
  cursor: pointer;
}

.range-btn:hover { color: var(--text); background: var(--panel-3); }

.range-btn.is-active {
  color: #1a1206;
  background: var(--gold);
  font-weight: 650;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--panel-2);
  color: var(--dim);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.pill.ok {
  color: var(--green);
  border-color: rgba(115, 191, 105, 0.34);
  background: var(--green-dim);
}
.pill.down {
  color: var(--red);
  border-color: rgba(242, 73, 92, 0.34);
  background: var(--red-dim);
}
.pill.pending {
  color: var(--orange);
  border-color: rgba(255, 152, 48, 0.34);
  background: var(--orange-dim);
}
.pill.off {
  color: var(--dim);
  border-color: var(--border-strong);
  background: var(--panel-2);
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 268px;
  gap: 20px;
  align-items: stretch;
}

.chart-wrap {
  position: relative;
  height: 210px;
  min-width: 0;
  padding: 6px 2px 0;
}

.chart {
  display: block;
  width: 100%;
  height: 100%;
}

.detail-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-content: start;
}

.detail-side {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
}

.detail-caption {
  margin: 0;
  font-size: 10px;
  line-height: 1.35;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--faint);
}

.detail-stats > div {
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  min-width: 0;
}

.detail-stats dt {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-stats dd {
  margin-top: 2px;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.detail-stats dd .unit {
  font-size: 10px;
  font-weight: 500;
  color: var(--faint);
  margin-left: 2px;
}

/* ---------- admin ---------- */

.add-panel { padding: 6px 10px 14px; }
.add-panel .panel-head { padding-bottom: 8px; }

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.admin-target {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) 250px minmax(320px, auto);
  align-items: center;
  gap: 12px 16px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.admin-target:hover { background: var(--panel-2); border-color: var(--border); }
.admin-target.is-off { opacity: 0.6; }

.admin-target.is-remove-armed {
  background: rgba(242, 73, 92, 0.07);
  border-color: rgba(242, 73, 92, 0.28);
}

.admin-identity {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.admin-metrics {
  display: flex;
  align-items: baseline;
  gap: 16px;
  min-width: 0;
}

.admin-metric {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.admin-metric b {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.admin-metric b.bad { color: var(--red); }

.admin-metric i {
  font-style: normal;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--faint);
  white-space: nowrap;
}

.admin-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.admin-controls .field { gap: 6px; }

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

.auth-panel {
  width: 100%;
  max-width: 420px;
  margin: 6vh auto 0;
  padding: 26px 26px 22px;
}

.auth-logo {
  display: grid;
  place-items: center;
  margin-bottom: 12px;
}

.auth-logo img {
  width: 58px;
  height: 58px;
  border-radius: 16px;
}

.auth-head h1 {
  font-size: 19px;
  font-weight: 650;
  text-align: center;
}

.auth-head p {
  margin: 6px auto 0;
  max-width: 330px;
  font-size: 12.5px;
  color: var(--faint);
  text-align: center;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.auth-field span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--faint);
}

.auth-field input {
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #0f1216;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
}

.auth-field input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(232, 180, 90, 0.16);
}

.form-error {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(242, 73, 92, 0.35);
  background: var(--red-dim);
  color: #ffd3d8;
  font-size: 12px;
}

.auth-note {
  margin-top: 14px;
  font-size: 11px;
  color: var(--faint);
  text-align: center;
}

/* ---------- footer, toast ---------- */

.footer {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 40px) 28px;
  font-size: 11.5px;
  color: var(--faint);
}

.footer code { font-size: 10.5px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  transform: translate(-50%, 16px);
  max-width: min(520px, calc(100vw - 32px));
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: #1d2229;
  color: var(--text);
  font-size: 12.5px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

.toast.error {
  border-color: rgba(242, 73, 92, 0.45);
  color: #ffd3d8;
}

.noscript {
  margin: 24px;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid rgba(242, 73, 92, 0.4);
  background: var(--red-dim);
  color: #ffd3d8;
}

/* ---------- responsive ---------- */

@media (max-width: 1180px) {
  .target {
    grid-template-columns: minmax(0, 1.4fr) minmax(80px, 1fr) 78px 78px 92px;
    gap: 6px 12px;
  }

  .admin-target {
    grid-template-columns: minmax(0, 1fr) minmax(0, auto);
    grid-template-areas:
      "identity controls"
      "metrics controls";
    gap: 8px 16px;
  }

  .admin-identity { grid-area: identity; }
  .admin-metrics { grid-area: metrics; }
  .admin-controls { grid-area: controls; }
}

@media (max-width: 980px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .intro { flex-direction: column; align-items: stretch; gap: 12px; }
  .intro-meta { flex-direction: row; align-items: center; justify-content: space-between; }

  .detail-grid { grid-template-columns: minmax(0, 1fr); }

  .detail-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .page { padding-top: 16px; gap: 12px; }

  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .add-form { flex-direction: column; }
  .add-form .btn-primary { height: 38px; }

  .target {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
      "identity identity identity"
      "spark spark spark"
      "ms loss uptime";
    gap: 10px 12px;
    padding: 12px;
    background: var(--panel-2);
    border-color: var(--border);
  }

  .target:hover { background: var(--panel-3); }

  .spark { height: 38px; }

  .metric { align-items: center; text-align: center; }
  .metric-value { justify-content: center; }

  .tile { min-height: 84px; padding: 12px 14px; }
  .tile-value { font-size: 26px; }

  .targets-panel { padding: 4px 8px 10px; }
  .detail { margin-top: 0; padding: 10px 0 2px; }
  .detail .panel-head { flex-wrap: wrap; row-gap: 6px; }
  .detail-heading { flex-wrap: wrap; row-gap: 2px; }
  .detail-ip { flex: 1 1 100%; }
  .chart-wrap { height: 170px; }

  .detail-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .admin-target {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "identity"
      "metrics"
      "controls";
  }

  .admin-controls { justify-content: flex-start; }

  .footer { flex-direction: column; gap: 6px; }
}

@media (max-width: 520px) {
  .topbar { height: 54px; padding: 0 14px; }
  .brand-name { font-size: 13.5px; }
  .brand-logo { width: 30px; height: 30px; }
  .topbar-sep, .clock, .admin-link span { display: none; }
  .api-status { font-size: 11px; padding: 4px 9px 4px 8px; }

  .stats { gap: 10px; }
  .tile-value { font-size: 23px; }
  .tile-sub { font-size: 11px; }

  .intro { padding: 14px; }
  .intro-text h1 { font-size: 16px; }
  .intro-meta { flex-direction: column; align-items: flex-start; gap: 4px; }

  .range-btn { padding: 0 7px; }

  .admin-metrics { gap: 12px; }
  .admin-controls .field { flex: 1 1 100%; justify-content: space-between; }
  .admin-controls .select-sm { flex: 1; max-width: 130px; }

  .auth-panel { margin-top: 2vh; padding: 22px 18px 18px; }

  .panel-head { gap: 8px; }
  .panel-head-actions { gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- whois links, logout, password ---------- */

.host-btn {
  display: block;
  max-width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.host-btn .host { display: block; }

.host-btn:hover .host { color: var(--gold); }

.host-btn:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 5px;
}

.whois-link {
  align-self: flex-start;
  margin-top: 1px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px dashed rgba(232, 180, 90, 0.45);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.whois-link:hover {
  color: #ffd98f;
  border-bottom-color: currentColor;
}

.whois-link:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

.topbar-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--dim);
  font-size: 11.5px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.topbar-logout:hover {
  color: var(--text);
  background: var(--panel-3);
  border-color: var(--border-strong);
}

.topbar-logout:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.password-panel {
  padding: 0;
  overflow: hidden;
}

.password-details { padding: 0 16px; }

.password-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 0;
  cursor: pointer;
  list-style: none;
}

.password-summary::-webkit-details-marker,
.host-summary::-webkit-details-marker { display: none; }

.password-summary::marker,
.host-summary::marker { content: ""; }

.password-summary-title {
  font-size: 13px;
  font-weight: 600;
}

.password-summary-hint {
  margin-left: auto;
  font-size: 11px;
  color: var(--faint);
}

.chevron {
  flex: none;
  color: var(--faint);
  transition: transform 0.18s ease;
}

details[open] > summary .chevron { transform: rotate(180deg); }

.password-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  padding: 4px 0 12px;
}

.password-form .form-error { grid-column: 1 / -1; }

.password-form .btn {
  justify-self: start;
  height: 36px;
}

.password-panel .hint {
  margin: 0 0 14px;
  padding: 0;
}

/* ---------- host detail page ---------- */

.page-host { max-width: 1080px; }

.host-crumbs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 11.5px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--dim);
  text-decoration: none;
  transition: color 0.15s ease;
}

.back-link:hover { color: var(--gold); }

.host-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
}

.host-head-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.host-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.host-title-row h1 {
  font-family: var(--mono);
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.host-sub {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--dim);
  overflow-wrap: anywhere;
}

.host-error {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(242, 73, 92, 0.34);
  background: var(--red-dim);
  color: #ffd3d8;
  font-size: 12px;
}

.host-head-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex: none;
}

.host-caption {
  font-size: 11px;
  color: var(--faint);
}

.host-stats { grid-template-columns: repeat(6, minmax(0, 1fr)); }

.host-section { padding: 0 18px; }

.host-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 0;
  cursor: pointer;
  list-style: none;
}

.host-summary-title {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.host-summary-hint {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--faint);
  text-align: right;
}

.host-section[open] > .host-summary { border-bottom: 1px solid var(--border); }

.host-section-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 0 18px;
}

.host-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.host-legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--faint);
}

.legend-line {
  width: 14px;
  height: 2px;
  border-radius: 2px;
  background: var(--green);
}

.legend-fail {
  width: 2px;
  height: 12px;
  margin-left: 8px;
  background: rgba(242, 73, 92, 0.6);
}

.host-chart-wrap {
  height: 280px;
  padding: 0;
}

.host-quality { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.host-quality dd { font-size: 15px; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.hourly {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hourly th,
.hourly td {
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

.hourly thead th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  color: var(--faint);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.hourly tbody th {
  text-align: left;
  font-weight: 500;
  color: var(--text);
}

.hourly tbody tr:last-child th,
.hourly tbody tr:last-child td { border-bottom: 0; }

.hourly tbody tr:hover { background: rgba(255, 255, 255, 0.025); }

.hourly tr.is-current { background: rgba(232, 180, 90, 0.06); }

.hourly .warn { color: var(--orange); }
.hourly .bad { color: var(--red); }

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

.whois-dl > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
}

.whois-dl dt {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--faint);
}

.whois-dl dd {
  font-family: var(--mono);
  font-size: 12px;
  overflow-wrap: anywhere;
}

@media (max-width: 1180px) {
  .host-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .password-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .page-host .host-header { flex-direction: column; align-items: stretch; gap: 10px; }
  .host-head-side { flex-direction: row; align-items: center; justify-content: space-between; }
  .host-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .host-quality { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .whois-dl { grid-template-columns: minmax(0, 1fr); }
  .host-chart-wrap { height: 200px; }
  .host-summary-hint { display: none; }
  .password-form { grid-template-columns: minmax(0, 1fr); }
  .password-form .btn { justify-self: stretch; }
}

@media (max-width: 520px) {
  .topbar-logout { padding: 0 8px; }
  .topbar-logout span { display: none; }
  .host-title-row h1 { font-size: 18px; }
  .host-section { padding: 0 12px; }
  .host-header { padding: 14px; }
}

/* The row identity is a div now; only the host button is clickable. */
.target-identity { cursor: default; }

/* ---------- remote agents / proxy sources ---------- */

.source-filter {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.source-filter-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  white-space: nowrap;
}

.source-filter .select { max-width: 210px; }

/* Multi-source chips: a target can be checked by several servers at once. */
.source-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.chip {
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--dim);
  font-size: 11px;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.chip:hover { color: var(--text); border-color: #4a5563; }

.chip.on {
  background: rgba(232, 180, 90, 0.16);
  border-color: rgba(232, 180, 90, 0.55);
  color: var(--gold);
}

.chip.on:hover { background: rgba(232, 180, 90, 0.24); }

.chip-off { font-size: 11px; color: var(--faint); }

.admin-controls .source-group { max-width: 340px; }
.add-sources-field { align-items: flex-start; }
.add-sources-field .field-label { padding-top: 8px; }
.add-form .source-group { flex: 1; }

.source-group.multi .chip.on { border-color: rgba(232, 180, 90, 0.7); }

.source-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  font-size: 10px;
  color: var(--faint);
  white-space: nowrap;
}

.source-badge.proxy {
  border-color: rgba(232, 180, 90, 0.34);
  background: rgba(232, 180, 90, 0.08);
  color: var(--gold);
}

.agents-panel { padding: 6px 10px 14px; }

.agents-panel .hint { margin: 0 6px 10px; }

.agent-form {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px 4px;
  flex-wrap: wrap;
}

.agent-form .field { align-items: flex-start; flex-direction: column; gap: 5px; }

.agent-form input {
  height: 36px;
  min-width: 190px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #0f1216;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
}

.agent-form input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(232, 180, 90, 0.16);
}

.agent-form input::placeholder { color: #565f6b; }

.agent-form .btn-primary { height: 36px; }

.agent-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
}

.agent-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) 210px minmax(320px, auto);
  align-items: center;
  gap: 10px 16px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.agent-row:hover { background: var(--panel-2); border-color: var(--border); }
.agent-row.is-off { opacity: 0.6; }

.agent-row.is-remove-armed {
  background: rgba(242, 73, 92, 0.07);
  border-color: rgba(242, 73, 92, 0.28);
}

.agent-identity {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.agent-metrics {
  display: flex;
  align-items: baseline;
  gap: 18px;
}

.agent-metric {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.agent-metric b {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.agent-metric i {
  font-style: normal;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--faint);
  white-space: nowrap;
}

.agent-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.token-box {
  margin: 10px 6px 4px;
  padding: 12px 14px;
  border: 1px solid rgba(232, 180, 90, 0.34);
  border-radius: 10px;
  background: rgba(232, 180, 90, 0.06);
}

.token-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.token-head strong { font-size: 12.5px; color: var(--gold); }

.token-head span { font-size: 10.5px; color: var(--faint); }

.token-value {
  display: block;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: #0c0f13;
  font-family: var(--mono);
  font-size: 12px;
  overflow-wrap: anywhere;
  user-select: all;
}

.token-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.token-config {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px dashed var(--border-strong);
  background: rgba(0, 0, 0, 0.22);
  color: var(--dim);
  font-family: var(--mono);
  font-size: 11px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 1180px) {
  .agent-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, auto);
    grid-template-areas:
      "identity controls"
      "metrics controls";
    gap: 8px 16px;
  }

  .agent-identity { grid-area: identity; }
  .agent-metrics { grid-area: metrics; }
  .agent-controls { grid-area: controls; }
}

@media (max-width: 760px) {
  .agent-row {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "identity"
      "metrics"
      "controls";
  }

  .agent-controls { justify-content: flex-start; }
  .agent-form { flex-direction: column; align-items: stretch; }
  .agent-form input { width: 100%; min-width: 0; }
  .source-filter .select { max-width: 150px; }
}

@media (max-width: 520px) {
  .token-head { flex-direction: column; gap: 2px; }
  .source-filter-label { display: none; }
}
