/* ============================================================
   Design system · ניסוי סוכני ההשקעות
   ============================================================ */
:root {
  --bg: #07090c;
  --bg-2: #0b0e13;
  --surface: #10141b;
  --surface-2: #151a23;
  --surface-3: #1b212c;
  --border: #1d2430;
  --border-2: #283142;
  --text: #e9edf3;
  --text-2: #a4aebf;
  --text-3: #6a7487;
  --accent: #7c9cff;
  --accent-2: #a5b9ff;
  --accent-glow: rgba(124, 156, 255, .18);
  --up: #34d399;
  --up-bg: rgba(52, 211, 153, .1);
  --down: #f87171;
  --down-bg: rgba(248, 113, 113, .1);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, .1);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 12px 32px -12px rgba(0,0,0,.6);
  --font: "Heebo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Inter", system-ui, -apple-system, sans-serif; /* ספרות טבלאיות נקיות, בלי אפס מנוקד */
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; }
::selection { background: var(--accent-glow); }

.num { font-family: var(--mono); font-feature-settings: "tnum", "ss01"; direction: ltr; unicode-bidi: isolate; letter-spacing: -.01em; }
.up { color: var(--up); }
.down { color: var(--down); }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }

/* ---------------- shell ---------------- */
.shell { display: grid; grid-template-columns: 272px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
  padding: 22px 16px;
  background: var(--bg-2);
  border-inline-end: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(140deg, #8fa9ff, #5b6fd6 55%, #2c3a8a);
  box-shadow: 0 6px 18px -6px rgba(124,156,255,.6), 0 0 0 1px rgba(255,255,255,.08) inset;
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 12px; color: var(--text-3); }

.nav-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; color: var(--text-3); padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: 14px;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nav a:hover { background: var(--surface); color: var(--text); }
.nav a.active { background: var(--surface-2); color: var(--text); box-shadow: 0 0 0 1px var(--border) inset; }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; box-shadow: 0 0 0 3px rgba(255,255,255,.03); }
.nav .end { margin-inline-start: auto; font-size: 12.5px; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.watch-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-2);
}
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; position: relative; }
.pulse.live { background: var(--up); }
.pulse.live::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid var(--up); opacity: 0; animation: ping 2s var(--ease) infinite;
}
.pulse.busy { background: var(--warn); }
@keyframes ping { 0% { transform: scale(.6); opacity: .7; } 100% { transform: scale(1.6); opacity: 0; } }

