:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #0d9488;
  --brand-dark: #0f766e;
  --navy: #16244a;
  --pink: #e05068;
  --danger: #dc2626;
  --warn: #f59e0b;
  --info: #6366f1;
  --ok: #16a34a;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg); color: var(--ink); direction: rtl;
}
button { font-family: inherit; cursor: pointer; border: none; border-radius: 8px; padding: 8px 14px; font-size: 14px; }
button.primary { background: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-dark); }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
button.ghost:hover { background: #f8fafc; }
button.danger { background: var(--danger); color: #fff; }
button.small { padding: 4px 8px; font-size: 12px; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 6px 0 0; }

/* ===== login ===== */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--card); padding: 36px 32px; border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,.1); width: 340px; text-align: center;
}
.login-logo { background: var(--navy); border-radius: 12px; padding: 18px 22px; margin-bottom: 10px; }
.login-logo img { display: block; width: 100%; height: auto; }
.login-card h1 { margin: 0; color: var(--brand); font-size: 30px; }
.login-card .sub { color: var(--muted); margin: 4px 0 22px; }
.login-card form { text-align: right; }
.login-card label { display: block; margin-bottom: 14px; font-size: 14px; color: var(--muted); }
.login-card input { width: 100%; margin-top: 4px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; }
.login-card button { width: 100%; background: var(--brand); color: #fff; padding: 11px; font-size: 15px; margin-top: 4px; }
.login-card .note { color: var(--muted); font-size: 12px; margin-top: 18px; }

/* ===== topbar ===== */
.topbar { background: var(--navy); padding: 0 20px; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.brand { display: flex; align-items: center; gap: 10px; padding: 10px 0 6px; }
.brand-logo { height: 42px; width: auto; display: block; }
.brand span { color: rgba(255,255,255,.7); font-weight: 400; font-size: 15px; }
.top-actions { display: flex; align-items: center; gap: 8px; padding-bottom: 8px; }
.tab { background: transparent; color: rgba(255,255,255,.7); border-radius: 8px 8px 0 0; border-bottom: 3px solid transparent; }
.tab:hover { color: #fff; }
.tab.active { color: #fff; font-weight: 700; border-bottom-color: var(--pink); }
#who { color: rgba(255,255,255,.85); font-size: 14px; margin-left: 6px; }
.topbar button.ghost { background: transparent; border: 1px solid rgba(255,255,255,.35); color: #fff; }
.topbar button.ghost:hover { background: rgba(255,255,255,.12); }

main { max-width: 1200px; margin: 22px auto; padding: 0 20px; }

/* ===== stats ===== */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--card); border-radius: 12px; padding: 16px; border: 1px solid var(--line); }
.stat .num { font-size: 28px; font-weight: 800; }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stat.ok .num { color: var(--ok); }
.stat.info .num { color: var(--info); }
.stat.warn .num { color: var(--warn); }

/* ===== toolbar ===== */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar input[type=search], .toolbar select {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; background: #fff;
}
.toolbar input[type=search] { min-width: 240px; flex: 1; }
.count { color: var(--muted); font-size: 13px; margin: 4px 2px 8px; }

/* ===== table ===== */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: right; padding: 11px 14px; border-bottom: 1px solid var(--line); }
th { background: #f8fafc; color: var(--muted); font-weight: 600; cursor: pointer; white-space: nowrap; position: sticky; top: 0; }
th[data-sort]:hover { color: var(--brand); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f0fdfa; }
tbody tr:last-child td { border-bottom: none; }

.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.active { background: #dcfce7; color: #166534; }
.badge.permanent { background: #e0e7ff; color: #3730a3; }
.badge.ended { background: #f1f5f9; color: #64748b; }

/* ===== modal ===== */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: flex-start; justify-content: center; padding: 30px; overflow: auto; z-index: 50; }
.modal-card { background: var(--card); border-radius: 16px; width: 720px; max-width: 100%; padding: 22px 26px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h2 { margin: 0; }
.warning-banner { background: #fef3c7; color: #92400e; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-form label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); gap: 4px; }
.grid-form label.full { grid-column: 1 / -1; }
.grid-form label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
.grid-form input, .grid-form select, .grid-form textarea {
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; font-family: inherit; color: var(--ink);
}
.grid-form input:disabled { background: #f1f5f9; color: var(--muted); }
.modal-foot { display: flex; align-items: center; gap: 10px; grid-column: 1 / -1; margin-top: 6px; }

/* ===== toast ===== */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 12px 22px; border-radius: 10px; font-size: 14px; z-index: 100; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.toast.err { background: var(--danger); }

/* ===== forecast ===== */
.fc-note { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin: 4px 0 14px; }
.fc-assume { margin-top: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.fc-assume summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.set-input { width: 130px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; text-align: left; direction: ltr; }
#fc-save { margin-top: 14px; }

/* ===== allowances ===== */
.al-amount { width: 120px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; direction: ltr; text-align: left; }
.al-amount:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.al-track { padding: 5px 6px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.al-fee { font-weight: 700; }
.row-link { color: var(--brand); cursor: pointer; font-weight: 600; }
.row-link:hover { text-decoration: underline; color: var(--brand-dark); }
.sumit-card-badge { padding: 9px 13px; border-radius: 8px; font-size: 13px; font-weight: 600; margin-bottom: 14px; }
.sumit-card-badge.ok { background: #dcfce7; color: #166534; }
.sumit-card-badge.no { background: #fee2e2; color: #991b1b; }
.updates-box { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.updates-head { font-weight: 700; font-size: 14px; margin-bottom: 8px; color: var(--ink); }
.updates-add { display: flex; gap: 8px; margin-bottom: 10px; }
.updates-add input { flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; font-family: inherit; }
.updates-list { display: flex; flex-direction: column; gap: 7px; max-height: 220px; overflow: auto; }
.update-item { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; }
.update-item.elig { border-right: 3px solid var(--brand); }
.update-body { font-size: 14px; }
.update-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ===== sumit ===== */
.sumit-box { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; max-width: 520px; }
.sumit-status { margin-bottom: 16px; }
.sumit-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; font-size: 14px; color: var(--muted); }
.sumit-field input { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; direction: ltr; text-align: left; }
.sumit-field small { color: var(--muted); font-size: 12px; }
.sumit-actions { display: flex; gap: 10px; }
.sumit-result { margin-top: 16px; }
.ok-box { background: #dcfce7; color: #166534; padding: 12px 14px; border-radius: 8px; font-weight: 600; }
.err-box { background: #fee2e2; color: #991b1b; padding: 12px 14px; border-radius: 8px; }
.muted { color: var(--muted); }

@media (max-width: 720px) {
  main { padding: 0 10px; margin: 14px auto; }
  /* topbar */
  .topbar { padding: 0 10px; }
  .brand { padding: 8px 0 4px; gap: 8px; }
  .brand-logo { height: 30px; }
  .brand span { display: none; }
  .top-actions { flex-wrap: wrap; gap: 6px; padding-bottom: 6px; }
  #who { font-size: 12px; order: -1; width: 100%; margin: 0; }
  .tab { padding: 6px 9px; font-size: 13px; }
  .topbar button.ghost { padding: 6px 9px; font-size: 12px; }
  /* stats + toolbar */
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 13px; }
  .stat .num { font-size: 22px; }
  .toolbar { gap: 8px; }
  .toolbar input[type=search] { min-width: 100%; }
  .toolbar select, .toolbar > button { flex: 1 1 44%; }
  .grid-form { grid-template-columns: 1fr; }
  /* modal full-screen */
  .modal { padding: 0; align-items: stretch; }
  .modal-card { width: 100% !important; max-width: 100%; min-height: 100vh; border-radius: 0; }

  /* טבלאות ראשיות -> כרטיסים בנייד */
  table.card-mobile thead { display: none; }
  table.card-mobile, table.card-mobile tbody, table.card-mobile tr, table.card-mobile td { display: block; width: 100%; }
  table.card-mobile tr { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; padding: 4px 12px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
  table.card-mobile tr:hover { background: #fff; }
  table.card-mobile td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); white-space: normal; }
  table.card-mobile td:last-child { border-bottom: none; }
  table.card-mobile td::before { content: attr(data-label); font-weight: 600; color: var(--muted); font-size: 12px; }
  table.card-mobile td:first-child { font-weight: 700; font-size: 16px; padding-top: 10px; }
  table.card-mobile td:first-child::before { content: ''; }
  table.card-mobile .al-amount { width: 130px; }
}
