@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0f1a22;
  --bg-soft: #12212b;
  --bg-softer: #162430;
  --fg: #e3eef6;
  --muted: #9fb3c8;
  --up: #39d67c;
  --mid: #4db5ff;
  --slow: #ffa938;
  --down: #ff4d4d;
  --border: #1e3240;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  --glow: 0 0 16px rgba(77, 181, 255, 0.2);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Vazirmatn", sans-serif;
  background: var(--bg);
  color: var(--fg);

  /* Sticky Footer */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.brand {
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.overall {
  font-size: 14px;
  color: var(--up);
  text-shadow: var(--glow);
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
}

.badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.badge.success { background: rgba(57,214,124,0.18); color: var(--up); }
.badge.danger { background: rgba(255,77,77,0.18); color: var(--down); }

.container {
  padding: 24px 24px 32px;
  max-width: 1280px;
  margin: 0 auto;
  flex: 1; /* برای چسبیدن فوتر به انتهای صفحه */
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.summary-card {
  position: relative;
  padding: 18px 20px;
  border-radius: 16px;
  background: var(--bg-softer);
  border: 1px solid rgba(77, 181, 255, 0.08);
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.summary-card::after {
  content: "";
  position: absolute;
  inset-inline-start: -40%;
  inset-block-end: -80%;
  width: 70%;
  height: 140%;
  background: radial-gradient(ellipse at center, rgba(77, 181, 255, 0.16), transparent 70%);
  opacity: 0.65;
  pointer-events: none;
}

.summary-card:hover {
  transform: translateY(-2px);
  border-color: rgba(77, 181, 255, 0.2);
}

.summary-card.accent { border-color: rgba(77, 181, 255, 0.35); }
.summary-card.accent .summary-value { color: var(--mid); }

.summary-card.alert { border-color: rgba(255, 77, 77, 0.25); }
.summary-card.alert .summary-value { color: var(--down); }
.summary-card.alert .summary-sub { color: rgba(255, 153, 153, 0.85); }

.summary-title { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.summary-value { font-size: 28px; font-weight: 700; line-height: 1.2; }
.summary-sub { margin-top: 6px; font-size: 12px; color: var(--muted); }
.summary-sub span { color: var(--up); font-weight: 600; }
.summary-trend { margin-top: 6px; font-size: 12px; color: #b9cfe2; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 12px;
}
.section-head h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.4;
}
.section-head span {
  color: var(--muted);
  font-size: 12px;
}

.alerts-panel,
.target-manager {
  margin-bottom: 18px;
}

.alerts-list {
  display: grid;
  gap: 8px;
}
.alert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 77, 77, 0.22);
  border-radius: 8px;
  background: rgba(255, 77, 77, 0.08);
}
.alert-name {
  color: #ffd4d4;
  font-weight: 700;
  font-size: 13px;
}
.alert-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}
.alert-duration {
  color: var(--down);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.searchbox input {
  background: var(--bg-soft);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 10px;
  min-width: 220px;
}

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 12px;
}
.chip.active {
  background: rgba(77,181,255,0.12);
  color: var(--mid);
  border-color: rgba(77,181,255,0.3);
}

.sortbox select {
  background: var(--bg-soft);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
}

.table-wrapper {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  position: relative;
}

