/* Reusable component styles. Layout/shell-specific rules live in app.css. */

* { box-sizing: border-box; }

/* ---------- typography helpers ---------- */
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-mono { font-family: var(--font-mono); }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  font-family: var(--font-sans); font-size: var(--text-sm); font-weight: 600;
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); cursor: pointer;
  transition: background var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease);
  white-space: nowrap; line-height: 1.2;
}
.btn:hover { background: var(--surface-3); border-color: var(--text-tertiary); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--text-on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { padding: 5px 10px; font-size: var(--text-xs); }
.btn-lg { padding: 11px 20px; font-size: var(--text-base); }
.btn-icon { padding: 8px; width: 34px; height: 34px; }
.btn-block { width: 100%; }

/* ---------- form controls ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: var(--text-sm); font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.field-hint { font-size: var(--text-xs); color: var(--text-tertiary); overflow-wrap: anywhere; line-height: 1.45; }
.field-error { font-size: var(--text-xs); color: var(--danger); }
.input, .select, .textarea {
  font-family: var(--font-sans); font-size: var(--text-base); color: var(--text);
  padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); width: 100%; transition: border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--text-tertiary); }
.textarea { resize: vertical; min-height: 90px; font-family: var(--font-sans); }
.input-sm { padding: 6px 10px; font-size: var(--text-sm); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: var(--text-base); }

/* ---------- cards / surfaces ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: var(--text-md); }
.card-header .sub { font-size: var(--text-sm); color: var(--text-tertiary); margin-top: 2px; }
.card-body { padding: 20px; }

/* ---------- stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--sp-4); }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.stat-card .icon-badge { width: 34px; height: 34px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; margin-bottom: 14px; background: var(--surface-3); color: var(--text-secondary); }
.stat-card.ok .icon-badge { background: var(--success-soft); color: var(--success); }
.stat-card.err .icon-badge { background: var(--danger-soft); color: var(--danger); }
.stat-card.warn .icon-badge { background: var(--warning-soft); color: var(--warning); }
.stat-card .label { font-size: var(--text-sm); color: var(--text-secondary); font-weight: 600; overflow-wrap: anywhere; }
.stat-card .value { font-size: clamp(var(--text-xl), 3vw, var(--text-3xl)); font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; line-height: 1.15; overflow-wrap: anywhere; }
.stat-card .delta { font-size: var(--text-xs); font-weight: 600; margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.stat-card .delta.up { color: var(--success); }
.stat-card .delta.down { color: var(--danger); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--text-base); }
th {
  text-align: left; color: var(--text-tertiary); font-weight: 700; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .06em; padding: 12px 20px; border-bottom: 1px solid var(--border);
  white-space: nowrap; background: var(--surface-2);
}
td { padding: 13px 20px; border-bottom: 1px solid var(--border); color: var(--text); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--duration-fast); cursor: default; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
td.wrap { white-space: normal; }
td.wrap-anywhere { white-space: normal; overflow-wrap: anywhere; min-width: 160px; max-width: 320px; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
th.num { text-align: right; }

/* ---------- responsive operational telemetry ---------- */
.system-sections, .system-list { display: grid; gap: 12px; }
.system-section { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); overflow: hidden; }
.system-section > summary { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:14px 16px; cursor:pointer; font-weight:700; background:var(--surface-2); }
.system-section > .system-list { padding: 12px; }
.system-row { border:1px solid var(--border); border-radius:var(--radius-md); background:var(--surface); min-width:0; overflow:hidden; }
.system-row-main { display:grid; grid-template-columns:minmax(240px,2fr) repeat(4,minmax(120px,1fr)); gap:14px; align-items:start; padding:14px 16px; }
.system-primary { min-width:0; display:grid; gap:4px; }
.system-primary strong { overflow-wrap:anywhere; }
.system-primary span, .system-label { color:var(--text-tertiary); font-size:var(--text-xs); }
.system-label { display:block; margin-bottom:4px; text-transform:uppercase; letter-spacing:.04em; }
.system-row-detail { border-top:1px solid var(--border); }
.system-row-detail > summary { cursor:pointer; padding:10px 16px; color:var(--text-secondary); font-size:var(--text-sm); }
.system-detail-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(160px,1fr)); gap:12px; padding:0 16px 14px; margin:0; }
.system-detail-grid div { min-width:0; }
.system-detail-grid dt { color:var(--text-tertiary); font-size:var(--text-xs); }
.system-detail-grid dd { margin:4px 0 0; overflow-wrap:anywhere; }
.system-detail-grid small { display:block; color:var(--text-tertiary); }
.system-summary { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; }
.system-summary .card { padding:16px; display:grid; gap:4px; }
.system-summary strong { font-size:var(--text-lg); }
.system-summary span { color:var(--text-secondary); }
.system-wide-card { grid-column:1 / -1; min-width:0; }
.system-pool-summary { display:flex; flex-wrap:wrap; gap:8px 20px; padding:0 16px 14px; color:var(--text-secondary); }
.system-pool-summary strong { color:var(--text-primary); font-variant-numeric:tabular-nums; }
.system-cell-subtext { display:block; margin-top:2px; color:var(--text-tertiary); font-size:var(--text-xs); overflow-wrap:anywhere; }
.system-empty { padding:20px; color:var(--text-tertiary); text-align:center; }
.system-error { padding:16px; color:var(--danger); }
.log-toolbar { display:flex; align-items:center; gap:12px; flex-wrap:wrap; padding:12px 16px; border-bottom:1px solid var(--border); }
.log-toolbar input { min-width:220px; flex:1; }
.log-content { margin:0; padding:12px 16px; max-height:65vh; overflow:auto; font-family:var(--font-mono); font-size:var(--text-sm); line-height:1.5; white-space:pre-wrap; overflow-wrap:anywhere; }
.log-meta { padding:10px 16px; color:var(--text-tertiary); font-size:var(--text-xs); border-bottom:1px solid var(--border); overflow-wrap:anywhere; }

