/* ─── תיקתק פיננסי — Cinematic Dark DNA ─────────────────────────────── */
:root {
  --bg: #0a0a0a;
  --surface: #0f0f10;
  --glass: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.08);
  --text: #fafafa;
  --text-2: #a1a1aa;
  --text-3: #71717a;
  --profit: #0d9488;   /* מאומת CVD מול הפסד */
  --loss: #ea580c;
  --profit-soft: rgba(13, 148, 136, 0.14);
  --loss-soft: rgba(234, 88, 12, 0.14);
  --mobile: #0891b2;   /* מאומת CVD מול חשמל */
  --electric: #7c3aed;
  --accent: linear-gradient(135deg, #00d4ff, #b366ff);
  --radius: 14px;
  --font: 'Heebo', -apple-system, 'Segoe UI', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { background: var(--bg); overflow-x: hidden; max-width: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100%;
}

/* רקע עומק עדין */
body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(0, 212, 255, 0.05), transparent 60%),
    radial-gradient(1000px 500px at 10% 110%, rgba(179, 102, 255, 0.05), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ─── סמן מותאם (מוסתר במגע) ─── */
.cursor {
  position: fixed; top: 0; left: 0;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  mix-blend-mode: difference;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
}
@media (pointer: coarse) {
  .cursor { display: none; }
}
@media (pointer: fine) {
  body { cursor: none; }
  a, button, select, input, label, td, th { cursor: none; }
}

/* ─── מעטפת ─── */
.app {
  position: relative; z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px 20px 80px;
  overflow-x: hidden;
}
.chart-box { max-width: 100%; overflow-x: auto; }

/* ─── כותרת עליונה ─── */
header.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 14px 20px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  position: sticky; top: 12px; z-index: 100;
  will-change: transform, opacity;
}
.brand { font-weight: 800; font-size: 19px; letter-spacing: -0.01em; white-space: nowrap; }
.brand small { font-weight: 300; color: var(--text-2); margin-inline-start: 6px; }

