/* Design tokens and components follow infra-portal (Tailwind slate + sky). */
:root {
  --bg: #020617;
  --panel: #0f172a;
  --panel-deep: #0a111e;
  --line: #1e293b;
  --line-strong: #334155;
  --text: #e2e8f0;
  --text-strong: #f8fafc;
  --soft: #cbd5e1;
  --muted: #94a3b8;
  --dim: #64748b;
  --faint: #475569;
  --accent: #0284c7;
  --accent-hover: #0369a1;
  --accent-text: #38bdf8;
  --brand: #0ea5e9;
  --green: #4ade80;
  --amber: #fbbf24;
  --red: #f87171;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.grow { flex: 1; }
.mono { font-family: var(--mono); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--line); }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }

/* Header */
.topbar {
  height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; color: #fff; text-decoration: none; }
.brand svg { color: var(--brand); }
.brand-tag {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--accent-text); background: #0c2a45; border: 1px solid #075985;
  border-radius: 999px; padding: 1px 7px;
}
.env-chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted);
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px;
}
.env-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px #16653455; }
.env-chip.bad .env-dot { background: var(--red); box-shadow: 0 0 0 3px #7f1d1d55; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px; border-radius: 6px; border: none; background: none; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { color: #fff; background: var(--line); }
.menu-btn { display: none; }

/* Layout */
.layout { display: flex; flex: 1; min-height: 0; }
#sidebar {
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  width: 256px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 20;
  transition: transform .2s ease;
}
.nav { flex: 1; overflow-y: auto; padding: 16px; }
.nav-label {
  font-size: 12px; font-weight: 600; color: var(--dim); text-transform: uppercase;
  letter-spacing: .05em; margin: 0 0 8px; padding: 0 8px;
}
.nav-link {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; margin-bottom: 4px;
  border-radius: 4px; border-left: 2px solid transparent;
  font-size: 14px; color: var(--soft); text-decoration: none;
}
.nav-link:hover { background: var(--line); color: #fff; }
.nav-link.nav-active { background: rgba(14, 165, 233, .15); color: var(--accent-text); border-left-color: var(--accent-text); }
.nav-link svg { flex-shrink: 0; }
.nav-count {
  margin-left: auto; min-width: 20px; height: 18px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; background: var(--line); color: var(--muted); font-size: 10px; font-weight: 700;
}
.nav-count:empty { display: none; }
.nav-count.live { background: #052e16; color: var(--green); }
.sidebar-foot { border-top: 1px solid var(--line); padding: 12px 16px 8px; }
.server-box { font-size: 12px; color: var(--dim); padding: 0 4px 10px; }
.server-box .row { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.server-box .val { color: var(--soft); font-family: var(--mono); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-links { display: flex; gap: 12px; padding: 4px 0 0; }
.client-links a { display: inline-flex; align-items: center; gap: 4px; color: var(--accent-text); font-size: 12px; text-decoration: none; }
.client-links a:hover { text-decoration: underline; }
a.btn-ghost { text-decoration: none; }
.version { padding: 4px 4px 0; font-size: 10px; color: var(--faint); font-family: var(--mono); }
main { flex: 1; min-width: 0; overflow-y: auto; }
.backdrop { display: none; }

/* Page */
.pm-wrap { padding: 28px 24px; max-width: 1560px; }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.page-title { font-size: 18px; font-weight: 700; color: var(--text-strong); }
.page-sub { font-size: 12px; color: var(--dim); margin-top: 2px; }
.head-actions { display: flex; align-items: center; gap: 10px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--soft); margin: 26px 0 10px; display: flex; align-items: baseline; gap: 8px; }
.section-note { font-size: 11px; font-weight: 500; color: var(--dim); }

/* Buttons */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px;
  background: var(--accent); color: #fff; border-radius: 8px; font-size: 13px; font-weight: 600;
  text-decoration: none; border: none; cursor: pointer; transition: background .15s; white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .55; cursor: default; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px;
  background: transparent; color: var(--muted); border-radius: 8px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--line-strong); cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn-ghost:hover { background: var(--line); color: var(--text); }
.btn-ghost.active { background: #1e3a5f; color: var(--accent-text); border-color: var(--accent); }
.btn-danger {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px;
  background: #b91c1c; color: #fff; border-radius: 8px; font-size: 13px; font-weight: 600;
  border: none; cursor: pointer; transition: background .15s; white-space: nowrap;
}
.btn-danger:hover { background: #991b1b; }
.btn-danger:disabled { opacity: .55; cursor: default; }

/* Summary cards */
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
  display: flex; gap: 12px; align-items: flex-start;
}
.stat-icon {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: #0c2a45; color: var(--accent-text); border: 1px solid #075985;
}
.stat-icon.green { background: #052e16; color: var(--green); border-color: #166534; }
.stat-icon.violet { background: #2e1065; color: #c4b5fd; border-color: #5b21b6; }
.stat-icon.amber { background: #422006; color: var(--amber); border-color: #78350f; }
.stat-icon.red { background: #450a0a; color: var(--red); border-color: #7f1d1d; }
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--dim); }
.stat-value { font-size: 20px; font-weight: 700; color: var(--text-strong); line-height: 1.3; margin-top: 2px; }
.stat-value small { font-size: 13px; font-weight: 600; color: var(--muted); }
.stat-sub { font-size: 12px; color: var(--dim); margin-top: 2px; }

/* Tabs and toolbar */
.tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; }
.tab-btn {
  padding: 8px 16px; font-size: 13px; font-weight: 500; color: var(--dim);
  background: none; border: none; border-bottom: 2px solid transparent;
  cursor: pointer; transition: all .15s; margin-bottom: -1px; white-space: nowrap;
}
.tab-btn:hover { color: var(--muted); }
.tab-btn.active { color: var(--accent-text); border-bottom-color: var(--accent); }
.tab-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px;
  background: var(--line); border-radius: 99px; font-size: 10px; font-weight: 700; color: var(--muted);
}
.tab-btn.active .tab-count { background: #1e3a5f; color: var(--accent-text); }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.toolbar-note { font-size: 12px; color: var(--faint); }
.search-box { position: relative; flex: 1; min-width: 180px; max-width: 320px; }
.search-box input {
  width: 100%; height: 36px; background: var(--panel); border: 1px solid var(--line-strong); color: var(--text);
  border-radius: 8px; padding: 0 10px 0 34px; font-size: 13px; outline: none;
}
.search-box input:focus { border-color: var(--accent); }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
/* Own chevron: the native one sits against the border and the height differs
   from the search field between browsers. */
select.filter {
  appearance: none; -webkit-appearance: none;
  height: 36px; padding: 0 34px 0 12px; font-size: 13px; line-height: 34px;
  background: var(--panel) no-repeat right 12px center / 12px 12px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M6 9l6 6 6-6' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  border: 1px solid var(--line-strong); border-radius: 8px; color: var(--muted); outline: none; cursor: pointer;
}
select.filter:hover { border-color: var(--faint); color: var(--soft); }
select.filter:focus { border-color: var(--accent); }
select.filter option { background: var(--panel); color: var(--text); }

/* Tables */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead tr { background: var(--line); border-bottom: 1px solid var(--line-strong); }
th {
  text-align: left; padding: 9px 14px; font-weight: 600; color: var(--muted); white-space: nowrap;
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
}
th.num, td.num { text-align: right; }
tbody tr { border-bottom: 1px solid var(--line); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #1e293b55; }
tbody tr.clickable { cursor: pointer; }
tbody tr.off td { color: var(--dim); }
td { padding: 11px 14px; vertical-align: middle; }
td.muted { color: var(--dim); font-size: 12px; }
td.nowrap { white-space: nowrap; }
.cell-sub { font-size: 12px; color: var(--dim); margin-top: 1px; }
.expiry.amber { color: var(--amber); font-weight: 600; }
.expiry.red { color: var(--red); font-weight: 600; }
.cell-clip { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.user-cell { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.user-name { color: var(--text); font-weight: 600; }
tr.off .user-name { color: var(--muted); }
.user-login { font-family: var(--mono); font-size: 12px; color: var(--dim); }
.user-email { font-family: var(--sans, inherit); }
.avatar {
  width: 30px; height: 30px; min-width: 30px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; font-weight: 700; line-height: 1; user-select: none;
}
.avatar.lg { width: 44px; height: 44px; min-width: 44px; font-size: 15px; }
.avatar.c0 { background: #0369a1; } .avatar.c1 { background: #7c3aed; } .avatar.c2 { background: #0f766e; }
.avatar.c3 { background: #b45309; } .avatar.c4 { background: #be185d; } .avatar.c5 { background: #4d7c0f; }
.avatar.c6 { background: #1d4ed8; } .avatar.c7 { background: #9333ea; }
tr.off .avatar { filter: grayscale(1); opacity: .6; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.badge.green { background: #052e16; color: var(--green); border: 1px solid #166534; }
.badge.amber { background: #422006; color: var(--amber); border: 1px solid #78350f; }
.badge.red { background: #450a0a; color: var(--red); border: 1px solid #7f1d1d; }
.badge.slate { background: var(--line); color: var(--muted); border: 1px solid var(--line-strong); }
.badge.sky { background: #0c2a45; color: #7dd3fc; border: 1px solid #075985; }
.badge.violet { background: #2e1065; color: #c4b5fd; border: 1px solid #5b21b6; }
.badge svg { flex-shrink: 0; }
.status-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.online { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--green); font-weight: 600; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 0 #22c55e88; animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 #22c55e88; } 70% { box-shadow: 0 0 0 7px #22c55e00; } 100% { box-shadow: 0 0 0 0 #22c55e00; } }

.traffic { display: flex; flex-direction: column; gap: 1px; font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.traffic .down { color: var(--soft); }
.traffic .up { color: var(--dim); }
.traffic b { font-weight: 600; }
.arrow-down { color: var(--accent-text); }
.arrow-up { color: var(--amber); }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; opacity: 0; transition: opacity .15s; }
tbody tr:hover .row-actions, .row-actions:focus-within { opacity: 1; }
.row-btn {
  padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 600;
  border: 1px solid var(--line-strong); background: var(--line); color: var(--muted);
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.row-btn:hover { background: var(--panel); color: var(--text); }
.row-btn.warn { color: #f59e0b; }
.row-btn.warn:hover { border-color: #d97706; color: #d97706; }
.row-btn.ok { color: #22d3ee; }
.row-btn.ok:hover { border-color: #06b6d4; color: #06b6d4; }
.row-btn.danger { color: var(--red); }
.row-btn.danger:hover { border-color: #b91c1c; color: #fca5a5; }
.row-btn:disabled { opacity: .5; cursor: default; }

.empty-state { text-align: center; padding: 56px 24px; color: var(--faint); }
.empty-state svg { width: 44px; height: 44px; margin: 0 auto 14px; opacity: .35; display: block; }
.empty-state .title { color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.loading { text-align: center; padding: 48px; color: var(--faint); }
.spinner {
  display: inline-block; width: 18px; height: 18px; border: 2px solid var(--line-strong);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite;
  margin-right: 8px; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Alerts */
.alert {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; margin-bottom: 16px;
  border-radius: 10px; font-size: 13px; background: #422006; border: 1px solid #78350f; color: #fde68a;
}
.alert.red { background: #450a0a; border-color: #7f1d1d; color: #fecaca; }
.alert svg { flex-shrink: 0; margin-top: 2px; }

/* Agents */
.agents { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.agent { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.agent-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.agent-name { font-family: var(--mono); font-size: 13px; color: var(--text); font-weight: 600; }
.agent-meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin-top: 10px; font-size: 12px; }
.agent-meta dt { color: var(--dim); }
.agent-meta dd { margin: 0; color: var(--soft); text-align: right; font-variant-numeric: tabular-nums; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(2, 6, 23, .72);
  display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 24px; overflow-y: auto;
  animation: fade .12s ease-out;
}
.modal {
  width: 100%; max-width: 520px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, .6);
  animation: rise .14s ease-out;
}
.modal.wide { max-width: 720px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.modal-title { font-size: 16px; font-weight: 700; color: var(--text-strong); }
.modal-sub { font-size: 12px; color: var(--dim); margin-top: 2px; }
.modal-body { padding: 16px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label, .field .label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field .optional { font-weight: 400; color: var(--dim); margin-left: 4px; }
.field input[type=text], .field input[type=email], .field input[type=password], .field input:not([type]) {
  width: 100%; background: var(--bg); border: 1px solid var(--line-strong); color: var(--text);
  border-radius: 8px; padding: 8px 11px; font-size: 13px; outline: none;
}
.field input:focus { border-color: var(--accent); }
.field input.mono { font-family: var(--mono); }
.field .hint { font-size: 11px; color: var(--dim); }
.field.error input { border-color: #b91c1c; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segment {
  display: flex; gap: 10px; align-items: flex-start; text-align: left; cursor: pointer;
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--bg);
  transition: all .15s;
}
.segment:hover { border-color: var(--faint); }
.segment.active { border-color: var(--accent); background: #0c2a45; }
.segment svg { flex-shrink: 0; margin-top: 2px; color: var(--dim); }
.segment.active svg { color: var(--accent-text); }
.segment .s-title { display: block; font-size: 13px; font-weight: 600; color: var(--text); }
.segment .s-sub { display: block; font-size: 11px; color: var(--dim); margin-top: 1px; }
.segment:disabled { opacity: .4; cursor: not-allowed; }
.segment:disabled:hover { border-color: var(--line-strong); }
.device-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.device-opt {
  display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 10px 6px;
  border-radius: 10px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--muted);
  font-size: 12px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.device-opt:hover { border-color: var(--faint); color: var(--text); }
.device-opt.active { border-color: var(--accent); background: #0c2a45; color: var(--accent-text); }
.device-opt:disabled { opacity: .35; cursor: not-allowed; }
.device-opt:disabled:hover { border-color: var(--line-strong); color: var(--muted); }
.field input[name=device_name] { margin-top: 2px; }
.device { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--soft); white-space: nowrap; }
.device svg { color: var(--dim); flex-shrink: 0; }
.device.unset { color: var(--dim); font-style: italic; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--soft); cursor: pointer; margin-bottom: 8px; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }

.secret-box { background: var(--panel-deep); border: 1px solid var(--line); border-radius: 10px; padding: 4px 0; margin-bottom: 14px; }
.secret-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 12px; }
.secret-row + .secret-row { border-top: 1px solid var(--line); }
.secret-row .k { font-size: 12px; color: var(--dim); }
.secret-row .v { font-family: var(--mono); font-size: 13px; color: var(--text); overflow-wrap: anywhere; }
.secret-row .v.big { font-size: 15px; color: var(--accent-text); letter-spacing: .02em; }
.copy-btn {
  padding: 4px 9px; border-radius: 6px; font-size: 11px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--line); color: var(--muted); transition: all .2s;
}
.copy-btn:hover { color: var(--text); }
.download-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 8px; }
.copy-btn.copied { background: #16a34a; border-color: #16a34a; color: #fff; }
.note { font-size: 12px; color: var(--dim); line-height: 1.55; }
.note code { font-family: var(--mono); font-size: 11.5px; background: var(--line); border-radius: 4px; padding: 1px 5px; color: var(--soft); }
.warn-note { display: flex; gap: 8px; font-size: 12px; color: #fde68a; background: #42200699; border: 1px solid #78350f; border-radius: 8px; padding: 8px 10px; margin-bottom: 14px; }
.warn-note svg { flex-shrink: 0; margin-top: 1px; }

.detail-head { display: flex; gap: 14px; align-items: center; }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 16px 0; }
.detail-item { background: var(--panel-deep); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; min-width: 0; }
.detail-item .k { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.detail-item .v { font-size: 13px; color: var(--text); margin-top: 3px; overflow-wrap: anywhere; }
.detail-item .v.mono { font-size: 12px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.mini-table { font-size: 12px; }
.mini-table td, .mini-table th { padding: 7px 10px; }

/* Toasts */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast {
  background: var(--panel); border: 1px solid var(--line-strong); border-left: 3px solid #16a34a;
  border-radius: 10px; padding: 10px 14px; font-size: 13px; color: var(--text);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, .5); animation: rise .15s ease-out;
}
.toast.error { border-left-color: #dc2626; }

@media (max-width: 1360px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
  .menu-btn { display: inline-flex; }
  .env-chip { display: none; }
  #sidebar { position: fixed; left: 0; transform: translateX(-100%); }
  body.menu-open #sidebar { transform: translateX(0); }
  body.menu-open .backdrop { display: block; position: fixed; inset: 56px 0 0; background: rgba(0, 0, 0, .5); z-index: 15; }
  .pm-wrap { padding: 20px 16px; }
  .stats { grid-template-columns: 1fr; }
  .grid-2, .segmented { grid-template-columns: 1fr; }
  .device-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
  .secret-row { grid-template-columns: minmax(0, 1fr) auto; }
  .secret-row .k { grid-column: 1 / -1; }
  .row-actions { opacity: 1; }
  .search-box { max-width: none; }
}
