/* פנדה · מערכת ניהול לסיטונאות טקסטיל
   שלוש ערכות נושא: clean-pro (ברירת מחדל), bold-dark, soft-air. מחליפים ב-data-theme על html. */

:root, [data-theme="clean-pro"] {
  --bg: #F3F4F8; --surface: #FFFFFF; --surface2: #F6F7FB; --ink: #141B4D; --muted: #5B6488; --line: #E2E5F0;
  --accent: #F9B914; --on-accent: #141B4D; --accent2: #0E7F8B;
  --hero: #141B4D; --on-hero: #FFFFFF; --hero-muted: #C7CDEB;
  --nav-bg: #FFFFFF; --nav-ink: #5B6488; --nav-on: #141B4D;
  --shadow: 0 10px 28px rgb(20 27 77 / .07); --radius: 20px; --radius-sm: 12px;
  --c-red: #D93F3F; --c-orange: #E8780C; --c-yellow: #C99300; --c-green: #1E9E5A; --c-teal: #0E7F8B; --c-blue: #3550C8; --c-purple: #7A4BD6; --c-gray: #7C849F;
}
[data-theme="bold-dark"] {
  --bg: #0D1030; --surface: #171B44; --surface2: #1F2452; --ink: #F2F4FF; --muted: #A9B0D6; --line: #2C326A;
  --accent: #F9B914; --on-accent: #141B4D; --accent2: #3FD0DE;
  --hero: #F9B914; --on-hero: #141B4D; --hero-muted: #4A3E10;
  --nav-bg: #171B44; --nav-ink: #A9B0D6; --nav-on: #F9B914;
  --shadow: 0 12px 30px rgb(0 0 0 / .35); --radius: 22px; --radius-sm: 14px;
  --c-red: #FF6B6B; --c-orange: #FF9F43; --c-yellow: #F9B914; --c-green: #3DD68C; --c-teal: #3FD0DE; --c-blue: #7C93FF; --c-purple: #B48CFF; --c-gray: #8D94BC;
}
[data-theme="soft-air"] {
  --bg: #EEEFF7; --surface: rgb(255 255 255 / .82); --surface2: #F5F5FB; --ink: #1D2045; --muted: #646A8F; --line: #DEE0EE;
  --accent: #19ABBA; --on-accent: #FFFFFF; --accent2: #C98A00;
  --hero: linear-gradient(135deg, #19ABBA, #35469C); --on-hero: #FFFFFF; --hero-muted: #DDF4F7;
  --nav-bg: #1D2045; --nav-ink: #A7ABC9; --nav-on: #FFFFFF;
  --shadow: 0 16px 40px rgb(53 70 156 / .10); --radius: 26px; --radius-sm: 16px;
  --c-red: #D9484D; --c-orange: #E07B12; --c-yellow: #B88A00; --c-green: #1F9A5B; --c-teal: #11909D; --c-blue: #35469C; --c-purple: #7550D0; --c-gray: #80869F;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: 'Heebo', system-ui, sans-serif; font-size: 16px; line-height: 1.5; color: var(--ink); background: var(--bg); }
h1, h2, h3, h4 { font-family: 'Rubik', 'Heebo', sans-serif; margin: 0; line-height: 1.15; font-weight: 800; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.hide { display: none !important; }
.i { width: 22px; height: 22px; flex: none; }

/* ---------- מבנה ---------- */
.shell { min-height: 100vh; padding-bottom: 92px; }
.main { max-width: 1100px; margin: 0 auto; padding: 14px 16px 30px; }
.top { display: flex; align-items: center; gap: 10px; padding: 6px 0 14px; }
.top h1 { font-size: 26px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .back { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow); border: 0; cursor: pointer; }
.top .sub { display: block; font-size: 14px; color: var(--muted); font-family: 'Heebo'; font-weight: 500; }

.nav { position: fixed; inset: auto 0 0 0; z-index: 30; display: flex; justify-content: space-around; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: var(--nav-bg); border-top: 1px solid var(--line); }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 52px; justify-content: center; font-size: 12.5px; font-weight: 700; color: var(--nav-ink); border-radius: 14px; position: relative; }
.nav a.on { color: var(--nav-on); }
.nav a.on .i { stroke-width: 2.4; }
.nav .dot { position: absolute; top: 4px; inset-inline-end: 22%; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; font-size: 11px; line-height: 18px; text-align: center; background: var(--c-red); color: #fff; }
[data-theme="soft-air"] .nav { inset: auto 12px 12px 12px; border-radius: 26px; border: 0; padding: 6px; }
[data-theme="bold-dark"] .nav { border-top-color: var(--line); }

@media (min-width: 900px) {
  .shell { padding-bottom: 0; padding-inline-start: 230px; }
  .nav { inset: 0 0 0 auto; width: 230px; flex-direction: column; justify-content: flex-start; gap: 4px; padding: 20px 14px; border-top: 0; border-inline-start: 1px solid var(--line); }
  [data-theme="soft-air"] .nav { inset: 12px 12px 12px auto; height: auto; }
  .nav a { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 14px; font-size: 15.5px; }
  .nav a.on { background: var(--surface2); }
  [data-theme="soft-air"] .nav a.on { background: rgb(255 255 255 / .12); }
  .nav .brandmark { display: flex !important; }
  .nav .dot { position: static; margin-inline-start: auto; }
  .main { padding: 26px 32px 40px; }
}
.brandmark { display: none !important; align-items: center; gap: 10px; padding: 4px 10px 18px; font-family: 'Rubik'; font-weight: 900; font-size: 20px; color: var(--nav-on); }
.brandmark span { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--accent); color: var(--on-accent); font-size: 18px; }

/* ---------- כרטיסים ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
[data-theme="soft-air"] .card { backdrop-filter: blur(10px); }
.card + .card, .stack > * + * { margin-top: 12px; }
.card h3 { font-size: 18px; display: flex; align-items: center; gap: 8px; }
.card h3 .more { margin-inline-start: auto; font-family: 'Heebo'; font-size: 14px; font-weight: 700; color: var(--accent2); }
.grid2 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.grid3 { display: grid; gap: 12px; }
@media (min-width: 700px) { .grid3 { grid-template-columns: repeat(3, 1fr); } .grid4 { grid-template-columns: repeat(4, 1fr) !important; } }
.grid4 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.cols > *, .grid2 > *, .grid3 > *, .grid4 > *, .row2 > * { min-width: 0; }
html, body { overflow-x: hidden; }
.cols { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .cols { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: start; } }

.hero { background: var(--hero); color: var(--on-hero); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.hero small { color: var(--hero-muted); font-weight: 600; }
[data-theme="clean-pro"] .hero small, [data-theme="soft-air"] .hero small { color: var(--hero-muted); }
.hero .big { font-family: 'Rubik'; font-weight: 900; font-size: 38px; line-height: 1.1; margin: 4px 0; }
.hero .row { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 10px; font-size: 14.5px; }
.hero .row b { font-family: 'Rubik'; font-size: 18px; display: block; }

.kpi { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; display: block; }
.kpi small { color: var(--muted); font-weight: 600; font-size: 14px; display: block; }
.kpi b { display: block; font-family: 'Rubik'; font-weight: 900; font-size: 28px; margin-top: 2px; }
.kpi em { font-style: normal; font-size: 13px; font-weight: 700; }
.kpi.warn b { color: var(--c-red); }

.hello { margin: 4px 0 14px; }
.hello h1 { font-size: 28px; }
.hello p { color: var(--muted); }

/* ---------- רשימות ---------- */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); min-height: 60px; cursor: pointer; }
.item:last-child { border-bottom: 0; }
.item__av { flex: none; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-weight: 800; background: var(--surface2); color: var(--ink); overflow: hidden; }
.item__av img { width: 100%; height: 100%; object-fit: cover; }
.item__main { flex: 1; min-width: 0; }
.item__main b { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item__main small { display: block; color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item__end { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 14px; }
.item__end b { font-family: 'Rubik'; }
.empty { text-align: center; padding: 30px 16px; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 18px; margin-bottom: 4px; }

.status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }

/* ---------- חיפוש ומסננים ---------- */
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border-radius: 999px; padding: 0 16px; box-shadow: var(--shadow); min-height: 50px; }
.search input { flex: 1; border: 0; background: transparent; outline: none; min-height: 48px; font-size: 16px; min-width: 0; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 0 14px; min-height: 40px; font-weight: 700; font-size: 14.5px; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
[data-theme="bold-dark"] .chip.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.chip em { font-style: normal; opacity: .65; margin-inline-start: 4px; }
.tabs { display: flex; gap: 4px; background: var(--surface2); border-radius: 999px; padding: 4px; margin-bottom: 12px; overflow-x: auto; scrollbar-width: none; }
.tabs button { flex: 1 0 auto; border: 0; background: transparent; border-radius: 999px; min-height: 42px; padding: 0 14px; font-weight: 700; cursor: pointer; color: var(--muted); }
.tabs button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- כפתורים ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 999px; border: 0; cursor: pointer; font-weight: 800; background: var(--accent); color: var(--on-accent); }
.btn.dark { background: var(--ink); color: var(--bg); }
.btn.ghost { background: var(--surface2); color: var(--ink); }
.btn.line { background: transparent; border: 1.5px solid var(--line); color: var(--ink); }
.btn.danger { background: color-mix(in srgb, var(--c-red) 12%, transparent); color: var(--c-red); }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: 14.5px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.fab { position: fixed; z-index: 25; inset-inline-start: 18px; bottom: calc(86px + env(safe-area-inset-bottom)); width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--accent); color: var(--on-accent); box-shadow: 0 12px 26px rgb(20 27 77 / .28); display: grid; place-items: center; cursor: pointer; }
.fab .i { width: 28px; height: 28px; }
@media (min-width: 900px) { .fab { bottom: 30px; inset-inline-start: 30px; } }
.iconbtn { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface2); cursor: pointer; color: var(--ink); flex: none; }

