/* שמחות — one stylesheet. Colors are tokens; dark mode redefines them. RTL throughout. */
:root {
  --bg: #f7f3ee;
  --surface: #ffffff;
  --surface-2: #f1ebe4;
  --text: #2a2226;
  --muted: #6f6469;
  --line: #e4dbd2;
  --brand: #5b2a4e;
  --brand-ink: #ffffff;
  --brand-soft: #efe3ec;
  --accent: #b9852f;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  --ok: #1f7a4d;
  --shadow: 0 1px 2px rgba(40, 20, 30, .06), 0 4px 16px rgba(40, 20, 30, .06);
  --radius: 12px;
  --sidebar-w: 248px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1619; --surface: #251e22; --surface-2: #2e262b; --text: #f1eaee; --muted: #b3a6ad; --line: #3d3238;
    --brand: #b98aac; --brand-ink: #1b1619; --brand-soft: #3a2c36; --accent: #d9ac5e;
    --danger: #f2827a; --danger-soft: #3d2221; --ok: #6fcf97;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1619; --surface: #251e22; --surface-2: #2e262b; --text: #f1eaee; --muted: #b3a6ad; --line: #3d3238;
  --brand: #b98aac; --brand-ink: #1b1619; --brand-soft: #3a2c36; --accent: #d9ac5e;
  --danger: #f2827a; --danger-soft: #3d2221; --ok: #6fcf97;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.5 Heebo, system-ui, "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); }
h1 { font-size: 1.5rem; margin: 0 0 .75rem; font-weight: 700; }
.muted { color: var(--muted); }
.boot { padding: 48px; text-align: center; color: var(--muted); }

/* buttons & forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand); filter: brightness(1.08); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); filter: brightness(1.08); }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 8px 0; color: var(--brand); font: inherit; cursor: pointer; text-decoration: underline; }
label { display: block; font-weight: 600; margin: 14px 0 6px; }
input, select {
  width: 100%; min-height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit;
}
input:focus, select:focus, .btn:focus-visible, a:focus-visible { outline: 3px solid var(--brand-soft); outline-offset: 1px; border-color: var(--brand); }
.form-error { color: var(--danger); min-height: 1.5em; margin: 10px 0; }
.form-error:empty { margin: 4px 0; }
.form-ok { color: var(--ok); margin: 10px 0; }

/* login */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.login-band { background: var(--brand); color: var(--brand-ink); padding: 28px 24px 22px; text-align: center; }
.login-title { font-size: 1.6rem; font-weight: 700; }
.login-date { opacity: .85; margin-top: 4px; }
.login-body { padding: 22px 24px 18px; }
.login-body h1 { font-size: 1.25rem; }
.login-body form .link-btn { display: block; margin: 10px auto 0; }
.login-credit { margin-top: 16px; color: var(--muted); font-size: .85rem; }
.center-card { max-width: 420px; margin: 15vh auto; padding: 24px; text-align: center; }

/* shell */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  height: 56px; padding: 0 16px; background: var(--brand); color: var(--brand-ink);
}
.app-name { color: inherit; text-decoration: none; font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.today { margin-inline-start: auto; white-space: nowrap; }
.today-day { opacity: .8; }
.menu-btn { display: none; background: none; border: 0; color: inherit; font-size: 1.5rem; width: 44px; height: 44px; cursor: pointer; }
.layout { display: flex; min-height: calc(100vh - 56px); }
.sidebar {
  width: var(--sidebar-w); flex: none; display: flex; flex-direction: column; gap: 4px;
  background: var(--surface); border-inline-end: 1px solid var(--line); padding: 16px 12px;
  position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto;
}
.org-name { font-weight: 700; padding: 4px 10px 10px; }
.org-picker { margin-bottom: 8px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: block; padding: 10px 12px; border-radius: 8px; color: var(--text); text-decoration: none; }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-admin { margin-top: 8px; border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; padding-top: 14px; }
.me { margin-top: auto; padding: 14px 10px 8px; border-top: 1px solid var(--line); }
.me-name { font-weight: 600; overflow-wrap: anywhere; }
.me-role { color: var(--muted); font-size: .9rem; }
.credit { display: flex; flex-direction: column; gap: 2px; padding: 10px; font-size: .82rem; color: var(--muted); border-top: 1px solid var(--line); }
.credit a { color: var(--muted); }
.version { margin-top: 4px; }
.content { flex: 1; min-width: 0; padding: 24px; }
.nav-scrim { display: none; }

/* pages */
.page { max-width: 1100px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-top: 8px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; text-decoration: none; color: var(--text); box-shadow: var(--shadow); }
.tile:hover { border-color: var(--brand); }
.tile-num { font-size: 2rem; font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.tile-label { color: var(--muted); }
.soon { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 18px 20px; max-width: 640px; }
.soon p { margin: 0 0 6px; }
.notice { max-width: 520px; margin: 8vh auto; text-align: center; }
.notice p { color: var(--muted); }

/* tabs, cards, tables, chips */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: 4px 0 18px; }
.tab { padding: 10px 14px; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 6px; font-size: 1.15rem; }
.new-org { max-width: 520px; margin-top: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head p { margin: 0; }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: start; font-weight: 600; color: var(--muted); font-size: .9rem; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.row-off td { color: var(--muted); }
.row-actions { white-space: nowrap; text-align: end; }
.row-actions .btn + .btn { margin-inline-start: 6px; }
.login-cell { text-align: right; overflow-wrap: anywhere; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .8rem; background: var(--surface-2); color: var(--muted); margin-inline-start: 6px; white-space: nowrap; }
.chip:first-child { margin-inline-start: 0; }
.chip-ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.chip-warn { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.btn-small { min-height: 34px; padding: 0 12px; font-size: .9rem; font-weight: 500; }
.inline-select { max-width: 360px; }

/* form bits */
.field { margin-bottom: 4px; }
.label { font-weight: 600; margin: 14px 0 6px; }
.hint { color: var(--muted); font-size: .88rem; margin-top: 4px; }
.radios { display: flex; flex-direction: column; gap: 6px; }
.radio, .check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; cursor: pointer; }
.radio input, .check input { width: 20px; min-height: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--brand); }
.check { margin-top: 16px; font-weight: 600; }
.readonly { margin-top: 14px; color: var(--muted); }

/* ordinary dialog (modal.js) */
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.modal-head h2 { margin: 0; font-size: 1.2rem; }
.modal-x { background: none; border: 0; font-size: 1.6rem; line-height: 1; color: var(--muted); cursor: pointer; width: 40px; height: 40px; border-radius: 8px; }
.modal-x:hover { background: var(--surface-2); }
.modal { max-height: calc(100vh - 32px); overflow-y: auto; }
.temp-pass { background: var(--brand-soft); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 1.25rem; letter-spacing: .04em; }

/* settings → units & packages */
.btn-danger-outline { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn-danger-outline:hover { background: var(--danger-soft); }
.small { font-size: .85rem; }
.units-gaps { margin-bottom: 18px; }
.units-gaps h2 + p { margin-top: 0; }
.units-gaps h2:not(:first-child) { margin-top: 22px; }
.gap-list { display: grid; gap: 10px; }
.gap { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.gap-what { flex: 1 1 200px; }
.gap-eq, .conv-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.gap .form-error { flex-basis: 100%; margin: 0; }
.gap .form-error:empty, .dlg-part > .form-error:empty { display: none; }
input.factor { width: 7.5em; text-align: left; }
.units-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.units-tools input[type=search] { width: auto; min-width: 14em; }
.units-table .chip { margin: 2px 0 2px 6px; }
.dlg-part + .dlg-part { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 6px; }
.dlg-part h3 { margin: 10px 0 4px; font-size: 1.05rem; }
.conv-line { padding: 6px 0; }
.conv-line .chip { margin: 0; }
.conv-new { border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 10px; }
.conv-new label { margin: 0; font-weight: 400; }
.conv-new input:not(.factor) { width: 7em; }

/* the red delete dialog (confirm-delete.js) */
.modal-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(20, 10, 15, .45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: 100%; max-width: 440px; background: var(--surface); border-radius: 14px; padding: 22px; box-shadow: 0 10px 40px rgba(0, 0, 0, .25); }
.modal-danger { border-top: 6px solid var(--danger); }
.modal-danger h2 { color: var(--danger); margin: 0 0 10px; font-size: 1.25rem; }
.modal-danger .also { background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: 8px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

/* phones & small tablets: the sidebar slides in */
@media (max-width: 640px) {
  /* tables become cards: each cell shows its column name */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .table td { border: 0; padding: 3px 0; display: flex; gap: 10px; }
  .table td[data-label]::before { content: attr(data-label); color: var(--muted); min-width: 96px; flex: none; font-size: .9rem; }
  .row-actions { text-align: start; padding-top: 8px !important; }
  .login-cell { text-align: start; }
}
@media (max-width: 820px) {
  .menu-btn { display: inline-block; margin-inline-start: -8px; }
  .today-day { display: none; }
  .sidebar {
    position: fixed; top: 56px; bottom: 0; right: 0; z-index: 30; height: auto;
    transform: translateX(100%); transition: transform .2s ease; box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-scrim { display: block; position: fixed; inset: 56px 0 0 0; z-index: 25; background: rgba(0, 0, 0, .3); }
  .content { padding: 16px; }
}
@media (max-width: 380px) { .app-name { font-size: 1rem; } }
@media print { .topbar, .sidebar, .nav-scrim { display: none !important; } .content { padding: 0; } }
