:root {
  color-scheme: dark;
  --bg: #0c121b;
  --panel: #141e2c;
  --line: #273447;
  --text: #e4ecf6;
  --muted: #9cacc2;
  --accent: #79dfc4;
  --blue: #84c9ff;
  --purple: #c4a7ff;
  --amber: #ffd181;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    14px/1.6 system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a,
input,
select,
textarea {
  outline-offset: 4px;
}
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
}
a {
  color: var(--blue);
  text-decoration: none;
}
button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #1a2839;
  color: var(--text);
  padding: 9px 13px;
  cursor: pointer;
  transition: background 0.15s;
}
button:hover {
  background: #24384d;
}
button:disabled {
  opacity: 0.55;
  cursor: wait;
}
.primary {
  background: var(--accent);
  color: #10231f;
  border-color: var(--accent);
  font-weight: 700;
}
.primary:hover {
  background: #9cebd5;
}
.quiet {
  background: transparent;
}
.muted,
small {
  color: var(--muted);
}
.brand {
  font-size: 27px;
  font-weight: 850;
  letter-spacing: 3px;
  color: var(--text);
  display: inline-block;
}
.brand span {
  color: var(--accent);
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: 25px;
  letter-spacing: -0.7px;
}
h2 {
  font-size: 19px;
}
h3 {
  font-size: 15px;
}
.badge {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.7px;
  font-weight: 800;
  border-radius: 5px;
  padding: 3px 7px;
}
.dev {
  color: var(--amber);
  background: #ffd18114;
  border: 1px solid #ffd18138;
}
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(ellipse at top, #142f38, transparent 65%);
}
.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 32px;
  display: grid;
  gap: 18px;
}
.login-card h1 {
  margin-top: 8px;
}
.login-card p {
  color: var(--muted);
}
.login-card > a {
  font-size: 12px;
  text-align: center;
}
.login-card > .badge {
  justify-self: start;
}
.shell {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  min-height: 100dvh;
}
aside {
  padding: 28px 18px;
  position: sticky;
  top: 0;
  height: 100dvh;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  background: #0f1824;
}
.workspace {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 1.4px;
  margin: 17px 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
nav {
  display: grid;
  gap: 5px;
}
nav a {
  color: var(--muted);
  padding: 11px 13px;
  border-radius: 8px;
  display: flex;
  gap: 12px;
  align-items: center;
}
nav a:hover {
  background: #172537;
  color: var(--text);
}
nav a.active {
  color: var(--accent);
  background: #79dfc410;
  border: 1px solid #79dfc42a;
}
nav .symbol {
  width: 19px;
  font-size: 18px;
  text-align: center;
}
.side-bottom {
  margin-top: auto;
  color: var(--muted);
  font-size: 12px;
}
.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
}
header {
  padding: 23px 32px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
}
header small {
  font-size: 10px;
  letter-spacing: 1.5px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
main {
  padding: 25px 32px;
  min-width: 0;
}
.notice {
  padding: 13px 16px;
  background: #192231;
  border: 1px solid var(--line);
  border-radius: 9px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 25px;
}
.source {
  margin-left: auto;
  color: var(--amber);
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat,
.card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 12px;
  padding: 22px;
}
.stat .value {
  font-size: 32px;
  line-height: 1.3;
  font-weight: 750;
  letter-spacing: -1px;
  margin: 8px 0;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.stat small {
  font-size: 11px;
}
.stat:nth-child(1) {
  border-top: 2px solid var(--amber);
}
.stat:nth-child(2) {
  border-top: 2px solid var(--purple);
}
.stat:nth-child(3) {
  border-top: 2px solid var(--blue);
}
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.toolbar p {
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
}
.table-wrap {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: auto;
  background: var(--panel);
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  white-space: nowrap;
}
th {
  padding: 13px 16px;
  background: #1b2839;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
td {
  padding: 15px 16px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
td .sub {
  display: block;
  font-size: 11px;
  color: var(--muted);
}
td button {
  padding: 5px 9px;
  font-size: 11px;
  margin: 2px;
}
.num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.key {
  color: var(--blue);
  font:
    12px ui-monospace,
    monospace;
}
.agent {
  color: var(--purple);
}
.merchant {
  color: var(--amber);
}
.pill {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 50px;
  background: #79dfc415;
  color: var(--accent);
}
.pill.off {
  color: var(--amber);
  background: #ffd18115;
}
.empty {
  padding: 50px 25px;
  text-align: center;
  color: var(--muted);
}
.empty h2 {
  color: var(--text);
  margin-bottom: 8px;
}
.empty p {
  max-width: 540px;
  margin: auto;
}
.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.card p {
  color: var(--muted);
  margin-top: 10px;
}
.card ul {
  color: var(--muted);
  padding-left: 18px;
}
.card li {
  margin: 8px 0;
}
.card code {
  color: var(--blue);
}
.api-list {
  display: grid;
  gap: 0;
}
.api-row {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.api-row:last-child {
  border: 0;
}
.api-row code {
  font-size: 12px;
  white-space: normal;
}
.api-row p {
  font-size: 12px;
  margin-top: 4px;
}
.method {
  font-size: 10px;
  color: var(--accent);
  display: inline-block;
  width: 45px;
}
.tip {
  border-left: 3px solid var(--blue);
  padding: 14px 18px;
  background: #84c9ff0c;
  margin: 18px 0;
  color: var(--muted);
}
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #0b1420;
  border: 1px solid var(--line);
  padding: 17px;
  border-radius: 9px;
  color: var(--blue);
  font-size: 12px;
}
label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}
input,
select,
textarea {
  width: 100%;
  min-width: 0;
  background: #0d1623;
  border: 1px solid #35475e;
  color: var(--text);
  border-radius: 8px;
  padding: 11px 13px;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}
textarea {
  resize: vertical;
  min-height: 95px;
}
dialog {
  border: 1px solid #3d5065;
  border-radius: 15px;
  padding: 25px;
  background: var(--panel);
  color: var(--text);
  width: min(480px, calc(100% - 28px));
  max-height: 90dvh;
  overflow: auto;
}
dialog::backdrop {
  background: #030811bb;
  backdrop-filter: blur(4px);
}
.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  align-items: center;
  margin-bottom: 20px;
}
.dialog-head button {
  font-size: 20px;
  padding: 0 9px;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}
#dialog-fields {
  display: grid;
  gap: 16px;
}
#key-dialog > p {
  margin: 15px 0;
}
.error {
  color: #ffb0a6;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.error:empty {
  display: none;
}
#toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: #21382f;
  color: #bcf5df;
  border: 1px solid #659b80;
  border-radius: 10px;
  padding: 14px 20px;
  max-width: calc(100% - 44px);
  z-index: 9;
}
footer {
  padding: 20px 32px;
  color: var(--muted);
  font-size: 11px;
  border-top: 1px solid var(--line);
  margin-top: 30px;
}
.skip {
  position: absolute;
  top: -70px;
  left: 10px;
  z-index: 10;
  padding: 10px;
  background: var(--panel);
}
.skip:focus {
  top: 10px;
}
[hidden] {
  display: none !important;
}
@media (max-width: 1050px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .columns {
    grid-template-columns: 1fr;
  }
  .shell {
    grid-template-columns: 190px minmax(0, 1fr);
  }
  header,
  main {
    padding: 20px;
  }
  .header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}
