:root {
  --bg: #f5f6f8; --panel: #ffffff; --ink: #18212b; --muted: #6b7684; --line: #e3e6ea;
  --brand: #1f3a5f; --brand-soft: #e8eef6; --accent: #2563eb;
  --ok: #157347; --ok-soft: #e6f4ec; --warn: #b54708; --warn-soft: #fff4e5; --bad: #b42318; --bad-soft: #fdecea;
  --radius: 10px; --gap: 16px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 -apple-system, "Segoe UI", Arial, "Noto Sans Hebrew", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 600; }
h3 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
.mt { margin-top: 20px; }
.muted { color: var(--muted); }
.small, small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; }
.hidden { display: none !important; }
.right { text-align: left; margin-bottom: 8px; }

/* layout */
.shell { display: flex; min-height: 100vh; }
.side { width: 220px; background: var(--panel); border-left: 1px solid var(--line); padding: 16px 10px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 16px; padding: 4px 10px 16px; }
.side nav a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--ink); margin-bottom: 2px; }
.side nav a:hover { background: var(--bg); text-decoration: none; }
.side nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.side .sep { font-size: 11px; color: var(--muted); padding: 14px 10px 4px; }
.me { margin-top: auto; border-top: 1px solid var(--line); padding: 12px 10px 0; font-size: 13px; }
.me-links { margin: 6px 0; font-size: 12px; }
main { flex: 1; padding: 20px 28px 60px; min-width: 0; }
.top { margin-bottom: 18px; }
.search input { width: 100%; max-width: 560px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); font-size: 14px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); align-items: start; }
.cols.wide-first { grid-template-columns: minmax(0, 2.2fr) minmax(240px, 1fr); }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.sub { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* cards & grid */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: var(--gap); }
.card.danger { border-color: #f3c7c3; }
.card-head { display: flex; justify-content: space-between; align-items: center; }
.collapsible h3 { cursor: pointer; }
.collapsible h3::after { content: " ▾"; color: var(--muted); }
.collapsible.closed > :not(h3) { display: none; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px 18px; }
.fld, .fv { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fld.wide, .fv.wide { grid-column: 1 / -1; }
.lbl { font-size: 12px; color: var(--muted); }
.val { word-break: break-word; }
.val.empty { color: #b8bec6; }
.hint { color: var(--muted); }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfd3f6; border-color: var(--accent); }
select[multiple] { padding: 4px; }
.chk { display: inline-flex; align-items: center; gap: 6px; }
.chk input { width: auto; }
.chips { display: flex; gap: 14px; flex-wrap: wrap; }
.full { width: 100%; }

/* buttons */
.btn { display: inline-block; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; font: inherit; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #172e4c; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
button.link { background: none; border: 0; color: var(--accent); padding: 0; cursor: pointer; font: inherit; }
.savebar { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 14px 0 4px; display: flex; gap: 8px; }

/* tables & lists */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: right; font-weight: 600; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); padding: 8px 6px; }
.tbl td { border-bottom: 1px solid var(--line); padding: 8px 6px; vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.late td { background: var(--bad-soft); }
.tbl tr.today td { background: var(--warn-soft); }
.tbl tr.off td { color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; }
.list li:last-child { border-bottom: 0; }
.tag { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); vertical-align: middle; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.soft { background: #eef0f3; color: var(--muted); }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 14px; }
.filters select { width: auto; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap); margin: 14px 0 var(--gap); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--ink); display: flex; flex-direction: column; }
.stat b { font-size: 24px; font-weight: 600; }
.stat span { color: var(--muted); font-size: 12px; }
a.stat:hover { text-decoration: none; border-color: #c9d4e3; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: var(--gap); overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--ink); }

/* tasks & gorms */
.task { display: flex; gap: 12px; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task.done .pre { color: var(--muted); text-decoration: line-through; }
.task-main { flex: 1; min-width: 0; }
.task-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; min-width: 200px; }
.note { margin-top: 4px; padding-right: 10px; border-right: 2px solid var(--line); }
.inline-note { display: flex; gap: 6px; align-items: center; }
.inline-note input { padding: 4px 8px; font-size: 12px; }
.gorm { padding: 8px 0; border-bottom: 1px solid var(--line); }
.gorm:last-child { border-bottom: 0; }
.gorm-c { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 4px; font-size: 13px; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

/* flash & auth */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.err { background: var(--bad-soft); color: var(--bad); }
.auth { max-width: 420px; margin: 8vh auto; padding: 0 16px; }
.auth-card { display: flex; flex-direction: column; gap: 14px; }
.auth-card h2 { margin: 0; font-size: 20px; }
.qr { display: flex; justify-content: center; }
.steps { margin: 0; padding-right: 18px; }
code { background: var(--bg); padding: 2px 6px; border-radius: 4px; }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; border-left: 0; border-bottom: 1px solid var(--line); }
  .side nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .side .sep { display: none; }
  .me { display: none; }
  main { padding: 14px 16px 40px; }
  .cols, .cols.wide-first { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .task { flex-direction: column; }
  .task-actions { align-items: stretch; min-width: 0; }
}

/* finance */
.fin-stats { margin: 0 0 14px; }
.stat.due b { color: var(--bad); }
.stat.ok b { color: var(--ok); }
.tbl.num td:not(:first-child), .tbl.num th:not(:first-child) { white-space: nowrap; }
.tbl tr.sum td { font-weight: 600; border-top: 2px solid var(--line); }
.sub-form { background: var(--bg); border-radius: 8px; padding: 12px; margin: 10px 0; }
.row-tools td { background: #fafbfc; }
.row-actions form { display: inline-flex; gap: 6px; align-items: center; }
.bar { height: 8px; background: var(--brand); border-radius: 4px; }
.confirm-box { border: 2px solid var(--warn); background: var(--warn-soft); }

/* message menu */
details.menu { position: relative; }
details.menu summary { list-style: none; }
details.menu summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; left: 0; top: 110%; background: #fff; border: 1px solid var(--line); border-radius: 8px; min-width: 220px; z-index: 10; box-shadow: 0 6px 24px rgba(0,0,0,.08); padding: 4px; }
.menu-list a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--ink); }
.menu-list a:hover { background: var(--bg); text-decoration: none; }
.actions form { display: inline; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #c4c9d0; margin-left: 6px; }
.status-dot.on { background: var(--ok); }
