/* ================================================================
   SecondNature Finance — ערכת "Open Fintech"
   בהשראת open-finance.ai: גרדיאנט סגול→כחול, כרטיסים לבנים,
   צללים רכים כחלחלים, צ'יפים פסטליים, טיפוגרפיה נקייה.
================================================================ */
:root {
  /* משטחים */
  --page: #f5f7fe;
  --surface: #ffffff;
  --surface-2: #f8faff;

  /* דיו */
  --ink: #0f172a;
  --ink-2: #475569;
  --muted: #94a3b8;

  /* מותג */
  --brand: #2563eb;
  --brand-deep: #1d4ed8;
  --brand-darker: #1e40af;
  --violet: #7c3aed;
  --grad: linear-gradient(120deg, #7c3aed 0%, #4f46e5 45%, #2563eb 100%);
  --grad-blue: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);

  /* סטטוס */
  --good: #0f9d6e;  --good-bg: #e7f8f0;
  --warn: #b45309;  --warn-bg: #fef5e0;
  --crit: #dc2626;  --crit-bg: #fdecec;
  --info: #2563eb;  --info-bg: #eaf1fe;
  --violet-bg: #f1edfd;
  --pink: #db2777;  --pink-bg: #fce9f3;

  /* גרפים */
  --grid: #e8ecf7;
  --baseline: #cbd5e8;
  --border: #e6eaf5;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(30, 64, 175, .04), 0 10px 34px rgba(37, 99, 235, .07);
  --shadow-lift: 0 4px 10px rgba(30, 64, 175, .08), 0 18px 50px rgba(37, 99, 235, .13);
  --sidebar-w: 256px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: light; }
body {
  font-family: 'Heebo', system-ui, -apple-system, "Segoe UI", sans-serif;
  background:
    radial-gradient(900px 380px at 85% -80px, rgba(124, 58, 237, .07), transparent 60%),
    radial-gradient(900px 380px at 10% -120px, rgba(37, 99, 235, .08), transparent 60%),
    var(--page);
  color: var(--ink);
  min-height: 100vh; font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- פס עליון גרדיאנט ---------- */
.promo-strip {
  position: fixed; inset-inline: 0; top: 0; height: 4px;
  background: var(--grad); z-index: 40;
}

/* ---------- סיידבר ---------- */
.sidebar {
  position: fixed; inset-block: 0; inset-inline-start: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 26px 16px 20px; z-index: 20;
}
.logo { display: flex; align-items: center; gap: 12px; padding: 2px 8px 22px; }
.logo-mark {
  width: 42px; height: 42px; border-radius: 13px; flex: 0 0 auto;
  background: var(--grad);
  color: #fff; font-weight: 800; font-size: 20px;
  display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(79, 70, 229, .35);
}
.logo-name { font-weight: 800; font-size: 15.5px; letter-spacing: -.01em; }
.logo-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.nav-sec {
  font-size: 11px; color: var(--muted); font-weight: 700;
  letter-spacing: .08em; margin: 18px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 11px; color: var(--ink-2);
  text-decoration: none; font-weight: 500; margin-bottom: 3px; font-size: 14px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active {
  background: var(--info-bg); color: var(--brand); font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, .14);
}
.ni { width: 20px; text-align: center; opacity: .9; }
.sidebar-foot { margin-top: auto; padding-top: 14px; }
.sidebar-foot .tip-box {
  background: var(--grad); border-radius: 14px; color: #fff;
  padding: 14px 15px; font-size: 12.5px; line-height: 1.55;
  box-shadow: 0 10px 26px rgba(79, 70, 229, .3);
}
.tip-box b { display: block; font-size: 13px; margin-bottom: 3px; }
.guide-btn {
  width: 100%; margin-top: 10px; padding: 10px;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink-2); font-family: inherit;
  font-size: 13.5px; font-weight: 700; cursor: pointer; transition: all .15s;
}
.guide-btn:hover { border-color: #c9d4f2; color: var(--brand); }

/* ---------- Onboarding ---------- */
.onb { max-width: 560px; padding: 0; overflow: hidden; }
.onb-hero {
  background: var(--grad); color: #fff; padding: 34px 30px 28px;
  text-align: center;
}
.onb-hero .onb-emoji { font-size: 44px; display: block; margin-bottom: 12px; }
.onb-hero h2 { color: #fff; font-size: 22px; font-weight: 800; margin: 0 0 6px; letter-spacing: -.01em; }
.onb-hero p { color: rgba(255,255,255,.85); font-size: 14px; line-height: 1.6; max-width: 420px; margin: 0 auto; }
.onb-body { padding: 22px 30px 26px; }
.onb-points { display: grid; gap: 10px; margin-bottom: 20px; }
.onb-point {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 13px; padding: 12px 14px; font-size: 13.5px; line-height: 1.55;
}
.onb-point .pi { font-size: 18px; flex: 0 0 auto; }
.onb-point b { display: block; font-size: 13.5px; }
.onb-point span { color: var(--ink-2); }
.onb-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.onb-dots { display: flex; gap: 6px; }
.onb-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--grid); transition: all .2s; }
.onb-dot.on { background: var(--brand); width: 22px; border-radius: 99px; }
.onb-skip { background: none; border: none; color: var(--muted); font-family: inherit; font-size: 13px; cursor: pointer; font-weight: 600; }
.onb-skip:hover { color: var(--ink-2); }