/* ---------- טפסים ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field label, .lbl { display: block; font-weight: 700; font-size: 14.5px; margin-bottom: 6px; }
.field label i { color: var(--c-red); font-style: normal; }
.input, .field input, .field select, .field textarea { width: 100%; min-height: 50px; padding: 10px 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--line); background: var(--surface); outline: none; font-size: 16px; }
.field textarea { min-height: 90px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent2); }
.field .hint { font-size: 13.5px; color: var(--muted); margin-top: 4px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button { border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px; min-height: 44px; padding: 0 16px; font-weight: 700; cursor: pointer; }
.seg button.on { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; }
.switch input { width: 50px; height: 28px; accent-color: var(--accent2); }
.savebar { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 20; display: flex; gap: 8px; padding: 12px 0 4px; background: linear-gradient(transparent, var(--bg) 30%); }
.savebar .btn { flex: 1; }
@media (min-width: 900px) { .savebar { bottom: 0; } }

/* ---------- חלון ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 50; background: rgb(10 12 40 / .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; background: var(--bg); border-radius: 26px 26px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .sheet-bg { align-items: center; } .sheet { border-radius: 26px; } }
.sheet h2 { font-size: 22px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.sheet h2 .x { margin-inline-start: auto; }
.sheet p + p { margin-top: 8px; }

/* ---------- הודעות ---------- */
.toast { position: fixed; z-index: 60; inset-inline: 16px; bottom: calc(90px + env(safe-area-inset-bottom)); max-width: 520px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 16px; background: #141B4D; color: #fff; font-weight: 600; box-shadow: 0 14px 30px rgb(0 0 0 / .25); }
.toast button { margin-inline-start: auto; border: 0; background: var(--accent); color: #141B4D; border-radius: 999px; padding: 6px 14px; font-weight: 800; cursor: pointer; }
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: var(--radius-sm); background: var(--surface2); border-inline-start: 4px solid var(--c); }
.alert + .alert { margin-top: 8px; }
.alert b { display: block; }
.alert small { color: var(--muted); }
.alert .btn { margin-inline-start: auto; flex: none; }
.note { padding: 12px 14px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--accent) 16%, var(--surface)); font-size: 14.5px; }

