:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --surface: #121820;
  --surface-2: #171f29;
  --surface-3: #1d2733;
  --line: #273342;
  --line-soft: #202a36;
  --text: #eef3f7;
  --muted: #8f9dac;
  --muted-2: #687787;
  --accent: #37e0a1;
  --accent-dark: #092d23;
  --blue: #67a7ff;
  --blue-dark: #122943;
  --warning: #f1ba63;
  --warning-dark: #342714;
  --danger: #ff7e88;
  --danger-dark: #36191e;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 48px rgb(0 0 0 / 25%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 80% -10%, rgb(55 224 161 / 8%), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

:focus-visible {
  outline: 3px solid rgb(103 167 255 / 75%);
  outline-offset: 3px;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(28px, 4vw, 42px); line-height: 1.08; letter-spacing: -0.035em; }
h2 { margin-bottom: 4px; font-size: 19px; line-height: 1.25; }
code, .mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
code { padding: 2px 5px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-3); color: #dbe7f1; }

.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;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 0 max(24px, calc((100vw - 1240px) / 2));
  border-bottom: 1px solid rgb(39 51 66 / 80%);
  background: rgb(11 15 20 / 88%);
  backdrop-filter: blur(16px);
}

.brand { display: inline-flex; align-items: center; gap: 11px; min-height: 44px; }
.brand > span:last-child { display: flex; flex-direction: column; line-height: 1.05; }
.brand strong { font-size: 15px; letter-spacing: .02em; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .16em; }

.brand-mark {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  background: var(--accent);
  box-shadow: 0 0 24px rgb(55 224 161 / 20%);
  color: #07140f;
  font-weight: 900;
}

.brand-mark-large { width: 46px; height: 46px; border-radius: 13px; font-size: 20px; }
.topnav { display: flex; align-items: center; gap: 18px; color: var(--muted); }
.topnav > a { min-height: 44px; padding: 11px 2px; }
.topnav > a:hover { color: var(--text); }
.topnav form { margin: 0; }