@media (max-width: 900px) {
  .system-row-main, .service-row-main { grid-template-columns:1fr 1fr; }
  .system-primary { grid-column:1 / -1; }
  .system-summary { grid-template-columns:1fr; }
}
@media (max-width: 560px) {
  .system-row-main, .service-row-main { grid-template-columns:1fr; padding:12px; }
  .system-primary { grid-column:auto; }
  .system-section > .system-list { padding:8px; }
  .log-toolbar input { min-width:100%; }
}

/* ---------- System → Server Health (new .sh-* classes only; no shared selector is changed) ---------- */
.sh-page, .sh-page #sh-body { min-width:0; }
.sh-page #sh-body, .sh-content { display:flex; flex-direction:column; gap:20px; }
.sh-updated { display:flex; align-items:center; justify-content:flex-end; gap:6px; flex-wrap:wrap; max-width:100%; font-size:var(--text-sm); overflow-wrap:anywhere; }
.sh-content.is-stale { opacity:.7; }
.sh-banner { padding:12px 16px; border:1px solid var(--warning); border-radius:var(--radius-md); background:var(--warning-soft); color:var(--text); font-size:var(--text-sm); line-height:1.5; overflow-wrap:anywhere; }
.sh-summary { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr)); gap:12px; }
.sh-summary-card { padding:14px 16px; display:grid; gap:4px; align-content:start; min-width:0; }
.sh-summary-label { color:var(--text-secondary); font-size:var(--text-xs); font-weight:600; text-transform:uppercase; letter-spacing:.04em; }
.sh-summary-card strong { font-size:var(--text-lg); line-height:1.3; }
.sh-summary-card small { color:var(--text-secondary); font-size:var(--text-sm); line-height:1.45; overflow-wrap:anywhere; }
.sh-section { display:flex; flex-direction:column; gap:12px; min-width:0; }
.sh-section-head h2 { font-size:var(--text-md); }
.sh-section-head p { margin:4px 0 0; color:var(--text-secondary); font-size:var(--text-sm); line-height:1.5; }
.sh-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,320px),1fr)); gap:16px; align-items:stretch; }
.sh-grid > .sh-wide { grid-column:1 / -1; }
/* Two-card sections use fixed halves so a full-width card below never leaves empty auto-fit tracks. */
.sh-grid.sh-grid-2 { grid-template-columns:repeat(2,minmax(0,1fr)); }
.sh-card { display:flex; flex-direction:column; min-width:0; }
.sh-card-danger { border-color:var(--danger); }
.sh-card-head { display:grid; gap:8px; padding:14px 20px; border-bottom:1px solid var(--border); background:var(--surface-2); }
.sh-card-title { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.sh-card-title h3 { font-size:var(--text-base); overflow-wrap:anywhere; }
.sh-scope { display:flex; align-items:flex-start; gap:8px; flex-wrap:wrap; color:var(--text-secondary); font-size:var(--text-sm); line-height:1.45; overflow-wrap:anywhere; }
.sh-scope > span:not(.sh-scope-tag) { flex:1 1 220px; min-width:0; }
.sh-scope .sh-scope-tag { font-family:inherit; }
.sh-scope-tag { display:inline-block; padding:2px 8px; border-radius:var(--radius-full); background:var(--surface-3); color:var(--text-secondary); font-family:var(--font-mono); font-size:var(--text-xs); white-space:nowrap; }
.sh-card-body { padding:16px 20px 20px; display:flex; flex-direction:column; gap:14px; min-width:0; flex:1; }
.sh-metrics { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,170px),1fr)); gap:16px 20px; margin:0; }
.sh-metric { min-width:0; }
.sh-metric dt { color:var(--text-secondary); font-size:var(--text-sm); overflow-wrap:anywhere; }
.sh-metric dd { margin:4px 0 0; min-width:0; }
.sh-value { display:block; font-size:var(--text-md); font-weight:600; font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }
.sh-metric small { display:block; margin-top:4px; color:var(--text-secondary); font-size:var(--text-sm); line-height:1.45; overflow-wrap:anywhere; }
.sh-bar { display:flex; align-items:center; gap:8px; margin-top:6px; }
.sh-bar .progress-bar { flex:1; }
.sh-bar span { min-width:34px; text-align:right; color:var(--text-secondary); font-size:var(--text-xs); font-variant-numeric:tabular-nums; }
.sh-note { margin:0; color:var(--text-secondary); font-size:var(--text-sm); line-height:1.5; }
.sh-empty { color:var(--text-secondary); font-size:var(--text-sm); }
.sh-alert { padding:10px 12px; border-radius:var(--radius-sm); background:var(--danger-soft); color:var(--danger-strong); font-size:var(--text-sm); line-height:1.5; overflow-wrap:anywhere; }
.sh-error-list { margin:0; list-style:none; display:grid; gap:4px; }
.sh-pool-summary { display:flex; flex-wrap:wrap; gap:8px 24px; color:var(--text-secondary); font-size:var(--text-sm); }
.sh-pool-summary strong { color:var(--text); font-variant-numeric:tabular-nums; }
.sh-help { margin-top:auto; padding-top:10px; border-top:1px solid var(--border); }
.sh-help > summary { cursor:pointer; color:var(--text-secondary); font-size:var(--text-xs); }
.sh-help dl { display:grid; gap:6px; margin:8px 0 0; }
.sh-help dt { color:var(--text-tertiary); font-size:var(--text-xs); text-transform:uppercase; letter-spacing:.04em; }
.sh-help dd { margin:2px 0 0; color:var(--text-secondary); font-size:var(--text-sm); line-height:1.45; overflow-wrap:anywhere; }
.sh-details > summary { cursor:pointer; padding:4px 0; color:var(--text-secondary); font-size:var(--text-sm); }
.sh-table th { white-space:normal; vertical-align:bottom; }
.sh-table td { vertical-align:top; overflow-wrap:anywhere; }
.sh-findings > summary { cursor:pointer; padding:12px 16px; font-weight:700; background:var(--surface-2); }
.sh-findings ul { list-style:none; margin:0; padding:8px 16px 12px; display:grid; gap:8px; }
.sh-findings li { display:flex; gap:10px; align-items:flex-start; flex-wrap:wrap; font-size:var(--text-sm); line-height:1.45; overflow-wrap:anywhere; }
.sh-findings li > span:last-child { flex:1 1 240px; min-width:0; }
.sh-sr-only { position:absolute; width:1px; height:1px; margin:-1px; padding:0; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0; }
@media (max-width: 900px) {
  .sh-grid.sh-grid-2 { grid-template-columns:1fr; }
}
@media (max-width: 720px) {
  .sh-updated { justify-content:flex-start; }
  .sh-card-head { padding:12px 14px; }
  .sh-card-body { padding:14px; }
}
@media (max-width: 560px) {
  .sh-table thead { display:none; }
  .sh-table, .sh-table tbody, .sh-table tr, .sh-table td { display:block; width:100%; }
  .sh-table tr { padding:10px 0; border-bottom:1px solid var(--border); }
  .sh-table tr:last-child { border-bottom:none; }
  .sh-table td { display:flex; flex-wrap:wrap; justify-content:space-between; align-items:baseline; gap:2px 12px; padding:3px 0; border:0; text-align:right; white-space:normal; }
  .sh-table td::before { content:attr(data-label); flex:0 0 42%; color:var(--text-secondary); font-size:var(--text-xs); text-align:left; }
  .sh-table td .system-cell-subtext { flex-basis:100%; text-align:right; }
  .sh-table td.system-empty { display:block; text-align:center; }
  .sh-table td.system-empty::before { content:none; }
}