/* ---------- ראשי ---------- */
.main { margin-inline-start: var(--sidebar-w); padding: 30px 36px 130px; max-width: 1320px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; gap: 12px; flex-wrap: wrap; }
.topbar h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.month-picker { min-width: 150px; font-weight: 600; }

/* ---------- כפתורים ושדות ---------- */
.btn {
  padding: 10px 18px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 600;
  transition: all .16s;
}
.btn:hover { border-color: #c9d4f2; box-shadow: 0 4px 14px rgba(37, 99, 235, .1); transform: translateY(-1px); }
.btn-primary {
  background: var(--brand); border-color: var(--brand); color: #fff;
  box-shadow: 0 6px 16px rgba(37, 99, 235, .28);
}
.btn-primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); }
.btn-danger { color: var(--crit); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 9px; box-shadow: none; }
.input, select.input, textarea.input {
  padding: 10px 13px; border-radius: 11px; border: 1.5px solid var(--border);
  background: var(--surface); font-family: inherit; font-size: 14px; color: var(--ink);
  outline: none; width: 100%; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(37, 99, 235, .12); }
select.input { width: auto; }

/* ---------- כרטיסים ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px;
}
.card h3 { font-size: 15.5px; font-weight: 700; margin-bottom: 15px; letter-spacing: -.01em; }
.card .sub { color: var(--muted); font-size: 12.5px; font-weight: 400; }

/* ---------- KPI ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { padding: 20px 22px; transition: transform .18s, box-shadow .18s; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.kpi .kpi-label { font-size: 13px; color: var(--ink-2); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.kpi .dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.kpi .kpi-value { font-size: 30px; font-weight: 800; margin-top: 8px; letter-spacing: -.03em; }
.kpi .kpi-foot { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.kpi-value.neg { color: var(--crit); }
.kpi-value.pos { color: var(--good); }

/* KPI ראשי — גרדיאנט כחול מלא, כמו הכרטיס הכחול באתר ההשראה */
.kpi.hero {
  background: var(--grad-blue); border: none; color: #fff;
  box-shadow: 0 14px 36px rgba(30, 64, 175, .35);
}
.kpi.hero .kpi-label { color: rgba(255, 255, 255, .85); }
.kpi.hero .kpi-value { color: #fff; }
.kpi.hero .kpi-foot { color: rgba(255, 255, 255, .7); }
.kpi.hero .dot { background: #fff !important; }
/* KPI שלילי — ורדרד כמו כרטיס העמלות */
.kpi.alert { background: var(--crit-bg); border-color: rgba(220, 38, 38, .15); }
.kpi.alert .kpi-value { color: var(--crit); }

/* ---------- גריד ---------- */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-32 { grid-template-columns: 3fr 2fr; }
@media (max-width: 1000px) { .grid-2, .grid-32 { grid-template-columns: 1fr; } }
.mb { margin-bottom: 18px; }

/* ---------- תובנות ---------- */
.insight {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 12px 15px; border-radius: 13px; margin-bottom: 9px;
  font-size: 14px; line-height: 1.55; border: 1px solid transparent;
}
.insight .ic { font-size: 15px; flex: 0 0 auto; margin-top: 1px; }
.insight.good { background: var(--good-bg); border-color: rgba(15, 157, 110, .18); }
.insight.warn { background: var(--warn-bg); border-color: rgba(180, 83, 9, .16); }
.insight.crit { background: var(--crit-bg); border-color: rgba(220, 38, 38, .16); }
.insight.info { background: var(--info-bg); border-color: rgba(37, 99, 235, .14); }

/* ---------- טבלאות ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  text-align: right; font-size: 11.5px; color: var(--muted); font-weight: 700;
  letter-spacing: .04em; padding: 9px 11px; border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}
.tbl td { padding: 11px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.num { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- תגיות (צ'יפים פסטליים) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 700; padding: 4px 11px; border-radius: 999px;
  white-space: nowrap;
}
.badge.paid { background: var(--good-bg); color: var(--good); }
.badge.unpaid { background: var(--crit-bg); color: var(--crit); }
.badge.pending { background: var(--warn-bg); color: var(--warn); }
.badge.open { background: var(--info-bg); color: var(--brand); }
.badge.won { background: var(--good-bg); color: var(--good); }
.badge.lost { background: #f1f5f9; color: var(--muted); }
.badge.pipeline { background: var(--violet-bg); color: var(--violet); }

.chk { width: 19px; height: 19px; accent-color: var(--brand); cursor: pointer; }

/* ---------- גרפים ---------- */
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 320px; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 12px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
.legend .li { display: flex; align-items: center; gap: 7px; }
.legend .sw { width: 13px; height: 13px; border-radius: 4px; }

/* ---------- מודאל ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(3px);
  display: none; align-items: flex-start; justify-content: center; z-index: 50;
  padding: 6vh 16px; overflow: auto;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--surface); border-radius: 20px; box-shadow: 0 30px 80px rgba(15, 23, 42, .3);
  width: 100%; max-width: 530px; padding: 26px;
  animation: modalIn .18s ease-out;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal h2 { font-size: 19px; font-weight: 800; margin-bottom: 18px; letter-spacing: -.01em; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-2); margin-bottom: 5px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-start; margin-top: 22px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 14px; padding-top: 22px; }

/* ---------- צ'אט — "Ask anything" צף ---------- */
.ask-bar {
  position: fixed; inset-block-end: 26px; inset-inline-start: calc(50% + var(--sidebar-w) / 2);
  transform: translateX(50%);
  width: min(560px, calc(100vw - var(--sidebar-w) - 60px));
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px;
  box-shadow: 0 14px 44px rgba(30, 64, 175, .18);
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px 8px 8px; z-index: 45; cursor: text;
  transition: box-shadow .2s, transform .2s;
}
.ask-bar:hover { box-shadow: 0 18px 54px rgba(30, 64, 175, .26); }
.ask-bar .ask-icon {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto;
  background: var(--grad); color: #fff; display: grid; place-items: center; font-size: 15px;
}
.ask-bar input {
  flex: 1; border: none; outline: none; background: none;
  font-family: inherit; font-size: 14.5px; color: var(--ink);
}
.ask-bar input::placeholder { color: var(--muted); }
.ask-bar .ask-send {
  width: 34px; height: 34px; border-radius: 50%; border: none; cursor: pointer; flex: 0 0 auto;
  background: var(--brand); color: #fff; font-size: 15px; display: grid; place-items: center;
  transition: background .15s;
}
.ask-bar .ask-send:hover { background: var(--brand-deep); }

.chat-panel {
  position: fixed; inset-block-end: 88px; inset-inline-start: calc(50% + var(--sidebar-w) / 2);
  transform: translateX(50%);
  width: min(560px, calc(100vw - var(--sidebar-w) - 60px)); height: 480px; max-height: calc(100vh - 140px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px;
  box-shadow: 0 30px 90px rgba(30, 64, 175, .3);
  display: none; flex-direction: column; z-index: 46; overflow: hidden;
  animation: modalIn .2s ease-out;
}
.chat-panel.show { display: flex; }
.chat-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 15px 20px; border-bottom: 1px solid var(--grid);
  background: linear-gradient(120deg, rgba(124, 58, 237, .07), rgba(37, 99, 235, .07));
}
.chat-head strong { font-weight: 800; }
.chat-sub { font-size: 12px; color: var(--muted); }
.chat-close { background: none; border: none; font-size: 16px; cursor: pointer; color: var(--muted); }
.chat-body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg {
  max-width: 85%; padding: 11px 15px; border-radius: 16px;
  font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
}
.chat-msg.bot { background: var(--surface-2); border: 1px solid var(--border); align-self: flex-start; border-start-start-radius: 5px; }
.chat-msg.user { background: var(--grad-blue); color: #fff; align-self: flex-end; border-start-end-radius: 5px; }
.chat-msg.typing { color: var(--muted); font-style: italic; }

/* ---------- טוסט ---------- */
.toast {
  position: fixed; inset-block-end: 96px; inset-inline-start: 50%;
  transform: translateX(50%);
  background: var(--ink); color: #fff;
  padding: 12px 22px; border-radius: 14px; font-size: 14px; font-weight: 600;
  box-shadow: 0 12px 34px rgba(15, 23, 42, .3);
  opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 100;
}
.toast.show { opacity: 1; }

/* ---------- שונות ---------- */
.empty { text-align: center; color: var(--muted); padding: 34px 10px; font-size: 14px; }
.row-flex { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 15px; }
.pill {
  padding: 7px 16px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); font-size: 13px; cursor: pointer; font-family: inherit;
  color: var(--ink-2); font-weight: 600; transition: all .14s;
}
.pill:hover { border-color: #c9d4f2; }
.pill.active { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 4px 12px rgba(37, 99, 235, .25); }
.link { color: var(--brand); cursor: pointer; text-decoration: none; font-weight: 700; }
.link:hover { text-decoration: underline; }
.icon-btn { background: none; border: none; cursor: pointer; font-size: 15px; color: var(--muted); padding: 4px; border-radius: 7px; transition: color .13s; }
.icon-btn:hover { color: var(--crit); }
.client-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.stat-inline { display: flex; gap: 30px; flex-wrap: wrap; }
.stat-inline .si b { font-size: 22px; display: block; font-weight: 800; letter-spacing: -.02em; }
.stat-inline .si span { font-size: 12.5px; color: var(--muted); }

@media (max-width: 860px) {
  .sidebar { position: static; width: 100%; flex-direction: row; overflow-x: auto; padding: 10px; align-items: center; }
  .sidebar nav { display: flex; gap: 4px; }
  .nav-sec, .logo-sub, .sidebar-foot { display: none; }
  .main { margin-inline-start: 0; padding: 16px 16px 120px; }
  .ask-bar, .chat-panel { inset-inline-start: 50%; width: min(560px, calc(100vw - 32px)); }
}