.page-shell { width: min(1240px, calc(100% - 48px)); margin: 0 auto; padding: 46px 0 64px; }
.narrow-shell { width: min(960px, calc(100% - 48px)); }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.page-heading h1 { margin-bottom: 6px; }
.lead { max-width: 740px; margin-bottom: 0; color: var(--muted); font-size: 16px; }
.eyebrow { margin-bottom: 8px; color: var(--accent); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .17em; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 750;
  line-height: 1.2;
  transition: border-color .16s ease, background .16s ease, color .16s ease, transform .16s ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { border-color: var(--accent); background: var(--accent); color: #07140f; }
.button-primary:hover { background: #5be8b4; }
.button-secondary { border-color: var(--line); background: var(--surface-2); color: var(--text); }
.button-secondary:hover { border-color: #425269; background: var(--surface-3); }
.button-quiet { border-color: transparent; background: transparent; color: var(--muted); }
.button-quiet:hover { background: var(--surface-2); color: var(--text); }
.button-full { width: 100%; min-height: 48px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.metric-card { position: relative; min-height: 142px; padding: 20px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, var(--surface-2), var(--surface)); }
.metric-card::after { content: ""; position: absolute; right: -34px; bottom: -55px; width: 110px; height: 110px; border: 24px solid rgb(255 255 255 / 2.5%); border-radius: 50%; }
.metric-card > span, .metric-card > small { position: relative; z-index: 1; display: block; color: var(--muted); }
.metric-card > span { font-size: 13px; font-weight: 700; }
.metric-card > strong { position: relative; z-index: 1; display: block; margin: 14px 0 4px; font-size: 34px; line-height: 1; letter-spacing: -.04em; }
.metric-card > small { font-size: 12px; }
.metric-positive { border-color: rgb(55 224 161 / 30%); background: linear-gradient(145deg, rgb(14 48 37), var(--surface)); }
.metric-positive > strong { color: var(--accent); }
.metric-muted > strong { color: #a5b0bb; }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: rgb(18 24 32 / 94%); box-shadow: var(--shadow); }
.panel + .panel, .json-grid + .panel, .detail-grid + .panel { margin-top: 18px; }
.panel-toolbar, .panel-title { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 22px; border-bottom: 1px solid var(--line-soft); }
.panel-toolbar p, .panel-title p { margin: 0; color: var(--muted); }
.panel-title .eyebrow { margin-bottom: 3px; }

.search { display: flex; align-items: center; gap: 8px; }
input, select {
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0d131a;
  color: var(--text);
}
input::placeholder { color: var(--muted-2); }
input:hover, select:hover { border-color: #3a4a5d; }
.search input { width: min(330px, 36vw); }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 18px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; white-space: nowrap; }
th { color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .09em; }
td { font-size: 13px; }
tbody tr { transition: background .14s ease; }
tbody tr:hover { background: rgb(255 255 255 / 1.8%); }
tbody tr:last-child td { border-bottom: 0; }
.strong-link { color: #d9e8f4; font-weight: 800; }
.strong-link:hover, .table-action:hover, .breadcrumbs a:hover { color: var(--accent); }
.cell-note { display: block; margin-top: 3px; color: var(--muted-2); font-size: 11px; }
.cell-error { max-width: 280px; overflow: hidden; color: var(--danger); text-overflow: ellipsis; }
.table-action { color: var(--blue); font-weight: 750; }

.status { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; }
.status i { display: block; width: 7px; height: 7px; border-radius: 50%; background: currentcolor; }
.status-online { color: var(--accent); }
.status-offline { color: var(--muted-2); }

.state { display: inline-flex; align-items: center; min-height: 26px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.state-success { border-color: rgb(55 224 161 / 32%); background: var(--accent-dark); color: var(--accent); }
.state-danger { border-color: rgb(255 126 136 / 28%); background: var(--danger-dark); color: var(--danger); }
.state-progress { border-color: rgb(103 167 255 / 28%); background: var(--blue-dark); color: var(--blue); }
.state-queued { border-color: rgb(241 186 99 / 28%); background: var(--warning-dark); color: var(--warning); }
.state-unknown { color: var(--muted); }
.state-large { min-height: 34px; padding: 7px 12px; font-size: 12px; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 20px; border-top: 1px solid var(--line-soft); color: var(--muted); }
.pagination > div { display: flex; gap: 8px; }
.empty-state { display: flex; min-height: 190px; flex-direction: column; align-items: center; justify-content: center; padding: 28px; color: var(--muted); text-align: center; }
.empty-state strong { margin-bottom: 5px; color: var(--text); font-size: 17px; }
.empty-inline { padding: 22px; color: var(--muted); }

.breadcrumbs { display: flex; align-items: center; gap: 9px; margin-bottom: 24px; color: var(--muted); font-size: 13px; }
.breadcrumbs span:last-child { max-width: 60vw; overflow: hidden; color: var(--text); text-overflow: ellipsis; white-space: nowrap; }
.device-heading { align-items: center; }
.connection-pair { display: flex; gap: 10px; }
.connection-pair > div { min-width: 118px; padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.connection-pair span, .connection-pair strong { display: block; }
.connection-pair span { margin-bottom: 4px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .09em; }
.connection-pair strong { font-size: 14px; }
.text-positive { color: var(--accent); }

.alert { margin-bottom: 18px; padding: 13px 16px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); color: #cbd5de; }
.alert-danger { border-color: rgb(255 126 136 / 28%); background: var(--danger-dark); color: #ffc3c8; }
.alert-warning { border-color: rgb(241 186 99 / 30%); background: var(--warning-dark); color: #f7d9a8; }
.alert-success { border-color: rgb(55 224 161 / 30%); background: var(--accent-dark); color: #aff4da; }
.alert-neutral { border-color: rgb(103 167 255 / 25%); background: var(--blue-dark); color: #c4dcff; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(340px, .65fr); gap: 18px; }
.definition-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; padding: 8px 22px 22px; }
.definition-grid > div { min-width: 0; padding: 15px 14px 15px 0; border-bottom: 1px solid var(--line-soft); }
.definition-grid > div:nth-last-child(-n+2) { border-bottom: 0; }
.definition-grid dt { margin-bottom: 5px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
.definition-grid dd { margin: 0; overflow-wrap: anywhere; color: #dfe8ef; font-size: 13px; }

.action-panel form { margin: 0 18px 10px; }
.action-panel form:first-of-type { margin-top: 18px; }
.command-button { display: grid; width: 100%; min-height: 76px; grid-template-columns: 38px 1fr auto; align-items: center; gap: 12px; padding: 12px; border: 1px solid rgb(55 224 161 / 26%); border-radius: 12px; background: var(--accent-dark); color: var(--text); cursor: pointer; text-align: left; }
.command-button:hover { border-color: var(--accent); background: #0d382b; }
.command-button > span:nth-child(2) { min-width: 0; }
.command-button strong, .command-button small { display: block; }
.command-button small { margin-top: 3px; color: #92ae9f; font-size: 11px; }
.command-icon { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 10px; background: rgb(55 224 161 / 12%); color: var(--accent); font-size: 19px; }
.command-button-test { border-color: var(--line); background: var(--surface-2); }
.command-button-test:hover { border-color: #46576d; background: var(--surface-3); }
.command-button-test .command-icon { background: rgb(103 167 255 / 10%); color: var(--blue); }
.command-button-test small { color: var(--muted); }
.safety-note { margin: 14px 18px 20px; color: var(--muted); font-size: 12px; }

.count-pill { display: inline-grid; min-width: 30px; height: 26px; place-items: center; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 12px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 20px 22px 22px; list-style: none; }
.tag-list li { padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: #c9d5df; font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }

.json-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 18px; }
.json-panel { min-width: 0; overflow: hidden; }
.json-panel summary { padding: 16px 20px; border-bottom: 1px solid var(--line-soft); cursor: pointer; color: #d9e3eb; font-weight: 750; }
.json-panel pre { min-height: 140px; max-height: 430px; margin: 0; padding: 18px 20px; overflow: auto; background: #0c1117; color: #aebdca; font: 12px/1.55 "SFMono-Regular", Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.json-panel.inset { border: 1px solid var(--line); border-radius: 12px; background: #0c1117; }
.history-more { display: flex; justify-content: flex-end; padding: 16px 20px; border-top: 1px solid var(--line-soft); }

.command-detail { padding-bottom: 22px; overflow: hidden; }
.command-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 22px; padding: 26px 26px 21px; border-bottom: 1px solid var(--line-soft); }
.command-detail-head h1 { margin-bottom: 8px; font-size: 30px; }
.command-detail-head p { margin: 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.command-detail > .alert { margin: 18px 22px 0; }
.command-fields { padding-top: 12px; }
.command-detail > .json-grid { padding: 0 22px; }
.command-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 22px 22px 0; padding-top: 20px; border-top: 1px solid var(--line-soft); }

.footer { display: flex; align-items: center; justify-content: space-between; width: min(1240px, calc(100% - 48px)); margin: 0 auto; padding: 20px 0 32px; border-top: 1px solid var(--line-soft); color: var(--muted-2); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }

.login-body { display: grid; place-items: center; padding: 24px; }
.login-shell { width: min(430px, 100%); }
.login-card { padding: 34px; border: 1px solid var(--line); border-radius: 22px; background: linear-gradient(150deg, rgb(23 31 41 / 97%), rgb(15 21 28 / 97%)); box-shadow: 0 28px 90px rgb(0 0 0 / 44%); }
.login-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 42px; }
.login-brand strong, .login-brand span { display: block; }
.login-brand strong { font-size: 16px; }
.login-brand span { margin-top: 2px; color: var(--muted); font-size: 12px; }
.login-card h1 { font-size: 32px; }
.login-card .lead { margin-bottom: 25px; font-size: 14px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack label { color: #cbd5de; font-size: 12px; font-weight: 750; }
.stack input { width: 100%; min-height: 48px; margin-bottom: 4px; }
.form-note { margin: 16px 0 0; color: var(--muted-2); font-size: 11px; text-align: center; }

.provision-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.provision-card { min-width: 0; }
.provision-form { padding: 20px 22px 22px; }
.provision-form select { width: 100%; }
.provision-form .button { margin-top: 8px; }
.field-note { min-height: 34px; color: var(--muted-2); font-size: 11px; }
.mobile-users-panel { margin-top: 18px; }
.mobile-users-panel form { margin: 0; }
.danger-action { color: var(--danger); }

.error-shell { display: grid; min-height: 100vh; place-items: center; padding: 28px; }
.error-card { width: min(520px, 100%); padding: 40px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); text-align: center; box-shadow: var(--shadow); }
.error-code { margin-bottom: 10px; color: var(--accent); font: 800 13px "SFMono-Regular", Consolas, monospace; letter-spacing: .14em; }
.error-card h1 { font-size: 30px; }
.error-card .lead { margin: 0 auto 24px; }

@media (max-width: 980px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
  .action-panel { order: -1; }
  .provision-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .topbar { min-height: 62px; padding: 0 16px; }
  .topnav { gap: 6px; }
  .topnav > a { display: none; }
  .page-shell, .narrow-shell { width: min(100% - 28px, 1240px); padding: 30px 0 46px; }
  .page-heading { align-items: flex-start; flex-direction: column; margin-bottom: 22px; }
  .device-heading { gap: 18px; }
  .connection-pair { width: 100%; }
  .connection-pair > div { flex: 1; min-width: 0; }
  .metric-grid { gap: 10px; }
  .metric-card { min-height: 126px; padding: 17px; }
  .metric-card > strong { font-size: 29px; }
  .panel-toolbar { align-items: stretch; flex-direction: column; }
  .search { align-items: stretch; flex-wrap: wrap; }
  .search input { width: 100%; flex: 1 0 100%; }
  .search .button { flex: 1; }
  th, td { padding: 13px 15px; }
  .definition-grid { grid-template-columns: 1fr; }
  .definition-grid > div:nth-last-child(-n+2) { border-bottom: 1px solid var(--line-soft); }
  .definition-grid > div:last-child { border-bottom: 0; }
  .json-grid { grid-template-columns: 1fr; }
  .command-detail-head { align-items: flex-start; flex-direction: column; }
  .command-detail > .json-grid { padding: 0 14px; }
  .command-footer { align-items: stretch; flex-direction: column-reverse; }
  .command-footer .button { width: 100%; }
  .pagination { align-items: stretch; flex-direction: column; }
  .pagination > div, .pagination .button { width: 100%; }
  .footer { width: calc(100% - 28px); align-items: flex-start; flex-direction: column; gap: 7px; }
  .login-card { padding: 27px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
