/* ================================================================
   HealthPing — Command Center UI
   Fonts: Plus Jakarta Sans + JetBrains Mono (self-hosted)
   ================================================================ */

/* JetBrains Mono */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/static/fonts/jbmono-cyr-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/static/fonts/jbmono-cyr.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/static/fonts/jbmono-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/static/fonts/jbmono-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Plus Jakarta Sans */
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/static/fonts/pjs-cyr-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/static/fonts/pjs-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/static/fonts/pjs-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg:         #0B0F1A;
  --surface:    #111827;
  --surface-2:  #0F1629;
  --surface-3:  #1a2435;
  --border:     #1e293b;
  --border-2:   #263044;

  --text:       #e2e8f0;
  --text-dim:   #64748b;
  --text-faint: #475569;

  --ok:      #4ade80;
  --ok-dot:  #22c55e;
  --late:    #f59e0b;
  --partial: #fb923c;
  --down:    #f87171;
  --new:     #64748b;

  --accent:     #6366F1;
  --accent-dim: #4338CA;
  --accent-hi:  #a5b4fc;

  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;

  --radius:    10px;
  --radius-sm: 6px;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; overscroll-behavior-x: none; }

html, body {
  margin: 0; padding: 0;
  overscroll-behavior-x: none;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 18% 0%, rgba(99,102,241,.14), transparent 52%),
    radial-gradient(ellipse at 82% 100%, rgba(139,92,246,.09), transparent 52%);
}

a { color: var(--accent-hi); text-decoration: none; }
a:hover { color: var(--text); }

button {
  font-family: var(--sans);
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

code, .mono { font-family: var(--mono); }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0,0,0,0);
}

/* ================================================================
   Login
   ================================================================ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px;
  box-shadow: 0 0 60px rgba(99,102,241,.08), 0 24px 48px rgba(0,0,0,.4);
}

.login-logo {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 6px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.login-logo .pulse-dot { color: var(--ok); }

.login-title {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 28px;
  line-height: 1.3;
  letter-spacing: -0.5px;
  color: var(--text);
}
.login-title .cursor {
  display: inline-block;
  width: 10px; height: 20px;
  background: var(--accent);
  margin-left: 4px;
  animation: blink 1.1s steps(1) infinite;
  vertical-align: middle;
  border-radius: 2px;
}
@keyframes blink { 50% { opacity: 0; } }

.field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 8px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.field-row { display: flex; gap: 8px; margin-bottom: 16px; }

input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
input[type="datetime-local"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  transition: border-color 0.15s;
}
input:hover { border-color: var(--border-2); }
input:focus { border-color: var(--accent); outline: none; }
input::placeholder { color: var(--text-faint); }

.btn-primary {
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  color: #fff;
  padding: 10px 20px;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 12px rgba(99,102,241,.35);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #5254CC, #7A4FD8);
  box-shadow: 0 4px 20px rgba(99,102,241,.5);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  background: var(--accent-dim);
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--text-dim);
  padding: 10px 16px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}
.btn-secondary:hover { border-color: var(--text-faint); color: var(--text); }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.btn-ghost:hover { color: var(--text); background: rgba(255,255,255,.07); }

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0;
  color: var(--text-faint);
  font-size: 12px;
}
.login-divider::before, .login-divider::after {
  content: ""; height: 1px;
  background: var(--border);
  flex: 1;
}

.login-hint {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
}
.login-hint code {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
}

.error-banner {
  background: rgba(248,113,113,.1);
  border: 1px solid rgba(248,113,113,.25);
  color: #fca5a5;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}

/* ================================================================
   Dashboard Shell
   ================================================================ */
.app-shell {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 28px 80px;
}

/* ================================================================
   Topbar / Nav
   ================================================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 80px;
  padding: 0 32px;
  margin: 0 -28px 28px;
  background: rgba(15,22,41,.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left  { display: flex; align-items: center; }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
  margin-right: 20px;
  flex-shrink: 0;
  text-decoration: none;
}
.brand-icon { display: none; }

.brand-logo {
  width: 68px; height: 68px;
  border-radius: 8px;
  flex-shrink: 0;
  display: block;
}

.topbar-nav { display: flex; align-items: center; gap: 2px; }

.nav-item {
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.07); }

/* ================================================================
   Summary Bar
   ================================================================ */
.summary-bar { display: flex; gap: 10px; margin-bottom: 24px; flex-wrap: wrap; }

.summary-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
}
.summary-pill .dot { width: 7px; height: 7px; border-radius: 50%; }

