:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --line: #d8dee7;
  --brand: #166b58;
  --brand-2: #0f4f84;
  --danger: #b42318;
  --ok: #067647;
  --warn: #b54708;
  --shadow: 0 8px 22px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  direction: ltr;
  font-family: Arial, Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--brand-2); text-decoration: none; }
h1 { margin: 0 0 4px; font-size: 24px; }
h2 { margin: 0 0 14px; font-size: 17px; }
.section-title { font-weight: 700; font-size: 16px; margin-bottom: 14px; }
.layout { display: grid; grid-template-columns: 270px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #101828;
  color: #fff;
  padding: 22px 16px;
}
.brand { font-weight: 700; font-size: 20px; margin-bottom: 26px; letter-spacing: 0; }
.nav-caption {
  color: #98a2b3;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 8px 10px;
}
.nav a {
  display: flex;
  align-items: center;
  min-height: 42px;
  color: #d1d5db;
  border-radius: 8px;
  padding: 9px 11px;
  margin-bottom: 5px;
  font-size: 14px;
}
.nav a:hover, .nav a.active { background: #243247; color: #fff; }
.nav a.active { box-shadow: inset 3px 0 0 #2dd4bf; }
.main { padding: 28px; min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid > div { min-width: 0; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.helper-band {
  margin: 14px 0;
  padding: 12px 14px;
  border: 1px solid #b9e6fe;
  border-radius: 8px;
  background: #f0f9ff;
  color: #184e77;
  font-size: 13px;
}
.helper-band code {
  font-family: Consolas, monospace;
  background: rgba(255,255,255,0.8);
  padding: 2px 5px;
  border-radius: 5px;
}
.metric-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}
.metric { font-size: 30px; font-weight: 700; margin-top: 8px; }
.muted { color: var(--muted); font-size: 13px; }
.table-shell {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.table-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}
.table-tools input,
.table-tools select {
  min-height: 38px;
}
.table-count {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  text-align: right;
}
.table-scroll {
  width: 100%;
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  min-width: 760px;
}
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
th { background: #eef2f6; font-size: 12px; color: #344054; text-transform: uppercase; letter-spacing: 0.02em; position: sticky; top: 0; z-index: 1; }
tbody tr:hover td { background: #f9fbfd; }
tr:last-child td { border-bottom: 0; }
td form.grid { align-items: end; }
td form + form { margin-top: 8px; }
.message-preview {
  min-width: 280px;
  max-width: 520px;
  white-space: normal;
  line-height: 1.55;
}
.chart-card {
  margin: 16px 0;
  overflow-x: auto;
}
.analytics-chart {
  display: block;
  width: 100%;
  min-width: 720px;
  height: auto;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.detail-value {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfe;
  min-height: 40px;
}
.message-full {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 120px;
  background: #fff;
  white-space: pre-wrap;
  line-height: 1.7;
}
.payload-view {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #101828;
  color: #f8fafc;
  overflow: auto;
  max-height: 260px;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(22, 107, 88, 0.18);
  border-color: var(--brand);
}
textarea { min-height: 110px; resize: vertical; }
label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.form-row { margin-bottom: 14px; }
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  font-family: inherit;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
}
.btn:hover { filter: brightness(0.96); }
.btn + .btn { margin-inline-start: 8px; }
.btn.secondary { background: #344054; }
.btn.danger { background: var(--danger); }
.status { display: inline-block; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700; background: #eef2f6; }
.status.active, .status.approved, .status.sent, .status.delivered, .status.info { background: #dcfae6; color: var(--ok); }
.status.online { background: #dcfae6; color: var(--ok); }
.status.android { background: #e0f2fe; color: #075985; }
.status.usb { background: #ede9fe; color: #5b21b6; }
.status.web-api { background: #ecfdf3; color: #05603a; }
.status.pending, .status.queued, .status.warning { background: #fff1d6; color: var(--warn); }
.status.stale { background: #fff1d6; color: var(--warn); }
.status.failed, .status.blocked, .status.rejected, .status.offline, .status.error, .status.critical { background: #fee4e2; color: var(--danger); }
.flash { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; background: #e9f7ef; color: var(--ok); }
.flash.error { background: #fee4e2; color: var(--danger); }
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.auth .card { width: min(420px, 100%); }
.ltr { direction: ltr; text-align: left; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.route-members {
  display: grid;
  gap: 8px;
  min-width: 360px;
}
.route-member {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}
.danger-zone {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid #fecdca;
  border-radius: 8px;
  background: #fff7f6;
}
.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 50;
}
.modal.is-open { display: block; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
}
.modal-panel {
  position: relative;
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  margin: 24px auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(17, 24, 39, 0.25);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}
.modal-body { padding: 16px; }
.icon-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: #eef2f6;
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .grid.cols-2, .grid.cols-4 { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .main { padding: 18px; }
  .table-tools { grid-template-columns: 1fr; }
  .table-count { text-align: left; }
  .detail-grid { grid-template-columns: 1fr; }
}
