/* מערכת שכר ועמלות — מכללת תרפיית המימדים */
:root {
  --bg: #f4f6fa; --card: #fff; --ink: #1e2633; --muted: #67748b;
  --brand: #4353a4; --brand-dark: #32407f; --brand-light: #eef0fb;
  --ok: #178a50; --ok-bg: #e8f7ef; --warn: #b8860b; --warn-bg: #fdf6e3;
  --red: #c0392b; --red-bg: #fdecea; --line: #e3e8f0;
  --radius: 12px; --shadow: 0 1px 3px rgba(30,38,51,.08), 0 4px 16px rgba(30,38,51,.05);
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Assistant", "Heebo", "Segoe UI", system-ui, sans-serif;
  direction: rtl;
}
#app { max-width: 1280px; margin: 0 auto; padding: 16px; }

/* ---------- topbar ---------- */
header.topbar {
  background: var(--brand); color: #fff; padding: 0 20px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  box-shadow: var(--shadow); position: sticky; top: 0; z-index: 50; min-height: 56px;
}
.topbar .logo { font-weight: 800; font-size: 1.1rem; padding: 12px 0; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a {
  color: #dfe4ff; text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 600;
}
.topbar nav a.active, .topbar nav a:hover { background: rgba(255,255,255,.16); color: #fff; }
.topbar .spacer { flex: 1; }
.topbar .user { font-size: .85rem; color: #cdd4f8; }
.topbar button { background: rgba(255,255,255,.14); color: #fff; border: 0; }

/* ---------- cards & layout ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 1.15rem; }
.card h3 { margin: 18px 0 8px; font-size: 1rem; }
.row { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- controls ---------- */
button, .btn {
  background: var(--brand); color: #fff; border: 0; border-radius: 8px;
  padding: 8px 16px; font-family: inherit; font-size: .95rem; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
button:hover { background: var(--brand-dark); }
button.secondary { background: var(--brand-light); color: var(--brand); }
button.secondary:hover { background: #dde2f7; }
button.danger { background: var(--red); }
button.small { padding: 4px 10px; font-size: .82rem; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea {
  font-family: inherit; font-size: .95rem; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--brand-light); border-color: var(--brand); }
label.fld { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); font-weight: 600; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: right; color: var(--muted); font-weight: 700; font-size: .82rem;
     padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:hover td { background: #fafbfe; }
tr.clickable { cursor: pointer; }
tr.total td { font-weight: 800; background: var(--brand-light); }
td.num, th.num { text-align: left; direction: ltr; font-variant-numeric: tabular-nums; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--brand); }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .78rem; font-weight: 700; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.gray { background: #eef1f6; color: var(--muted); }
.badge.brand { background: var(--brand-light); color: var(--brand); }

tr.below-floor td { background: var(--red-bg); }
tr.excluded td { opacity: .45; text-decoration: line-through; }
tr.excluded td.actions { text-decoration: none; opacity: 1; }
tr.cancelled td { background: #f3eef9; color: #6d5a8e; }
.alert-red {
  background: var(--red-bg); border: 1px solid #f2c3bd; border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 14px; color: var(--red); font-weight: 600;
}
.alert-warn { background: var(--warn-bg); border: 1px solid #ead9a6; border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 14px; color: #7c5c06; }

/* ---------- summary sidebar ---------- */
.summary { position: sticky; top: 72px; }
.summary .line { display: flex; justify-content: space-between; padding: 6px 0; font-size: .95rem; }
.summary .line.sep { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }
.summary .line.grand { font-size: 1.25rem; font-weight: 800; color: var(--brand); }
.summary .sub { font-size: .8rem; color: var(--muted); }

/* ---------- misc ---------- */
.muted { color: var(--muted); font-size: .85rem; }
.login-box { max-width: 380px; margin: 10vh auto; }
.login-box .logo { text-align: center; font-size: 1.5rem; font-weight: 800; color: var(--brand); margin-bottom: 18px; }
#toast {
  position: fixed; bottom: 22px; right: 50%; transform: translateX(50%);
  background: var(--ink); color: #fff; padding: 10px 22px; border-radius: 10px;
  opacity: 0; transition: opacity .25s; z-index: 100; max-width: 90vw;
}
#toast.show { opacity: .96; }
#toast.error { background: var(--red); }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid #fff;
  border-top-color: transparent; border-radius: 50%; animation: sp 0.8s linear infinite; vertical-align: -2px; }
@keyframes sp { to { transform: rotate(360deg); } }
dialog {
  border: 0; border-radius: var(--radius); box-shadow: 0 8px 40px rgba(0,0,0,.25);
  padding: 22px; max-width: 480px; width: 92vw; direction: rtl; font-family: inherit;
}
dialog::backdrop { background: rgba(20,26,40,.45); }
dialog h3 { margin-top: 0; }
.chart { width: 100%; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { background: var(--brand-light); border-radius: 10px; padding: 12px 14px; }
.tile .v { font-size: 1.3rem; font-weight: 800; color: var(--brand); }
.tile .t { font-size: .8rem; color: var(--muted); font-weight: 600; }
.tabs { display: flex; gap: 6px; border-bottom: 2px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); font-weight: 700;
  border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
.formula-help { background: #f8f9fd; border-radius: 8px; padding: 10px 14px; font-size: .85rem; color: var(--muted); }

@media print {
  .topbar, .no-print, button { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  .summary { position: static; }
}