/* ================================================================
   Checks Grid
   ================================================================ */
.checks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

/* ================================================================
   Check Card
   ================================================================ */
.check-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.check-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 28px rgba(99,102,241,.14);
}
.check-card[data-status="down"] {
  border-color: rgba(248,113,113,.4);
  box-shadow: 0 0 20px rgba(248,113,113,.06);
}
.check-card[data-status="late"] { border-color: rgba(245,158,11,.35); }
.check-card--paused { opacity: 0.5; border-style: dashed; }
.check-card--paused:hover { border-color: var(--border); box-shadow: none; }

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card-title {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.35;
  letter-spacing: -0.2px;
  word-break: break-word;
  color: var(--text);
}

/* ================================================================
   Status Pills
   ================================================================ */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 100px;
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid;
}
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; }

.status-ok      { color: var(--ok);      background: rgba(74,222,128,.1);   border-color: rgba(74,222,128,.25); }
.status-late    { color: var(--late);    background: rgba(245,158,11,.1);   border-color: rgba(245,158,11,.25); }
.status-partial { color: var(--partial); background: rgba(251,146,60,.1);   border-color: rgba(251,146,60,.25); }
.status-down    { color: var(--down);    background: rgba(248,113,113,.1);  border-color: rgba(248,113,113,.25); }
.status-new     { color: var(--new);     background: rgba(100,116,139,.1);  border-color: rgba(100,116,139,.25); }

/* ================================================================
   Status Dots
   ================================================================ */
.dot-ok      { background: var(--ok-dot); box-shadow: 0 0 8px rgba(34,197,94,.7); }
.dot-late    { background: var(--late);   box-shadow: 0 0 7px rgba(245,158,11,.6); }
.dot-partial { background: var(--partial);box-shadow: 0 0 7px rgba(251,146,60,.6); }
.dot-down    { background: var(--down);   box-shadow: 0 0 8px rgba(248,113,113,.7); }
.dot-new     { background: var(--new); }

/* ================================================================
   Sparkline / Pulse
   ================================================================ */
.pulse-wrap { height: 80px; position: relative; }
.pulse-wrap svg { width: 100%; height: 100%; display: block; }

/* ================================================================
   Expiry Overlay (SSL / Domain)
   ================================================================ */
.expiry-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  gap: 2px;
}
.expiry-label {
  font-size: 10px;
  color: var(--text-faint);
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  line-height: 1;
}
.expiry-days {
  font-size: 42px;
  font-weight: 800;
  font-family: var(--mono);
  line-height: 1;
  letter-spacing: -1px;
}
.expiry-until {
  font-size: 10px;
  color: var(--text-faint);
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1;
}
.expiry-date {
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--mono);
  line-height: 1;
  margin-top: 1px;
}

/* ================================================================
   Meta rows
   ================================================================ */
.meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--mono);
}

.countdown-row { margin-top: 2px; }
.countdown-row .countdown {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* ================================================================
   URL Row
   ================================================================ */
.url-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
}
.url-row code {
  flex: 1;
  font-size: 11.5px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ================================================================
   Icon Buttons
   ================================================================ */
.icon-btn {
  background: transparent;
  color: var(--text-faint);
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 12px;
}
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,.08); }

/* ================================================================
   Card Footer
   ================================================================ */
.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  /* прижимаем футер к низу карточки: карточка — flex-колонка, грид тянет их
     по высоте ряда, поэтому кнопки действий выравниваются по нижней кромке */
  margin-top: auto;
}
.card-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.icon-btn { white-space: nowrap; }

.curl-toggle {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  background: none;
  padding: 0;
}
.curl-toggle:hover { color: var(--text-dim); }

.curl-snippet {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  white-space: pre-wrap;
  word-break: break-all;
  display: none;
}
.curl-snippet.open { display: block; }

.delete-btn { color: var(--text-faint); }
.delete-btn:hover { color: var(--down); background: rgba(248,113,113,.1); }

/* ================================================================
   Region Badges
   ================================================================ */
.region-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.region-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-dim);
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 100px;
}
.region-badge .dot { width: 5px; height: 5px; border-radius: 50%; }

