/* ============================================================
   NetWatch — shared stylesheet (worker + admin pages)
   Dark theme, system font stack, no external resources.
   Status colors: green = OK, red = problem, amber = partial,
   gray = offline/unknown. Status is NEVER conveyed by color
   alone — every status element carries an icon and/or label.
   ============================================================ */

:root {
  /* Surfaces */
  --bg: #0d1117;
  --surface: #161c24;
  --surface-2: #1d2530;
  --surface-3: #242e3b;
  --border: #2c3542;
  --border-strong: #3b4654;

  /* Ink */
  --text: #e6edf3;
  --text-2: #a3b1bf;
  --text-muted: #74818f;

  /* Accent (interactive, sparkline series) */
  --accent: #58a6ff;
  --accent-dim: #388bfd;

  /* Status (reserved — always with icon/label) */
  --ok: #3fb950;
  --ok-tint: rgba(63, 185, 80, 0.14);
  --bad: #f85149;
  --bad-tint: rgba(248, 81, 73, 0.14);
  --warn: #d29922;
  --warn-tint: rgba(210, 153, 34, 0.15);
  --off: #8b949e;
  --off-tint: rgba(139, 148, 158, 0.14);

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.25);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Consolas",
          "Liberation Mono", monospace;
}

/* ---------- Base ---------- */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3 { margin: 0; font-weight: 650; line-height: 1.25; }
p { margin: 0; }

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

input {
  font-family: inherit;
  font-size: inherit;
  color: var(--text);
}

[hidden] { display: none !important; }

.muted { color: var(--text-muted); }
.mono  { font-family: var(--mono); }

a { color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 550;
  transition: background 0.15s ease, border-color 0.15s ease,
              transform 0.05s ease;
  user-select: none;
}

.btn:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--text-muted);
}

.btn:active:not(:disabled) { transform: translateY(1px); }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
}

.btn-block { width: 100%; }

.btn-icon {
  padding: 8px 11px;
  font-size: 15px;
  line-height: 1;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  padding: 5px 10px;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

/* ---------- Inputs ---------- */

.input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  transition: border-color 0.15s ease;
}

.input::placeholder { color: var(--text-muted); }

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.2);
}

input[type="date"].input {
  width: auto;
  padding: 7px 10px;
  color-scheme: dark;
  font-family: var(--mono);
  font-size: 14px;
}

/* ---------- Cards / badges / dots ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-ok   { background: var(--ok-tint);   color: var(--ok); }
.badge-bad  { background: var(--bad-tint);  color: var(--bad); }
.badge-warn { background: var(--warn-tint); color: var(--warn); }
.badge-off  { background: var(--off-tint);  color: var(--off); }

.dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex: none;
}

.dot-ok   { background: var(--ok);   box-shadow: 0 0 8px rgba(63, 185, 80, 0.6); }
.dot-bad  { background: var(--bad);  box-shadow: 0 0 8px rgba(248, 81, 73, 0.6); }
.dot-warn { background: var(--warn); box-shadow: 0 0 8px rgba(210, 153, 34, 0.6); }
.dot-off  { background: var(--off); }

/* ---------- Banner ---------- */

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 15px;
}

.banner-error {
  background: var(--bad-tint);
  color: var(--bad);
  border-bottom: 1px solid rgba(248, 81, 73, 0.35);
}

/* ---------- Pulse / spin ---------- */

@keyframes nw-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

.pulsing { animation: nw-pulse 1.6s ease-in-out infinite; }

@keyframes nw-spin {
  to { transform: rotate(360deg); }
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: nw-spin 0.8s linear infinite;
  vertical-align: middle;
}

@media (prefers-reduced-motion: reduce) {
  .pulsing { animation: none; }
  .spinner { animation-duration: 1.6s; }
  * { transition-duration: 0.01ms !important; }
}

/* ---------- Sparkline ---------- */

.sparkline {
  display: block;
  width: 100%;
  height: auto;
}

.sparkline .spark-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sparkline .spark-fail {
  fill: var(--bad);
}

.sparkline .spark-base {
  stroke: var(--border);
  stroke-width: 1;
}

.sparkline .spark-empty {
  fill: var(--text-muted);
  font-size: 10px;
  font-family: var(--font);
}

/* ============================================================
   WORKER PAGE
   ============================================================ */