.status-chip {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--text-2);
  white-space: nowrap;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.status-dot.ok { background: #22c55e; box-shadow: 0 0 8px rgba(34, 197, 94, 0.7); }
.status-dot.err { background: var(--loss); box-shadow: 0 0 8px rgba(234, 88, 12, 0.7); }

nav.tabs { display: flex; gap: 4px; margin-inline-start: auto; }
nav.tabs button {
  font-family: var(--font);
  font-size: 14px; font-weight: 600;
  color: var(--text-2);
  background: transparent;
  border: none;
  padding: 8px 14px;
  border-radius: 9px;
  transition: color 0.3s, background 0.3s;
}
nav.tabs button:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
nav.tabs button.active { color: var(--text); background: rgba(255, 255, 255, 0.09); }

.btn {
  font-family: var(--font);
  font-size: 13.5px; font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--glass-border);
  padding: 8px 16px;
  border-radius: 9px;
  transition: background 0.3s, border-color 0.3s, transform 0.2s;
}
.btn:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.2); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: rgba(0, 212, 255, 0.13); border-color: rgba(0, 212, 255, 0.35); }
.btn.primary:hover { background: rgba(0, 212, 255, 0.22); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

/* ─── תצוגות ─── */
.view { display: none; }
.view.active { display: block; }

.view-head {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin: 26px 2px 18px;
}
.view-head h1 {
  font-size: 26px; font-weight: 800; letter-spacing: -0.02em;
  overflow: hidden; /* מסכת reveal */
}
.view-head h1 .line { display: inline-block; will-change: transform; }

.live-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700;
  color: #22c55e;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.25);
  padding: 3px 11px; border-radius: 99px;
}
.live-badge .pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: #22c55e;
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); }
  70% { box-shadow: 0 0 0 9px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

input[type="date"], input[type="month"], input[type="text"], input[type="password"], input[type="number"], select {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  border-radius: 9px;
  padding: 7px 12px;
  outline: none;
  transition: border-color 0.3s;
  color-scheme: dark;
}
input:focus, select:focus { border-color: rgba(0, 212, 255, 0.5); }

/* ─── כרטיסי KPI ─── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(20px);
  padding: 16px 18px 14px;
  will-change: transform, opacity;
  position: relative;
  overflow: hidden;
}
.kpi .label { font-size: 12.5px; color: var(--text-2); font-weight: 400; margin-bottom: 4px; }
.kpi .value {
  font-size: 27px; font-weight: 800; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  direction: ltr; text-align: right;
}
.kpi .sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.kpi.hero { grid-column: span 2; }
.kpi.hero .value { font-size: 38px; }
.kpi .value.pos { color: var(--profit); }
.kpi .value.neg { color: var(--loss); }
.kpi.hero::after {
  content: '';
  position: absolute; inset-inline-start: 0; top: 0; bottom: 0;
  width: 3px;
}
.kpi.hero.pos::after { background: var(--profit); }
.kpi.hero.neg::after { background: var(--loss); }

/* ─── פס "החודש עד עכשיו" במסך הלייב ─── */
.month-strip {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 20px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(20px);
  padding: 12px 18px;
  margin-bottom: 18px;
  font-size: 14px; color: var(--text-2);
  will-change: transform, opacity;
}
.month-strip .ms-label {
  font-weight: 700; color: var(--text);
  padding-inline-end: 14px;
  border-inline-end: 1px solid var(--glass-border);
}
.month-strip .ms-item b {
  color: var(--text); font-weight: 700;
  font-variant-numeric: tabular-nums; direction: ltr;
  margin-inline-start: 4px;
}
.month-strip .ms-muted { color: var(--text-3); font-size: 12.5px; margin-inline-start: auto; }
.month-strip b.pos { color: var(--profit) !important; }
.month-strip b.neg { color: var(--loss) !important; }

/* ─── פאנלים ─── */
.panel {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(20px);
  padding: 18px 20px;
  margin-bottom: 16px;
  will-change: transform, opacity;
}
.panel h2 {
  font-size: 16px; font-weight: 700;
  display: flex; align-items: center; gap: 9px;
  margin-bottom: 14px;
}
.panel h2 .team-dot { width: 10px; height: 10px; border-radius: 3px; }
.panel h2 .team-dot.mobile { background: var(--mobile); }
.panel h2 .team-dot.electric { background: var(--electric); }
.panel h2 .spacer { margin-inline-start: auto; font-size: 12.5px; font-weight: 400; color: var(--text-3); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

.mini-kpis {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; margin-bottom: 13px;
}
.mini-kpi {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  padding: 9px 12px;
}
.mini-kpi .label { font-size: 11.5px; color: var(--text-3); }
.mini-kpi .value {
  font-size: 17px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  direction: ltr; text-align: right;
}
.mini-kpi .value.pos { color: var(--profit); }
.mini-kpi .value.neg { color: var(--loss); }

/* ─── טבלאות נציגים ─── */
.table-wrap { overflow-x: auto; }
table.reps {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.reps th {
  font-size: 11.5px; font-weight: 600; color: var(--text-3);
  text-align: right;
  padding: 6px 9px;
  border-bottom: 1px solid var(--glass-border);
  white-space: nowrap;
}
table.reps td {
  padding: 7px 9px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
table.reps tr:last-child td { border-bottom: none; }
table.reps tr { transition: background 0.25s; }
table.reps tbody tr:hover { background: rgba(255, 255, 255, 0.035); }
td.num { direction: ltr; text-align: right; }
td.pos { color: var(--profit); font-weight: 700; }
td.neg { color: var(--loss); font-weight: 700; }
.shift-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-3); opacity: 0.35;
  margin-inline-end: 7px;
}
.shift-dot.on { background: #22c55e; opacity: 1; box-shadow: 0 0 7px rgba(34, 197, 94, 0.8); }
.rate-warn { color: var(--loss); font-size: 11px; margin-inline-start: 5px; }

/* ─── heatmap ניודים לפי שעה ─── */
table.porter-heat th { text-align: center; font-size: 11px; }
table.porter-heat th:first-child { text-align: right; }
table.porter-heat td.heat { text-align: center; border-radius: 4px; min-width: 30px; transition: background 0.4s; }
table.porter-heat td:first-child { white-space: nowrap; }
table.porter-heat th.hcol { font-size: 10px; line-height: 1.15; min-width: 30px; color: var(--text-3); }
table.porter-heat th.hcol.cur, table.porter-heat td.heat.cur, table.porter-heat td.cur {
  outline: 2px solid var(--profit); outline-offset: -2px;
}
table.porter-heat th.hcol.cur { color: var(--profit); font-weight: 700; }
table.porter-heat .sumcol { border-inline-start: 2px solid var(--glass-border); }

/* ─── כפתור החלפה מכירות/ניודים ─── */
.toggle-group {
  display: inline-flex; gap: 2px; margin-inline-start: 12px;
  background: rgba(255,255,255,0.05); border-radius: 9px; padding: 3px;
  vertical-align: middle;
}
.toggle-btn {
  font-family: var(--font); font-size: 13px; font-weight: 600;
  color: var(--text-2); background: transparent; border: none;
  padding: 5px 14px; border-radius: 7px; transition: all 0.25s;
}
.toggle-btn:hover { color: var(--text); }
.toggle-btn.active { color: var(--text); background: rgba(0,212,255,0.15); }
table.porter-heat tr.porter-total td {
  border-top: 2px solid var(--glass-border);
  font-weight: 700; color: var(--text-2);
}
table.porter-heat thead th:nth-child(2),
table.porter-heat tbody td:nth-child(2) {
  border-inline-start: 1px solid var(--glass-border);
}
table.porter-heat thead th:nth-child(4),
table.porter-heat tbody td:nth-child(4) {
  border-inline-end: 2px solid var(--glass-border);
}

/* ─── גרפים ─── */
.chart-box { direction: ltr; }
.chart-box svg { display: block; width: 100%; height: auto; }
.chart-tooltip {
  position: fixed;
  background: rgba(20, 20, 22, 0.97);
  border: 1px solid var(--glass-border);
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 12.5px;
  pointer-events: none;
  z-index: 999;
  direction: rtl;
  display: none;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
.chart-tooltip b { font-variant-numeric: tabular-nums; }
.chart-tooltip .tip-table { border-collapse: collapse; margin-top: 7px; font-size: 12.5px; }
.chart-tooltip .tip-table th, .chart-tooltip .tip-table td { padding: 3px 9px; text-align: center; white-space: nowrap; }
.chart-tooltip .tip-table th { font-weight: 700; border-bottom: 1px solid var(--glass-border); padding-bottom: 4px; }
.chart-tooltip .tip-table td { font-variant-numeric: tabular-nums; direction: ltr; }
.chart-tooltip .tip-table th:first-child { color: var(--text-3); font-weight: 400; }
.chart-tooltip .tip-table td:first-child {
  text-align: right; direction: rtl; color: var(--text-2); font-weight: 400;
  border-inline-end: 1px solid var(--glass-border);
}
.bar { transition: opacity 0.2s; }
.bar:hover { opacity: 0.75; }

/* ─── התראות ─── */
.alerts-banner { margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
.alert-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--loss-soft);
  border: 1px solid rgba(234, 88, 12, 0.3);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13.5px;
}
.alert-item .ack {
  margin-inline-start: auto;
  background: none; border: none;
  color: var(--text-2); font-size: 16px;
  font-family: var(--font);
}
.alert-item .ack:hover { color: var(--text); }

/* ─── מודאל התחברות ─── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  z-index: 500;
  display: none;
  align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: min(400px, 92vw);
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 30px 28px;
  will-change: transform, opacity;
}
.modal h3 { font-size: 19px; font-weight: 800; margin-bottom: 6px; }
.modal p { font-size: 13.5px; color: var(--text-2); margin-bottom: 18px; }
.modal .field { margin-bottom: 12px; }
.modal .field label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 5px; }
.modal .field input { width: 100%; }
.modal .error { color: var(--loss); font-size: 13px; margin: 8px 0; min-height: 18px; }
.modal .actions { display: flex; gap: 10px; margin-top: 14px; }
.modal .actions .btn { flex: 1; }
.linklike {
  display: block; width: 100%; margin-top: 14px;
  background: none; border: none;
  font-family: var(--font); font-size: 13px;
  color: #00d4ff; text-align: center;
  transition: opacity 0.2s;
}
.linklike:hover { opacity: 0.75; text-decoration: underline; }

/* ─── הגדרות ─── */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.setting-field label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 4px; }
.setting-field input, .setting-field select { width: 100%; }
.settings-actions { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; }

/* ─── השוואה ─── */
.compare-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.compare-card { text-align: center; padding: 24px 18px; }
.compare-card .title { font-size: 15px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.compare-card .big {
  font-size: 34px; font-weight: 800;
  font-variant-numeric: tabular-nums; direction: ltr;
}
.compare-card .big.pos { color: var(--profit); }
.compare-card .big.neg { color: var(--loss); }
.compare-card .rows { margin-top: 14px; text-align: right; font-size: 13.5px; }
.compare-card .rows div { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.compare-card .rows div:last-child { border-bottom: none; }
.compare-card .rows span:last-child { direction: ltr; font-variant-numeric: tabular-nums; }

/* ─── שלד טעינה ─── */
.skeleton { color: transparent !important; background: rgba(255,255,255,0.06); border-radius: 6px; animation: shimmer 1.4s ease-in-out infinite; }
@keyframes shimmer { 50% { opacity: 0.45; } }

.reconcile-note { font-size: 12px; color: var(--text-3); margin-top: 8px; }
.reconcile-note.warn { color: #eab308; }

footer.app-footer {
  margin-top: 30px; text-align: center;
  font-size: 12px; color: var(--text-3);
}

@media (max-width: 720px) {
  .kpi.hero { grid-column: span 1; }
  .kpi .value { font-size: 22px; }
  .kpi.hero .value { font-size: 28px; }
  header.topbar { flex-wrap: wrap; gap: 10px; }
  nav.tabs { margin-inline-start: 0; width: 100%; overflow-x: auto; }
  .mini-kpis { grid-template-columns: repeat(2, 1fr); }
}