/* ---------- badges / status pills ---------- */
.badge {
  font-size: 10.5px; font-weight: 700; padding: 4px 10px; border-radius: var(--radius-full);
  background: var(--surface-3); color: var(--text-secondary); display: inline-flex; align-items: center; gap: 5px;
  letter-spacing: .02em; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-soft); color: var(--success-strong); }
.badge-danger { background: var(--danger-soft); color: var(--danger-strong); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-neutral { background: var(--surface-3); color: var(--text-secondary); }

/* ---------- tabs (segmented) ---------- */
.tabbar { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 20px; }
.tabbar-item {
  font-size: var(--text-sm); font-weight: 600; color: var(--text-tertiary); padding: 13px 4px;
  margin-right: 22px; cursor: pointer; border-bottom: 2px solid transparent; transition: color var(--duration-fast);
  display: flex; align-items: center; gap: 6px;
}
.tabbar-item:hover { color: var(--text); }
.tabbar-item.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabbar-item .count { font-size: 10px; background: var(--surface-3); color: var(--text-secondary); padding: 1px 6px; border-radius: var(--radius-full); }
.tabbar-item.active .count { background: var(--primary-soft); color: var(--primary); }

/* ---------- toolbar (search/filter row) ---------- */
.toolbar { display: flex; align-items: center; gap: var(--sp-2); padding: 14px 20px; flex-wrap: wrap; }
.search-input { position: relative; flex: 1; min-width: 200px; max-width: 340px; }
.search-input svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-tertiary); }
.search-input input { padding-left: 34px; }
.toolbar-spacer { flex: 1; }

