:root {
  color-scheme: light;
  --ink: #172035;
  --muted: #667085;
  --line: #dfe4ec;
  --canvas: #f4f6f9;
  --surface: #ffffff;
  --nav: #11192c;
  --nav-soft: #202a42;
  --accent: #c93f2f;
  --accent-dark: #a92f23;
  --accent-soft: #fff0ed;
  --success: #16794f;
  --success-soft: #eaf8f1;
  --warning: #9a6700;
  --warning-soft: #fff6d8;
  --danger: #b42318;
  --danger-soft: #ffebe9;
  --radius-sm: 0.55rem;
  --radius: 0.9rem;
  --radius-lg: 1.25rem;
  --shadow: 0 18px 45px rgba(16, 24, 40, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 20rem;
  background: var(--canvas);
  color: var(--ink);
  line-height: 1.5;
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.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;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 17rem minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem 1rem;
  background:
    linear-gradient(155deg, rgba(240, 90, 71, 0.18), transparent 28%),
    var(--nav);
  color: #fff;
}

.sidebar-version { margin: 0.7rem 0 0; color: var(--nav-muted); font-size: 0.72rem; text-align: center; }

.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.25rem 0.55rem 1.75rem;
  color: inherit;
  text-decoration: none;
}

.brand__mark {
  width: 2.55rem;
  height: 2.55rem;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 0.75rem 0.75rem 0.75rem 0.18rem;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
  font-size: 1.35rem;
  box-shadow: 0 8px 22px rgba(240, 90, 71, 0.3);
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.1rem; letter-spacing: -0.02em; }
.brand small { color: #aeb8ce; font-size: 0.79rem; letter-spacing: 0.13em; text-transform: uppercase; }
.brand__mark--large { width: 4rem; height: 4rem; margin: 0 auto 1.5rem; font-size: 2rem; }

.navigation { display: grid; gap: 0.35rem; }

.nav-item {
  width: 100%;
  min-height: 2.85rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.65rem 0.8rem;
  border: 0;
  border-radius: 0.7rem;
  background: transparent;
  color: #bbc4d7;
  cursor: pointer;
  text-align: left;
  font-weight: 650;
  font-size: 0.92rem;
  transition: background 150ms ease, color 150ms ease, transform 150ms ease;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav-item:active { transform: translateY(1px); }
.nav-item.is-active { background: var(--nav-soft); color: #fff; box-shadow: inset 3px 0 var(--accent); }
.nav-icon { width: 1.4rem; text-align: center; color: #7887a6; }
.nav-item.is-active .nav-icon { color: var(--accent); }

.account-card {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.045);
}

.avatar {
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  background: #35405a;
  color: #fff;
  font-weight: 800;
  font-size: 0.78rem;
}

.account-card__text { min-width: 0; flex: 1; }
.account-card__text strong, .account-card__text small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-card__text strong { font-size: 0.82rem; }
.account-card__text small { color: #929eb6; font-size: 0.72rem; }

.main-content { min-width: 0; }

.topbar {
  min-height: 7.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.5rem clamp(1.25rem, 3vw, 3.25rem);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 0.2rem;
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: clamp(1.65rem, 3vw, 2.15rem); line-height: 1.15; letter-spacing: -0.04em; }
h2 { margin: 0; font-size: 1.35rem; line-height: 1.25; letter-spacing: -0.025em; }
h3 { margin: 0; font-size: 1rem; }

.topbar__actions { display: flex; align-items: center; gap: 0.65rem; }

.search-box {
  min-width: 14rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--muted);
}

.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box input { width: 100%; min-height: 2.6rem; border: 0; outline: 0; background: transparent; color: var(--ink); }

.button, .icon-button {
  border: 0;
  cursor: pointer;
  text-decoration: none;
  transition: transform 130ms ease, background 130ms ease, border-color 130ms ease, box-shadow 130ms ease;
}

.button {
  min-height: 2.65rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.62rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 760;
  font-size: 0.9rem;
}

.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.button--primary { background: var(--accent); color: #fff; box-shadow: 0 7px 18px rgba(240, 90, 71, 0.2); }
.button--primary:hover { background: var(--accent-dark); }
.button--ghost { border: 1px solid var(--line); background: #fff; color: #344054; }
.button--ghost:hover { border-color: #c3cad5; background: #fafbfc; }
.button--danger { border: 1px solid #f2b8b5; background: var(--danger-soft); color: var(--danger); }
.button--small { min-height: 2.15rem; padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.button--wide { width: 100%; }

.icon-button {
  width: 2.35rem;
  height: 2.35rem;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 0.55rem;
  background: transparent;
  color: inherit;
  font-size: 1.3rem;
}
.icon-button:hover { background: rgba(127, 127, 127, 0.13); }

.content { padding: clamp(1.25rem, 3vw, 3.25rem); }
.stack { display: grid; gap: 1.25rem; }

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

.metric-card, .panel {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.025);
}

.metric-card {
  position: relative;
  overflow: hidden;
  min-height: 9rem;
  padding: 1.25rem;
  border-radius: var(--radius);
}

.metric-card::after {
  content: "";
  position: absolute;
  right: -1.4rem;
  bottom: -2.2rem;
  width: 6rem;
  height: 6rem;
  border: 1rem solid var(--accent-soft);
  border-radius: 50%;
}

.metric-card small { display: block; color: var(--muted); font-size: 0.85rem; font-weight: 650; }
.metric-card strong { display: block; margin-top: 1.1rem; font-size: 2.25rem; line-height: 1; letter-spacing: -0.06em; }
.metric-card span { display: block; margin-top: 0.55rem; color: #8992a3; font-size: 0.78rem; }

.panel { overflow: hidden; border-radius: var(--radius-lg); }
.panel__header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.2rem 1.35rem; border-bottom: 1px solid var(--line); }
.panel__header p { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.84rem; }
.panel__body { padding: 1.35rem; }
.panel__body--flush { padding: 0; }

.split-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(18rem, 0.65fr); gap: 1.25rem; }
.duo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 0.9rem 1.15rem; border-bottom: 1px solid #edf0f4; vertical-align: middle; }
th { background: #fafbfc; color: #667085; font-size: 0.72rem; font-weight: 820; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; }
td { font-size: 0.9rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfcfd; }
.cell-title { display: block; font-weight: 760; color: var(--ink); }
.cell-meta { display: block; margin-top: 0.12rem; color: var(--muted); font-size: 0.76rem; }
.cell-actions { text-align: right; white-space: nowrap; }
.cell-error { display: block; max-width: 19rem; margin-top: 0.35rem; color: var(--danger); font-size: 0.76rem; }

.link-row { display: flex; flex-wrap: wrap; gap: 0.4rem 0.8rem; }
.text-link { color: var(--accent-dark); font-size: 0.8rem; font-weight: 760; text-decoration: none; white-space: nowrap; }
.text-link:hover { text-decoration: underline; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.24rem 0.55rem;
  border-radius: 999px;
  background: #f0f2f5;
  color: #475467;
  font-size: 0.73rem;
  font-weight: 760;
  white-space: nowrap;
}
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--accent { background: var(--accent-soft); color: var(--accent-dark); }
.badge-dot { width: 0.42rem; height: 0.42rem; border-radius: 50%; background: currentColor; }

.chip-row { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.connections-table { min-width: 86rem; }
.connections-table td { vertical-align: top; }
.client-summary { min-width: 13rem; display: grid; gap: 0.25rem; }
.client-summary--empty { align-content: start; }
.client-summary__line { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; }
.client-summary__line strong { font-size: 0.84rem; }
.history-button { padding: 0; border: 0; background: transparent; color: var(--accent-dark); cursor: pointer; font: inherit; font-size: 0.74rem; font-weight: 780; text-decoration: underline; text-underline-offset: 0.15rem; }
.history-button:hover { color: var(--accent); }

.empty-state { padding: 3rem 1.25rem; text-align: center; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 0.3rem; color: var(--ink); }

.activity-list { display: grid; }
.activity-item { display: grid; grid-template-columns: 0.7rem minmax(0, 1fr) auto; gap: 0.8rem; align-items: start; padding: 0.85rem 0; border-bottom: 1px solid #edf0f4; }
.activity-item:last-child { border-bottom: 0; }
.activity-marker { width: 0.55rem; height: 0.55rem; margin-top: 0.42rem; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.activity-item p { margin: 0; font-size: 0.88rem; }
.activity-item time { color: var(--muted); font-size: 0.75rem; white-space: nowrap; }

.setup-list { display: grid; gap: 0.7rem; counter-reset: setup; }
.setup-item { display: grid; grid-template-columns: 2rem minmax(0, 1fr); gap: 0.75rem; align-items: center; padding: 0.8rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fafbfc; }
.setup-item::before { counter-increment: setup; content: counter(setup); width: 2rem; height: 2rem; display: grid; place-items: center; border-radius: 50%; background: var(--nav); color: #fff; font-size: 0.78rem; font-weight: 800; }
.setup-item strong { display: block; font-size: 0.86rem; }
.setup-item small { color: var(--muted); }

.dialog { width: min(38rem, calc(100% - 2rem)); padding: 0; border: 0; border-radius: var(--radius-lg); background: transparent; color: var(--ink); }
.dialog--wide { width: min(76rem, calc(100% - 2rem)); }
.dialog::backdrop { background: rgba(8, 13, 25, 0.62); backdrop-filter: blur(4px); }
.dialog__card { overflow: hidden; border-radius: var(--radius-lg); background: #fff; box-shadow: var(--shadow); }
.dialog__card--key { border-top: 5px solid var(--accent); }
.dialog__header, .dialog__footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.2rem 1.35rem; }
.dialog__header { border-bottom: 1px solid var(--line); }
.dialog__footer { border-top: 1px solid var(--line); background: #fafbfc; }
.dialog__body { display: grid; gap: 1rem; padding: 1.35rem; }
.dialog__body > p { margin: 0; color: var(--muted); }
.dialog-meta { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.8rem; }
.diagnostics-history { max-height: min(68vh, 45rem); overflow: auto; padding: 0; }
.history-table { min-width: 66rem; }
.history-table td { vertical-align: top; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.field { display: grid; gap: 0.4rem; }
.field--wide { grid-column: 1 / -1; }
.field label, .field > span { color: #344054; font-size: 0.82rem; font-weight: 720; }
.field input, .field select {
  width: 100%;
  min-height: 2.8rem;
  padding: 0.62rem 0.75rem;
  border: 1px solid #cfd5df;
  border-radius: var(--radius-sm);
  outline: none;
  background: #fff;
  color: var(--ink);
}
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field small { color: var(--muted); font-size: 0.74rem; }

.check-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.check-card { display: flex; align-items: center; gap: 0.55rem; padding: 0.7rem 0.8rem; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; }
.check-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.secret-box { display: flex; align-items: center; gap: 0.65rem; padding: 0.75rem; border: 1px solid #f1b1a8; border-radius: var(--radius-sm); background: var(--accent-soft); }
.secret-box code { min-width: 0; flex: 1; overflow-wrap: anywhere; font-size: 0.86rem; color: #7a271a; }

.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: radial-gradient(circle at 50% 0%, #273450, var(--nav) 54%); }
.auth-screen[hidden] { display: none; }
.auth-panel { width: min(28rem, 100%); padding: 2.5rem; border-radius: 1.4rem; background: #fff; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.28); text-align: center; }
.auth-panel h1 { margin-bottom: 0.8rem; }
.auth-panel p:not(.eyebrow) { margin: 0 0 1.5rem; color: var(--muted); }

.toast-region { position: fixed; z-index: 20; right: 1.25rem; bottom: 1.25rem; display: grid; gap: 0.65rem; width: min(23rem, calc(100% - 2.5rem)); }
.toast { padding: 0.9rem 1rem; border: 1px solid #28354e; border-radius: var(--radius-sm); background: #172035; color: #fff; box-shadow: var(--shadow); animation: toast-in 180ms ease-out; }
.toast--error { border-color: #dc766b; background: #7a271a; }
.toast strong { display: block; margin-bottom: 0.1rem; font-size: 0.86rem; }
.toast span { color: #d6dce7; font-size: 0.8rem; }
@keyframes toast-in { from { opacity: 0; transform: translateY(0.5rem); } }

.loading-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.loading-grid span { height: 9rem; border-radius: var(--radius); background: linear-gradient(100deg, #e8ebf0 25%, #f5f6f8 45%, #e8ebf0 65%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position-x: -200%; } }

@media (max-width: 70rem) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-grid, .duo-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
  .topbar__actions { flex-wrap: wrap; justify-content: flex-end; }
}

@media (max-width: 52rem) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; padding: 0.8rem; }
  .brand { padding: 0.2rem 0.35rem 0.75rem; }
  .navigation { display: flex; overflow-x: auto; padding-bottom: 0.3rem; scrollbar-width: thin; }
  .nav-item { width: auto; flex: 0 0 auto; padding-inline: 0.8rem; }
  .nav-item.is-active { box-shadow: inset 0 -3px var(--accent); }
  .nav-icon { display: none; }
  .account-card { display: none; }
  .topbar { min-height: auto; }
}

@media (max-width: 42rem) {
  .topbar { display: grid; padding: 1.15rem; }
  .topbar__actions { justify-content: stretch; }
  .search-box { width: 100%; min-width: 0; order: 3; }
  .topbar__actions .button { flex: 1; }
  .content { padding: 1rem; }
  .metric-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .field--wide { grid-column: auto; }
  .dialog__footer { flex-direction: column-reverse; }
  .dialog__footer .button { width: 100%; }
  .panel__header { align-items: flex-start; flex-direction: column; }
  th, td { padding: 0.8rem; }
  .auth-panel { padding: 2rem 1.35rem; }
}

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