:root {
  color-scheme: dark;
  --bg: #071018;
  --bg-elevated: #0b1721;
  --panel: rgba(15, 31, 43, 0.92);
  --panel-soft: rgba(20, 42, 56, 0.72);
  --line: rgba(144, 183, 207, 0.18);
  --line-strong: rgba(144, 183, 207, 0.32);
  --text: #edf7fb;
  --muted: #9bb0bd;
  --blue: #4aa8ff;
  --green: #56e0bb;
  --amber: #ffc765;
  --red: #ff7785;
  --purple: #aa91ff;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% -10%, rgba(74, 168, 255, 0.16), transparent 35%),
    radial-gradient(circle at 85% 0%, rgba(86, 224, 187, 0.12), transparent 32%),
    linear-gradient(180deg, #09141d 0%, var(--bg) 48%, #050b10 100%);
}

button, input { font: inherit; }
button { cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(7, 16, 24, 0.88);
  backdrop-filter: blur(18px);
}

.brand-block { display: flex; align-items: center; gap: 16px; }
.brand-mark { width: 52px; height: 52px; position: relative; display: grid; place-items: center; }
.brand-mark::before,
.brand-mark::after,
.brand-mark span {
  content: "";
  position: absolute;
  border: 2px solid var(--green);
  border-top-color: transparent;
  border-bottom-color: transparent;
  border-radius: 50%;
}
.brand-mark::before { inset: 3px; border-color: var(--blue); border-top-color: transparent; border-bottom-color: transparent; }
.brand-mark::after { inset: 12px; }
.brand-mark span:nth-child(1) { width: 7px; height: 7px; border: 0; background: var(--green); box-shadow: 0 0 18px var(--green); }
.brand-mark span:nth-child(2) { inset: 19px; border-color: var(--blue); border-top-color: transparent; border-bottom-color: transparent; }
.brand-mark span:nth-child(3) { display: none; }

.eyebrow, .section-kicker {
  display: block;
  color: var(--green);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.7rem, 3vw, 2.35rem); letter-spacing: -0.045em; line-height: 1; }
.brand-block p { margin-top: 5px; color: var(--muted); font-size: 0.88rem; }

.operator-box {
  display: grid;
  grid-template-columns: minmax(180px, 280px) auto auto;
  align-items: end;
  gap: 8px;
}
.operator-box label { grid-column: 1 / -1; color: var(--muted); font-size: 0.72rem; }
.operator-box input {
  min-width: 0;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 0 12px;
  color: var(--text);
  background: rgba(2, 10, 16, 0.65);
  outline: none;
}
.operator-box input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(74, 168, 255, 0.12); }

.button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 0 13px;
  font-weight: 750;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: 0.4; }
