:root {
  color: #20242a;
  background: #f4f6f7;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
  --border: #d8dde1;
  --muted: #68717a;
  --surface: #ffffff;
  --ink: #20242a;
  --green: #167448;
  --green-soft: #e5f4eb;
  --amber: #9a6100;
  --amber-soft: #fff2d4;
  --red: #b13a36;
  --red-soft: #fde9e7;
  --blue: #2e63a4;
  --blue-soft: #e9f1fb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: #f4f6f7;
  color: var(--ink);
}

button, input, select { font: inherit; letter-spacing: 0; }
a { color: var(--blue); }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #24282e;
}
.login-view[hidden], #application[hidden] { display: none; }
.login-panel {
  width: min(380px, 100%);
  padding: 28px;
  border-top: 4px solid var(--green);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .28);
}
.login-panel h1 { margin: 0 0 24px; font-size: 26px; }
.login-panel label { display: block; margin: 13px 0 6px; font-size: 13px; font-weight: 700; }
.login-panel input, .login-panel button { width: 100%; }
.login-panel button { margin-top: 18px; }
.form-error { color: var(--red); font-size: 13px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: 72px;
  padding: 12px clamp(18px, 4vw, 48px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: var(--ink);
  background: rgba(255, 255, 255, .98);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 9px rgba(31, 38, 44, .05);
}

.topbar h1, .workspace h2, dialog h2 { margin: 0; letter-spacing: 0; }
.topbar h1 { font-size: 24px; line-height: 1.15; }
.main-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}
.main-brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 6px;
  color: #fff;
  background: var(--green);
  font-size: 20px;
  font-weight: 800;
}
.main-brand small,
.main-brand strong { display: block; }
.main-brand small { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.main-brand strong { margin-top: 1px; font-size: 18px; }
.eyebrow { margin: 0 0 4px; color: #638170; font-size: 12px; text-transform: uppercase; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 14px; }
.sync-state { color: var(--muted); font-size: 13px; white-space: nowrap; }

main { padding: 22px clamp(18px, 4vw, 48px) 48px; }

.view-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
  background: #f4f6f7;
}
.view-tab {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 13px;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
}
.view-tab.is-active { color: var(--ink); border-color: var(--green); }
.app-view[hidden], .admin-only[hidden], .manager-only[hidden] { display: none !important; }

.summary {
  display: grid;
  grid-template-columns: repeat(8, minmax(112px, 1fr));
  gap: 1px;
  margin-bottom: 22px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--border);
}

