:root {
  color-scheme: light;
  --bg: #FBF7F2;
  --surface: #FFFFFF;
  --surface-2: #FDFAF6;
  --ink: #2B2D3A;
  --muted: #6F7184;
  --line: #ECE6EE;
  --brand: #3E5BA9;
  --brand-2: #F29A88;
  --brand-soft: #FDEEE9;
  --good: #2E8B57;
  --bad: #D0503E;
  --chip: #EEF1FA;
  --shadow: 0 1px 2px rgba(40, 45, 80, .05), 0 6px 18px rgba(40, 45, 80, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #1A1B22;
    --surface: #23242D;
    --surface-2: #292A34;
    --ink: #F1F0F5;
    --muted: #A7A8B8;
    --line: #383A47;
    --brand: #93AAF2;
    --brand-2: #F29A88;
    --brand-soft: #33283A;
    --good: #6FCB94;
    --bad: #F08C7E;
    --chip: #2C2E3A;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Rubik', 'Segoe UI', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--brand); }
.muted { color: var(--muted); }
h1, h2, h3 { margin: 0; font-weight: 700; }

/* כניסה */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-box { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 10px; }
.login-box h1 { font-size: 20px; margin-bottom: 6px; }
.login-box input { font: inherit; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); }
.err { color: var(--bad); margin: 0; }
.btn { font: inherit; font-weight: 500; background: var(--brand); color: #fff; border: 0; border-radius: 10px; padding: 12px; cursor: pointer; }
@media (prefers-color-scheme: dark) { .btn { color: #1A1B22; } }

/* כותרת וטאבים */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); border-bottom: 1px solid var(--line); }
.top-row { max-width: 1100px; margin: 0 auto; padding: 12px 16px 6px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top h1 { font-size: 18px; }
.top h1 .sub { font-weight: 400; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.icon-btn.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(-360deg); } }
.tabs { max-width: 1100px; margin: 0 auto; padding: 4px 12px 10px; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; text-decoration: none; color: var(--ink); background: var(--chip); padding: 7px 14px; border-radius: 999px; font-size: 14px; }
.tabs a.on { background: var(--brand); color: #fff; }
@media (prefers-color-scheme: dark) { .tabs a.on { color: #1A1B22; } }
.tabs a:focus-visible, .seg button:focus-visible, .chip:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 14px 16px 40px; }
.banner { background: var(--brand-soft); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; font-size: 14px; }
.banner.warn { border-color: var(--bad); }
.seg { display: inline-flex; background: var(--chip); border-radius: 999px; padding: 3px; margin-bottom: 12px; }
.seg button { font: inherit; font-size: 14px; border: 0; background: transparent; color: var(--ink); padding: 6px 14px; border-radius: 999px; cursor: pointer; }
.seg button.on { background: var(--surface); box-shadow: var(--shadow); font-weight: 500; }

/* כרטיסים ופאנלים */
.lead { font-size: 14px; color: var(--muted); margin: 0 0 12px; }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
@media (min-width: 720px) { .cards { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); min-width: 0; }
.card .label { font-size: 13px; color: var(--muted); }
.card .value { font-size: 26px; font-weight: 700; line-height: 1.2; margin-top: 2px; direction: ltr; text-align: right; font-variant-numeric: tabular-nums; }
.card .delta { font-size: 13px; margin-top: 2px; }
.card.hero { background: var(--brand-soft); }
.up { color: var(--good); }
.down { color: var(--bad); }
.flat { color: var(--muted); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); margin-bottom: 14px; min-width: 0; }
.panel h2 { font-size: 16px; margin-bottom: 4px; }
.panel .hint { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.grid2 { display: grid; gap: 14px; }
@media (min-width: 860px) { .grid2 { grid-template-columns: 1fr 1fr; } .grid2 > .panel { margin-bottom: 0; } .grid2 { margin-bottom: 14px; } }
.chart { position: relative; height: 240px; }

/* טבלאות */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: right; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-weight: 500; color: var(--muted); font-size: 13px; }
td.num, th.num { text-align: left; direction: ltr; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }

/* פסים */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; align-items: center; gap: 8px; font-size: 14px; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; background: var(--chip); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--brand-2); border-radius: 999px; }
.bar-row .n { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 40px; text-align: left; }

/* משפך */
.funnel { display: flex; flex-direction: column; gap: 6px; }
.f-step { display: grid; grid-template-columns: 110px 1fr 90px; gap: 8px; align-items: center; font-size: 14px; }
.f-bar { height: 26px; background: var(--brand-2); border-radius: 6px; min-width: 2px; }
.f-step .meta { color: var(--muted); font-size: 13px; text-align: left; font-variant-numeric: tabular-nums; }

/* מפת חום */
.heat { display: grid; grid-template-columns: 38px repeat(24, minmax(12px, 1fr)); gap: 2px; font-size: 11px; min-width: 520px; }
.heat .h { text-align: center; color: var(--muted); }
.heat .d { color: var(--muted); }
.heat .c { aspect-ratio: 1; border-radius: 3px; background: var(--chip); }

/* פיד וביקורים */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 46px 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.feed li:last-child { border-bottom: 0; }
.feed .t { color: var(--muted); font-variant-numeric: tabular-nums; }
.feed .k-purchase { color: var(--good); font-weight: 500; }
.feed .k-cart { color: var(--brand); font-weight: 500; }
.feed .k-coupon_fail, .feed .k-cart_remove { color: var(--bad); }
.feed .who { color: var(--muted); font-size: 13px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; align-items: center; }
.chip { font: inherit; font-size: 13px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 5px 12px; border-radius: 999px; cursor: pointer; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chips input[type=date] { font: inherit; font-size: 13px; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }

.visit { border-right: 4px solid var(--line); }
.visit.has-cart { border-right-color: var(--brand-2); }
.visit.has-purchase { border-right-color: var(--good); }
.visit h3 { font-size: 15px; }
.visit .src { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.visit .line { display: grid; grid-template-columns: 44px 1fr; gap: 6px; font-size: 14px; padding: 2px 0; }
.visit .line .t { color: var(--muted); font-variant-numeric: tabular-nums; }
.visit .line .note { display: block; color: var(--muted); font-size: 13px; }
.visit .end { font-size: 13px; color: var(--muted); margin-top: 6px; }

.alerts { margin: 0; padding: 0; list-style: none; }
.alerts li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.alerts li:last-child { border-bottom: 0; }
.status { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; background: var(--chip); }
.status.ok { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.status.warn { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.compare3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; text-align: center; }
.compare3 .value { font-size: 28px; font-weight: 700; }
.loading { color: var(--muted); padding: 30px 0; text-align: center; }
