/* style.css — тёмная тема, мобильно-дружелюбно (PWA для телефона). */

:root {
  --bg: #0f1419;
  --surface: #1a2029;
  --surface-2: #232b36;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #3b82f6;
  --error: #f87171;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  font-size: 18px;
  margin: 0;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}
.client { padding: 22px; }
.client + .client { margin-top: 4px; }
.client-foot { margin-top: 16px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.06); }

.card h2 {
  margin: 0 0 16px;
  font-size: 16px;
}

label {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--muted);
}

input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  font-size: 16px; /* >=16px чтобы iOS не зумил при фокусе */
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 10px;
  outline: none;
}

input:focus {
  border-color: var(--accent);
}

.btn {
  display: inline-block;
  width: 100%;
  padding: 13px 16px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
}

.btn:active { opacity: 0.85; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--surface-2);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
}

.muted { color: var(--muted); }

.help-panel {
  position: fixed;
  top: 54px;
  right: 16px;
  width: 400px;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.help-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.help-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.help-desc {
  font-size: 12px;
  color: var(--muted);
}
.help-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.help-row code {
  flex: 1;
  background: var(--surface-2);
  border-radius: 6px;
  padding: 5px 9px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.help-copy {
  font-size: 12px;
  padding: 4px 10px;
  white-space: nowrap;
  flex-shrink: 0;
}
.help-copy.copied {
  color: #4ade80;
  border-color: #4ade80;
}

.cmd-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.cmd-line { display: flex; gap: 8px; align-items: center; }
.cmd-code {
  flex: 1;
  background: var(--surface-2);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.error {
  color: var(--error);
  font-size: 14px;
  margin-top: 12px;
}

/* ===== Обзор (Этап 2) ===== */
.topbar-right { display: flex; align-items: center; gap: 10px; }
.small { font-size: 12px; }
:root { --ok: #34d399; --warn: #fbbf24; --bad: #f87171; }

.client-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; cursor: pointer; user-select: none; }
.client-head h2 { margin: 0; display: flex; align-items: center; gap: 8px; flex: 1; }
.chevron { color: var(--muted); font-size: 13px; transition: transform .2s; flex: none; }
.client:not(.collapsed) .chevron { transform: rotate(90deg); }
.client.collapsed .client-head { margin-bottom: 0; }
.client.collapsed .client-body { display: none; }
.badge { font-size: 11px; font-weight: 600; color: var(--muted); background: var(--surface-2); padding: 2px 8px; border-radius: 999px; }
.count { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); }
.count.ok { color: var(--ok); } .count.warn { color: var(--warn); } .count.bad { color: var(--bad); }

.srv { background: var(--surface-2); border-radius: 10px; padding: 14px 16px; margin-top: 12px; }
.srv-head { display: flex; align-items: center; gap: 8px; }
.srv-name { font-weight: 600; flex: 1; }
.srv-status { font-size: 12px; }
.srv-status.ok { color: var(--ok); } .srv-status.warn { color: var(--warn); }
.srv-status.bad { color: var(--bad); } .srv-status.mute { color: var(--muted); }
.srv-sub { margin: 4px 0 10px; }
.srv-alert { font-size: 11px; font-weight: 700; color: var(--bad); background: rgba(248,113,113,.12); border: 1px solid rgba(248,113,113,.35); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.tag-act  { color: #ffffff; font-weight: 600; }
.tag-wait { color: #f5a623; font-weight: 600; }
.srv-alarm { box-shadow: inset 0 0 0 1px rgba(248,113,113,.45); }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.dot.mute { background: var(--muted); }

.metrics { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.metric-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.bar { height: 8px; background: rgba(255,255,255,0.18); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s; }
.bar-fill.ok { background: var(--ok); } .bar-fill.warn { background: var(--warn); } .bar-fill.bad { background: var(--bad); }

@media (max-width: 420px) { .metrics { grid-template-columns: 1fr; } }

/* сервисы (HTTP up/down) внутри сервера */
.svc-list { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.svc { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: rgba(255,255,255,.04); border-radius: 8px; text-decoration: none; color: var(--text); font-size: 13px; }
.svc:hover { background: rgba(255,255,255,.08); }
.svc-name { flex: 1; }
.svc-disk { display: block; }
.svc-head2 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.svc-head2 .svc-name { flex: 1; }
.svc-disk .metric { margin-bottom: 6px; }

/* Неактивный процесс Claude (без [акт]) — желтая подсветка + кнопка DEL */
.svc-inactive { background: rgba(251,191,36,.07); border: 1px solid rgba(251,191,36,.22); }
.svc-inactive:hover { background: rgba(251,191,36,.12); }
.proc-del-btn { background: rgba(251,191,36,.12); color: #fbbf24; border: 1px solid rgba(251,191,36,.35); border-radius: 5px; padding: 1px 7px; font-size: 11px; font-weight: 700; letter-spacing: .05em; cursor: pointer; flex: none; }
.proc-del-btn:hover { background: rgba(251,191,36,.25); }

/* ===== Тревоги ===== */
.alert-card { margin-bottom: 16px; }
.alert-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.alert-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-weight: 600; font-size: 14px; }
.alert-msg { margin-top: 2px; word-break: break-word; }
.alert-time { flex: none; white-space: nowrap; }

/* ===== Этап 3: тулбар + модалки ===== */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; }
.btn-sm { background: var(--surface-2); color: var(--text); border: 1px solid rgba(255,255,255,.08); border-radius: 8px; padding: 8px 14px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-sm:active { opacity: .85; }
.btn-del { background: transparent; color: var(--muted); border: 1px solid rgba(255,255,255,.08); border-radius: 6px; padding: 2px 8px; font-size: 11px; cursor: pointer; flex: none; }
.btn-del:hover { color: var(--text); border-color: rgba(255,255,255,.2); }
.btn-del:active { opacity: .7; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100; }
.modal.hidden { display: none; }
.modal-box { width: 100%; max-width: 460px; margin: 0; max-height: 90vh; overflow: auto; }
.modal-box h2 { margin-top: 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.modal-actions .btn, .modal-actions .btn-ghost { width: auto; }
.row { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text); margin: 0 0 14px; }
.row select { flex: 1; padding: 10px; font-size: 16px; background: var(--surface-2); color: var(--text); border: 1px solid transparent; border-radius: 8px; }
.cmd { width: 100%; font-family: ui-monospace, monospace; font-size: 12px; background: #0b0e12; color: #c8e1ff; border: 1px solid var(--surface-2); border-radius: 8px; padding: 10px; resize: vertical; }

/* ===== Прокси-индикатор ===== */
.proxy-badge { display: flex; align-items: center; gap: 6px; }
.proxy-badge-ok   { color: var(--ok)  !important; border-color: rgba(52,211,153,.3) !important; }
.proxy-badge-bad  { color: var(--bad) !important; border-color: rgba(248,113,113,.4) !important;
                    animation: proxy-pulse 2s ease-in-out infinite; }
.proxy-badge-mute { color: var(--muted); }
@keyframes proxy-pulse {
  0%, 100% { box-shadow: none; }
  50%       { box-shadow: 0 0 0 3px rgba(248,113,113,.18); }
}

/* ===== Интернет: блок проверки задержки ===== */
.net-check-box { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; }
.net-check-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.net-check-title { font-size: 13px; font-weight: 600; color: var(--muted); }
.net-check-head .btn-sm { padding: 4px 10px; font-size: 12px; }
.net-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.net-name { width: 64px; flex: none; font-size: 13px; font-weight: 500; }
.net-gauge { flex: 1; }
.net-val { width: 52px; flex: none; text-align: right; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.net-val.ok { color: var(--ok); } .net-val.warn { color: var(--warn); } .net-val.bad { color: var(--bad); }
.net-jitter { width: 90px; flex: none; text-align: right; }
.net-fail { color: var(--bad); font-size: 13px; }
.net-machine + .net-machine { margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.06); }
.net-machine-title { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }

/* ===== Расход интернета ===== */
.traffic-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.traffic-table th,
.traffic-table td { padding: 7px 8px; border-bottom: 1px solid rgba(255,255,255,.06); vertical-align: top; }
.traffic-table thead th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid rgba(255,255,255,.12); }
.traffic-table tfoot td { border-bottom: none; border-top: 2px solid rgba(255,255,255,.12); padding-top: 10px; }
.tr-name   { font-weight: 500; white-space: nowrap; }
.tr-muted  { color: var(--muted); }
.tr-num    { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tr-total  { font-weight: 600; color: var(--text); }
.tr-period { font-size: 11px; color: var(--muted); padding-left: 12px; line-height: 1.5; }
.traffic-legend { margin: 14px 0 0; font-size: 11px; line-height: 1.7; padding: 10px 12px; background: rgba(255,255,255,.03); border-radius: 8px; }

/* Вкладки и навигация по месяцам */
.tr-tabs { display: flex; gap: 4px; margin: 0 0 16px; border-bottom: 1px solid rgba(255,255,255,.08); padding-bottom: 0; }
.tr-tab { background: transparent; color: var(--muted); border: none; border-bottom: 2px solid transparent; padding: 7px 14px; font-size: 13px; font-weight: 500; cursor: pointer; margin-bottom: -1px; }
.tr-tab:hover { color: var(--text); }
.tr-tab-active { color: var(--text); border-bottom-color: var(--accent); }
.tr-month-nav { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; }
.tr-month-label { flex: 1; text-align: center; font-weight: 600; font-size: 14px; }
.tr-nav-btn { padding: 5px 14px; font-size: 16px; line-height: 1; }
.tr-nav-btn:disabled { opacity: .3; cursor: default; }