/* ---------- pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: space-between; gap:12px; padding: 14px 20px; border-top: 1px solid var(--border); font-size: var(--text-sm); color: var(--text-secondary); }
.pagination .controls, .pagination-pages { display: flex; align-items:center; gap: 6px; }
.pagination-page { min-width:34px; justify-content:center; }
.pagination-page.active { color:var(--text-on-primary); background:var(--primary); border-color:var(--primary); }
.pagination-ellipsis { min-width:22px; text-align:center; color:var(--text-tertiary); }
@media (max-width: 760px) {
  .pagination { align-items:flex-start; flex-direction:column; }
  .pagination .controls { width:100%; overflow-x:auto; padding-bottom:2px; }
  .pagination-summary { white-space:normal; }
}

/* ---------- empty state ---------- */
.empty-state { text-align: center; padding: 56px 24px; color: var(--text-secondary); }
.empty-state .icon { width: 44px; height: 44px; margin: 0 auto 16px; color: var(--text-tertiary); }
.empty-state h3 { font-size: var(--text-md); color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: var(--text-base); margin: 0 0 18px; }

/* ---------- skeleton loading ---------- */
@keyframes skeleton-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
.skeleton { background: var(--surface-3); border-radius: var(--radius-sm); animation: skeleton-pulse 1.4s ease-in-out infinite; }
.skeleton-text { height: 12px; border-radius: 4px; margin: 4px 0; }
.skeleton-row td { padding: 14px 20px; }