.button-primary { color: #03131b; background: var(--green); }
.button-secondary { color: var(--text); border-color: var(--line-strong); background: var(--panel-soft); }
.button-danger { color: #fff; border-color: rgba(255, 119, 133, 0.38); background: rgba(255, 119, 133, 0.16); }
.button-small { min-height: 32px; padding: 0 10px; font-size: 0.78rem; }

main { width: min(1540px, calc(100% - 32px)); margin: 22px auto 70px; }
.banner {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 14px;
  color: var(--muted);
  background: var(--panel-soft);
}
.banner-good { color: #bffbed; border-color: rgba(86, 224, 187, 0.3); background: rgba(86, 224, 187, 0.09); }
.banner-bad { color: #ffd1d6; border-color: rgba(255, 119, 133, 0.35); background: rgba(255, 119, 133, 0.1); }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card {
  min-height: 135px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(18, 39, 53, 0.94), rgba(9, 22, 32, 0.94));
  box-shadow: var(--shadow);
}
.metric-label { color: var(--muted); font-size: 0.76rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; }
.metric-card strong { margin: 7px 0 1px; font-size: clamp(2.1rem, 5vw, 3.2rem); line-height: 1; letter-spacing: -0.06em; }
.metric-card > span:last-child { color: var(--green); font-size: 0.82rem; }

.panel {
  margin-top: 18px;
  padding: clamp(17px, 2.5vw, 27px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 18px; }
.section-heading h2 { margin-top: 5px; font-size: clamp(1.25rem, 2.4vw, 1.72rem); letter-spacing: -0.035em; }
.section-heading > p { max-width: 670px; color: var(--muted); font-size: 0.88rem; line-height: 1.5; text-align: right; }

.agent-grid, .radio-grid, .function-grid { display: grid; gap: 13px; }
.agent-grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.radio-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.function-grid { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.empty-state { display: block; padding: 24px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 12px; text-align: center; }

.card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 16px;
  background: linear-gradient(155deg, rgba(22, 45, 59, 0.8), rgba(9, 22, 31, 0.94));
}
.card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--blue); opacity: 0.8; }
.card.utility::before { background: var(--purple); }
.card.offline { opacity: 0.68; }
.card-header { display: flex; align-items: start; justify-content: space-between; gap: 14px; }
.card h3 { margin: 0; font-size: 1rem; letter-spacing: -0.02em; }
.card-subtitle { margin-top: 4px; color: var(--muted); font-size: 0.78rem; }
.card-description { min-height: 40px; margin-top: 13px; color: #c5d3da; font-size: 0.84rem; line-height: 1.45; }
.card-meta { display: grid; grid-template-columns: auto 1fr; gap: 7px 12px; margin-top: 15px; font-size: 0.78rem; }
.card-meta dt { color: var(--muted); }
.card-meta dd { min-width: 0; margin: 0; color: var(--text); overflow-wrap: anywhere; }
.path {
  margin-top: 14px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(2, 9, 14, 0.62);
  color: #b6d7e7;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.72rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--muted);
  background: rgba(4, 13, 20, 0.55);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 9px currentColor; }
.status-online, .status-available, .status-running, .status-succeeded { color: var(--green); }
.status-starting, .status-queued, .status-dispatched, .status-unknown { color: var(--amber); }
.status-error, .status-failed, .status-unavailable, .status-offline { color: var(--red); }
.status-stopped, .status-completed, .status-disabled { color: var(--muted); }
.status-in_use { color: var(--blue); }

.radio-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 10px; color: var(--blue); background: rgba(74, 168, 255, 0.1); font-size: 1.3rem; }
.capabilities { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.capability { border: 1px solid var(--line); border-radius: 999px; padding: 3px 7px; color: var(--muted); font-size: 0.65rem; }
.warning { margin-top: 10px; color: var(--amber); font-size: 0.75rem; }
.error-text { margin-top: 9px; color: #ffb2bb; font-size: 0.75rem; overflow-wrap: anywhere; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 0.67rem; letter-spacing: 0.08em; text-transform: uppercase; }
tbody tr:hover { background: rgba(74, 168, 255, 0.04); }
.empty-table { padding: 26px; color: var(--muted); text-align: center; }
.link-button { border: 0; padding: 0; color: var(--blue); background: transparent; text-decoration: underline; text-underline-offset: 3px; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 40;
  max-width: min(480px, calc(100vw - 44px));
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  padding: 12px 15px;
  color: var(--text);
  background: #102331;
  box-shadow: var(--shadow);
  transition: opacity 180ms ease, transform 180ms ease;
}
.toast.visible { transform: translateY(0); opacity: 1; }
.toast.error { border-color: rgba(255, 119, 133, 0.45); background: #321721; }

dialog { width: min(820px, calc(100vw - 34px)); max-height: 82vh; border: 1px solid var(--line-strong); border-radius: 15px; padding: 0; color: var(--text); background: #0b1822; box-shadow: 0 25px 90px rgba(0, 0, 0, 0.6); }
dialog::backdrop { background: rgba(0, 6, 10, 0.74); backdrop-filter: blur(3px); }
.dialog-shell { padding: 20px; }
.dialog-header { display: flex; justify-content: space-between; align-items: start; gap: 20px; }
.icon-button { width: 35px; height: 35px; border: 1px solid var(--line); border-radius: 9px; color: var(--text); background: var(--panel-soft); font-size: 1.4rem; }
#dialog-content { max-height: 60vh; overflow: auto; margin: 18px 0 0; padding: 14px; border: 1px solid var(--line); border-radius: 9px; color: #c6d9e2; background: #050d13; font-size: 0.75rem; white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .topbar { position: static; align-items: stretch; flex-direction: column; }
  .operator-box { grid-template-columns: 1fr auto auto; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-heading { align-items: start; flex-direction: column; gap: 8px; }
  .section-heading > p { text-align: left; }
}

@media (max-width: 560px) {
  main { width: min(100% - 20px, 1540px); margin-top: 12px; }
  .topbar { padding: 16px 12px; }
  .operator-box { grid-template-columns: 1fr 1fr; }
  .operator-box input { grid-column: 1 / -1; }
  .metrics { grid-template-columns: 1fr; }
  .metric-card { min-height: 112px; }
  .panel { padding: 15px; }
  .agent-grid, .radio-grid, .function-grid { grid-template-columns: 1fr; }
}
