:root {
  color-scheme: light;
  --bg: #f6f6f4; --surface: #fcfcfb; --surface-2: #f0efec; --line: #e4e3df;
  --text: #0b0b0b; --text-2: #52514e; --muted: #7d7c77;
  --accent: #2a78d6; --accent-soft: #e3eefb; --live: #1baf7a; --danger: #d93a39; --warn: #c98500;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111111; --surface: #1a1a19; --surface-2: #232321; --line: #2e2e2b;
    --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8e86;
    --accent: #3987e5; --accent-soft: #1c2a3d; --live: #199e70; --danger: #e66767; --warn: #c98500;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111111; --surface: #1a1a19; --surface-2: #232321; --line: #2e2e2b;
  --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8e86;
  --accent: #3987e5; --accent-soft: #1c2a3d; --live: #199e70; --danger: #e66767; --warn: #c98500;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.7 Vazirmatn, Tahoma, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 500; transition: background .15s, border-color .15s; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .6; cursor: default; }
.btn:focus-visible, .input:focus-visible, .seg button:focus-visible, .tabs a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.input { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); outline: none; }
.input:focus { border-color: var(--accent); }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 5px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; margin: 8px 0; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }
.err { color: var(--danger); font-size: 13px; min-height: 20px; }

/* layout */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top .in { max-width: 1240px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; color: var(--text); }
.brand svg { width: 26px; height: 26px; }
.top .sp { flex: 1; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 24px 20px 60px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card h3 { margin: 0 0 12px; font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.card h3 .muted { font-weight: 400; font-size: 12px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-live { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
@media (max-width: 960px) { .g3, .g-live { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) { .g2 { grid-template-columns: minmax(0, 1fr); } .wrap { padding: 16px 16px 48px; } .top .in { padding: 10px 16px; } }
.mt { margin-top: 16px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* page header */
.ph { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.ph h1 { margin: 0; font-size: 22px; display: flex; align-items: center; gap: 10px; }
.ph .dom { font-size: 13px; color: var(--muted); font-weight: 400; direction: ltr; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--text); border-color: var(--accent); font-weight: 600; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 8px; cursor: pointer; color: var(--text-2); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }

/* live dot */
.dot { position: relative; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--live); flex: none; }
.dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--live); animation: pulse 1.8s ease-out infinite; }
.dot.off { background: var(--muted); } .dot.off::after { display: none; }
@keyframes pulse { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(3); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .dot::after { animation: none; } }

/* stats */
.hero-num { font-size: 64px; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.kpi .l { font-size: 12.5px; color: var(--muted); }
.kpi .v { font-size: 26px; font-weight: 800; line-height: 1.3; }
.delta { font-size: 12px; font-weight: 600; }
.delta.up { color: var(--live); } .delta.down { color: var(--danger); } .delta.flat { color: var(--muted); }
.mini { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 16px; }
.mini b { display: block; font-size: 20px; }
.mini span { font-size: 12px; color: var(--muted); }

/* bar lists */
.bl { list-style: none; margin: 0; padding: 0; }
.bl li { position: relative; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; }
.bl li .b { position: absolute; inset-block: 2px; inset-inline-start: 0; background: var(--accent-soft); border-radius: 8px; z-index: 0; transition: width .4s; }
.bl li > *:not(.b) { position: relative; z-index: 1; }
.bl .lb { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bl .lb small { color: var(--muted); margin-inline-start: 8px; font-size: 11.5px; direction: ltr; unicode-bidi: isolate; }
.bl .v { font-weight: 700; }
.bl .s { color: var(--muted); font-size: 12px; min-width: 48px; text-align: end; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; font-size: 13px; }

/* tables */
.tbl-wrap { overflow-x: auto; margin: 0 -18px -18px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: start; color: var(--muted); font-weight: 500; font-size: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl th:first-child, .tbl td:first-child { padding-inline-start: 18px; }
.tbl .pg { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); font-size: 11.5px; color: var(--text-2); }
.tag.new { background: color-mix(in srgb, var(--live) 18%, transparent); color: var(--text); }

/* feed */
.feed { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; }
.feed li { display: flex; gap: 10px; align-items: center; padding: 8px 4px; border-bottom: 1px dashed var(--line); animation: fadein .4s; }
.feed li:last-child { border-bottom: 0; }
.feed .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes fadein { from { opacity: 0; transform: translateY(-4px); } }

/* charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid-l { stroke: var(--line); stroke-width: 1; }
.chart .ax { fill: var(--muted); font-size: 11px; font-family: inherit; }
.tip { position: absolute; pointer-events: none; background: var(--text); color: var(--bg); padding: 6px 10px; border-radius: 8px; font-size: 12px; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); z-index: 5; box-shadow: var(--shadow); }
.tip b { font-size: 13px; }

/* code */
pre.code { direction: ltr; text-align: left; background: #0f1115; color: #e6e6e6; border-radius: 12px; padding: 14px 16px; font: 12.5px/1.7 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-x: auto; margin: 0; white-space: pre-wrap; word-break: break-all; }
pre.code .k { color: #7fb4ff; } pre.code .s { color: #a5e07a; } pre.code .c { color: #8a8f98; }
.code-box { position: relative; }
.code-box pre.code { padding-left: 76px; }
.code-box .btn { position: absolute; top: 8px; left: 8px; background: #23262d; border-color: #33363d; color: #fff; }
code.i { direction: ltr; unicode-bidi: isolate; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 12.5px; }

/* sites list */
.sites { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.site { display: block; color: var(--text); transition: transform .15s, border-color .15s; }
.site:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.site .n { font-weight: 700; font-size: 16px; }
.site .d { color: var(--muted); font-size: 12.5px; direction: ltr; text-align: right; }
.site .stats { display: flex; gap: 20px; margin-top: 14px; }
.site .stats b { display: block; font-size: 22px; line-height: 1.2; }
.site .stats span { color: var(--muted); font-size: 12px; }
.add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border-style: dashed; color: var(--muted); cursor: pointer; min-height: 150px; background: transparent; box-shadow: none; }
.add:hover { color: var(--accent); border-color: var(--accent); }
.add .plus { font-size: 30px; line-height: 1; }

/* status */
.status { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); font-size: 13px; }
.status.ok { background: color-mix(in srgb, var(--live) 14%, transparent); }
.status.wait { background: color-mix(in srgb, var(--warn) 14%, transparent); }

/* modal & toast */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fadein .15s; }
.modal .card { width: min(440px, 100%); padding: 22px; }
.modal h2 { margin: 0 0 16px; font-size: 18px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; z-index: 60; box-shadow: var(--shadow); animation: fadein .2s; }

/* preview */
.preview { width: 100%; height: 600px; border: 1px solid var(--line); border-radius: 14px; background: repeating-linear-gradient(45deg, var(--surface-2) 0 10px, var(--surface) 10px 20px); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sw { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.sw.on { box-shadow: 0 0 0 2px var(--text); }
.loading { padding: 60px 0; text-align: center; color: var(--muted); }
