:root {
  color-scheme: dark;
  --ink: #f2f6ee;
  --muted: #94a197;
  --quiet: #62706a;
  --panel: rgba(13, 18, 17, 0.86);
  --panel-strong: rgba(19, 26, 24, 0.94);
  --field: rgba(255, 255, 255, 0.055);
  --line: rgba(215, 232, 210, 0.14);
  --line-strong: rgba(215, 232, 210, 0.24);
  --green: #b8ef7b;
  --cyan: #4ecbb8;
  --amber: #f1b44c;
  --red: #f06661;
  --blue: #82a8d8;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(115deg, rgba(184, 239, 123, 0.1), transparent 30%),
    linear-gradient(305deg, rgba(78, 203, 184, 0.13), transparent 34%),
    #070a09;
  color: var(--ink);
  font-family: "Bahnschrift", "Aptos", "Segoe UI Variable", sans-serif;
  letter-spacing: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 0 93%, rgba(255, 255, 255, 0.035) 93% 94%, transparent 94%),
    linear-gradient(0deg, transparent 0 92%, rgba(255, 255, 255, 0.03) 92% 93%, transparent 93%);
  background-size: 72px 72px;
  mask-image: linear-gradient(to bottom, black, transparent 82%);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.58;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: var(--field);
  color: var(--ink);
  outline: none;
}

select {
  color: var(--ink);
}

select option {
  background: #111815;
  color: var(--ink);
}

input:focus,
select:focus {
  border-color: rgba(184, 239, 123, 0.62);
  box-shadow: 0 0 0 3px rgba(184, 239, 123, 0.1);
}

label {
  display: grid;
  gap: 8px;
  min-width: 0;
}

label span,
.eyebrow,
.traffic-main span,
.traffic-split span,
.fleet-strip span,
.metric span,
.flow span,
.speed-grid span {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

#network-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  opacity: 0.42;
}

.auth-shell,
.shell {
  position: relative;
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 0;
}

