:root {
  --ink: #1A1A1A;
  --ink-2: #55524D;
  --ink-3: #8A867F;
  --bg: #F2F0EC;
  --card: #FFFFFF;
  --line: #DEDAD3;
  --accent: #3A8C84;
  --accent-soft: #E3F0EE;
  --green: #1F7A3A;
  --green-soft: #E4F2E8;
  --orange: #B4610A;
  --orange-soft: #FBEEDC;
  --red: #B3261E;
  --red-soft: #FBE5E3;
  --radius: 14px;
  --tap: 52px;
  font-family: "Assistant", "Segoe UI", "Arial Hebrew", Arial, system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-size: 17px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 24px; margin: 4px 0 12px; }
h2 { font-size: 19px; margin: 18px 0 8px; }
h3 { font-size: 17px; margin: 0; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

/* כותרת עליונה */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; }
.brand-logo { height: 34px; width: auto; display: block; }
.topbar-title { flex: 1; font-weight: 700; font-size: 16px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sync { font-size: 18px; color: var(--ink-3); min-width: 20px; text-align: center; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; font-size: 22px; text-decoration: none; color: var(--ink); border-radius: 50%; }
.icon-btn:active { background: var(--line); }

.app { max-width: 1100px; margin: 0 auto; padding: 16px 16px calc(110px + env(safe-area-inset-bottom)); }

/* כפתורים */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 20px; border-radius: 999px;
  border: 1.5px solid var(--ink); background: transparent; font-weight: 700; cursor: pointer; text-decoration: none; color: var(--ink);
}
.btn.primary { background: var(--ink); color: #fff; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { border-color: var(--line); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 15px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.block { width: 100%; }
.actionbar {
  position: fixed; inset: auto 0 0 0; z-index: 9;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, rgba(242,240,236,0));
  display: flex; gap: 10px; justify-content: center;
}
.actionbar .btn { flex: 1; max-width: 520px; }

/* כרטיסים ורשימות */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 10px 0; }
.list { list-style: none; padding: 0; margin: 0; }
.row-link { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.row-link .grow { flex: 1; min-width: 0; }
.chev { color: var(--ink-3); font-size: 20px; }
.empty { text-align: center; padding: 40px 10px; color: var(--ink-2); }
.empty img { width: 90px; opacity: .85; }

.field { display: block; margin: 12px 0; }
.field > span { display: block; font-size: 14px; color: var(--ink-2); margin-bottom: 4px; }
.field input, .field select { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: #fff; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* תגים ורמות ביטחון */
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; background: var(--line); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.orange { background: var(--orange-soft); color: var(--orange); }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-inline-end: 6px; }
.dot.green { background: var(--green); } .dot.orange { background: var(--orange); } .dot.red { background: var(--red); }

/* קבצים */
.file-card { display: grid; grid-template-columns: 84px 1fr; gap: 12px; align-items: center; }
.thumb { width: 84px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.file-card > div { min-width: 0; }
.file-card .grid2 { grid-template-columns: minmax(0, 1fr); gap: 6px; }
@media (min-width: 600px) { .file-card .grid2 { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); } }
.file-card select { min-height: 40px; border-radius: 8px; border: 1px solid var(--line); background: #fff; padding: 0 8px; width: 100%; min-width: 0; font-size: 15px; }
.upload { display: grid; place-items: center; gap: 6px; padding: 26px; border: 2px dashed var(--line); border-radius: var(--radius); background: #fff; text-align: center; cursor: pointer; }
.upload input { display: none; }

/* התקדמות */
.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.steps { list-style: none; padding: 0; }
.steps li { padding: 8px 0; display: flex; gap: 10px; align-items: center; }

/* שאלות */
.q-card { border-inline-start: 5px solid var(--orange); }
.q-card.red { border-inline-start-color: var(--red); }
.q-card.done { border-inline-start-color: var(--green); opacity: .85; }
.q-crop { width: 100%; border-radius: 10px; border: 1px solid var(--line); margin: 10px 0; background: #fff; min-height: 60px; display: block; }
.q-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* תוצאות */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none; position: sticky; top: 59px; background: var(--bg); z-index: 5; }
.tab { flex: none; min-height: 42px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-weight: 700; cursor: pointer; }
.tab[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.kpi b { display: block; font-size: 24px; }
.kpi span { font-size: 13px; color: var(--ink-2); }

.el-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.el-head h3 { font-size: 18px; }
.tbl-wrap { overflow-x: auto; margin: 8px -16px 0; padding: 0 16px; }
table.rebar { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 640px; }
table.rebar th { font-size: 13px; color: var(--ink-2); font-weight: 700; text-align: center; padding: 6px 4px; border-bottom: 2px solid var(--ink); background: #FAF9F6; }
table.rebar td { text-align: center; padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.rebar tr.tap { cursor: pointer; }
table.rebar tr.tap:active td, table.rebar tr.tap:hover td { background: var(--accent-soft); }
table.rebar td.shape { color: var(--ink); padding: 2px; }
table.rebar tfoot td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: none; }
.mini { width: auto; min-width: 0; font-size: 14px; }
.mini td, .mini th { padding: 4px 10px; }

.check-ok { color: var(--green); font-weight: 700; }
.check-bad { color: var(--red); font-weight: 700; }
.banner { border-radius: var(--radius); padding: 12px 14px; margin: 10px 0; font-weight: 600; }
.banner.red { background: var(--red-soft); color: var(--red); }
.banner.orange { background: var(--orange-soft); color: var(--orange); }
.banner.green { background: var(--green-soft); color: var(--green); }

/* חלון תחתון (מקור בתוכנית) */
.sheet { position: fixed; inset: 0; z-index: 30; background: rgba(26,26,26,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-body { background: var(--bg); width: 100%; max-width: 720px; max-height: 88vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet-body canvas { width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.toast { position: fixed; bottom: calc(96px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; z-index: 40; font-size: 15px; }

.history li { padding: 8px 0; border-bottom: 1px solid var(--line); }

@media (min-width: 900px) {
  .app { padding-top: 24px; }
  .split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
  .sheet { align-items: center; }
  .sheet-body { border-radius: 18px; }
}

/* הדפסה / PDF */
.print-only { display: none; }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 12px; }
  .topbar, .actionbar, .tabs, .no-print, .toast, .sheet { display: none !important; }
  .app { padding: 0; max-width: none; }
  .print-only { display: block; }
  .card { border: none; padding: 0; margin: 0 0 12px; break-inside: avoid; }
  .tbl-wrap { overflow: visible; margin: 0; padding: 0; }
  table.rebar { min-width: 0; font-size: 11px; }
  table.rebar td, table.rebar th { border: 1px solid #999; }
  .el-block { break-inside: avoid; }
  [data-tabpanel] { display: block !important; }
}
.print-head { justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #1A1A1A; padding-bottom: 6px; margin-bottom: 10px; }
@media print { .print-head { display: flex !important; } }
.print-head img { height: 46px; }