.main { min-width: 0; padding: 26px 36px 60px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.eyebrow { font-size: 12.5px; color: var(--text-3); font-weight: 500; margin-bottom: 4px; }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin: 0; line-height: 1.15; }
h2 { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: -.005em; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

/* ---------------- primitives ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 20px 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 0; }
.card-head .hint { font-size: 12.5px; color: var(--text-3); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text);
  font-weight: 600; font-size: 14px; cursor: pointer;
  transition: transform .12s var(--ease), background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-3); border-color: #34405a; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn svg { width: 16px; height: 16px; }
.btn-primary {
  background: linear-gradient(180deg, #8aa6ff, #6683f2);
  border-color: transparent; color: #0a0f24;
  box-shadow: 0 8px 22px -10px rgba(124,156,255,.8), 0 0 0 1px rgba(255,255,255,.18) inset;
}
.btn-primary:hover { background: linear-gradient(180deg, #9db5ff, #7590f7); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface); color: var(--text); border-color: transparent; }
.btn-block { width: 100%; height: 46px; font-size: 15px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.badge.up { background: var(--up-bg); color: var(--up); }
.badge.down { background: var(--down-bg); color: var(--down); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.accent { background: var(--accent-glow); color: var(--accent-2); }

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.input {
  height: 46px; padding: 0 14px; border-radius: 11px;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border-2); font: inherit; font-size: 15px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input::placeholder { color: var(--text-3); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow); background: var(--bg); }
.input.ltr { direction: ltr; text-align: left; font-family: var(--mono); font-size: 14px; }

.flash {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: 11px; margin-bottom: 18px;
  font-size: 14px; border: 1px solid;
}
.flash.ok { background: var(--up-bg); border-color: rgba(52,211,153,.25); color: #a7f3d0; }
.flash.error { background: var(--down-bg); border-color: rgba(248,113,113,.25); color: #fecaca; }
.flash.warn { background: var(--warn-bg); border-color: rgba(251,191,36,.25); color: #fde68a; }

/* ---------------- KPI ---------------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 14px; }
.kpi { padding: 18px 20px; position: relative; overflow: hidden; }
.kpi-label { font-size: 12.5px; color: var(--text-3); font-weight: 500; display: flex; align-items: center; gap: 7px; }
.kpi-value { font-size: 26px; font-weight: 600; margin-top: 8px; letter-spacing: -.02em; }
.kpi-sub { font-size: 13px; margin-top: 4px; color: var(--text-2); }
.kpi.highlight { background: radial-gradient(120% 140% at 100% 0%, rgba(124,156,255,.13), transparent 55%), var(--surface); }

/* ---------------- grid ---------------- */
.grid { display: grid; gap: 14px; }
.grid-main { grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* ---------------- chart ---------------- */
.chart-wrap { position: relative; padding: 10px 14px 14px; }
.chart { width: 100%; height: 300px; display: block; direction: ltr; }
.spark { direction: ltr; }
.chart.small { height: 220px; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .base-line { stroke: var(--text-3); stroke-dasharray: 3 5; stroke-width: 1; opacity: .7; }
.chart .axis { fill: var(--text-3); font: 11px var(--mono); }
.chart .series { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; transition: opacity .2s; }
.chart .series.passive { stroke-dasharray: 5 5; stroke-width: 1.75; }
.chart .area { opacity: .14; }
.chart .cross { stroke: var(--text-3); stroke-width: 1; }
.chart.dim .series:not(.hot) { opacity: .22; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5;
  min-width: 190px; padding: 10px 12px; border-radius: 11px;
  background: rgba(16,20,27,.96); border: 1px solid var(--border-2);
  box-shadow: 0 16px 40px -12px rgba(0,0,0,.8);
  font-size: 13px; opacity: 0; transform: translateY(4px);
  transition: opacity .12s, transform .12s;
}
.chart-tip.show { opacity: 1; transform: none; }
.chart-tip .t { color: var(--text-3); font-size: 12px; margin-bottom: 6px; }
.chart-tip .r { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.chart-tip .r .v { margin-inline-start: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 0 22px 18px; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; cursor: default; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.empty-chart { height: 300px; display: grid; place-items: center; text-align: center; color: var(--text-3); font-size: 14px; }

/* ---------------- leaderboard ---------------- */
.board { list-style: none; margin: 0; padding: 8px; }
.board li a {
  display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 12px;
  padding: 12px 12px; border-radius: 11px; transition: background .15s;
}
.board li a:hover { background: var(--surface-2); }
.board .rank { font: 600 13px var(--mono); color: var(--text-3); text-align: center; }
.board li:first-child .rank { color: var(--warn); }
.board .who { display: flex; align-items: center; gap: 11px; min-width: 0; }
.avatar {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-size: 17px;
  background: color-mix(in srgb, var(--c) 16%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--c) 30%, transparent) inset;
}
.avatar.lg { width: 56px; height: 56px; border-radius: 15px; font-size: 27px; }
.board .name { font-weight: 600; font-size: 14.5px; }
.board .meta { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board .val { text-align: left; }
.board .val .v { font-size: 15px; font-weight: 600; }
.board .val .c { font-size: 12.5px; }

/* ---------------- agent cards ---------------- */
.agents { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 14px; margin-top: 14px; }
.agent-card { padding: 18px; display: flex; flex-direction: column; gap: 14px; transition: border-color .2s, transform .2s var(--ease); }
.agent-card:hover { border-color: var(--border-2); transform: translateY(-2px); }
.agent-card .top { display: flex; align-items: center; gap: 11px; }
.agent-card .name { font-weight: 600; }
.agent-card .value { font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.agent-card .thought { font-size: 13px; color: var(--text-2); line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; min-height: 62px; }
.agent-card .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.spark { width: 100%; height: 44px; display: block; }

/* ---------------- tables ---------------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: right; font-weight: 500; font-size: 12px; color: var(--text-3); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table .l { text-align: left; }
.sym { font: 600 13.5px var(--mono); letter-spacing: .02em; }
.table-wrap { overflow-x: auto; }

/* ---------------- timeline ---------------- */
.timeline { list-style: none; margin: 0; padding: 6px 22px 14px; }
.tl { display: grid; grid-template-columns: 36px 1fr; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.tl:last-child { border-bottom: 0; }
.tl-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: 16px; }
.tl-icon.buy { background: var(--up-bg); color: var(--up); }
.tl-icon.sell { background: var(--down-bg); color: var(--down); }
.tl-icon svg { width: 17px; height: 17px; }
.tl-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 14px; }
.tl-head .when { margin-inline-start: auto; color: var(--text-3); font-size: 12.5px; }
.tl-body { margin-top: 5px; font-size: 14px; color: var(--text-2); line-height: 1.65; }
.tl-trigger { display: inline-flex; gap: 6px; align-items: center; margin-top: 8px; font-size: 12.5px; color: var(--warn); background: var(--warn-bg); padding: 3px 10px; border-radius: 8px; }
.tl-log { margin-top: 8px; font: 12.5px var(--mono); color: var(--text-3); direction: ltr; text-align: right; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; padding: 16px 22px 4px; }
.chip-btn { padding: 6px 13px; border-radius: 999px; border: 1px solid var(--border-2); background: transparent; color: var(--text-2); font-size: 13px; font-weight: 500; cursor: pointer; transition: all .15s; }
.chip-btn:hover { color: var(--text); border-color: #3a4558; }
.chip-btn.on { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ---------------- agent page ---------------- */
.hero { display: flex; align-items: center; gap: 18px; padding: 22px; }
.hero .big { font-size: 34px; font-weight: 600; letter-spacing: -.025em; }
.hero .style { color: var(--text-2); font-size: 14px; max-width: 560px; margin-top: 6px; }
.hero-stats { margin-inline-start: auto; display: grid; grid-template-columns: repeat(3, auto); gap: 6px 28px; text-align: left; }
.hero-stats .k { font-size: 12px; color: var(--text-3); }
.hero-stats .v { font-size: 16px; font-weight: 600; }

/* ---------------- settings ---------------- */
.settings { display: grid; grid-template-columns: 220px minmax(0, 720px); gap: 30px; }
.settings-nav { position: sticky; top: 26px; align-self: start; display: flex; flex-direction: column; gap: 2px; }
.settings-nav a { padding: 8px 12px; border-radius: 9px; color: var(--text-2); font-size: 14px; }
.settings-nav a:hover { background: var(--surface); color: var(--text); }
.section { padding: 24px; margin-bottom: 18px; scroll-margin-top: 20px; }
.section h2 { display: flex; align-items: center; gap: 10px; }
.section > p { color: var(--text-2); font-size: 14px; margin: 6px 0 20px; }
.status-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 11px; background: var(--bg-2); border: 1px solid var(--border); margin-bottom: 18px; font-size: 14px; }
.inline-form { display: flex; gap: 10px; }
.inline-form .input { flex: 1; }
.rules { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 4px 0 18px; }
.rule { padding: 14px; border-radius: 11px; background: var(--bg-2); border: 1px solid var(--border); }
.rule .k { font-size: 12px; color: var(--text-3); }
.rule .v { font-size: 18px; font-weight: 600; margin-top: 3px; }
.meta-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

/* ---------------- login ---------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(420px, .9fr); }
.auth-art {
  position: relative; overflow: hidden;
  background:
    radial-gradient(60% 50% at 70% 30%, rgba(124,156,255,.22), transparent 70%),
    radial-gradient(50% 50% at 20% 80%, rgba(45,212,191,.12), transparent 70%),
    linear-gradient(180deg, #0a0d14, #06080b);
  border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column; justify-content: space-between; padding: 44px;
}
.auth-art::before {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 56px 56px; opacity: .35;
  mask-image: radial-gradient(70% 60% at 50% 45%, #000 30%, transparent 75%);
}
.auth-art > * { position: relative; }
.auth-lines { position: absolute; inset: 14% 0 40% 0; width: 100%; height: 46%; }
.auth-lines path { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 1400; stroke-dashoffset: 1400; animation: draw 2.6s var(--ease) forwards; }
.auth-lines path:nth-child(2) { animation-delay: .25s; }
.auth-lines path:nth-child(3) { animation-delay: .5s; }
.auth-lines path:nth-child(4) { animation-delay: .75s; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.auth-quote { max-width: 460px; }
.auth-quote h2 { font-size: 34px; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; }
.auth-quote p { color: var(--text-2); font-size: 15.5px; margin: 12px 0 0; }
.auth-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 22px; }
.auth-panel { display: grid; place-items: center; padding: 40px; }
.auth-card { width: 100%; max-width: 380px; animation: rise .6s var(--ease) both; }
.auth-card h1 { font-size: 26px; margin: 26px 0 6px; }
.auth-card .lead { color: var(--text-2); margin: 0 0 28px; }
.auth-foot { margin-top: 26px; display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-3); }
.auth-foot svg { width: 14px; height: 14px; }
.pw-wrap { position: relative; }
.pw-wrap .input { width: 100%; padding-inline-start: 46px; }
.pw-toggle { position: absolute; inset-inline-start: 6px; top: 6px; width: 34px; height: 34px; border: 0; background: transparent; color: var(--text-3); border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.pw-toggle:hover { color: var(--text); background: var(--surface-2); }
.pw-toggle svg { width: 18px; height: 18px; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.fade-in { animation: rise .45s var(--ease) both; }
.fade-in:nth-child(2) { animation-delay: .04s; }
.fade-in:nth-child(3) { animation-delay: .08s; }
.fade-in:nth-child(4) { animation-delay: .12s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .auth-lines path { stroke-dashoffset: 0; }
}
.section h2 svg { width: 18px; height: 18px; color: var(--accent-2); }
.tl-trigger svg { width: 13px; height: 13px; }

/* ---------------- costs ---------------- */
.bars { width: 100%; height: 260px; display: block; direction: ltr; }
.bars .bar { transition: opacity .15s; }
.bars .bar:hover { opacity: .8; }
.split-bar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--surface-3); gap: 2px; }
.split-bar span { display: block; height: 100%; }
.split-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.split-legend .k { font-size: 12.5px; color: var(--text-3); }
.split-legend .v { font-size: 20px; font-weight: 600; margin: 2px 0; }
.note-box { margin-top: 18px; padding: 12px 14px; border-radius: 11px; background: var(--bg-2); border: 1px solid var(--border); font-size: 13px; color: var(--text-2); line-height: 1.6; }
.share { display: inline-block; width: calc(100% - 44px); height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; vertical-align: middle; margin-inline-end: 8px; }
.share span { display: block; height: 100%; border-radius: 99px; }

/* hidden must win over display rules (filters) */
[hidden] { display: none !important; }

/* agent explanations */
.agent-card .tagline { font-size: 13px; color: var(--text-2); line-height: 1.55; margin-top: -4px; }
.agent-card .tagline b { color: var(--text); font-weight: 600; }
.hero .style b { color: var(--text); font-weight: 600; }
.section-intro { margin: 22px 2px 12px; }
.section-intro h2 { font-size: 17px; }
.section-intro p { margin-top: 4px; color: var(--text-2); font-size: 13.5px; line-height: 1.65; max-width: 860px; }
.section-intro b { color: var(--text); font-weight: 600; }
.about-body { display: grid; grid-template-columns: 1.4fr 1fr; gap: 26px; padding: 4px 22px 20px; }
.about-body .k { font-size: 12.5px; color: var(--text-3); margin-bottom: 8px; }
.about-body ul { margin: 0; padding-inline-start: 18px; display: grid; gap: 6px; color: var(--text-2); font-size: 14px; line-height: 1.6; }
.about-body p { margin: 0; color: var(--text-2); font-size: 14px; line-height: 1.65; }
.risk { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--text-3); }
.risk i { width: 16px; height: 6px; border-radius: 99px; background: var(--surface-3); }
.risk i.on { background: var(--c); }
.risk i:last-of-type { margin-inline-end: 4px; }

/* ---------------- responsive ----------------
   שלוש צורות: מחשב (סרגל צד רחב), טאבלט ומסך פנימי של מתקפל (סרגל צר),
   טלפון ומסך חיצוני של מתקפל (כותרת עליונה + סרגל לשוניות תחתון).
   env(safe-area-inset-*) שומר מרחק מהמגרעת ומפס הבית של האייפון. */
.nav-more, .sheet-backdrop { display: none; }

@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .settings { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { display: none; }
}

/* טאבלט / מתקפל פתוח */
@media (max-width: 1024px) and (min-width: 761px) and (min-height: 501px) {
  .shell { grid-template-columns: 224px minmax(0, 1fr); }
  .sidebar { padding: 18px 12px; }
  .main { padding: 22px 24px 50px; }
  .hero { flex-wrap: wrap; }
  .hero-stats { margin: 0; width: 100%; text-align: right; }
}

/* טלפון / מסך חיצוני של מתקפל, וגם טלפון לרוחב (מסך נמוך) */
@media (max-width: 760px), (max-width: 1024px) and (max-height: 500px) {
  html { -webkit-text-size-adjust: 100%; }
  .shell { display: block; min-height: 100dvh; }

  .sidebar {
    position: sticky; top: 0; z-index: 40; height: auto;
    flex-direction: row; align-items: center; gap: 10px;
    padding: calc(10px + env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
    border-inline-end: 0; border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg-2) 96%, transparent);
  }
  .brand { padding: 0; gap: 10px; min-width: 0; }
  .brand-mark { width: 32px; height: 32px; border-radius: 9px; }
  .brand-mark svg { width: 17px; height: 17px; }
  .brand-sub, .nav-label { display: none; }
  .sidebar-foot { margin: 0 auto 0 0; flex-direction: row; align-items: center; gap: 6px; }
  .watch-pill { padding: 7px 10px; font-size: 12px; white-space: nowrap; }
  .sidebar-foot .btn { width: 40px !important; height: 40px; padding: 0; justify-content: center !important; }
  .sidebar-foot .btn .label { display: none; }

  /* סרגל לשוניות תחתון */
  .nav:not(.agents-nav) {
    position: fixed; inset-inline: 0; bottom: 0; z-index: 50;
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px;
    padding: 6px max(6px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    background: var(--bg-2); border-top: 1px solid var(--border);
    box-shadow: 0 -10px 30px -12px rgba(0,0,0,.6);
  }
  .nav:not(.agents-nav) a, .nav-more {
    flex-direction: column; justify-content: center; gap: 3px;
    min-height: 50px; padding: 6px 2px; border-radius: 12px;
    font-size: 11px; font-weight: 500; white-space: nowrap; text-align: center;
  }
  .nav:not(.agents-nav) a.active { box-shadow: none; background: var(--surface-2); color: var(--text); }
  .nav:not(.agents-nav) svg { width: 21px; height: 21px; }
  .nav-more {
    display: flex; align-items: center; border: 0; background: transparent; color: var(--text-2);
    cursor: pointer; font: inherit; font-size: 11px; -webkit-tap-highlight-color: transparent;
  }
  .nav-more svg { width: 21px; height: 21px; }
  body.agents-open .nav-more { background: var(--surface-2); color: var(--text); }

  /* רשימת הסוכנים נפתחת כגיליון מלמטה */
  .agents-nav {
    position: fixed; z-index: 45; inset-inline: 10px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    max-height: min(62dvh, 520px); overflow-y: auto; overscroll-behavior: contain;
    padding: 8px; border-radius: 18px;
    background: var(--surface); border: 1px solid var(--border-2);
    box-shadow: 0 24px 60px -10px rgba(0,0,0,.75);
    transform: translateY(16px); opacity: 0; pointer-events: none;
    transition: transform .22s var(--ease), opacity .18s var(--ease);
  }
  .agents-nav a { min-height: 46px; font-size: 15px; }
  body.agents-open .agents-nav { transform: none; opacity: 1; pointer-events: auto; }
  .sheet-backdrop {
    /* מתחת לכותרת (z 40), שבתוכה נמצאים הגיליון וסרגל הלשוניות */
    display: block; position: fixed; inset: 0; z-index: 39;
    background: rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  body.agents-open .sheet-backdrop { opacity: 1; pointer-events: auto; }

  .main {
    padding: 18px max(14px, env(safe-area-inset-right)) calc(96px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }
  .topbar { flex-direction: column; align-items: stretch; gap: 14px; margin-bottom: 18px; }
  .topbar-actions { flex-wrap: wrap; }
  .topbar-actions > * { flex: 1 1 auto; }
  .topbar-actions .btn, .topbar-actions form .btn { width: 100%; justify-content: center; min-height: 44px; }
  h1 { font-size: 24px; }

  .kpis { gap: 10px; }
  .kpi { padding: 14px 15px; }
  .kpi-value { font-size: 22px !important; }
  .kpi-sub { font-size: 12px; }
  .grid, .agents { gap: 10px; }
  .agents { grid-template-columns: minmax(0, 1fr); }
  .card-head { flex-wrap: wrap; padding: 16px 16px 0; }
  .timeline { padding: 4px 16px 12px; }
  .filters { padding: 14px 16px 4px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .filters::-webkit-scrollbar { display: none; }
  .chip-btn { white-space: nowrap; min-height: 36px; flex: none; }
  .tl-head .when { margin-inline-start: 0; width: 100%; }
  .table th, .table td { padding: 10px 10px; }

  .hero { flex-wrap: wrap; padding: 18px; gap: 14px; }
  .hero .big { font-size: 28px; }
  .hero-stats { margin: 0; width: 100%; text-align: right; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 14px; }
  .about-body { grid-template-columns: minmax(0, 1fr); padding: 4px 16px 18px; gap: 18px; }
  .card-pad { padding: 16px; }
  .rules, .meta-list, .two { grid-template-columns: minmax(0, 1fr); }
  .split-legend { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

  /* iOS מגדיל את הדף כשמקלידים בשדה קטן מ-16px */
  .input, .input.ltr { font-size: 16px; }

  .auth { grid-template-columns: minmax(0, 1fr); min-height: 100dvh; }
  .auth-art { display: none; }
  .auth-panel { padding: calc(28px + env(safe-area-inset-top)) 20px calc(28px + env(safe-area-inset-bottom)); }
}

/* מסכים צרים במיוחד (iPhone SE, מסך חיצוני של מתקפל) */
@media (max-width: 380px) {
  .brand-name { font-size: 14px; }
  .watch-pill span:last-child { display: none; }
  .watch-pill { padding: 9px; }
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-legend { grid-template-columns: minmax(0, 1fr); }
  .nav:not(.agents-nav) a, .nav-more { font-size: 10.5px; }
}

/* טלפון לרוחב: הכותרת לא נדבקת למעלה כדי לחסוך גובה, והלשוניות נמוכות יותר */
@media (max-width: 1024px) and (max-height: 500px) {
  .sidebar { position: static; }
  .nav:not(.agents-nav) a, .nav-more { min-height: 40px; flex-direction: row; gap: 6px; font-size: 12px; }
  .agents-nav { bottom: calc(60px + env(safe-area-inset-bottom)); max-height: 70dvh; }
  .main { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
}