.auth-panel {
  width: min(960px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 24px;
  align-items: stretch;
}

.brand-block,
.auth-card,
.aggregate,
.fleet-strip,
.panel-form,
.panel-list,
.server-card,
.panel-card,
.empty-state {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.brand-block {
  min-height: 420px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    linear-gradient(135deg, rgba(184, 239, 123, 0.16), transparent 44%),
    linear-gradient(315deg, rgba(241, 180, 76, 0.1), transparent 36%),
    rgba(12, 17, 16, 0.88);
}

.brand-row {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 46px;
  border: 1px solid rgba(184, 239, 123, 0.38);
  border-radius: 8px;
  background: rgba(184, 239, 123, 0.1);
  color: var(--green);
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-weight: 900;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.brand-block h1 {
  max-width: 9ch;
  margin-top: 16px;
  font-size: clamp(3rem, 8vw, 6.8rem);
  line-height: 0.84;
  font-weight: 900;
}

.auth-card {
  padding: 22px;
  display: grid;
  align-content: center;
  gap: 16px;
  background: rgba(14, 20, 18, 0.92);
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.segment {
  min-height: 34px;
  border: 0;
  padding: 0 14px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segment.is-active {
  background: rgba(184, 239, 123, 0.14);
  color: var(--ink);
}

.primary-button,
.ghost-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  font-weight: 900;
}

.primary-button {
  border-color: rgba(184, 239, 123, 0.58);
  background: var(--green);
  color: #10150f;
}

.primary-button:hover {
  filter: brightness(1.06);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.045);
}

.ghost-button:hover {
  border-color: rgba(184, 239, 123, 0.5);
  background: rgba(184, 239, 123, 0.1);
}

.danger-button {
  border-color: rgba(240, 102, 97, 0.4);
  background: rgba(240, 102, 97, 0.1);
  color: #ffaaa5;
}

.danger-button:hover {
  border-color: rgba(240, 102, 97, 0.7);
  background: rgba(240, 102, 97, 0.16);
}

.form-error {
  min-height: 20px;
  color: #ffaaa5;
  font-size: 0.88rem;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
}

.check-row input {
  width: 18px;
  height: 18px;
  min-height: 0;
  accent-color: var(--amber);
}

.check-row span {
  color: var(--ink);
  text-transform: none;
}

.limit-input {
  display: flex;
  gap: 8px;
}

.limit-input input {
  flex: 1 1 auto;
  min-width: 0;
}

.limit-input select {
  flex: 0 0 82px;
  width: 82px;
  padding: 0 8px;
}

.shell {
  padding: 24px 0 42px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin-top: 2px;
  font-size: clamp(2rem, 5vw, 4.8rem);
  line-height: 0.88;
  font-weight: 900;
}

.topbar__right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

.account {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.account span {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view {
  margin-top: 16px;
}

.status-actions {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.pulse {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(184, 239, 123, 0.48);
  animation: pulse 1.7s infinite;
}

.aggregate {
  display: grid;
  grid-template-columns: minmax(260px, 0.82fr) 1.18fr;
  gap: 0;
  overflow: hidden;
  background:
    linear-gradient(100deg, rgba(184, 239, 123, 0.18), transparent 42%),
    rgba(10, 15, 14, 0.78);
}

.traffic-main {
  min-height: 172px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--line);
}

.traffic-main strong {
  display: block;
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: clamp(2.1rem, 6vw, 5.2rem);
  line-height: 0.95;
  overflow-wrap: anywhere;
}

.traffic-split,
.fleet-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.traffic-split > div,
.fleet-strip > div {
  min-width: 0;
  padding: 22px;
  border-left: 1px solid var(--line);
}

.traffic-split > div:first-child,
.fleet-strip > div:first-child {
  border-left: 0;
}

.traffic-split strong,
.fleet-strip strong {
  display: block;
  margin-top: 12px;
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: clamp(1.15rem, 2.4vw, 2.1rem);
  overflow-wrap: anywhere;
}

.fleet-strip {
  margin-top: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  background: rgba(12, 18, 17, 0.62);
}

.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.server-card {
  min-width: 0;
  padding: 18px;
  background:
    linear-gradient(145deg, rgba(78, 203, 184, 0.08), transparent 38%),
    var(--panel);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.24);
}

.server-card.offline {
  border-color: rgba(240, 102, 97, 0.32);
  background:
    linear-gradient(145deg, rgba(240, 102, 97, 0.12), transparent 42%),
    var(--panel);
}

.server-card.pending {
  border-color: rgba(241, 180, 76, 0.32);
  background:
    linear-gradient(145deg, rgba(241, 180, 76, 0.1), transparent 42%),
    var(--panel);
}

.server-card.stale {
  border-color: rgba(241, 180, 76, 0.3);
}

.server-card__head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.server-card h2,
.panel-card h3 {
  margin: 5px 0 0;
  font-size: clamp(1.1rem, 2vw, 1.55rem);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.server-address,
.panel-url {
  margin-top: 8px;
  color: var(--blue);
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.server-state,
.panel-scheme {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 3px 9px;
  background: rgba(184, 239, 123, 0.12);
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.offline .server-state {
  background: rgba(240, 102, 97, 0.12);
  color: var(--red);
}

.pending .server-state {
  background: rgba(241, 180, 76, 0.12);
  color: var(--amber);
}

.stale .server-state {
  background: rgba(241, 180, 76, 0.12);
  color: var(--amber);
}

.cpu-ring {
  flex: 0 0 78px;
  width: 78px;
  height: 78px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #101614 0 55%, transparent 56%),
    conic-gradient(var(--green) var(--cpu, 0%), rgba(255, 255, 255, 0.09) 0);
}

.cpu-ring span {
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-weight: 900;
  font-size: 0.92rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.metric,
.speed-cell {
  min-width: 0;
}

.metric strong,
.flow strong,
.speed-grid strong {
  display: block;
  margin-top: 8px;
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 0.96rem;
  overflow-wrap: anywhere;
}

.bar {
  height: 8px;
  margin-top: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.bar i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--green));
  transition: width 320ms ease;
}

.flow {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.speed-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.speed-cell {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background:
    linear-gradient(135deg, rgba(78, 203, 184, 0.12), transparent 70%),
    rgba(255, 255, 255, 0.035);
}

.speed-cell--up strong {
  color: var(--green);
}

.speed-cell--down strong {
  color: var(--cyan);
}

.server-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.82rem;
}

.server-footer span,
.panel-meta span {
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(255, 255, 255, 0.035);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  min-height: 74px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.section-head h2 {
  margin-top: 4px;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 0.95;
}

.section-head > strong {
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: clamp(2rem, 4vw, 4rem);
  color: var(--green);
}

.manager-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.42fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.panel-form {
  align-self: start;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
  background:
    linear-gradient(145deg, rgba(241, 180, 76, 0.08), transparent 42%),
    var(--panel-strong);
}

.panel-form.is-editing {
  border-color: rgba(241, 180, 76, 0.4);
  background:
    linear-gradient(145deg, rgba(241, 180, 76, 0.14), transparent 42%),
    var(--panel-strong);
}

.form-title {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-title h3 {
  font-size: 1.25rem;
}

.rail {
  width: 4px;
  height: 28px;
  border-radius: 999px;
  background: var(--amber);
}

.span-2 {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  gap: 10px;
}

.form-actions button {
  flex: 1 1 0;
}

.panel-list {
  min-height: 260px;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
  background: rgba(12, 18, 17, 0.58);
  box-shadow: none;
}

.panel-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
  background:
    linear-gradient(145deg, rgba(130, 168, 216, 0.08), transparent 42%),
    rgba(16, 23, 21, 0.88);
  box-shadow: none;
}

.panel-card.is-editing {
  border-color: rgba(241, 180, 76, 0.42);
  background:
    linear-gradient(145deg, rgba(241, 180, 76, 0.14), transparent 42%),
    rgba(16, 23, 21, 0.9);
}

.panel-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.panel-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.empty-state {
  min-height: 132px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 22px;
  background: var(--panel-strong);
  color: var(--muted);
  box-shadow: none;
}

.empty-state strong {
  color: var(--ink);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 36px));
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(15, 22, 20, 0.96);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-weight: 800;
}

/* Traffic limit warnings */
.limit-banner {
  margin-bottom: 14px;
  padding: 14px 18px;
  border: 1px solid rgba(241, 180, 76, 0.5);
  border-left-width: 4px;
  border-radius: var(--radius);
  background:
    linear-gradient(100deg, rgba(241, 180, 76, 0.16), transparent 60%),
    rgba(20, 17, 9, 0.86);
  box-shadow: var(--shadow);
}

.limit-banner.is-exceeded {
  border-color: rgba(240, 102, 97, 0.6);
  background:
    linear-gradient(100deg, rgba(240, 102, 97, 0.18), transparent 60%),
    rgba(24, 12, 11, 0.88);
}

.limit-banner__title {
  display: block;
  margin-bottom: 10px;
  color: var(--amber);
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.limit-banner.is-exceeded .limit-banner__title {
  color: var(--red);
}

.limit-banner__list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.limit-banner__item {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 11px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.84rem;
  font-weight: 700;
}

.limit-banner__item.warning {
  border-color: rgba(241, 180, 76, 0.5);
  color: var(--amber);
}

.limit-banner__item.exceeded {
  border-color: rgba(240, 102, 97, 0.55);
  color: var(--red);
}

/* Per-card traffic limit usage */
.card-limits {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.card-limit-row {
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 0.82rem;
  color: var(--muted);
}

.card-limit-row.warning {
  color: var(--amber);
}

.card-limit-row.exceeded {
  color: var(--red);
  font-weight: 800;
}

.server-card.limit-warning {
  border-color: rgba(241, 180, 76, 0.42);
}

.server-card.limit-exceeded {
  border-color: rgba(240, 102, 97, 0.5);
  background:
    linear-gradient(145deg, rgba(240, 102, 97, 0.1), transparent 42%),
    var(--panel);
}

/* Panel manager badges */
.panel-meta .badge-off {
  border-color: rgba(240, 102, 97, 0.4);
  color: var(--red);
}

.panel-meta .badge-muted {
  color: var(--amber);
}

@keyframes pulse {
  70% {
    box-shadow: 0 0 0 10px rgba(184, 239, 123, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(184, 239, 123, 0);
  }
}

@media (max-width: 980px) {
  .auth-panel,
  .manager-grid {
    grid-template-columns: 1fr;
  }

  .brand-block {
    min-height: 280px;
  }

  .topbar,
  .topbar__right {
    align-items: stretch;
  }

  .topbar {
    display: grid;
  }

  .topbar__right {
    justify-content: space-between;
  }

  .aggregate {
    grid-template-columns: 1fr;
  }

  .traffic-main {
    min-height: 142px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .traffic-split {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .traffic-split > div:nth-child(odd) {
    border-left: 0;
  }
}

@media (max-width: 640px) {
  .auth-shell,
  .shell {
    width: min(100vw - 20px, 720px);
  }

  .brand-row,
  .topbar__right,
  .account,
  .status-actions,
  .section-head {
    align-items: stretch;
  }

  .topbar__right,
  .account,
  .status-actions,
  .section-head {
    display: grid;
  }

  .segmented {
    width: 100%;
  }

  .segment {
    min-width: 0;
  }

  .fleet-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .traffic-split > div,
  .fleet-strip > div {
    padding: 16px;
  }

  .panel-form,
  .server-grid,
  .metric-grid,
  .flow,
  .speed-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .panel-card {
    grid-template-columns: 1fr;
  }

  .panel-meta {
    justify-content: flex-start;
  }

  .panel-actions {
    justify-content: flex-start;
  }

  .server-card__head {
    align-items: center;
  }

  .cpu-ring {
    flex-basis: 68px;
    width: 68px;
    height: 68px;
  }
}

@media (max-width: 420px) {
  .traffic-split,
  .fleet-strip {
    grid-template-columns: 1fr;
  }

  .traffic-split > div,
  .fleet-strip > div {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .traffic-split > div:first-child,
  .fleet-strip > div:first-child {
    border-top: 0;
  }
}