table.grid {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

thead th {
  text-align: right;
  padding: 12px 16px;
  font-size: 12px;
  letter-spacing: 0.2px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: rgba(12, 24, 33, 0.55);
}

tbody td {
  border-bottom: 1px dashed rgba(30, 50, 64, 0.7);
  padding: 12px 16px;
  vertical-align: middle;
  height: 34px;
  line-height: 1.2;
  font-size: 13px;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }

tr.row-down td { background: rgba(255, 77, 77, 0.06); }
tr.row-slow td { background: rgba(255, 169, 56, 0.07); }

.col-time { width: 120px; }
.col-status { width: 170px; }
.col-ip { width: 160px; }
.col-name { width: 220px; }
.col-timeline { width: auto; }

.status { font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: currentColor;
}
.status.up { color: var(--up); }
.status.down { color: var(--down); }

.status-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sparkline {
  width: 120px;
  height: 26px;
  display: block;
}

.sparkline-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.sparkline-line {
  fill: none;
  stroke: var(--mid);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.95;
}

.sparkline-line.down {
  stroke: var(--down);
}

.sparkline-baseline {
  stroke: rgba(255,255,255,0.08);
  stroke-width: 1;
}

.sparkline-point {
  fill: var(--mid);
  stroke: #0c151c;
  stroke-width: 1;
}

.timeline-cell { width: 100%; }
.timeline-track {
  width: 100%;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  flex-wrap: nowrap !important;
  overflow: hidden;
  direction: ltr;
  background: transparent;
}

.segment {
  flex: 0 0 8px;
  height: 14px;
  border-radius: 3px;
  background: #264653;
  transition: opacity 0.3s ease;
}
.segment.up-fast { background: var(--up); }
.segment.up-mid { background: var(--mid); }
.segment.up-slow { background: var(--slow); }
.segment.down {
  background: repeating-linear-gradient(
    135deg,
    rgba(255, 77, 77, 0.85) 0px,
    rgba(255, 77, 77, 0.85) 6px,
    rgba(255, 77, 77, 0.4) 6px,
    rgba(255, 77, 77, 0.4) 10px
  );
}

.lastcheck {
  color: var(--muted);
  font-family: ui-monospace, monospace;
  font-size: 12px;
}
.ip {
  font-family: ui-monospace, monospace;
  color: #b9cfe2;
}

.empty-state {
  display: none;
  text-align: center;
  padding: 24px;
  color: var(--muted);
}
.empty-state.compact {
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.target-form {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(160px, 1fr) 100px 90px auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}
.target-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}
.target-form input {
  min-height: 34px;
  background: var(--bg-soft);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
}
.target-form input:focus,
.searchbox input:focus,
.sortbox select:focus {
  outline: none;
  border-color: rgba(77, 181, 255, 0.55);
}
.check-label {
  align-items: center;
  flex-direction: row !important;
  padding-bottom: 7px;
}
.check-label input {
  min-height: auto;
}
.target-form-actions {
  display: flex;
  gap: 8px;
}
.target-form-actions button,
.mini-btn {
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(77, 181, 255, 0.12);
  color: var(--fg);
  cursor: pointer;
  padding: 6px 10px;
  font-size: 12px;
}
.target-form-actions button:hover,
.mini-btn:hover {
  border-color: rgba(77, 181, 255, 0.42);
}
.mini-btn.danger {
  background: rgba(255, 77, 77, 0.12);
  color: #ffc1c1;
}
.form-message {
  min-height: 18px;
  align-self: center;
  color: var(--muted);
  font-size: 12px;
}
.form-message.success { color: var(--up); }
.form-message.error { color: var(--down); }

.target-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
}
.target-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}
.target-table th,
.target-table td {
  padding: 10px 12px;
  border-bottom: 1px dashed rgba(30, 50, 64, 0.7);
  font-size: 12px;
  text-align: right;
}
.target-table th {
  color: var(--muted);
  background: rgba(12, 24, 33, 0.55);
}
.target-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Footer */
.page-footer {
  text-align: center;
  padding: 18px 12px 28px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
}

/* Tooltip حرفه‌ای */
.tooltip-card {
  position: fixed;
  left: -9999px;
  top: -9999px;
  background: #101a22;
  color: #eaf3fb;
  border: 1px solid rgba(77, 181, 255, 0.25);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.35);
  font-size: 12px;
  max-width: 260px;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.12s ease;
  pointer-events: none;
}
.tooltip-card.show { opacity: 1; }

.tooltip-card::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  background: #101a22;
  border-left: 1px solid rgba(77, 181, 255, 0.25);
  border-top: 1px solid rgba(77, 181, 255, 0.25);
  transform: rotate(45deg);
  inset-inline-start: 14px;
  inset-block-start: -5px;
}

.tt-title {
  font-weight: 700;
  margin-bottom: 6px;
}
.tt-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 2px 0;
  color: #c6d8e8;
}
.tt-row b {
  color: #fff;
  font-weight: 600;
}

.back-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(77, 181, 255, 0.35);
  border-radius: 50%;
  background: #101a22;
  color: var(--fg);
  box-shadow: var(--shadow);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 9990;
}
.back-top.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

@media (max-width: 900px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .filters { flex-direction: column; align-items: stretch; }
  .table-wrapper { overflow-x: auto; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 4px; }
  .target-form { grid-template-columns: 1fr; }
  .target-form-actions { justify-content: flex-start; }
}