.metric {
  min-height: 92px;
  padding: 17px 18px;
  border: 0;
  border-top: 4px solid var(--muted);
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.metric:hover { background: #f8faf9; }
.metric.is-active {
  position: relative;
  z-index: 1;
  box-shadow: inset 0 0 0 2px currentColor;
}
.metric span { display: block; color: var(--muted); font-size: 13px; font-weight: 650; }
.metric strong { display: block; margin-top: 6px; font-size: 30px; line-height: 1; }
.metric small {
  display: block;
  min-height: 16px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}
.metric-healthy { border-color: var(--green); }
.metric-checking { border-color: var(--blue); }
.metric-recovering { border-color: var(--amber); }
.metric-attention { border-color: var(--red); }
.metric-payment { border-color: #c35400; }
.metric-quarantine { border-color: #9d2f25; }
.metric-selective { border-color: #008c95; }

.period-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  margin-bottom: 22px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.period-summary div { padding: 12px 18px; border-right: 1px solid var(--border); }
.period-summary div:last-child { border-right: 0; }
.period-summary span { display: block; color: var(--muted); font-size: 12px; }
.period-summary strong { display: block; margin-top: 3px; font-size: 18px; }

.selective-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  margin-bottom: 22px;
  border: 1px solid var(--border);
  border-left: 4px solid #008c95;
  background: var(--surface);
}
.selective-summary div { min-height: 78px; padding: 12px 16px; border-right: 1px solid var(--border); }
.selective-summary div:last-child { border-right: 0; }
.selective-summary span,
.selective-summary small { display: block; color: var(--muted); font-size: 12px; }
.selective-summary strong { display: block; margin: 4px 0 2px; font-size: 16px; }

.location-workspace { margin-bottom: 24px; }
.location-summary { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.location-row {
  display: grid;
  grid-template-columns:
    minmax(160px, 1.1fr)
    minmax(150px, .9fr)
    minmax(150px, .9fr)
    minmax(190px, 1.2fr)
    minmax(190px, 1.2fr);
  gap: 16px;
  align-items: center;
  width: 100%;
  min-height: 76px;
  padding: 11px 4px;
  border: 0;
  border-bottom: 1px solid var(--border);
  color: inherit;
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.location-row:last-child { border-bottom: 0; }
.location-row:hover { background: #f8faf9; }
.location-row.is-active {
  box-shadow: inset 4px 0 0 var(--green);
  background: #f2f8f4;
}
.location-cell > span,
.location-cell > small { display: block; color: var(--muted); font-size: 11px; }
.location-cell > strong { display: block; margin-top: 3px; font-size: 14px; }
.location-selective-active { color: #006d75; }
.location-selective-inactive { color: var(--muted); }

.workspace { margin-top: 18px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.section-heading h2 { font-size: 18px; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.filters { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

input, select {
  height: 38px;
  min-width: 150px;
  padding: 0 10px;
  border: 1px solid #bfc6cc;
  border-radius: 5px;
  color: var(--ink);
  background: #fff;
}

input:focus, select:focus, button:focus-visible { outline: 3px solid rgba(46, 99, 164, .24); outline-offset: 1px; }
#searchFilter { width: min(260px, 100%); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
table { width: 100%; min-width: 1540px; border-collapse: collapse; }
.fleet-table th:nth-child(5),
.fleet-table td:nth-child(5) { width: 205px; min-width: 205px; }
.fleet-table th:nth-child(9),
.fleet-table td:nth-child(9) { width: 255px; min-width: 255px; }
.hardware-table { min-width: 1820px; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid #e7eaed; vertical-align: middle; }
th { color: #59636c; background: #f8f9fa; font-size: 12px; font-weight: 750; text-transform: uppercase; }
td { font-size: 13px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfc; }
.row-anomaly { background: #fffaf0; }
.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-transform: inherit;
}
.sort-button::after { content: "↕"; color: #9aa2a9; font-size: 11px; }
.sort-button.is-active[data-direction="asc"]::after { content: "↑"; color: var(--green); }
.sort-button.is-active[data-direction="desc"]::after { content: "↓"; color: var(--green); }
.cell-primary { display: block; font-weight: 700; }
.cell-secondary { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.status-reason-line { display: block; width: 178px; min-height: 32px; }
.diagnostic-help-text {
  display: inline;
  width: auto;
  max-width: 100%;
  border-bottom: 0;
  text-decoration-line: underline;
  text-decoration-style: dotted;
  text-decoration-color: #8c969e;
  text-underline-offset: 3px;
  cursor: help;
  outline: none;
}
.diagnostic-help-text:focus { text-decoration-color: var(--blue); }
.diagnostic-tooltip {
  position: fixed;
  z-index: 10000;
  width: min(390px, calc(100vw - 20px));
  padding: 9px 10px;
  border: 1px solid #aeb6bd;
  border-radius: 5px;
  color: #fff;
  background: #2b3036;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .18);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
  pointer-events: none;
}
.rotation-state-line {
  display: inline;
  margin-top: 5px;
  color: #3f596e;
  line-height: 1.35;
}
.rotation-state-warning { color: var(--amber); font-weight: 700; }
.rotation-state-critical { color: var(--red); font-weight: 700; }

.status { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 8px; border-radius: 4px; font-size: 12px; font-weight: 750; }
.status-healthy { color: var(--green); background: var(--green-soft); }
.status-checking { color: var(--blue); background: var(--blue-soft); }
.status-rotating, .status-recovering { color: var(--amber); background: var(--amber-soft); }
.status-needs_attention { color: var(--red); background: var(--red-soft); }
.status-payment_required { color: #8c3f00; background: #fff0df; }
.status-quarantine { color: #86271f; background: #ffe7e3; }
.production-state-select {
  width: 128px;
  min-width: 128px;
  height: 29px;
  padding: 0 6px;
  font-size: 12px;
}
.rotation-select {
  display: block;
  width: 92px;
  min-width: 92px;
  height: 28px;
  margin-top: 7px;
  padding: 0 7px;
  font-size: 12px;
}
.rotation-control-cell .rotation-select { margin-top: 0; }

.empty-state { padding: 42px 16px; color: var(--muted); text-align: center; }
.empty-state[hidden] { display: none; }

.wiki-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 920px);
  gap: 36px;
  align-items: start;
}
.wiki-toc {
  position: sticky;
  top: 16px;
  display: grid;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  border-right: 1px solid var(--border);
}
.wiki-toc strong {
  padding: 8px 14px 9px 0;
  font-size: 13px;
  text-transform: uppercase;
}
.wiki-toc a {
  padding: 5px 14px 5px 0;
  color: #4f5962;
  font-size: 12px;
  line-height: 1.3;
  text-decoration: none;
}
.wiki-toc a:hover { color: var(--blue); text-decoration: underline; }
.wiki-content { min-width: 0; }
.wiki-header {
  padding-bottom: 20px;
  border-bottom: 2px solid #adb5bc;
}
.wiki-header h2 { margin: 0; font-size: 26px; }
.wiki-header > p:not(.eyebrow) { margin: 7px 0 0; color: var(--muted); }
.wiki-header .wiki-rule {
  max-width: 820px;
  padding: 10px 12px;
  border-left: 4px solid var(--amber);
  color: #4b4f54;
  background: #fff7e5;
  font-size: 13px;
  line-height: 1.5;
}
.wiki-search {
  display: grid;
  grid-template-columns: minmax(220px, 420px);
  gap: 5px;
  margin-top: 16px;
}
.wiki-search label { font-size: 13px; font-weight: 700; }
.wiki-search input { width: 100%; }
.wiki-map {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-top: 18px;
  border: 1px solid var(--border);
  background: var(--border);
}
.wiki-map a {
  min-width: 0;
  padding: 12px 14px;
  color: #27323a;
  background: #fff;
  text-decoration: none;
}
.wiki-map a:hover {
  color: var(--blue);
  background: #f7fafc;
}
.wiki-map strong,
.wiki-map span {
  display: block;
}
.wiki-map strong {
  margin-bottom: 3px;
  font-size: 13px;
}
.wiki-map span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}
.wiki-content > section {
  padding: 24px 0 4px;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 140px;
}
.wiki-content h3 { margin: 0 0 12px; font-size: 20px; }
.wiki-content h4 { margin: 18px 0 7px; font-size: 15px; }
.wiki-content p,
.wiki-content li {
  color: #3f474e;
  line-height: 1.62;
}
.wiki-content p { margin: 8px 0; }
.wiki-content ul,
.wiki-content ol { margin: 8px 0 10px; padding-left: 24px; }
.wiki-content li + li { margin-top: 4px; }
.wiki-content code,
.wiki-content pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.wiki-content code {
  padding: 1px 4px;
  border: 1px solid #d7dce0;
  border-radius: 3px;
  background: #f7f8f9;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.wiki-content pre {
  overflow-x: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #f7f8f9;
  font-size: 12px;
  line-height: 1.6;
}
.wiki-table {
  width: 100%;
  min-width: 0;
  margin: 12px 0;
  table-layout: fixed;
  border: 1px solid var(--border);
}
.wiki-table th,
.wiki-table td {
  height: auto;
  padding: 9px 10px;
  vertical-align: top;
  text-transform: none;
  overflow-wrap: anywhere;
}
.wiki-table th:first-child,
.wiki-table td:first-child { width: 34%; }
.wiki-changelog h4 {
  margin-bottom: 2px;
  color: var(--green);
}
.wiki-changelog p { margin-top: 2px; }
.wiki-related {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 24px;
  margin: 20px 0 12px;
  padding: 12px 14px;
  border-left: 3px solid #9aa6ae;
  background: #f7f8f9;
}
.wiki-related > div {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 5px 10px;
  min-width: 0;
}
.wiki-related strong {
  width: 100%;
  color: #59636b;
  font-size: 11px;
  text-transform: uppercase;
}
.wiki-related a {
  color: #26618b;
  font-size: 12px;
  line-height: 1.4;
  text-decoration: underline;
  text-decoration-color: #a8c2d4;
  text-underline-offset: 2px;
}
.wiki-related a:hover {
  color: #123f5f;
  text-decoration-color: currentColor;
}
.wiki-related-backlinks a { color: #5e596f; }

.incidents-section { margin-top: 28px; }
.incident-list { border-top: 1px solid var(--border); }
.incident-item { display: grid; grid-template-columns: minmax(230px, 1fr) minmax(180px, .8fr) minmax(320px, 1.6fr); gap: 18px; padding: 14px 4px; border-bottom: 1px solid var(--border); }
.incident-item p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.incident-modem { display: block; font-size: 15px; }
.incident-meta { color: #4e5861 !important; font-weight: 650; }
.incident-id { display: block; margin-top: 7px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; font-weight: 500; overflow-wrap: anywhere; }
.timeline { display: grid; gap: 6px; }
.timeline-step { padding: 7px 9px; border-left: 3px solid #aeb7bf; color: #49525a; background: #f8f9fa; font-size: 11px; }
.timeline-step-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.timeline-step-heading span { color: var(--muted); white-space: nowrap; }
.timeline-step p { margin-top: 4px; }

.button { min-height: 38px; padding: 7px 13px; border: 1px solid transparent; border-radius: 5px; cursor: pointer; font-weight: 700; }
a.button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.button-primary { color: #fff; background: #216a47; border-color: #216a47; }
.button-primary:hover { background: #185438; }
.button-secondary { color: #283038; background: #fff; border-color: #b9c0c6; }
.button-secondary:hover { background: #f0f2f3; }
.topbar .button-secondary { color: #283038; background: #fff; border-color: #b9c0c6; }
.topbar .button-secondary:hover { background: #f0f2f3; }
.button:disabled { cursor: wait; opacity: .6; }

dialog { width: min(460px, calc(100vw - 32px)); padding: 0; border: 1px solid #bfc6cc; border-radius: 7px; color: var(--ink); box-shadow: 0 18px 54px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(22, 25, 29, .48); }
dialog form { padding: 20px; }
.dialog-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
dialog .eyebrow { color: var(--green); }
dialog label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 700; }
dialog select { width: 100%; }
.field-help {
  margin: 6px 0 15px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.password-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 7px;
}
.password-field input { width: 100%; min-width: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.icon-button { width: 34px; height: 34px; padding: 0; border: 0; border-radius: 4px; color: #59636c; background: transparent; cursor: pointer; font-size: 25px; line-height: 1; }
.icon-button:hover { background: #eef0f2; }

.compact-button { min-height: 30px; padding: 4px 9px; font-size: 12px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 5px; min-width: 148px; }
.port-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.port-item { padding: 2px 5px; border: 1px solid #d5dbe0; border-radius: 3px; color: #4f5962; background: #f8f9fa; font-size: 11px; }
.port-copy { font: inherit; cursor: pointer; }
.port-copy:hover, .port-copy:focus-visible { border-color: #6f9fbd; background: #eaf4fa; color: #245f82; outline: none; }
.port-copy.loading { cursor: wait; opacity: .65; }
.copy-feedback { position: fixed; z-index: 1000; max-width: min(320px, calc(100vw - 16px)); padding: 7px 10px; border: 1px solid #8ec4ab; border-radius: 5px; background: #e9f7f0; color: #245c44; box-shadow: 0 6px 18px rgb(28 43 51 / 18%); font-size: 12px; font-weight: 650; pointer-events: none; }
.copy-feedback-error { border-color: #d8aaa5; background: #fff0ee; color: #7a332d; }
.management-list { border-top: 1px solid var(--border); }
.management-block { border-bottom: 1px solid var(--border); }
.management-row {
  display: grid;
  grid-template-columns: minmax(200px, 1.2fr) minmax(180px, 1fr) minmax(180px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 13px 4px;
  border-bottom: 0;
}
.management-row p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.management-actions { display: flex; gap: 7px; justify-content: flex-end; }
.download-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.install-section pre {
  overflow-x: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #f8f9fa;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.node-command {
  overflow-x: auto;
  margin: 0 4px 13px;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #f8f9fa;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.node-command[hidden] { display: none; }
.node-settings-dialog {
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
}
.node-settings-dialog form {
  max-height: calc(100vh - 24px);
  overflow-y: auto;
}
.node-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.node-settings-grid-address { grid-template-columns: minmax(0, 1fr) 140px; }
.node-settings-grid input { width: 100%; }
.node-router-settings {
  margin: 20px 0 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.node-router-settings legend { padding: 0 6px; font-size: 14px; font-weight: 800; }
.checkbox-line {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 15px;
}
.checkbox-line input { width: 18px; height: 18px; margin: 0; }
.node-router-fields { display: grid; gap: 14px; }
.node-router-test-status {
  margin-top: 14px;
  padding: 9px 11px;
  border-left: 3px solid #aeb7bf;
  background: #f5f7f8;
  color: #4f5962;
  font-size: 12px;
  line-height: 1.45;
}
.node-router-test-status.is-running { border-color: #c8942d; background: #fff7df; color: #795000; }
.node-router-test-status.is-success { border-color: #3f966b; background: #e9f7f0; color: #245c44; }
.node-router-test-status.is-error { border-color: #bd5b52; background: #fff0ee; color: #7a332d; }
.node-settings-actions { flex-wrap: wrap; }
.wide-dialog {
  width: min(1240px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
}
.wide-dialog form {
  max-height: calc(100vh - 24px);
  overflow-y: auto;
}
.modem-profile-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr);
  gap: 28px;
  align-items: start;
  padding: 4px 0 18px;
  border-bottom: 1px solid var(--border);
}
.modem-profile-hero h3 { margin: 4px 0 5px; font-size: 24px; }
.modem-profile-hero p { margin: 0; color: var(--muted); font-size: 12px; }
.modem-profile-health {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px 10px;
  align-items: center;
}
.modem-profile-health p {
  grid-column: 1 / -1;
  line-height: 1.5;
}
.modem-sms-launcher {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f8fafb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.modem-sms-launcher strong,
.modem-sms-launcher span { display: block; }
.modem-sms-launcher span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.modem-sms-launcher .has-unread {
  border-color: #d4a43a;
  background: #fff7df;
  color: #79560c;
}
.modem-profile-overview {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}
.modem-overview-group {
  display: grid;
  grid-template-columns: minmax(170px, .7fr) minmax(0, 3.3fr);
  overflow: hidden;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 6px;
}
.modem-overview-health {
  border-left-color: #23805c;
  background: #f6fbf8;
}
.modem-overview-rotation {
  border-left-color: #276ca8;
  background: #f6f9fc;
}
.modem-overview-pool {
  border-left-color: #6b5f9e;
  background: #f8f7fc;
}
.modem-overview-selective {
  border-left-color: #a87518;
  background: #fffaf0;
}
.modem-overview-heading {
  padding: 14px 15px;
  border-right: 1px solid var(--border);
}
.modem-overview-heading h3 {
  margin: 0;
  font-size: 15px;
}
.modem-overview-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}
.modem-overview-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.modem-overview-metrics > div,
.modem-profile-facts > div {
  min-width: 0;
  padding: 11px 12px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.modem-overview-metrics > div:nth-child(4n),
.modem-profile-facts > div:nth-child(4n) { border-right: 0; }
.modem-overview-metrics > div:nth-last-child(-n + 4),
.modem-profile-facts > div:nth-last-child(-n + 4) { border-bottom: 0; }
.modem-overview-metrics span,
.modem-overview-metrics small,
.modem-profile-facts span,
.modem-profile-facts small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}
.modem-overview-metrics strong,
.modem-profile-facts strong {
  display: block;
  margin: 4px 0 2px;
  overflow-wrap: anywhere;
  font-size: 15px;
}
.modem-profile-section {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.modem-profile-section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 10px;
}
.modem-profile-section-heading h3 { margin: 0; font-size: 17px; }
.modem-profile-section-heading p {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}
.modem-profile-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.modem-profile-probes {
  margin-top: 12px;
  border-top: 1px solid var(--border);
}
.modem-profile-probes > div {
  display: grid;
  grid-template-columns: 82px minmax(130px, .55fr) minmax(0, 1.45fr);
  gap: 12px;
  align-items: center;
  padding: 8px 4px;
  border-bottom: 1px solid #e7eaed;
  font-size: 12px;
}
.probe-result { font-weight: 750; }
.probe-ok { color: var(--green); }
.probe-failed { color: var(--red); }
.profile-table-wrap {
  margin-top: 12px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 5px;
}
.profile-table { min-width: 680px; }
.profile-notice {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-left: 4px solid var(--amber);
  background: #fff9e9;
  font-size: 12px;
  line-height: 1.5;
}
.ip-pool-signal { border-left-color: #6b5f9e; background: #f8f7fc; }
.ip-pool-concentrated { border-left-color: var(--red); background: #fff4f3; }
.ip-pool-watch { border-left-color: var(--amber); background: #fff9e9; }
.ip-pool-diverse { border-left-color: var(--green); background: #f3faf6; }
.ip-operator-block {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f8fafb;
}
.ip-operator-block > strong { display: block; font-size: 13px; }
.ip-operator-block > small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.4;
}
.ip-operator-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}
.ip-operator-grid > div {
  min-width: 0;
  padding: 9px;
  border: 1px solid #e3e7e9;
  border-radius: 5px;
  background: var(--surface);
  display: grid;
  gap: 3px;
}
.ip-operator-grid strong,
.ip-operator-grid span,
.ip-operator-grid small { overflow-wrap: anywhere; }
.ip-operator-grid strong { font-size: 13px; }
.ip-operator-grid span { font-size: 13px; font-weight: 700; }
.ip-operator-grid small { color: var(--muted); font-size: 10px; }
.ip-subnet-summary {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.ip-subnet-block {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f8fafb;
}
.ip-subnet-block > strong { display: block; margin-bottom: 8px; font-size: 13px; }
.ip-subnet-list { display: grid; gap: 5px; }
.ip-subnet-list > div {
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid #e3e7e9;
  border-radius: 5px;
  background: var(--surface);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 8px;
}
.ip-subnet-list span,
.ip-subnet-list strong,
.ip-subnet-list small { overflow-wrap: anywhere; }
.ip-subnet-list span { font: 12px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.ip-subnet-list strong { font-size: 12px; text-align: right; }
.ip-subnet-list small { grid-column: 1 / -1; color: var(--muted); font-size: 10px; }
.sms-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.sms-message-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.sms-message {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}
.sms-message-unread {
  border-left: 4px solid #d4a43a;
  background: #fffdf7;
}
.sms-message-heading,
.sms-message-footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}
.sms-message-heading span,
.sms-message-footer span {
  color: var(--muted);
  font-size: 11px;
}
.sms-read-badge {
  padding: 3px 6px;
  border-radius: 4px;
  background: #edf1f3;
  color: var(--muted);
  font-weight: 750;
}
.sms-read-badge.is-unread {
  background: #fff1c7;
  color: #79560c;
}
.sms-message-footer { align-items: flex-start; flex-wrap: wrap; }
.sms-message-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 7px; }
.sms-message p {
  margin: 10px 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
}
.profile-empty,
.profile-loading {
  margin: 0;
  padding: 18px 4px;
  color: var(--muted);
  font-size: 13px;
}
.causal-timeline { border-top: 1px solid var(--border); }
.causal-event {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(0, 1fr);
  gap: 16px;
  padding: 12px 0 12px 12px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--border);
}
.causal-event > div:first-child {
  display: grid;
  align-content: start;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
}
.causal-event time { font-size: 11px; }
.causal-event strong { font-size: 13px; }
.causal-event p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.causal-good { border-left-color: var(--green); }
.causal-warn { border-left-color: var(--amber); }
.causal-bad { border-left-color: var(--red); }
.modem-profile-checks > summary {
  cursor: pointer;
  font-size: 17px;
  font-weight: 750;
}
.history-summary { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--border); }
.history-summary div { padding: 10px; border-right: 1px solid var(--border); }
.history-summary div:last-child { border-right: 0; }
.history-samples { max-height: 420px; margin-top: 16px; overflow-y: auto; border-top: 1px solid var(--border); }
.history-sample { display: grid; grid-template-columns: 160px 160px 1fr; gap: 12px; padding: 8px 4px; border-bottom: 1px solid #e7eaed; font-size: 12px; }
.history-incidents { margin-top: 12px; border-top: 1px solid var(--border); }
.history-incident { border-bottom: 1px solid var(--border); }
.history-incident summary {
  display: grid;
  grid-template-columns: 160px 150px 1fr;
  gap: 12px;
  padding: 10px 6px;
  cursor: pointer;
  font-size: 12px;
}
.history-incident summary:hover { background: #f8f9fa; }
.history-incident-body { padding: 2px 10px 14px 24px; }
.history-incident-body > p { margin: 4px 0; color: var(--muted); font-size: 12px; }
.history-diagnosis { max-width: 760px; line-height: 1.5; }
.history-incident .timeline { margin-top: 10px; }
.history-rotation { margin-top: 12px; border-top: 1px solid var(--border); }
.history-rotation details { border-bottom: 1px solid var(--border); }
.history-rotation summary {
  display: grid;
  grid-template-columns: 160px 180px 1fr;
  gap: 12px;
  padding: 9px 6px;
  cursor: pointer;
  font-size: 12px;
}
.history-rotation-body { padding: 0 10px 12px 24px; color: var(--muted); font-size: 12px; }
.history-rotation-body p { margin: 4px 0; }

@media (max-width: 820px) {
  .summary { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
  .period-summary { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
  .selective-summary { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
  .location-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modem-profile-hero { grid-template-columns: 1fr; gap: 15px; }
  .modem-overview-group { grid-template-columns: 1fr; }
  .modem-overview-heading {
    padding-bottom: 10px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .modem-overview-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modem-overview-metrics > div:nth-child(4n) { border-right: 1px solid var(--border); }
  .modem-overview-metrics > div:nth-child(2n) { border-right: 0; }
  .modem-overview-metrics > div:nth-last-child(-n + 4) { border-bottom: 1px solid var(--border); }
  .modem-overview-metrics > div:nth-last-child(-n + 2) { border-bottom: 0; }
  .modem-profile-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modem-profile-facts > div:nth-child(4n) { border-right: 1px solid var(--border); }
  .modem-profile-facts > div:nth-child(2n) { border-right: 0; }
  .modem-profile-facts > div:nth-last-child(-n + 4) { border-bottom: 1px solid var(--border); }
  .modem-profile-facts > div:nth-last-child(-n + 2) { border-bottom: 0; }
  .ip-subnet-summary { grid-template-columns: 1fr; }
  .section-heading { align-items: start; flex-direction: column; }
  .filters { width: 100%; justify-content: start; }
  .incident-item { grid-template-columns: 1fr; gap: 8px; }
  .management-row { grid-template-columns: 1fr; gap: 7px; }
  .management-actions { justify-content: flex-start; }
  .node-settings-grid,
  .node-settings-grid-address { grid-template-columns: 1fr; }
  .node-settings-actions { justify-content: stretch; }
  .node-settings-actions .button { flex: 1 1 100%; }
  .password-field { grid-template-columns: 1fr 1fr; }
  .password-field input { grid-column: 1 / -1; }
  .wiki-layout { grid-template-columns: 1fr; gap: 18px; }
  .wiki-toc {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
    padding-bottom: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .wiki-toc strong { grid-column: 1 / -1; }
  .wiki-map { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wiki-related { grid-template-columns: 1fr; }
  .wiki-content > section { scroll-margin-top: 235px; }
}

@media (max-width: 560px) {
  .wiki-map { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .summary { grid-template-columns: 1fr 1fr; }
  .period-summary { grid-template-columns: 1fr 1fr; }
  .selective-summary { grid-template-columns: 1fr; }
  .selective-summary div { border-right: 0; border-bottom: 1px solid var(--border); }
  .selective-summary div:last-child { border-bottom: 0; }
  .location-row { grid-template-columns: 1fr; gap: 7px; }
  .wide-dialog {
    width: calc(100vw - 12px);
    max-height: calc(100vh - 12px);
  }
  .wide-dialog form {
    max-height: calc(100vh - 12px);
    padding: 14px;
  }
  .modem-overview-metrics,
  .modem-profile-facts { grid-template-columns: 1fr; }
  .modem-overview-metrics > div:nth-child(n),
  .modem-profile-facts > div:nth-child(n) {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .modem-overview-metrics > div:last-child,
  .modem-profile-facts > div:last-child { border-bottom: 0; }
  .modem-profile-section-heading { display: block; }
  .modem-profile-section-heading p {
    margin-top: 5px;
    text-align: left;
  }
  .modem-profile-probes > div {
    grid-template-columns: 74px 1fr;
    gap: 4px 9px;
  }
  .modem-profile-probes > div > span:last-child { grid-column: 1 / -1; }
  .causal-event {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .sms-message-heading,
  .sms-message-footer {
    align-items: flex-start;
    flex-direction: column;
  }
  .modem-sms-launcher { align-items: stretch; flex-direction: column; }
  .modem-sms-launcher .button { width: 100%; }
  .sms-message-actions { width: 100%; margin-left: 0; }
  .metric { min-height: 82px; padding: 14px; }
  .metric strong { font-size: 26px; }
  .filters, .filters input, .filters select { width: 100%; }
  .view-tabs { overflow: visible; flex-wrap: wrap; gap: 0; }
  .view-tab { min-height: 34px; padding: 5px 9px; font-size: 13px; }
  .history-summary { grid-template-columns: 1fr 1fr; }
  .history-sample { grid-template-columns: 1fr; gap: 3px; }
  .history-incident summary { grid-template-columns: 1fr; gap: 3px; }
  .history-rotation summary { grid-template-columns: 1fr; gap: 3px; }
  .history-incident-body { padding-left: 10px; }
  .wiki-header h2 { font-size: 22px; }
  .wiki-table { table-layout: auto; }
  .wiki-table th:first-child,
  .wiki-table td:first-child { width: 42%; }
}