.region-checkboxes { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.region-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 100px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.region-checkbox input { accent-color: var(--accent); }
.region-checkbox.checked { color: var(--accent-hi); border-color: var(--accent-dim); background: rgba(99,102,241,.08); }

/* ================================================================
   Empty State
   ================================================================ */
.empty-state {
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 64px 24px;
  text-align: center;
  color: var(--text-dim);
}
.empty-state .mono { color: var(--text-faint); font-size: 12px; margin-bottom: 14px; font-family: var(--mono); }
.empty-state h3 { margin: 0 0 8px; color: var(--text); font-weight: 700; }
.empty-state p { margin: 0 0 24px; font-size: 14px; }

/* ================================================================
   Toast
   ================================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 100px;
  font-size: 13px;
  font-family: var(--mono);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* ================================================================
   Modal
   ================================================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(5,8,20,.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 40;
}
.modal {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 16px;
  padding: 28px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 0 80px rgba(0,0,0,.6), 0 0 40px rgba(99,102,241,.08);
}
.modal h3 {
  margin: 0 0 20px;
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
}

/* ================================================================
   Template Gallery
   ================================================================ */
.template-gallery {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
  max-height: 220px;
  overflow-y: auto;
}
.template-card {
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: border-color 0.15s, background 0.15s;
}
.template-card:hover { border-color: var(--accent); background: rgba(99,102,241,.06); }
.template-card .tpl-title { font-size: 12.5px; font-weight: 600; color: var(--text); line-height: 1.3; }
.template-card .tpl-type {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.template-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 6px;
  color: var(--text-faint);
  font-size: 11px;
}
.template-divider::before, .template-divider::after {
  content: ""; height: 1px;
  background: var(--border);
  flex: 1;
}

.tpl-hint {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
  background: rgba(99,102,241,.07);
  border-left: 2px solid var(--accent-dim);
  padding: 8px 12px;
  border-radius: 0 4px 4px 0;
  margin-bottom: 14px;
}

.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s;
}
select:hover { border-color: var(--border-2); }
select:focus { border-color: var(--accent); outline: none; }

textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  resize: vertical;
  transition: border-color 0.15s;
}
textarea:focus { border-color: var(--accent); outline: none; }
textarea:focus-visible { outline: none; }

/* ================================================================
   Telegram Banner
   ================================================================ */
.telegram-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 18px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--text-dim);
}
.telegram-banner strong { color: var(--text); }
.telegram-banner code { color: var(--accent-hi); }

/* ================================================================
   Webhook List
   ================================================================ */
.webhook-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}
.webhook-row:hover { border-color: var(--border-2); }
.webhook-row .wh-info { flex: 1; min-width: 0; }
.webhook-row .wh-name { font-size: 13px; font-weight: 600; color: var(--text); }
.webhook-row .wh-url {
  font-family: var(--mono); font-size: 11px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.webhook-row .wh-status {
  font-family: var(--mono); font-size: 10px;
  padding: 2px 8px; border-radius: 100px; white-space: nowrap;
}
.wh-status.ok    { color: var(--ok);   background: rgba(74,222,128,.1);  border: 1px solid rgba(74,222,128,.2); }
.wh-status.error { color: var(--down); background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.2); }
.wh-status.never { color: var(--text-faint); background: var(--surface-3); border: 1px solid var(--border); }
.webhook-row .wh-actions { display: flex; gap: 4px; }
.webhook-empty { color: var(--text-faint); font-family: var(--mono); font-size: 12px; text-align: center; padding: 12px 0; }

/* ================================================================
   Bulk Result
   ================================================================ */
.bulk-result-box {
  font-size: 12.5px; line-height: 1.6;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px;
}
.bulk-result-box .ok   { color: var(--ok); }
.bulk-result-box .skip { color: var(--text-dim); }
.bulk-result-box .err  { color: var(--down); }
.bulk-result-box code  { font-family: var(--mono); font-size: 11.5px; color: var(--text-dim); }

/* ================================================================
   Tools Modal
   ================================================================ */