@media (max-width: 760px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }
  aside {
    position: static;
    height: auto;
    padding: 17px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .workspace,
  .side-bottom {
    display: none;
  }
  aside > .brand {
    font-size: 21px;
  }
  nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 13px;
  }
  nav a {
    padding: 7px 9px;
    font-size: 12px;
    gap: 6px;
  }
  nav .symbol {
    font-size: 14px;
    width: 15px;
  }
  header {
    gap: 12px;
    padding: 18px 16px;
  }
  header h1 {
    font-size: 20px;
  }
  .header-actions {
    gap: 6px;
  }
  .header-actions button {
    font-size: 11px;
    padding: 7px 9px;
  }
  #admin-name {
    display: none;
  }
  main {
    padding: 18px 16px;
  }
  .notice {
    gap: 8px;
  }
  .source {
    margin-left: 0;
    width: 100%;
  }
  .stat {
    padding: 17px;
  }
  .stat .value {
    font-size: 27px;
  }
  .toolbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }
  table,
  tbody,
  tr,
  td {
    display: block;
    white-space: normal;
    min-width: 0;
  }
  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  tr {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    margin-bottom: 12px;
    padding: 5px 0;
  }
  td {
    border-top: 0;
    padding: 8px 14px;
    overflow-wrap: anywhere;
  }
  td:before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 10px;
    display: block;
    margin-bottom: 3px;
  }
  td button {
    padding: 7px 10px;
  }
  footer {
    padding: 18px 16px;
  }
  .stats {
    gap: 10px;
  }
  .login-card {
    padding: 24px;
  }
  dialog {
    padding: 20px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* BEGIN: Realtime/infrastructure display, compact on small screens. */
.live-state {
  font-size: 11px;
  color: var(--amber);
}
.live-state.connected {
  color: var(--accent);
}
.infrastructure {
  margin-top: 18px;
}
.infrastructure-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 10px;
}
.infrastructure-grid strong {
  display: block;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
@media (max-width: 760px) {
  .live-state {
    max-width: 100px;
    font-size: 10px;
  }
  .infrastructure-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
/* END: Realtime/infrastructure display. */
/* BEGIN: Responsive partner profile editor; keep long notes and IP lists full width. */
dialog:has(#dialog-fields [name="fullName"]){width:min(780px,calc(100% - 28px))}
#dialog-fields:has([name="fullName"]){grid-template-columns:repeat(2,minmax(0,1fr))}
#dialog-fields:has([name="fullName"]) label:has(textarea),#dialog-fields:has([name="fullName"])>p{grid-column:1/-1}
@media(max-width:640px){#dialog-fields:has([name="fullName"]){grid-template-columns:minmax(0,1fr)}}
/* END: Partner profile editor. */
/* BEGIN: Agent user counts act as clear links to the nested user list. */
a.user-count{display:inline-flex;align-items:center;justify-content:center;min-width:48px;padding:7px 12px;border:1px solid #697982;border-radius:7px;background:#242a2e!important;color:#fff1cf!important;line-height:1.5!important;font-weight:700}
a.user-count:hover{background:#3a444b!important;border-color:#dfc78f}
a.back-agents{display:inline-block;padding:5px 0;font-size:14px}
/* END: Agent user-count links. */