.worker-page main {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

/* --- Setup screen --- */

.setup-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.setup-card {
  width: 100%;
  max-width: 420px;
  padding: 32px 28px;
  text-align: center;
}

.brand-mark {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}

.setup-card h1 { font-size: 24px; margin-bottom: 8px; }

.setup-card .setup-note {
  color: var(--text-2);
  font-size: 15px;
  margin-bottom: 22px;
}

.setup-card label {
  display: block;
  text-align: left;
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 6px;
}

.setup-card .input { margin-bottom: 16px; }

/* --- Monitor header --- */

.worker-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.worker-header .brand-mark { margin-bottom: 0; }

.worker-name {
  font-size: 15px;
  color: var(--text-2);
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.worker-name strong {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}

/* --- Big status card --- */

.status-card {
  padding: 28px 24px 20px;
  text-align: center;
  margin-bottom: 16px;
  border-top: 4px solid var(--off);
  transition: border-color 0.3s ease;
}

.status-card.is-ok   { border-top-color: var(--ok); }
.status-card.is-bad  { border-top-color: var(--bad); }
.status-card.is-wait { border-top-color: var(--off); }

.status-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 6px;
}

.status-icon {
  font-size: 44px;
  font-weight: 700;
  line-height: 1;
  font-family: var(--mono);
}

.status-text {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.status-card.is-ok  .status-icon,
.status-card.is-ok  .status-text { color: var(--ok); }
.status-card.is-bad .status-icon,
.status-card.is-bad .status-text { color: var(--bad); }
.status-card.is-wait .status-icon,
.status-card.is-wait .status-text { color: var(--off); }

.status-latency {
  font-size: 16px;
  color: var(--text-2);
  font-family: var(--mono);
  min-height: 24px;
  margin-bottom: 18px;
}

.status-spark-wrap {
  padding: 0 4px;
}

.status-spark-label {
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: left;
  margin-bottom: 4px;
}

/* --- Telephony card --- */

.tel-card {
  padding: 22px 24px;
  margin-bottom: 16px;
}

.tel-button {
  width: 100%;
  padding: 22px 20px;
  border-radius: var(--radius);
  border: 1px solid #c93430;
  background: linear-gradient(180deg, #e5534b 0%, #c93430 100%);
  color: #ffffff;
  text-align: center;
  box-shadow: 0 4px 14px rgba(248, 81, 73, 0.35);
  transition: filter 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}

.tel-button:hover:not(:disabled) { filter: brightness(1.08); }

.tel-button:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 2px 8px rgba(248, 81, 73, 0.3);
}

.tel-button:disabled {
  filter: grayscale(0.55) brightness(0.75);
  cursor: not-allowed;
  box-shadow: none;
}

.tel-button .tel-title {
  display: block;
  font-size: 23px;
  font-weight: 750;
  margin-bottom: 4px;
}

.tel-button .tel-sub {
  display: block;
  font-size: 14.5px;
  font-weight: 450;
  opacity: 0.9;
}

/* --- Telephony progress / verdict panel --- */

.tel-panel {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 15px;
}

.tel-panel .tel-panel-title {
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.tel-panel .tel-panel-detail {
  color: var(--text-2);
  font-size: 14px;
}

.tel-panel.verdict-ok {
  border-color: rgba(63, 185, 80, 0.5);
  background: var(--ok-tint);
}
.tel-panel.verdict-ok .tel-panel-title { color: var(--ok); }

.tel-panel.verdict-bad {
  border-color: rgba(248, 81, 73, 0.5);
  background: var(--bad-tint);
}
.tel-panel.verdict-bad .tel-panel-title { color: var(--bad); }

.tel-panel.verdict-queued {
  border-color: rgba(210, 153, 34, 0.5);
  background: var(--warn-tint);
}
.tel-panel.verdict-queued .tel-panel-title { color: var(--warn); }

.tel-progress-track {
  margin-top: 10px;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.tel-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.4s ease;
}

/* --- Secondary info row --- */

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.info-tile {
  padding: 12px 14px;
}

.info-tile .info-label {
  font-size: 12.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.info-tile .info-value {
  font-size: 15.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 7px;
}

.info-value.state-ok   { color: var(--ok); }
.info-value.state-bad  { color: var(--bad); }
.info-value.state-off  { color: var(--off); }

.worker-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.transient-note {
  margin-bottom: 14px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 14px;
}

/* ============================================================
   ADMIN PAGE
   ============================================================ */

.admin-page main {
  max-width: 1360px;
  margin: 0 auto;
  padding: 20px 20px 48px;
}

/* --- Header --- */

.admin-header {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.admin-title {
  font-size: 19px;
  font-weight: 700;
  white-space: nowrap;
}

.admin-title .brand-accent { color: var(--accent); }

.admin-clock {
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 600;
  color: var(--text-2);
  min-width: 96px;
}

.date-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.refresh-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.updated-ago {
  font-size: 13.5px;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 150px;
}

/* --- Sections --- */

.admin-section { margin-top: 26px; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head h2 { font-size: 20px; }

.section-head .section-count {
  color: var(--text-muted);
  font-size: 14.5px;
}

.empty-state {
  padding: 28px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 15.5px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 28px 20px;
  color: var(--text-muted);
  font-size: 15px;
}

/* --- Workers grid --- */

.workers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

.worker-card {
  padding: 16px 18px 14px;
  border-left: 4px solid var(--off);
}

.worker-card.w-ok   { border-left-color: var(--ok); }
.worker-card.w-bad  { border-left-color: var(--bad); }
.worker-card.w-warn { border-left-color: var(--warn); }

.worker-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2px;
}

.worker-card-name {
  font-size: 17px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.worker-card-ip {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  cursor: default;
}

.worker-card-state {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 10px;
}

.worker-card-state .state-word-ok   { color: var(--ok);  font-weight: 650; }
.worker-card-state .state-word-bad  { color: var(--bad); font-weight: 650; }
.worker-card-state .state-word-warn { color: var(--warn); font-weight: 650; }

.worker-card-spark { margin-bottom: 10px; }

.worker-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 13.5px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.worker-card-meta .latency {
  font-family: var(--mono);
  color: var(--text-2);
}

/* --- Telephony (prominent) section --- */

.telephony-section .card {
  border-color: var(--border-strong);
}

.tel-list {
  display: flex;
  flex-direction: column;
}

.tel-row {
  display: grid;
  grid-template-columns: 110px minmax(130px, 1fr) minmax(240px, 2fr);
  gap: 10px 16px;
  align-items: center;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
}

.tel-row:last-child { border-bottom: none; }

.tel-row-time {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--text-2);
  white-space: nowrap;
}

.tel-row-name {
  font-weight: 650;
  font-size: 15.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tel-row-verdict {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: flex-start;
}

.tel-row-detail {
  font-size: 13px;
  color: var(--text-muted);
}

/* --- Outages table --- */

.table-wrap {
  overflow-x: auto;
}

.outages-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.outages-table th {
  text-align: left;
  font-size: 12.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 11px 18px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

.outages-table td {
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.outages-table tr:last-child td { border-bottom: none; }

.outages-table .td-time { font-family: var(--mono); color: var(--text-2); white-space: nowrap; }
.outages-table .td-name { font-weight: 600; }
.outages-table .td-dur  { font-variant-numeric: tabular-nums; white-space: nowrap; }

.ongoing-label {
  color: var(--bad);
  font-weight: 650;
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .admin-header { gap: 10px; padding: 10px 14px; }
  .date-nav { margin-left: 0; }
  .updated-ago { min-width: 0; }
  .tel-row {
    grid-template-columns: 110px 1fr;
  }
  .tel-row-verdict { grid-column: 1 / -1; }
}

@media (max-width: 480px) {
  .status-text { font-size: 24px; }
  .status-icon { font-size: 36px; }
  .tel-button .tel-title { font-size: 19px; }
  .worker-header { flex-wrap: wrap; }
}

/* Big TV readability: scale up on very wide screens */
@media (min-width: 1900px) {
  body.admin-page { font-size: 18px; }
  .admin-title { font-size: 23px; }
  .admin-clock { font-size: 23px; }
  .section-head h2 { font-size: 24px; }
  .workers-grid { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
}

/* ============================================================
   v1.1 — LOGIN, SETTINGS, PBX
   ============================================================ */

/* ---------- Shared form-state helpers ---------- */

.field-error {
  color: var(--bad);
  font-size: 13.5px;
  font-weight: 600;
  margin: -8px 0 12px;
}

.field-help {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 6px;
}

.input.input-error {
  border-color: var(--bad);
}

.input.input-error:focus {
  border-color: var(--bad);
  box-shadow: 0 0 0 3px rgba(248, 81, 73, 0.2);
}

.spinner-sm {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

@keyframes nw-shake {
  10%, 90%      { transform: translateX(-2px); }
  20%, 80%      { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60%      { transform: translateX(7px); }
}

.shake { animation: nw-shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97); }

@media (prefers-reduced-motion: reduce) {
  .shake { animation: none; }
}

/* ---------- Login screen (admin) ---------- */

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 32px 28px;
  text-align: center;
}

.login-card h1 { font-size: 24px; margin-bottom: 8px; }

.login-card .login-note {
  color: var(--text-2);
  font-size: 15px;
  margin-bottom: 22px;
}

.login-card label {
  display: block;
  text-align: left;
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 6px;
}

.login-card .input { margin-bottom: 14px; }

.login-card .field-error {
  text-align: left;
  margin: -6px 0 12px;
}

/* ---------- Header: PBX chip + actions ---------- */

.pbx-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.15s ease, filter 0.15s ease;
}

.pbx-chip:hover { filter: brightness(1.2); }
.pbx-chip:active { transform: translateY(1px); }

.pbx-chip.pbx-ok {
  color: var(--ok);
  background: var(--ok-tint);
  border-color: rgba(63, 185, 80, 0.45);
}

.pbx-chip.pbx-bad {
  color: var(--bad);
  background: var(--bad-tint);
  border-color: rgba(248, 81, 73, 0.45);
}

.pbx-chip.pbx-off {
  color: var(--off);
  background: var(--off-tint);
  border-color: var(--border-strong);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- PBX panel ---------- */

.pbx-card {
  padding: 16px 18px;
  border-left: 4px solid var(--off);
}

.pbx-card.p-ok  { border-left-color: var(--ok); }
.pbx-card.p-bad { border-left-color: var(--bad); }
.pbx-card.p-off { border-left-color: var(--off); }

.pbx-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 36px;
  align-items: flex-start;
}

.pbx-stat-label {
  font-size: 12.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.pbx-stat-value {
  font-size: 17px;
  font-weight: 650;
  min-height: 27px;
  display: flex;
  align-items: center;
}

.pbx-stat-value.val-bad { color: var(--bad); }

.pbx-stat-value.mono-val {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--text-2);
  font-size: 15.5px;
}

.pbx-ok-note {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--ok);
  font-weight: 650;
  font-size: 15px;
}

.pbx-timeline-label {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.pbx-timeline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pbx-tl-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13.5px;
  white-space: nowrap;
}

.pbx-tl-item .tl-time {
  font-family: var(--mono);
  color: var(--text-2);
}

.pbx-tl-item .tl-what { font-weight: 650; }

.pbx-tl-item.tl-ok {
  border-color: rgba(63, 185, 80, 0.4);
}
.pbx-tl-item.tl-ok .tl-what { color: var(--ok); }

.pbx-tl-item.tl-bad {
  border-color: rgba(248, 81, 73, 0.4);
}
.pbx-tl-item.tl-bad .tl-what { color: var(--bad); }

/* ---------- Telephony: badge pair per signal ---------- */

.tel-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* ---------- Settings modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(1, 4, 9, 0.72);
  backdrop-filter: blur(2px);
}

.modal {
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 22px 24px 24px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.modal-head h2 { font-size: 20px; }

.modal-x {
  font-size: 16px;
  line-height: 1;
  padding: 6px 9px;
}

.modal .form-field { margin-bottom: 16px; }

.modal label {
  display: block;
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 6px;
}

.modal .field-error { margin: 8px 0 0; }

.modal-sep {
  border-top: 1px solid var(--border);
  margin: 20px 0 16px;
}

.modal-subhead {
  font-size: 16px;
  margin-bottom: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* ---------- Toast ---------- */

@keyframes nw-toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 60;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  border: 1px solid rgba(63, 185, 80, 0.5);
  color: var(--ok);
  font-weight: 650;
  font-size: 15px;
  box-shadow: var(--shadow);
  animation: nw-toast-in 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
}

/* ---------- Worker page: server-side PBX probe line ---------- */

.tel-pbx-line {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 14px;
  font-weight: 600;
}

.tel-pbx-line.pbx-ok  { color: var(--ok); }
.tel-pbx-line.pbx-bad { color: var(--bad); }

/* ---------- v1.1 responsive ---------- */

@media (max-width: 860px) {
  .header-actions { gap: 6px; }
  .pbx-stats { gap: 12px 22px; }
  .modal { padding: 18px 16px 20px; }
}