/* ---------- overlays: modal / drawer ---------- */
.overlay-backdrop {
  position: fixed; inset: 0; background: rgba(18, 16, 25, 0.42); z-index: var(--z-drawer);
  opacity: 0; transition: opacity var(--duration-base) var(--ease); pointer-events: none;
}
.overlay-backdrop.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); background: var(--surface);
  box-shadow: var(--shadow-lg); z-index: var(--z-drawer); display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform var(--duration-base) var(--ease);
}
.drawer.open { transform: translateX(0); }
.drawer.wide { width: min(640px, 100vw); }
.drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.drawer-header h2 { font-size: var(--text-lg); }
.drawer-body { padding: 22px; overflow-y: auto; flex: 1; }
.drawer-footer { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); flex-shrink: 0; background: var(--surface-2); }

.modal-wrap { position: fixed; inset: 0; z-index: var(--z-modal); display: flex; align-items: center; justify-content: center; padding: 24px; pointer-events: none; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 480px;
  opacity: 0; transform: scale(.97) translateY(6px); transition: opacity var(--duration-base) var(--ease), transform var(--duration-base) var(--ease);
  max-height: 88vh; display: flex; flex-direction: column; pointer-events: auto;
}
.modal.wide { max-width: 720px; }
.modal.open { opacity: 1; transform: none; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-header h2 { font-size: var(--text-lg); }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); flex-shrink: 0; background: var(--surface-2); }
.overlay-close { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); color: var(--text-secondary); cursor: pointer; border: none; background: transparent; }
.overlay-close:hover { background: var(--surface-3); color: var(--text); }