/* ---------- מוצר ומלאי ---------- */
.stockbar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.stockbar div { background: var(--surface2); border-radius: 12px; padding: 8px 4px; }
.stockbar b { display: block; font-family: 'Rubik'; font-size: 20px; }
.stockbar small { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.pimg { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: var(--radius-sm); background: var(--surface2); display: grid; place-items: center; color: var(--muted); }
.matrix-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.matrix { border-collapse: separate; border-spacing: 4px; min-width: 100%; }
.matrix th { font-size: 13.5px; font-weight: 700; color: var(--muted); padding: 4px; white-space: nowrap; }
.matrix th.rowh { text-align: start; color: var(--ink); }
.matrix td { padding: 0; }
.matrix input { width: 64px; min-height: 46px; text-align: center; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); font-size: 16px; font-weight: 700; }
.matrix input:focus { border-color: var(--accent2); outline: none; }
.matrix .cell { min-width: 64px; min-height: 46px; display: grid; place-items: center; border-radius: 10px; background: var(--surface2); font-weight: 700; padding: 4px; line-height: 1.1; }
.matrix .cell small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
.matrix .cell.low { background: color-mix(in srgb, var(--c-red) 12%, transparent); color: var(--c-red); }
.matrix .cell.off { opacity: .4; text-decoration: line-through; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--line); vertical-align: -2px; margin-inline-end: 4px; }

