:root {
  --navy: #22303C;
  --navy-2: #34495E;
  --gold: #B08D3C;
  --bg: #F5F6F8;
  --card: #FFFFFF;
  --text: #1F2937;
  --muted: #6B7280;
  --line: #E5E7EB;
  --ok: #16A34A;
  --ok-bg: #DCFCE7;
  --warn-bg: #FEF3C7;
  --bad: #DC2626;
  --bad-bg: #FEE2E2;
  --grey-bg: #F3F4F6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 1px 8px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Heebo', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--navy-2); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.loading { padding: 48px; text-align: center; color: var(--muted); }

/* ---------- סרגל עליון ---------- */
.topbar {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; white-space: nowrap; }
.brand-mark { background: #fff; border-radius: 8px; padding: 4px 5px; display: flex; }
.brand-mark img { height: 28px; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 16px; }
.brand-text small { font-size: 11.5px; color: var(--gold); letter-spacing: .3px; }
.topbar { border-bottom: 3px solid var(--gold); }
.login-logo { display: block; width: 100%; max-width: 300px; margin: 4px auto 18px; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: #CBD5E1;
  padding: 6px 12px;
  border-radius: 6px;
  white-space: nowrap;
}
.nav a.active { background: rgba(255,255,255,.12); color: #fff; }
.nav a.soon { opacity: .5; pointer-events: none; }
.nav a.soon::after { content: ' · בקרוב'; font-size: 12px; }
.user { display: flex; align-items: center; gap: 10px; white-space: nowrap; font-size: 14px; }
.user button {
  background: transparent; border: 1px solid rgba(255,255,255,.35); color: #fff;
  border-radius: 6px; padding: 3px 10px; cursor: pointer;
}
.demo-banner {
  background: var(--gold); color: #1F2937; text-align: center; font-size: 13px; padding: 4px 8px; font-weight: 500;
}

/* ---------- עמוד ---------- */
main { max-width: 1280px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; flex: 1; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card h2 { font-size: 16px; margin: 0; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card .body { padding: 16px 18px; }

/* ---------- כפתורים ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 14px;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--grey-bg); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- סינון ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--line); align-items: center; }
.filters input[type=search] { flex: 1; min-width: 200px; }
input[type=text], input[type=search], input[type=email], input[type=password], input[type=date], input[type=month], select, textarea {
  border: 1px solid #D1D5DB; border-radius: 8px; padding: 7px 10px; background: #fff; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #93C5FD; outline-offset: 0; border-color: #93C5FD; }
.count { color: var(--muted); font-size: 14px; }

/* ---------- טבלה ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: right; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 500; color: var(--muted); font-size: 13px; background: #FAFAFB; position: sticky; top: 0; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover { background: #F8FAFC; }
td.num { font-variant-numeric: tabular-nums; direction: ltr; text-align: right; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

/* ---------- תגיות ---------- */
.chip {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px;
  background: var(--grey-bg); color: #374151; margin-left: 4px; white-space: nowrap;
}
.chip.ok { background: var(--ok-bg); color: #166534; }
.chip.warn { background: var(--warn-bg); color: #92400E; }
.chip.bad { background: var(--bad-bg); color: #991B1B; }
.chip.muted { color: var(--muted); }
.chip.todo { background: #FCE4EC; color: #9D174D; }
.chip .x { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 4px 0 0; font: inherit; }
.card.todo-card { border-inline-start: 4px solid #EC4899; }
.sub-name { display: block; color: var(--muted); font-size: .85em; font-weight: normal; }

/* ---------- טופס ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 13px; color: var(--muted); }
.field.wide { grid-column: 1 / -1; }
.field .value { padding: 7px 0; min-height: 38px; }
textarea { min-height: 80px; resize: vertical; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.checks label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.savebar {
  position: sticky; bottom: 0; background: rgba(245,246,248,.95); padding: 12px 0; margin-top: 16px;
  display: flex; gap: 10px; align-items: center; justify-content: flex-start; border-top: 1px solid var(--line);
}
.msg { font-size: 14px; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--bad); }

/* ---------- כרטיס תיק ---------- */
.client-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.client-head h1 { margin: 0; font-size: 24px; }
.client-head .sub { color: var(--muted); }
.back { color: var(--muted); font-size: 14px; display: inline-block; margin-bottom: 8px; }
.cols { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-top: 16px; align-items: start; }
.cols > div { min-width: 0; }
.cols > div > .card + .card { margin-top: 16px; }
.history li { margin-bottom: 6px; font-size: 13px; }
.history .when { color: var(--muted); }

/* ---------- כניסה ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 380px; padding: 28px; }
.login h1 { margin: 0 0 4px; font-size: 22px; color: var(--navy); }
.login p { margin: 0 0 20px; color: var(--muted); }
.login .field { margin-bottom: 14px; }
.login .btn { width: 100%; padding: 10px; }

@media (max-width: 800px) {
  main { padding: 16px; }
  .topbar { padding: 0 16px; gap: 12px; }
  .cols { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .brand-text { display: none; }
}

/* ---------- דיווחים שוטפים ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.active { color: var(--navy); border-bottom-color: var(--gold); font-weight: 500; }
.month-picker { display: flex; align-items: center; gap: 8px; }
.month-picker strong { min-width: 120px; text-align: center; }
.month-picker .btn { padding: 4px 12px; }
.hint { color: var(--muted); font-size: 13px; margin: 10px 2px; }
label.inline { display: flex; align-items: center; gap: 6px; white-space: nowrap; cursor: pointer; }
.late-text { color: var(--bad); font-weight: 500; }
.soon-text { color: #B45309; font-weight: 500; }

.grid-wrap { max-height: calc(100vh - 260px); }
.grid-table th.colhead { min-width: 104px; font-size: 12px; line-height: 1.3; vertical-align: bottom; z-index: 2; }
.grid-table th.colhead .sub { color: #9CA3AF; font-weight: 400; }
.grid-table th.rowhead { position: sticky; right: 0; background: #fff; z-index: 1; min-width: 170px; font-weight: 500; color: var(--text); font-size: 14px; }
.grid-table thead th.rowhead { z-index: 3; background: #FAFAFB; color: var(--muted); }
.grid-table td.cell { padding: 4px; text-align: center; }
.grid-table td.cell.na { color: #D1D5DB; }
.status {
  width: 100%; border: 2px solid transparent; border-radius: 6px; padding: 4px 6px; font-size: 12px; cursor: pointer;
  white-space: nowrap; color: #1F2937;
}
.status:hover { filter: brightness(.95); }
td.cell.late .status { border-color: var(--bad); }
td.cell.soon .status { border-color: #F59E0B; }

/* ---------- חלון ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(17,24,39,.45); display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px 16px; z-index: 50; overflow-y: auto;
}
.modal { width: 100%; max-width: 560px; }
.modal h3 { font-size: 14px; margin: 16px 0 8px; color: var(--navy); }
.modal-actions { position: static; background: none; padding: 12px 18px; margin: 0; }
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  display: inline-block; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); cursor: pointer; font-size: 13px; background: #fff;
}
.choice input:checked + span { background: var(--c); border-color: #374151; font-weight: 500; }
.choice input:focus-visible + span { outline: 2px solid #93C5FD; }
.choice input:disabled + span { cursor: default; opacity: .6; }
.choice input:disabled:checked + span { opacity: 1; }

[hidden] { display: none !important; }

/* ---------- דוחות שנתיים ---------- */
.stats { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: stretch; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 16px; min-width: 150px; box-shadow: var(--shadow); }
.stat-num { font-size: 24px; font-weight: 700; color: var(--navy); }
.stat-num span { font-size: 15px; color: var(--muted); font-weight: 400; }
.stat-label { font-size: 13px; color: var(--muted); }
.bar { height: 5px; background: var(--grey-bg); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--gold); }
.stage-pill { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 12px; cursor: pointer; align-self: center; font-size: 13px; }
.stage-pill b { background: var(--c); border-radius: 999px; padding: 0 7px; margin-right: 4px; }
.stage-pill.on { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }
ul.missing { list-style: none; padding: 0; margin: 0; }
.missing-item { display: flex; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.missing-item label { display: flex; align-items: center; gap: 8px; flex: 1; cursor: pointer; }
.missing-item.got span { text-decoration: line-through; color: var(--muted); }
.add-row { display: flex; gap: 8px; margin-top: 8px; }
.add-row input { flex: 1; }
.link-btn { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px 6px; }
.link-btn:hover { color: var(--bad); }

/* ---------- שכר טרחה ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px; display: flex; flex-direction: column; gap: 2px; border-inline-start: 4px solid var(--gold); }
.tile span { color: var(--muted); font-size: 13px; }
.tile strong { font-size: 22px; color: var(--navy); }
.tile small { color: var(--muted); }
.btn.small { padding: 3px 10px; font-size: 13px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; }
.big-balance { font-size: 22px; font-weight: 700; }
tr.muted-row td { color: var(--muted); }
.filed-by { display: block; font-size: 10px; color: #4B5563; font-weight: 400; }

.sub-tabs { border-bottom: 0; margin-top: -8px; }
.sub-tabs a { border: 1px solid var(--line); border-radius: 999px; margin: 0 0 0 6px; padding: 4px 14px; }
.sub-tabs a.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* שדה לא רלוונטי לסוג הישות */
.na-field { background: #F3F4F6 !important; color: #9CA3AF !important; cursor: not-allowed; }
.na-warn { border-color: #F59E0B !important; background: #FFFBEB !important; }

.alert-card { border-inline-start: 4px solid #F59E0B; background: #FFFBEB; margin-bottom: 12px; }
#fee-tabs { margin-bottom: 12px; }