/* ---------- toasts ---------- */
.toast-stack { position: fixed; bottom: 24px; right: 24px; z-index: var(--z-toast); display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.toast {
  background: var(--text); color: #fff; padding: 12px 18px; border-radius: var(--radius-md); font-size: var(--text-sm); font-weight: 500;
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px; max-width: 360px;
  opacity: 0; transform: translateY(8px); transition: opacity var(--duration-base) var(--ease), transform var(--duration-base) var(--ease);
}
.toast.show { opacity: 1; transform: none; }
.toast.success { background: var(--success-strong); }
.toast.error { background: var(--danger-strong); }

/* ---------- tooltip ---------- */
/* Открывается ВНИЗ и прижата к левому краю иконки (не по центру) —
   большинство тултипов в приложении стоят в H1 у самого верха страницы
   (первая строка под topbar), поэтому открытие вверх обрезало верх
   бабла за пределами окна браузера, а центрирование по горизонтали
   уводило её за левый край экрана у коротких заголовков. Снизу и справа
   места почти всегда достаточно (страница минимум ~360px шириной). */
.tip { position: relative; display: inline-flex; align-items: center; border-radius: 50%; }
.tip:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.tip .tip-icon { width: 14px; height: 14px; color: var(--text-tertiary); cursor: help; }
.tip-bubble {
  position: fixed; top: 0; left: 0;
  background: var(--text); color: #fff; font-size: 11.5px; font-weight: 500; line-height: 1.4;
  padding: 8px 11px; border-radius: var(--radius-sm); width: max-content; max-width: min(240px, calc(100vw - 48px));
  opacity: 0; pointer-events: none; transition: opacity var(--duration-fast); z-index: var(--z-tooltip); box-shadow: var(--shadow-md);
}
.tip-bubble.open { opacity: 1; transition: opacity var(--duration-fast); }

/* ---------- copyable (click-to-copy technical values) ---------- */
.copyable {
  position: relative; display: inline-flex; align-items: center; gap: 5px;
  cursor: pointer; border-radius: var(--radius-sm); padding: 1px 3px; margin: -1px -3px;
  transition: background var(--duration-fast);
}
.copyable:hover, .copyable:focus-visible { background: var(--surface-2); }
.copyable:focus-visible { outline: 1.5px solid var(--primary); outline-offset: 1px; }
.copyable .copyable-text.mono { font-family: var(--font-mono); }
.copyable .copyable-icon, .copyable .copyable-check {
  width: 12px; height: 12px; flex-shrink: 0; display: inline-flex;
  opacity: 0; transition: opacity var(--duration-fast);
}
.copyable .copyable-icon svg, .copyable .copyable-check svg {
  width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.copyable:hover .copyable-icon, .copyable:focus-visible .copyable-icon { opacity: 1; color: var(--text-tertiary); }
.copyable .copyable-check { position: absolute; right: -1px; color: var(--success); }
.copyable.copied .copyable-icon { opacity: 0; }
.copyable.copied .copyable-check { opacity: 1; }
/* Native title tooltip (не .tip — избегаем тяжёлого bubble ради одной строки) */
.copyable::after {
  content: 'Click to copy'; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; font-size: 10.5px; font-weight: 500; white-space: nowrap;
  padding: 4px 8px; border-radius: var(--radius-sm); opacity: 0; pointer-events: none; transition: opacity var(--duration-fast); z-index: var(--z-tooltip);
}
.copyable:hover::after { opacity: 1; }
.copyable.copied::after { content: '✓ Copied'; opacity: 1; background: var(--success); }

/* ---------- channel selection cards (campaign wizard step 1) ---------- */
.channel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--sp-3); }
.channel-card {
  border: 1.5px solid var(--border); border-radius: var(--radius-lg); padding: 20px 16px; text-align: center;
  cursor: pointer; transition: all var(--duration-fast) var(--ease); background: var(--surface);
}
.channel-card:hover { border-color: var(--text-tertiary); }
.channel-card.selected { border-color: var(--primary); background: var(--primary-soft); }
.channel-card .icon { width: 30px; height: 30px; margin: 0 auto 10px; color: var(--text-secondary); }
.channel-card.selected .icon { color: var(--primary); }
.channel-card .name { font-weight: 700; font-size: var(--text-base); }
.channel-card .desc { font-size: var(--text-xs); color: var(--text-tertiary); margin-top: 3px; }

