:root {
  --bg0: #ffffff;
  --bg1: #f7f7f7;
  --bg2: #eeeeee;
  --line: #e5e5e5;
  --text: #0a0a0a;
  --muted: #5c5c5c;
  --accent: #111111;
  --accent-2: #f97316;
  --danger: #ef4444;
  --ok: #111111;
  --card: #ffffff;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
  --radius: 14px;
  --font: "Vazirmatn", "IRANSans", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg0);
  min-height: 100vh;
  line-height: 1.7;
}

a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
a:hover { opacity: 0.75; }

.container { width: min(1100px, calc(100% - 2rem)); margin: 0 auto; }

.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 0; gap: 1rem;
}
.brand {
  display: inline-flex; align-items: center; gap: 0.55rem;
  font-weight: 800; font-size: 1.15rem; color: var(--text);
  text-decoration: none; letter-spacing: 0.01em;
  direction: ltr;
  unicode-bidi: isolate;
}
.brand:hover { opacity: 1; text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid #111; object-fit: cover; background: #fff;
  flex: 0 0 auto;
}
.brand-text {
  color: #111; font-weight: 800;
  direction: ltr; unicode-bidi: isolate;
  white-space: nowrap;
}
.hero h1[dir="ltr"] {
  direction: ltr;
  unicode-bidi: isolate;
}
.nav { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.nav a { color: var(--muted); font-size: 0.95rem; text-decoration: none; }
.nav a:hover { color: var(--text); }

.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid #111; cursor: pointer;
  background: #111; color: #fff;
  font-weight: 700; font-family: inherit;
  padding: 0.65rem 1rem; border-radius: 10px;
  transition: transform .15s ease, background .15s ease, color .15s ease;
}
.btn:hover { transform: translateY(-1px); background: #000; text-decoration: none; color: #fff; }
.btn.secondary { background: #fff; color: #111; }
.btn.secondary:hover { background: #f3f3f3; color: #111; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { padding: 0.38rem 0.75rem; font-size: 0.85rem; }

.hero { padding: 4.5rem 0 3rem; display: grid; gap: 1.2rem; }
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.25; margin: 0; max-width: 14ch; color: #111;
}
.hero p { color: var(--muted); max-width: 42ch; margin: 0; font-size: 1.05rem; }
.hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.5rem; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin: 1.25rem 0 2rem;
}
.panel h2, .panel h3 { margin-top: 0; }
.muted { color: var(--muted); }
.error {
  background: #fef2f2; border: 1px solid #fecaca; color: #991b1b;
  padding: 0.8rem 1rem; border-radius: 12px; margin-bottom: 1rem;
}
.success {
  background: #f5f5f5; border: 1px solid #d4d4d4; color: #111;
  padding: 0.8rem 1rem; border-radius: 12px; margin-bottom: 1rem;
}

label { display: block; margin: 0.8rem 0 0.35rem; color: var(--muted); font-size: 0.92rem; }
input[type="text"], input[type="password"], input[type="url"], input[type="file"], textarea {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  font-family: inherit;
  font-size: 1rem;
}
form .actions { margin-top: 1.1rem; display: flex; gap: 0.6rem; flex-wrap: wrap; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: right; padding: 0.75rem 0.4rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top; font-size: 0.95rem;
}
.table th { color: var(--muted); font-weight: 600; }
.badge {
  display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px;
  font-size: 0.8rem; border: 1px solid var(--line); color: #111;
}
.badge.ok { border-color: #111; }
.badge.warn { color: #9a3412; border-color: #fdba74; background: #fff7ed; }
.badge.bad { color: #991b1b; border-color: #fecaca; background: #fef2f2; }

.card-number {
  font-size: 1.35rem; letter-spacing: 0.08em; font-weight: 800;
  color: #111; direction: ltr; text-align: right;
}
.grid-2 {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.stat {
  background: #fff; border: 1px solid var(--line);
  border-radius: 14px; padding: 1rem;
}
.stat strong { display: block; font-size: 1.2rem; }
.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted); padding: 1.5rem 0 2.5rem; margin-top: 2rem;
  font-size: 0.9rem;
}
.code {
  direction: ltr; display: inline-block; background: #f5f5f5;
  padding: 0.2rem 0.55rem; border-radius: 8px; border: 1px solid var(--line);
}

.alerts-toolbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 0.75rem; margin: 0.8rem 0 0.85rem; flex-wrap: wrap;
}
.alerts-tools { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.tiny { font-size: 0.8rem; }
.pending-chip {
  display: none;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid #111;
  background: #111;
  color: #fff;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
}
.pending-chip.is-on { display: inline-flex; }
.pending-chip:hover { background: #000; }

.filter-tabs {
  display: flex; gap: 0.35rem; flex-wrap: wrap;
  margin: 0 0 1rem;
  padding: 0.35rem;
  background: #f3f3f3;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.filter-tab {
  appearance: none; border: 1px solid transparent;
  background: transparent; color: #525252;
  font: inherit; font-weight: 700; font-size: 0.88rem;
  padding: 0.55rem 0.95rem; border-radius: 10px;
  cursor: pointer; transition: .15s ease;
}
.filter-tab:hover { color: #111; background: rgba(0,0,0,0.04); }
.filter-tab.is-active {
  color: #fff;
  background: #111;
  border-color: #111;
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

.live-pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  border: 1px solid #111;
  background: #111;
  color: #fff;
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font-size: 0.82rem;
  white-space: nowrap;
}
.live-pill.offline {
  color: #9a3412;
  border-color: #fdba74;
  background: #fff7ed;
}
.live-dot {
  width: 0.5rem; height: 0.5rem; border-radius: 50%;
  background: currentColor;
  animation: pulse 1.6s infinite;
}
.live-pill.offline .live-dot { animation: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,255,255,.45); }
  70% { box-shadow: 0 0 0 8px rgba(255,255,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
}

.alerts-list { display: grid; gap: 0.75rem; margin-bottom: 2rem; }
.alerts-section { display: grid; gap: 0.75rem; }
.alerts-divider {
  display: flex; align-items: center; gap: 0.75rem;
  margin: 0.4rem 0 0.1rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}
.alerts-divider::before,
.alerts-divider::after {
  content: "";
  flex: 1;
  border-top: 2px dotted #a3a3a3;
}
.alerts-divider span { color: #111; white-space: nowrap; }

.alert-card {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 0.85rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.7rem;
  overflow: hidden;
  align-items: stretch;
}
.alert-card.is-unseen {
  border-color: #111;
  box-shadow: inset 3px 0 0 #111, var(--shadow);
}
.alert-card.is-seen { opacity: 0.82; }
.alert-card.no-media { grid-template-columns: 1fr; }

.alert-media {
  display: block;
  border-radius: 12px;
  overflow: hidden;
  background: #f0f0f0;
  border: 1px solid var(--line);
  align-self: stretch;
  min-height: 112px;
  height: 100%;
}
.alert-media img {
  width: 100%;
  height: 100%;
  min-height: 112px;
  max-height: 148px;
  object-fit: cover;
  object-position: center;
  display: block;
  background: #f0f0f0;
}

.alert-body { min-width: 0; display: grid; gap: 0.2rem; align-content: start; }
.alert-tags { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.tag {
  display: inline-flex; align-items: center;
  font-size: 0.7rem; font-weight: 800;
  padding: 0.12rem 0.45rem; border-radius: 999px;
  border: 1px solid transparent;
}
.tag-new { color: #fff; background: #ef4444; border-color: #ef4444; }
.tag-seen { color: #111; background: #f3f3f3; border-color: #d4d4d4; }

.phone-hero {
  display: block;
  direction: ltr;
  text-align: right;
  font-size: clamp(1.45rem, 5.5vw, 1.95rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #111;
  line-height: 1.15;
  text-decoration: none;
  margin: 0 0 0.1rem;
}
.phone-hero:hover { text-decoration: none; opacity: 0.7; }
button.phone-hero, .phone-missing {
  width: 100%;
  border: 1px dashed #f97316;
  background: #fff7ed;
  font: inherit;
  cursor: pointer;
  padding: 0.3rem 0.45rem;
  border-radius: 10px;
  font-size: 1rem;
  color: #9a3412;
}
.phone-actions { display: grid; gap: 0.25rem; }
.phone-fallback {
  display: block;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: #525252;
  text-decoration: none;
  padding: 0.15rem 0;
}
.phone-fallback:hover { color: #111; text-decoration: underline; }
a.phone-chat {
  border: 1px solid #111 !important;
  background: #111 !important;
  color: #fff !important;
  text-align: center;
  font-size: 1rem !important;
  padding: 0.35rem 0.5rem;
  border-radius: 10px;
}

.alert-title {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.4;
  font-weight: 700;
}
.alert-title a { color: #111; text-decoration: none; }
.alert-title a:hover { text-decoration: underline; }
.alert-row {
  display: flex; justify-content: space-between; gap: 0.5rem; align-items: baseline;
}
.alert-price {
  margin: 0; color: #111; font-weight: 800; font-size: 0.9rem;
}
.attr-inline {
  display: flex; flex-wrap: wrap; gap: 0.25rem 0.55rem;
  color: var(--muted); font-size: 0.75rem;
}
.attr-inline b { color: #111; font-weight: 600; }
.alert-desc {
  margin-top: 0.2rem;
  border-top: 1px solid var(--line);
  padding-top: 0.25rem;
}
.alert-desc summary {
  cursor: pointer; color: var(--muted); font-size: 0.78rem; user-select: none;
}
.alert-desc p {
  margin: 0.35rem 0 0; white-space: pre-wrap; color: var(--text); font-size: 0.82rem;
}
.empty-alerts { margin-top: 0; }

.toast-host {
  position: fixed; top: 4.5rem; left: 50%; transform: translateX(-50%);
  z-index: 50; display: grid; gap: 0.5rem; width: min(420px, calc(100% - 1.5rem));
  pointer-events: none;
}
.toast {
  background: #111;
  border: 1px solid #111;
  color: #fff;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow);
  opacity: 0; transform: translateY(-8px);
  transition: .25s ease;
  font-weight: 700;
}
.toast.toast-new { background: #ef4444; border-color: #ef4444; }
.toast.toast-warn { background: #fff7ed; border-color: #f97316; color: #9a3412; }
.toast.toast-info { background: #111; }
.toast.toast-ok { background: #111; }
.toast.show { opacity: 1; transform: none; }

.install-sheet {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,0.45);
  display: grid; place-items: end center;
  padding: 1rem;
}
.install-sheet[hidden] { display: none; }
.install-card {
  width: min(440px, 100%);
  background: #fff;
  color: #111;
  border-radius: 18px;
  border: 1px solid var(--line);
  padding: 1.1rem 1.15rem 1.25rem;
  box-shadow: 0 24px 60px rgba(0,0,0,0.2);
}
.install-card h3 { margin: 0 0 0.5rem; font-size: 1.05rem; }
.install-card ol { margin: 0.4rem 0 1rem; padding-right: 1.2rem; color: #404040; }
.install-card li { margin: 0.35rem 0; }
.install-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }

@media (max-width: 700px) {
  .container { width: min(1100px, calc(100% - 1rem)); }
  .site-header .nav a { font-size: 0.82rem; }
  .alert-card { grid-template-columns: 96px 1fr; gap: 0.65rem; padding: 0.55rem; }
  .alert-media { min-height: 96px; }
  .alert-media img { min-height: 96px; max-height: 128px; }
  .phone-hero { font-size: 1.5rem; }
  .filter-tab { font-size: 0.8rem; padding: 0.45rem 0.75rem; }
}