/* ---------- שורות הזמנה ומסמך ---------- */
.lines { display: flex; flex-direction: column; gap: 8px; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 12px; border-radius: var(--radius-sm); background: var(--surface2); }
.line b { font-weight: 700; }
.line small { color: var(--muted); font-size: 13.5px; }
.line .qty { display: flex; align-items: center; gap: 6px; }
.line .qty input { width: 70px; min-height: 42px; text-align: center; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 700; }
.line .price input { width: 90px; min-height: 42px; text-align: center; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); }
.totals { display: grid; gap: 4px; margin-top: 10px; font-size: 15.5px; }
.totals div { display: flex; justify-content: space-between; }
.totals .grand { font-family: 'Rubik'; font-weight: 900; font-size: 22px; padding-top: 6px; border-top: 1px dashed var(--line); }
.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tbl th { text-align: start; font-weight: 700; color: var(--muted); padding: 8px 6px; border-bottom: 1.5px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 6px; border-bottom: 1px solid var(--line); }
.tbl .num { text-align: end; white-space: nowrap; }
.tblwrap { overflow-x: auto; }

/* ---------- קטלוג ---------- */
.cat-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 700px) { .cat-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .cat-grid { grid-template-columns: repeat(4, 1fr); } }
.pcard { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; cursor: pointer; }
.pcard .ph { aspect-ratio: 1; background: var(--surface2); display: grid; place-items: center; color: var(--muted); overflow: hidden; }
.pcard .ph img { width: 100%; height: 100%; object-fit: cover; }
.pcard .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.pcard .body b { font-weight: 700; line-height: 1.25; }
.pcard .price { font-family: 'Rubik'; font-weight: 900; font-size: 19px; margin-top: auto; }

/* ---------- ברקוד ---------- */
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.label { border: 1px dashed var(--line); border-radius: 10px; padding: 8px; text-align: center; background: #fff; color: #000; font-size: 12.5px; }
.label svg { width: 100%; height: 50px; }

/* ---------- מסמך להדפסה ---------- */
.doc { background: #fff; color: #111; border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); font-size: 14.5px; }
.doc .dh { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 3px solid #141B4D; padding-bottom: 12px; margin-bottom: 14px; }
.doc h2 { font-size: 24px; color: #141B4D; }
.doc .copy { display: inline-block; margin-top: 6px; padding: 2px 10px; border: 1.5px solid #D93F3F; color: #D93F3F; border-radius: 6px; font-weight: 800; font-size: 13px; }
.doc .tbl th { color: #555; border-color: #ccc; }
.doc .tbl td { border-color: #e5e5e5; }
.doc .foot { margin-top: 16px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.doc .totals { min-width: 230px; }
@media print {
  body { background: #fff; }
  .nav, .fab, .top, .noprint, .savebar, .toast { display: none !important; }
  .shell { padding: 0 !important; }
  .main { padding: 0 !important; max-width: none; }
  .doc, .card { box-shadow: none; border-radius: 0; padding: 0; }
  .label { border-color: #bbb; break-inside: avoid; }
}

/* ---------- כניסה ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 420px; padding: 26px; }
.login h1 { font-size: 30px; margin: 10px 0 4px; }
.users { display: grid; gap: 8px; margin-top: 16px; }
.users button { display: flex; align-items: center; gap: 12px; text-align: start; padding: 10px 12px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; min-height: 60px; }
.users button b { display: block; }
.users button small { color: var(--muted); }

.bar { height: 10px; border-radius: 5px; background: var(--surface2); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.hdate { font-size: 13.5px; color: var(--muted); }

/* ---------- מצב שמירה בענן ---------- */
.syncst { position: fixed; z-index: 40; top: calc(8px + env(safe-area-inset-top)); inset-inline-start: 12px; padding: 4px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700; background: var(--surface); color: var(--muted); box-shadow: var(--shadow); pointer-events: none; transition: opacity .3s; }
.syncst[data-s="ok"] { opacity: 0; }
.syncst[data-s="error"] { color: #fff; background: var(--c-red); opacity: 1; }
@media print { .syncst { display: none; } }