/* ---------- wizard stepper ---------- */
.stepper { display: flex; align-items: center; padding: 20px 28px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.step { display: flex; align-items: center; gap: 10px; color: var(--text-tertiary); font-size: var(--text-sm); font-weight: 600; }
.step .step-num {
  width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--border-strong); display: flex;
  align-items: center; justify-content: center; font-size: var(--text-xs); flex-shrink: 0; background: var(--surface); color: var(--text-secondary);
}
.step.active { color: var(--text); }
.step.active .step-num { border-color: var(--primary); background: var(--primary); color: var(--text-on-primary); }
.step.done .step-num { border-color: var(--success); background: var(--success); color: #fff; }
.step-connector { flex: 1; height: 1.5px; background: var(--border-strong); margin: 0 12px; min-width: 20px; }
.step-connector.done { background: var(--success); }

/* ---------- radio / selection cards (generic) ---------- */
.option-list { display: flex; flex-direction: column; gap: 8px; }
.option-card {
  border: 1.5px solid var(--border); border-radius: var(--radius-md); padding: 14px 16px; cursor: pointer;
  display: flex; align-items: center; gap: 12px; transition: all var(--duration-fast) var(--ease);
}
.option-card:hover { border-color: var(--text-tertiary); }
.option-card.selected { border-color: var(--primary); background: var(--primary-soft); }
.option-card .radio { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--border-strong); flex-shrink: 0; position: relative; }
.option-card.selected .radio { border-color: var(--primary); }
.option-card.selected .radio::after { content: ''; position: absolute; inset: 3px; border-radius: 50%; background: var(--primary); }
.option-card .option-title { font-weight: 600; font-size: var(--text-base); }
.option-card .option-desc { font-size: var(--text-xs); color: var(--text-tertiary); }

/* ---------- misc ---------- */
.divider { height: 1px; background: var(--border); border: none; margin: var(--sp-4) 0; }
.hint-banner {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-md);
  background: var(--info-soft); color: var(--info); font-size: var(--text-sm); line-height: 1.5; overflow-wrap:anywhere; min-width:0;
}
.hint-banner svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.progress-bar { height: 6px; border-radius: var(--radius-full); background: var(--surface-3); overflow: hidden; }
.progress-bar .fill { height: 100%; background: var(--primary); border-radius: var(--radius-full); transition: width var(--duration-base) var(--ease); }

/* Platform Overview: compact progressive channel infographic. Bars encode
   the displayed delivery percentage only; no undocumented threshold or
   health conclusion is inferred from their neutral colour. */
.channel-overview-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:12px; padding:16px; }
.channel-overview-card { min-width:0; padding:14px; border:1px solid var(--border); border-radius:var(--radius-md); background:var(--surface-2); display:grid; gap:12px; }
.channel-overview-head { display:flex; justify-content:space-between; gap:12px; align-items:center; }
.channel-overview-head span { color:var(--text-secondary); font-variant-numeric:tabular-nums; }
.channel-overview-numbers { display:flex; justify-content:space-between; gap:12px; flex-wrap:wrap; color:var(--text-secondary); font-size:var(--text-xs); }
.channel-overview-numbers b { color:var(--text); font-size:var(--text-base); font-variant-numeric:tabular-nums; }
.channel-overview-bar { height:8px; border-radius:var(--radius-full); background:var(--surface-3); overflow:hidden; }
.channel-overview-bar span { display:block; height:100%; border-radius:inherit; background:var(--primary); transition:width var(--duration-base) var(--ease); }

/* User-controlled polling shared by every live dashboard surface. */
.page-header-tools { display:flex; flex-direction:column; align-items:flex-end; gap:6px; min-width:0; }
.auto-refresh { display:flex; align-items:center; justify-content:flex-end; gap:8px; flex-wrap:wrap; color:var(--text-secondary); font-size:var(--text-xs); }
.auto-refresh-toggle, .auto-refresh-period { display:inline-flex; align-items:center; gap:6px; white-space:nowrap; }
.auto-refresh-toggle input { accent-color:var(--primary); }
.auto-refresh-period input { width:64px; height:30px; padding:4px 7px; border:1px solid var(--border); border-radius:var(--radius-sm); background:var(--surface); color:var(--text); font:inherit; }
.auto-refresh-state { min-width:64px; }
.dashboard-period { display:inline-flex; align-items:center; gap:7px; color:var(--text-secondary); font-size:var(--text-xs); white-space:nowrap; }
.dashboard-period .select { min-width:104px; }
@media (max-width: 720px) {
  .page-header-tools { width:100%; align-items:flex-start; }
  .auto-refresh { justify-content:flex-start; }
  .dashboard-period { width:100%; justify-content:space-between; }
}
