@font-face {
  font-family: 'Vazirmatn';
  font-weight: 100 900;
  font-display: swap;
  src: url(/fonts/vazirmatn-arabic.woff2) format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+200C-200E, U+2010-2011, U+204F, U+FB50-FDFF, U+FE70-FEFC;
}
@font-face {
  font-family: 'Vazirmatn';
  font-weight: 100 900;
  font-display: swap;
  src: url(/fonts/vazirmatn-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212;
}

:root {
  --bg: #0B1120;
  --glass: rgba(30, 41, 59, 0.55);
  --glass-strong: rgba(30, 41, 59, 0.85);
  --line: rgba(148, 163, 184, 0.16);
  --line-strong: rgba(148, 163, 184, 0.32);
  --text: #F1F5F9;
  --muted: #A3B1C6;
  --accent: #60A5FA;
  --accent-ink: #0B1120;
  --ok: #34D399;
  --down: #F87171;
  --warn: #FBBF24;
  --idle: #64748B;
  --radius: 14px;
  --radius-sm: 10px;
  --gap: 16px;
  --sidebar: 236px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --t: 160ms;
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Vazirmatn', Tahoma, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(900px 600px at 100% -10%, rgba(96, 165, 250, 0.14), transparent 60%),
    radial-gradient(700px 500px at -10% 110%, rgba(167, 139, 250, 0.12), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  font-feature-settings: 'ss01';
}
[hidden] { display: none !important; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.sprite { display: none; }
.icon {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num, [dir="ltr"] { font-variant-numeric: tabular-nums; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.skip-link {
  position: fixed; top: 8px; right: 8px; z-index: 100;
  padding: 10px 16px; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-ink); font-weight: 700; text-decoration: none;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
}
@supports not (backdrop-filter: blur(1px)) { .glass { background: var(--glass-strong); } }

/* ------------------------------ buttons -------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap;
  cursor: pointer; touch-action: manipulation;
  transition: background var(--t) var(--ease), border-color var(--t) var(--ease), opacity var(--t);
}
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover:not(:disabled) { background: #93C5FD; }
.btn--ghost { background: rgba(148, 163, 184, 0.08); border-color: var(--line); }
.btn--ghost:hover:not(:disabled) { background: rgba(148, 163, 184, 0.16); border-color: var(--line-strong); }
.btn--danger { background: rgba(248, 113, 113, 0.14); border-color: rgba(248, 113, 113, 0.4); color: #FCA5A5; }
.btn--danger:hover:not(:disabled) { background: rgba(248, 113, 113, 0.24); }
.btn--block { width: 100%; }
.btn--icon { width: 44px; padding: 0; }
.btn--sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn--sm.btn--icon { width: 36px; }
.btn.is-busy .icon { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------- forms --------------------------------- */
.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea, .search input {
  min-height: 44px; width: 100%; padding: 0 12px;
  background: rgba(2, 6, 23, 0.45); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  color: var(--text); font-size: 15px;
  transition: border-color var(--t);
}
.field textarea { padding: 10px 12px; min-height: 84px; resize: vertical; line-height: 1.7; }
.field input:focus, .field select:focus, .field textarea:focus, .search input:focus { border-color: var(--accent); }
.field--inline { min-width: 180px; }
.form-error { color: #FCA5A5; font-size: 14px; }
.hint {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: rgba(251, 191, 36, 0.08); border: 1px solid rgba(251, 191, 36, 0.25);
  color: #FDE68A; font-size: 13px;
}
.hint .icon { margin-top: 3px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.checks { border: 0; padding: 0; display: grid; gap: 8px; }
.checks legend { margin-bottom: 8px; }
.check {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer;
}
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.check:has(input:disabled) { opacity: 0.55; cursor: not-allowed; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

.switch { display: inline-flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track {
  position: relative; width: 44px; height: 24px; border-radius: 99px;
  background: rgba(148, 163, 184, 0.3); transition: background var(--t);
}
.switch__track::after {
  content: ''; position: absolute; top: 3px; right: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform var(--t) var(--ease);
}
.switch input:checked + .switch__track { background: var(--ok); }
.switch input:checked + .switch__track::after { transform: translateX(-20px); }
.switch input:focus-visible + .switch__track { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ------------------------------- login --------------------------------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login__card { width: min(400px, 100%); padding: 32px; display: grid; gap: 18px; }
.login__brand { text-align: center; display: grid; justify-items: center; gap: 6px; margin-bottom: 6px; }
.login__brand h1 { font-size: 22px; }
.logo {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, #60A5FA, #A78BFA); color: var(--accent-ink);
}
.logo .icon { width: 22px; height: 22px; stroke-width: 2.4; }

/* ------------------------------ layout --------------------------------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 12px; height: calc(100vh - 24px); margin: 12px 12px 12px 0;
  display: flex; flex-direction: column; padding: 16px 12px;
}
.sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; font-weight: 800; }
.nav { display: grid; gap: 4px; }
.nav a, .bottom-nav a {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px;
  border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; font-weight: 600;
  transition: background var(--t), color var(--t);
}
.nav a:hover { background: rgba(148, 163, 184, 0.08); color: var(--text); }
.nav a[aria-current="page"] { background: rgba(96, 165, 250, 0.14); color: var(--text); }
.nav a[aria-current="page"] .icon { color: var(--accent); }
.sidebar__foot {
  margin-top: auto; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 8px 0; border-top: 1px solid var(--line);
}

.main { padding: 20px 24px 40px; min-width: 0; outline: none; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 20px;
}
.topbar h1 { font-size: 22px; }
.topbar__actions { display: flex; align-items: center; gap: 12px; }
.freshness { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.freshness::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.freshness.is-stale { color: #FDE68A; }
.freshness.is-stale::before { background: var(--warn); }
.freshness.is-offline { color: #FCA5A5; }
.freshness.is-offline::before { background: var(--down); }

.section-title { font-size: 15px; font-weight: 700; color: var(--muted); margin: 28px 0 12px; }
.sales-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sales-head .section-title { margin-bottom: 12px; }
.live-line { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.live-line strong { color: var(--text); font-weight: 600; }
.live-msg { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: rgba(2, 6, 23, 0.3); }
.live-msg p { color: var(--text); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#margins-form, #sub-form { display: grid; gap: 14px; }
#margins-form .btn, #sub-form .btn { justify-self: start; }
.card { padding: 20px; }
.card__title { display: flex; align-items: center; gap: 10px; font-size: 16px; margin-bottom: 16px; }

/* ------------------------------- stats --------------------------------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); }
.stat { padding: 16px 18px; display: grid; gap: 4px; }
.stat__label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.stat__value { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat__sub { font-size: 12px; color: var(--muted); }
.stat--ok .stat__value { color: var(--ok); }
.stat--down .stat__value { color: var(--down); }
.stat--warn .stat__value { color: var(--warn); }

/* --------------------------- status cards ------------------------------ */
.status-grid, .project-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.site { padding: 18px; display: grid; gap: 14px; border-top: 3px solid var(--c, var(--accent)); }
.site__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.site__name { display: grid; }
.site__name strong { font-size: 17px; }
.site__name a { font-size: 13px; color: var(--muted); text-decoration: none; direction: ltr; text-align: right; }
.site__name a:hover { color: var(--text); text-decoration: underline; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px;
  font-size: 12px; font-weight: 700; white-space: nowrap; border: 1px solid transparent;
}
.badge .icon { width: 14px; height: 14px; stroke-width: 2.6; }
.badge--ok { color: var(--ok); background: rgba(52, 211, 153, 0.1); border-color: rgba(52, 211, 153, 0.3); }
.badge--down { color: #FCA5A5; background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.35); }
.badge--warn { color: #FDE68A; background: rgba(251, 191, 36, 0.1); border-color: rgba(251, 191, 36, 0.3); }
.badge--idle { color: var(--muted); background: rgba(148, 163, 184, 0.1); border-color: var(--line); }

.checks-list { display: grid; gap: 10px; }
.check-row { display: grid; gap: 6px; }
.check-row__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
.check-row__meta { display: flex; gap: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.bars { display: flex; gap: 2px; height: 26px; align-items: stretch; direction: ltr; }
.bars span { flex: 1; min-width: 2px; border-radius: 2px; background: var(--ok); opacity: 0.85; }
.bars span.is-down { background: var(--down); opacity: 1; }
.bars span.is-empty { background: rgba(148, 163, 184, 0.15); }

.site__foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted); padding-top: 10px; border-top: 1px solid var(--line);
}
.site__foot span { display: inline-flex; align-items: center; gap: 6px; }
.site__foot .icon { width: 14px; height: 14px; }
.ssl-warn { color: #FDE68A; }
.ssl-bad { color: #FCA5A5; }

/* ------------------------------ projects ------------------------------- */
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  padding: 2px 10px; border-radius: 99px; font-size: 12px; direction: ltr;
  background: rgba(148, 163, 184, 0.1); border: 1px solid var(--line); color: var(--muted);
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.notes-status { font-size: 12px; color: var(--muted); min-height: 18px; }

/* ------------------------------- backups ------------------------------- */
.backup-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); align-items: start; }
.backup-layout .card { display: grid; gap: 14px; }
.backup-layout .card__title { margin-bottom: 0; }
.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: right; font-size: 12px; font-weight: 600; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td:last-child { text-align: left; white-space: nowrap; }
.table .actions { justify-content: flex-end; flex-wrap: nowrap; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }

/* -------------------------------- logs --------------------------------- */
.toolbar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: 220px; }
.search .icon { position: absolute; top: 13px; right: 12px; color: var(--muted); pointer-events: none; }
.search input { padding-right: 40px; }
.log-list { list-style: none; padding: 0; }
.log-list li {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  padding: 10px 4px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.log-list li:last-child { border-bottom: 0; }
.log-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: rgba(148, 163, 184, 0.1); color: var(--muted); }
.log-icon .icon { width: 15px; height: 15px; }
.log-icon--ok { color: var(--ok); background: rgba(52, 211, 153, 0.1); }
.log-icon--down { color: var(--down); background: rgba(248, 113, 113, 0.12); }
.log-icon--warn { color: var(--warn); background: rgba(251, 191, 36, 0.1); }
.log-text { min-width: 0; overflow-wrap: anywhere; }
.log-text strong { font-weight: 600; margin-left: 6px; }
.log-time { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ------------------------------ skeleton ------------------------------- */
.skeleton { min-height: 180px; position: relative; overflow: hidden; }
.skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(148, 163, 184, 0.08), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { from { transform: translateX(100%); } to { transform: translateX(-100%); } }

/* ------------------------------- dialog -------------------------------- */
.dialog {
  width: min(420px, calc(100% - 32px)); padding: 24px; color: var(--text);
  background: var(--glass-strong);
}
.dialog::backdrop { background: rgba(2, 6, 23, 0.7); backdrop-filter: blur(4px); }
.dialog h2 { font-size: 18px; margin-bottom: 8px; }
.dialog__actions { display: flex; justify-content: flex-start; gap: 8px; margin-top: 20px; }

/* ------------------------------- toasts -------------------------------- */
.toasts {
  position: fixed; bottom: 20px; left: 20px; z-index: 50;
  display: grid; gap: 8px; width: min(360px, calc(100% - 40px));
}
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  background: var(--glass-strong); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  backdrop-filter: blur(16px); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  font-size: 14px; animation: toast-in 200ms var(--ease);
}
.toast .icon { margin-top: 3px; }
.toast--ok .icon { color: var(--ok); }
.toast--error .icon { color: var(--down); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* --------------------------- bottom nav -------------------------------- */
.bottom-nav { display: none; }

/* ------------------------------ responsive ----------------------------- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .status-grid, .project-grid, .backup-layout { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 16px 14px calc(96px + env(safe-area-inset-bottom)); }
  .topbar h1 { font-size: 19px; }
  .topbar__actions .btn span { display: none; }
  .topbar__actions .btn { width: 44px; padding: 0; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px;
    position: fixed; bottom: 10px; right: 10px; left: 10px; z-index: 40;
    padding: 6px; padding-bottom: calc(6px + env(safe-area-inset-bottom));
    background: var(--glass-strong);
  }
  .bottom-nav a { flex-direction: column; justify-content: center; gap: 2px; min-height: 52px; padding: 4px; font-size: 11px; }
  .bottom-nav a[aria-current="page"] { background: rgba(96, 165, 250, 0.14); color: var(--text); }
  .bottom-nav a[aria-current="page"] .icon { color: var(--accent); }
  .toasts { bottom: calc(88px + env(safe-area-inset-bottom)); left: 12px; width: calc(100% - 24px); }
  .row { grid-template-columns: 1fr; }
  .log-list li { grid-template-columns: auto 1fr; }
  .log-time { grid-column: 2; }
}
@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px; }
  .stat__value { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
@media (forced-colors: active) {
  .bars span { forced-color-adjust: none; }
}
