/* ============================================================
   it-pulse design system (design/ → merged)
   ============================================================ */
:root {
  --bg:      #f8f9fb;
  --surface: #ffffff;
  --fg:      #0f172a;
  --muted:   #64748b;
  --border:  #e2e8f0;
  --accent:  #0d9488;

  --success: #059669;
  --danger:  #dc2626;
  --warn:    #d97706;
  --info:    #2563eb;

  --radius:  8px;
  --font:    14px/1.55 -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono:    'JetBrains Mono', 'SF Mono', ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font: var(--font); color: var(--fg); background: var(--bg); -webkit-font-smoothing: antialiased; }

/* — Nav —————————————————————————————— */
nav {
  background: #0f172a;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 100;
}
nav .brand {
  font-weight: 650;
  font-size: 15px;
  color: #f8fafc;
  letter-spacing: -0.02em;
  margin-right: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent);
}
nav a {
  color: #94a3b8;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 14px 14px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  letter-spacing: 0.01em;
}
nav a:hover { color: #e2e8f0; }
nav a.active {
  color: #f8fafc;
  border-bottom-color: var(--accent);
}
nav .spacer { flex: 1; }
nav .btn-nav {
  background: transparent;
  border: 1px solid #334155;
  color: #94a3b8;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  letter-spacing: 0.02em;
}
nav .btn-nav:hover { border-color: #475569; color: #e2e8f0; }

/* — Main container ———————————————————— */
main {
  padding: 28px 32px;
  max-width: 1320px;
  margin: 0 auto;
}

/* — Page header ——————————————————————— */
.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h1 {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--fg);
}
.page-header .subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

/* — Status cards ——————————————————————— */
.status-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}
.status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.status-card .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-card .dot.up { background: var(--success); box-shadow: 0 0 6px oklch(55% 0.16 155 / 0.4); }
.status-card .dot.down { background: var(--danger); box-shadow: 0 0 6px oklch(55% 0.18 25 / 0.4); }
.status-card .dot.blocked { background: var(--warn); }
.status-card .dot.inactive { background: #94a3b8; }
.status-card .count {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.status-card .label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 550;
}

/* — Group / card ————————————————————————— */
.group,
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}
.card { margin-bottom: 24px; }
.group-header,
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.group-header h2,
.card-header h2 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.group-header .group-count {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

/* — Tables ————————————————————————————— */
table { border-collapse: collapse; width: 100%; }
th {
  text-align: left;
  padding: 10px 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
td {
  padding: 10px 20px;
  font-size: 13px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
td a { color: var(--fg); text-decoration: none; font-weight: 510; }
td a:hover { color: var(--accent); }
tr.row-inactive td { opacity: 0.45; }
tr.row-inactive:hover td { opacity: 0.7; }

/* — Status dot inline ————————————————— */
.dot-inline {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  vertical-align: middle;
}
.dot-inline.up { background: var(--success); }
.dot-inline.down { background: var(--danger); }
.dot-inline.blocked { background: var(--warn); }
.dot-inline.pending,
.dot-inline.inactive { background: #cbd5e1; }

/* — Uptime value —————————————————————— */
.uptime {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.uptime.good { color: var(--success); }
.uptime.warn { color: var(--warn); }
.uptime.bad { color: var(--danger); }
.uptime.na { color: #cbd5e1; }

/* — Timestamp / mono ————————————————————— */
.ts {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.mono,
.w-mono { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }

/* — Tag / badge ————————————————————————— */
.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 550;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}
.tag.manual { background: #f0f9ff; color: #0369a1; }
.tag.synced { background: #f0fdf4; color: #15803d; }

/* — Group chip ————————————————————————— */
.chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 550;
  padding: 2px 10px;
  border-radius: 12px;
  background: #f1f5f9;
  color: #475569;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* — Buttons ————————————————————————————— */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 510;
  text-decoration: none;
  color: var(--fg);
  transition: background 0.12s, border-color 0.12s;
  line-height: 1.4;
}
.btn:hover { background: #f1f5f9; border-color: #cbd5e1; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { background: #0f766e; border-color: #0f766e; }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }

form.inline { display: inline; }

/* — Monitor detail ————————————————————— */
.monitor-header { margin-bottom: 24px; }
.monitor-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.monitor-title h1 {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.status-pill .pill-dot { width: 6px; height: 6px; border-radius: 50%; }
.status-pill.down { background: #fef2f2; color: var(--danger); }
.status-pill.down .pill-dot { background: var(--danger); }
.status-pill.up { background: #f0fdf4; color: var(--success); }
.status-pill.up .pill-dot { background: var(--success); }
.status-pill.blocked { background: #fffbeb; color: var(--warn); }
.status-pill.blocked .pill-dot { background: var(--warn); }
.status-pill.pending,
.status-pill.inactive { background: #f1f5f9; color: var(--muted); }
.status-pill.pending .pill-dot,
.status-pill.inactive .pill-dot { background: #94a3b8; }

.monitor-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--muted);
  flex-wrap: wrap;
}
.monitor-meta a { color: var(--accent); text-decoration: none; }
.monitor-meta a:hover { text-decoration: underline; }
.monitor-meta .sep { color: var(--border); }

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 20px 0 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
}
.stat-card .stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 4px;
}
.stat-card .stat-value {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-card .stat-value.good { color: var(--success); }
.stat-card .stat-value.warn { color: var(--warn); }
.stat-card .stat-value.bad { color: var(--danger); }
.stat-card .stat-value.na { color: #cbd5e1; }

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.actions input[type="datetime-local"] {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}

.alert-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 12px 18px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 510;
  color: var(--danger);
}
.alert-banner.blocked {
  background: #fffbeb;
  border-color: #fde68a;
  color: var(--warn);
}
.alert-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

.http-code {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
}
.http-code.ok { color: var(--success); }
.http-code.err { color: var(--danger); }

.latency {
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.latency.fast { color: var(--success); }
.latency.mid { color: var(--warn); }
.latency.slow { color: var(--danger); }

.error-msg {
  font-size: 12px;
  color: var(--muted);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* — Form card —————————————————————————— */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 520px;
}
.form-card .hint {
  font-size: 13px;
  color: var(--muted);
  padding: 10px 14px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 20px;
}
.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 550;
  color: var(--fg);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.field .field-help {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.field input,
.field select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--fg);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}
.field input::placeholder { color: #94a3b8; }
.field input:disabled,
.field select:disabled {
  background: #f1f5f9;
  color: var(--muted);
  cursor: not-allowed;
}
.field select { cursor: pointer; }
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-actions { display: flex; gap: 10px; margin-top: 24px; }

/* — Login —————————————————————————————— */
body.centered {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.login-brand .logo-dot { width: 10px; height: 10px; box-shadow: 0 0 10px var(--accent); }
.login-brand span:last-child {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.login-card h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.login-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 24px;
}
.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  font-size: 13px;
  font-weight: 510;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
}
.btn-login {
  width: 100%;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 4px;
  letter-spacing: 0.01em;
}
.btn-login:hover { background: #0f766e; }

/* — Inline edit / add forms ——————————— */
.edit-input {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
  font-family: inherit;
  color: var(--fg);
  background: var(--surface);
  transition: border-color 0.15s;
  outline: none;
}
.edit-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.08);
}
select.edit-input { cursor: pointer; }
.edit-input.w-name { width: 180px; }
.edit-input.w-channel { width: 150px; }
.edit-input.w-order { width: 60px; text-align: center; }

.add-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.add-form h2 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
}
.add-form .form-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* — Proxies ————————————————————————————— */
.status-dot-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
}
.status-dot-inline .dot { width: 7px; height: 7px; border-radius: 50%; }
.status-dot-inline .dot.active { background: var(--success); }
.status-dot-inline .dot.disabled { background: #cbd5e1; }
.status-dot-inline .dot.active + span { color: var(--success); }
.status-dot-inline .dot.disabled + span { color: var(--muted); }
.fail-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-left: 6px;
}
.fail-count-bad { color: var(--warn); font-weight: 600; }
.type-badge {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.type-badge.socks5 { background: #f0f9ff; color: #0369a1; }
.type-badge.http { background: #faf5ff; color: #7e22ce; }
.creds-mask { color: var(--muted); letter-spacing: 0.1em; }
.actions-cell { display: flex; gap: 4px; justify-content: flex-end; }

/* — Incidents ——————————————————————————— */
.kind-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.kind-pill.down { background: #fef2f2; color: var(--danger); }
.kind-pill.blocked { background: #fffbeb; color: var(--warn); }
.kind-pill.open { font-weight: 700; }
.duration {
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.duration.open { color: var(--danger); }

/* — Search ————————————————————————————— */
.header-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}
.search-input {
  width: 260px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--fg);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}
.search-input::placeholder { color: #94a3b8; }

/* — Dashboard: один вьюпорт, скролл внутри таблиц ——— */
.dash {
  display: flex;
  flex-direction: column;
  /* 52px nav + 28px паддинги main сверху/снизу */
  height: calc(100vh - 52px - 56px);
  min-height: 400px;
}
.dash .page-header { margin-bottom: 16px; }
.dash .status-grid { margin-bottom: 16px; }
.dash .groups-area {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.dash .group {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}
.dash .group-header { flex-shrink: 0; }
.dash .table-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.dash .table-wrap th {
  position: sticky;
  top: 0;
  z-index: 1;
}

/* — Utility ———————————————————————————— */
.muted { color: var(--muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* — Responsive ————————————————————————— */
@media (max-width: 768px) {
  main { padding: 16px; }
  .status-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  th, td { padding: 8px 12px; }
  nav { padding: 0 12px; gap: 0; overflow-x: auto; }
  nav a { padding: 14px 10px; font-size: 12px; white-space: nowrap; }
  .form-card { padding: 20px; }
  .field-row { grid-template-columns: 1fr; }
  .edit-input.w-name { width: 140px; }
  .edit-input.w-channel { width: 120px; }
}
@media (max-width: 480px) {
  .status-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .status-card { padding: 12px 14px; }
  .status-card .count { font-size: 20px; }
}