.tools-tabs {
  display: flex; flex-wrap: wrap; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.ttab {
  background: none; border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-family: var(--mono); font-size: 11.5px;
  padding: 7px 10px; cursor: pointer;
  margin-bottom: -1px;
  transition: color 0.15s; white-space: nowrap;
}
.ttab:hover { color: var(--text); }
.ttab.active { color: var(--accent-hi); border-bottom-color: var(--accent); }

.tools-result {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px;
  font-family: var(--mono); font-size: 12px; color: var(--text);
  word-break: break-all;
  max-height: 300px; overflow-y: auto;
}
.tools-map {
  margin-bottom: 8px; border-radius: var(--radius-sm); overflow: hidden;
  display: none;
}
.tools-result .tr-ok  { color: var(--ok); }
.tools-result .tr-err { color: var(--down); }
.tools-result .tr-key { color: var(--text-dim); }
.tools-result .tr-val { color: var(--text); }
.tools-result table { width: 100%; border-collapse: collapse; }
.tools-result td { padding: 3px 8px 3px 0; vertical-align: top; }
.tools-result td:first-child { color: var(--text-dim); white-space: nowrap; min-width: 80px; }

/* DNSCheck result rows (dnschecker.org style) */
.dns-list { display: flex; flex-direction: column; }
.dns-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 2px; border-bottom: 1px solid var(--border);
}
.dns-row:last-child { border-bottom: none; }
.dns-flag { flex-shrink: 0; display: flex; align-items: center; width: 24px; }
.dns-flag img { display: block; border-radius: 2px; box-shadow: 0 0 0 1px var(--border); }
.dns-loc { flex: 1; min-width: 0; font-family: var(--sans); }
.dns-city { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dns-prov { font-size: 10.5px; color: var(--text-dim); margin-top: 1px; }
.dns-rec {
  font-family: var(--mono); font-size: 11.5px; color: var(--accent);
  text-align: right; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dns-rec.fail { color: var(--down); }
.dns-mark { flex-shrink: 0; }
.dns-mark.ok { color: var(--ok); }
.dns-mark.fail { color: var(--down); }

/* PortScan result rows */
.ps-list {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px;
}
.ps-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--border);
}
.ps-row.is-open { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, var(--bg)); }
.ps-port { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--text); min-width: 42px; }
.ps-svc { flex: 1; font-family: var(--sans); font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ps-badge { font-size: 10px; font-weight: 600; padding: 1px 7px; border-radius: 10px; white-space: nowrap; }
.ps-badge.open { color: var(--ok); background: color-mix(in srgb, var(--ok) 15%, transparent); }
.ps-badge.closed { color: var(--text-dim); background: color-mix(in srgb, var(--text-dim) 12%, transparent); }
@media (max-width: 520px) { .ps-list { grid-template-columns: 1fr; } }

/* ================================================================
   History Modal
   ================================================================ */
.history-modal { max-width: 640px; }
.history-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.history-modal-head h3 { margin: 0; }

.history-tabs { display: flex; gap: 6px; margin-bottom: 20px; }
.htab {
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 5px 14px; font-family: var(--mono); font-size: 12px;
  border-radius: 100px;
  transition: all 0.15s;
}
.htab:hover { color: var(--text); border-color: var(--border-2); }
.htab.active { background: rgba(99,102,241,.15); border-color: var(--accent-dim); color: var(--accent-hi); }

.hbars-wrap { display: flex; align-items: flex-end; gap: 2px; height: 60px; }
.hbar-col { flex: 1; min-width: 4px; max-width: 32px; height: 100%; display: flex; align-items: flex-end; }
.hbar { width: 100%; min-height: 4px; border-radius: 2px; cursor: default; transition: opacity 0.1s; }
.hbar:hover { opacity: 0.65; }
.hbars-range { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 10px; color: var(--text-faint); margin-top: 4px; }

.history-stats { display: flex; gap: 24px; margin: 16px 0 4px; flex-wrap: wrap; }
.hstat { display: flex; flex-direction: column; gap: 2px; font-family: var(--mono); font-size: 11px; color: var(--text-dim); }
.hstat-val { font-size: 20px; font-weight: 700; color: var(--text); letter-spacing: -0.5px; }

.history-events { max-height: 260px; overflow-y: auto; font-family: var(--mono); font-size: 11.5px; }
.hev-row {
  display: grid;
  grid-template-columns: 130px 36px 64px 90px 1fr;
  align-items: center; gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.hev-row:last-child { border-bottom: none; }
.hev-ts     { color: var(--text-dim); }
.hev-status { font-weight: 600; }
.hev-ok     { color: var(--ok); }
.hev-down   { color: var(--down); }
.hev-ms     { color: var(--text-dim); text-align: right; }
.hev-region { color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hev-error  { color: var(--down); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ================================================================
   Incidents
   ================================================================ */
.history-incidents { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; }
.inc-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0; font-family: var(--mono); font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.inc-row:last-child { border-bottom: none; }
.inc-badge { font-size: 10px; padding: 2px 7px; border-radius: 4px; white-space: nowrap; font-weight: 600; }
.inc-badge--open     { background: rgba(248,113,113,.12); color: var(--down); border: 1px solid rgba(248,113,113,.2); }
.inc-badge--resolved { background: rgba(74,222,128,.1);   color: var(--ok);   border: 1px solid rgba(74,222,128,.2); }
.inc-ts    { color: var(--text-dim); white-space: nowrap; }
.inc-dur   { color: var(--text); font-weight: 600; white-space: nowrap; }
.inc-cause { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }

/* ================================================================
   Misc
   ================================================================ */
.theme-toggle { font-size: 16px; padding: 6px 9px; }
.copy-btn { font-size: 14px; }

/* ================================================================
   Light Theme
   ================================================================ */
[data-theme="light"] {
  --bg:         #F8F9FB;
  --surface:    #FFFFFF;
  --surface-2:  #FFFFFF;
  --surface-3:  #F1F4F8;
  --border:     #E2E8F0;
  --border-2:   #CBD5E1;

  --text:       #0F172A;
  --text-dim:   #64748B;
  --text-faint: #94A3B8;

  --ok:      #16A34A;
  --ok-dot:  #22C55E;
  --late:    #A16207;
  --partial: #C2410C;
  --down:    #DC2626;
  --new:     #6E7781;

  --accent:     #4F46E5;
  --accent-dim: #4338CA;
  --accent-hi:  #4F46E5;
}

[data-theme="light"] body {
  background-image:
    radial-gradient(ellipse at 18% 0%, rgba(79,70,229,.06), transparent 52%),
    radial-gradient(ellipse at 82% 100%, rgba(22,163,74,.04), transparent 52%);
}

[data-theme="light"] .topbar {
  background: rgba(255,255,255,.92);
}


[data-theme="light"] .modal-backdrop { background: rgba(15,23,42,.5); }

[data-theme="light"] .check-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 24px rgba(79,70,229,.12);
}

[data-theme="light"] .btn-ghost:hover { background: rgba(0,0,0,.05); }
[data-theme="light"] .nav-item:hover  { background: rgba(0,0,0,.05); }

[data-theme="light"] .dot-ok      { box-shadow: 0 0 6px rgba(34,197,94,.5); }
[data-theme="light"] .dot-late    { box-shadow: 0 0 5px rgba(161,98,7,.45); }
[data-theme="light"] .dot-partial { box-shadow: 0 0 5px rgba(194,65,12,.45); }
[data-theme="light"] .dot-down    { box-shadow: 0 0 6px rgba(220,38,38,.5); }

[data-theme="light"] .status-ok   { color: #15803d; background: rgba(22,163,74,.08); border-color: rgba(22,163,74,.22); }
[data-theme="light"] .status-late { color: #a16207; background: rgba(161,98,7,.08);  border-color: rgba(161,98,7,.22); }
[data-theme="light"] .status-down { color: #dc2626; background: rgba(220,38,38,.08); border-color: rgba(220,38,38,.22); }

[data-theme="light"] .region-badge { background: #f8fafc; }

[data-theme="light"] .check-card--paused { opacity: 0.55; }

/* ================================================================
   Responsive
   ================================================================ */
@media (max-width: 680px) {
  .modal-grid { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 8px; }
  .topbar-left { flex-wrap: wrap; }
  .topbar-nav { display: none; }
}

@media (max-width: 640px) {
  .app-shell { padding: 0 12px 60px; }
  .topbar { margin: 0 -12px 20px; padding: 10px 14px; }
  .checks-grid { grid-template-columns: 1fr; gap: 10px; }
  .check-card { padding: 14px 14px 12px; }
  .card-actions { flex-wrap: wrap; gap: 4px; }
  .modal { padding: 20px; max-width: 100% !important; width: calc(100vw - 24px); }
  .history-modal { max-height: calc(100vh - 32px); overflow-y: auto; }
  .hbars-wrap { gap: 1px; }
  .hbar-col { width: 4px; }
  .summary-bar { flex-wrap: wrap; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .login-title .cursor { animation: none; opacity: 1; }
  .check-card, .toast { transition: none; }
  .btn-primary:hover { transform: none; }
}

/* ================================================================
   Теги, фильтр, аптайм, mute, типы вебхуков
   ================================================================ */
.tag-filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin: -8px 0 22px; }
.tag-chip {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 100px;
  cursor: pointer;
  transition: all .12s ease;
}
.tag-chip:hover { color: var(--text); border-color: var(--accent-dim); }
.tag-chip.active { color: var(--accent-hi); border-color: var(--accent-dim); background: rgba(99,102,241,.1); }

.card-tags { display: flex; flex-wrap: wrap; gap: 5px; margin: -4px 0 8px; }
.card-tag {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  background: rgba(99,102,241,.07);
  border: 1px solid rgba(99,102,241,.18);
  padding: 1px 7px;
  border-radius: 4px;
}

.uptime-row { align-items: center; }
.uptime-label { color: var(--text-faint); font-family: var(--mono); font-size: 11px; }
.uptime-vals { font-family: var(--mono); font-size: 11px; letter-spacing: .2px; }

.muted-badge { margin-right: 4px; font-size: 11px; }

.wh-kind {
  font-family: var(--mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .4px;
  padding: 1px 6px;
  border-radius: 4px;
  vertical-align: middle;
}
.wh-kind-generic { color: var(--text-faint); background: var(--surface-3); border: 1px solid var(--border); }
.wh-kind-slack   { color: #E0115F; background: rgba(224,17,95,.1);  border: 1px solid rgba(224,17,95,.25); }
.wh-kind-discord { color: #5865F2; background: rgba(88,101,242,.12); border: 1px solid rgba(88,101,242,.3); }

/* ================================================================
   Просмотр страницы статуса (только для авторизованных)
   ================================================================ */
#statusView { min-height: 100vh; padding: 40px 20px; }
.sv-wrap { max-width: 640px; margin: 0 auto; }
.sv-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.sv-head h1 { font-size: 22px; font-weight: 700; }
.sv-back { font-size: 13px; color: var(--accent-hi); text-decoration: none; white-space: nowrap; }
.sv-back:hover { text-decoration: underline; }
.sv-desc { color: var(--text-dim); font-size: 14px; margin-bottom: 20px; line-height: 1.5; }
.sv-overall {
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; font-weight: 600; margin: 16px 0 20px;
  padding: 14px 18px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
}
.sv-dot { width: 10px; height: 10px; border-radius: 50%; }
.sv-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.sv-row { display: flex; align-items: center; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--border); }
.sv-row:last-child { border-bottom: none; }
.sv-name { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; }
.sv-type { font-size: 11px; color: var(--text-dim); background: var(--surface-3); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; white-space: nowrap; }
.sv-meta { font-size: 12px; color: var(--text-dim); font-family: var(--mono); white-space: nowrap; }
.sv-status { font-size: 13px; font-weight: 500; white-space: nowrap; }
.sv-foot { text-align: center; font-size: 12px; color: var(--text-faint); margin-top: 18px; }

/* ================================================================
   Проекты (папки проверок): заголовки-группы + модалка
   ================================================================ */
/* Карточка-папка проекта (уровень 1) */
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}
.project-card:hover { border-color: var(--accent); box-shadow: 0 0 24px rgba(99,102,241,.14); }
.project-card:active { transform: translateY(1px); }
.project-card[data-status="down"] { border-color: rgba(248,113,113,.4); }
.project-card[data-status="late"] { border-color: rgba(245,158,11,.35); }
.pc-head { display: flex; align-items: center; gap: 9px; }
.pc-icon { font-size: 17px; }
.pc-name { font-size: 15px; font-weight: 600; color: var(--text); flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-actions { display: flex; gap: 2px; }
.pc-meta { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
.pc-stats { display: flex; flex-wrap: wrap; gap: 10px; font-family: var(--mono); font-size: 12px; }
.pc-open { font-family: var(--mono); font-size: 11px; color: var(--accent-hi); margin-top: 2px; }

/* Бар навигации внутри проекта (уровень 2) */
.project-back-bar {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 4px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.pc-back {
  font-family: var(--mono); font-size: 12px; color: var(--accent-hi);
  background: none; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 5px 10px; cursor: pointer;
}
.pc-back:hover { border-color: var(--accent-dim); }
.pb-title { font-size: 15px; font-weight: 600; color: var(--text); }
.project-header-actions { margin-left: auto; display: flex; gap: 2px; }
.project-empty { grid-column: 1 / -1; color: var(--text-faint); font-family: var(--mono);
  font-size: 13px; text-align: center; padding: 28px 0; }

.project-row {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 0; border-bottom: 1px solid var(--border);
}
.project-row:last-child { border-bottom: none; }
.project-row-name { flex: 1; font-size: 14px; }
.project-row-count { font-family: var(--mono); font-size: 11px; color: var(--text-faint); }
.projects-empty { color: var(--text-faint); font-family: var(--mono); font-size: 12px; text-align: center; padding: 8px 0; }
