/* =============================================================
   PlantOS — עיצוב משותף (Web)
   RTL, עברית, מראה תעשייתי-מודרני.
   ============================================================= */

:root {
  --brand-900: #0f2942;
  --brand-800: #143453;
  --brand-700: #1b4269;
  --brand-600: #235284;
  --brand-500: #2f6aa8;
  --brand-400: #4a86c5;
  --accent:    #f59e0b;
  --accent-600:#d97706;

  --green:  #16a34a;  --green-bg:  #dcfce7;
  --red:    #dc2626;  --red-bg:    #fee2e2;
  --orange: #ea580c;  --orange-bg: #ffedd5;
  --blue:   #2563eb;  --blue-bg:   #dbeafe;
  --purple: #7c3aed;  --purple-bg: #ede9fe;
  --gray:   #64748b;  --gray-bg:   #e2e8f0;

  --bg:        #f1f5f9;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --border:    #e2e8f0;
  --border-2:  #cbd5e1;
  --text:      #0f172a;
  --text-2:    #475569;
  --text-3:    #94a3b8;

  --radius:   14px;
  --radius-sm:10px;
  --shadow:   0 1px 3px rgba(15,41,66,.06), 0 4px 16px rgba(15,41,66,.05);
  --shadow-lg:0 10px 40px rgba(15,41,66,.14);
  --sidebar-w: 260px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Assistant", "Rubik", "Heebo", system-ui, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
h1,h2,h3,h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
.ic { width: 20px; height: 20px; fill: currentColor; flex: 0 0 auto; }

/* ---------------- Layout shell ---------------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--brand-900), var(--brand-800));
  color: #dbe6f2;
  display: flex; flex-direction: column;
  position: fixed; inset-inline-start: 0; top: 0; bottom: 0;
  z-index: 40;
}
.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 20px 20px 18px;
}
.brand-logo {
  width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-600));
  display: grid; place-items: center; font-size: 20px;
  box-shadow: 0 4px 14px rgba(245,158,11,.35);
}
.brand-name { font-size: 20px; font-weight: 800; color: #fff; letter-spacing: -.02em; }
.brand-sub  { font-size: 11.5px; color: #7f9bbd; margin-top: 1px; }

.nav { padding: 8px 12px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 11px; color: #6d87a8; padding: 14px 10px 6px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px; color: #b9cae0;
  font-size: 14.5px; font-weight: 500; margin-bottom: 2px;
  transition: background .15s, color .15s; position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--brand-600); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.nav-item .ic { width: 19px; height: 19px; opacity: .9; }
.nav-item .badge-count {
  margin-inline-start: auto; background: var(--accent); color: #3a2600;
  font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: 999px;
}
.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 8px; border-radius: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: 0 0 auto;
  background: var(--brand-500); color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
}
.user-chip .u-name { font-size: 14px; font-weight: 700; color: #fff; }
.user-chip .u-role { font-size: 11.5px; color: #85a0c1; }

.main { flex: 1; margin-inline-start: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 64px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 26px;
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 20px; }
.topbar .crumb { color: var(--text-3); font-size: 13px; }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); display: grid; place-items: center;
  position: relative; transition: .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .pip {
  position: absolute; top: 7px; inset-inline-end: 7px; width: 8px; height: 8px;
  background: var(--red); border-radius: 50%; border: 2px solid var(--surface);
}

.content { padding: 26px; max-width: 1400px; width: 100%; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  font-size: 14.5px; font-weight: 600; transition: .15s; background: var(--surface-2); color: var(--text);
}
.btn .ic { width: 18px; height: 18px; }
.btn-primary { background: var(--brand-600); color: #fff; box-shadow: 0 2px 8px rgba(35,82,132,.25); }
.btn-primary:hover { background: var(--brand-700); }
.btn-accent { background: var(--accent); color: #3a2600; }
.btn-accent:hover { background: var(--accent-600); color: #fff; }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------- Cards / grid ---------------- */
.grid { display: grid; gap: 18px; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1150px){ .cols-4{grid-template-columns:repeat(2,1fr)} .cols-3{grid-template-columns:repeat(2,1fr)} }
@media (max-width: 780px){ .cols-4,.cols-3,.cols-2{grid-template-columns:1fr} }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }
.card-head {
  display: flex; align-items: center; gap: 10px; padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 16px; }
.card-head .sub { color: var(--text-3); font-size: 12.5px; }
.card-head .btn { margin-inline-start: auto; }

/* KPI */
.kpi { display: flex; flex-direction: column; gap: 6px; padding: 20px; position: relative; overflow: hidden; }
.kpi .kpi-top { display: flex; align-items: center; gap: 12px; }
.kpi .kpi-icon {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
}
.kpi .kpi-icon .ic { width: 24px; height: 24px; }
.kpi .kpi-val { font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.kpi .kpi-label { color: var(--text-2); font-size: 13.5px; font-weight: 600; }
.kpi .kpi-hint { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.tint-red .kpi-icon{background:var(--red-bg);color:var(--red)}
.tint-green .kpi-icon{background:var(--green-bg);color:var(--green)}
.tint-orange .kpi-icon{background:var(--orange-bg);color:var(--orange)}
.tint-blue .kpi-icon{background:var(--blue-bg);color:var(--blue)}
.tint-purple .kpi-icon{background:var(--purple-bg);color:var(--purple)}
.tint-brand .kpi-icon{background:#e4edf6;color:var(--brand-600)}

/* ---------------- Badges & dots ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap;
}
.badge-green{background:var(--green-bg);color:#15803d}
.badge-red{background:var(--red-bg);color:#b91c1c}
.badge-orange{background:var(--orange-bg);color:#c2410c}
.badge-blue{background:var(--blue-bg);color:#1d4ed8}
.badge-purple{background:var(--purple-bg);color:#6d28d9}
.badge-gray{background:var(--gray-bg);color:#475569}
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-green{background:var(--green)} .dot-red{background:var(--red)}
.dot-orange{background:var(--orange)} .dot-blue{background:var(--blue)}
.dot-purple{background:var(--purple)} .dot-gray{background:var(--gray)}
.dot-pulse { box-shadow: 0 0 0 0 rgba(220,38,38,.5); animation: pulse 1.8s infinite; }
@keyframes pulse { 70%{box-shadow:0 0 0 8px rgba(220,38,38,0)} 100%{box-shadow:0 0 0 0 rgba(220,38,38,0)} }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th {
  text-align: start; font-size: 12.5px; color: var(--text-3); font-weight: 700;
  padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap;
  background: var(--surface-2);
}
table.tbl td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tr.clickable { cursor: pointer; transition: background .12s; }
table.tbl tr.clickable:hover { background: var(--surface-2); }
.cell-main { font-weight: 700; }
.cell-sub { color: var(--text-3); font-size: 12.5px; }

/* ---------------- Toolbar / filters ---------------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.search {
  display: flex; align-items: center; gap: 8px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 0 12px; height: 42px; min-width: 240px;
}
.search input { border: none; outline: none; background: transparent; font: inherit; width: 100%; color: var(--text); }
.search .ic { color: var(--text-3); width: 18px; height: 18px; }
select.sel, input.inp, textarea.inp {
  height: 42px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  padding: 0 12px; font: inherit; color: var(--text); outline: none;
}
select.sel:focus, input.inp:focus, textarea.inp:focus { border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(47,106,168,.12); }
textarea.inp { height: auto; padding: 10px 12px; resize: vertical; min-height: 84px; }
label.fld { display: block; }
label.fld .lbl { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; display: block; }
label.fld .inp, label.fld .sel { width: 100%; }

/* ---------------- Equipment image ---------------- */
.eq-img { border-radius: 12px; display: grid; place-items: center; aspect-ratio: 16/10; overflow: hidden; }
.eq-emoji { font-size: 40px; filter: drop-shadow(0 4px 8px rgba(0,0,0,.3)); }
.eq-img.sm { width: 46px; height: 46px; aspect-ratio: auto; border-radius: 10px; }
.eq-img.sm .eq-emoji { font-size: 22px; }

/* ---------------- List rows ---------------- */
.list { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: center; gap: 14px; padding: 14px 20px;
  border-bottom: 1px solid var(--border); transition: background .12s; cursor: pointer;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--surface-2); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 700; }
.list-row .meta { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }

/* ---------------- Bars (reports) ---------------- */
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 54px; align-items: center; gap: 12px; }
.bar-track { background: var(--surface-2); border-radius: 8px; height: 24px; overflow: hidden; border: 1px solid var(--border); }
.bar-fill { height: 100%; border-radius: 8px; background: linear-gradient(90deg, var(--brand-500), var(--brand-400)); }
.bar-val { font-weight: 700; font-size: 13px; text-align: start; }
.bar-label { font-size: 13px; color: var(--text-2); font-weight: 600; text-align: start; }

/* ---------------- Modal ---------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); backdrop-filter: blur(2px);
  display: grid; place-items: center; z-index: 100; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface); border-radius: 18px; width: 100%; max-width: 560px;
  box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto;
  transform: translateY(10px) scale(.98); transition: transform .2s;
}
.modal-overlay.open .modal { transform: none; }
.modal-lg { max-width: 760px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 20px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 18px; }
.modal-head .x { margin-inline-start: auto; width: 34px; height: 34px; border-radius: 8px; border: none; background: var(--surface-2); color: var(--text-2); font-size: 20px; line-height: 1; }
.modal-head .x:hover { background: var(--gray-bg); }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-start; }

/* form grid */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 620px){ .form-grid{grid-template-columns:1fr} }

/* ---------------- Detail layout ---------------- */
.detail-grid { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
@media (max-width: 980px){ .detail-grid{grid-template-columns:1fr} }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; }
.kv dt { color: var(--text-3); font-size: 13px; font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; font-size: 14px; }

.section-title { font-size: 13px; font-weight: 700; color: var(--text-3); text-transform: none; margin: 4px 0 10px; }

/* timeline */
.timeline { position: relative; padding-inline-start: 22px; }
.timeline::before { content:''; position:absolute; inset-inline-start: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 0 0 18px; }
.tl-item::before { content:''; position:absolute; inset-inline-start: -22px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand-500); border: 2px solid var(--surface); box-shadow: 0 0 0 2px var(--border); }
.tl-item .tl-time { font-size: 12px; color: var(--text-3); }
.tl-item .tl-text { font-weight: 600; }

/* checklist */
.checklist { display: flex; flex-direction: column; gap: 4px; }
.check-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; transition: .12s; cursor: pointer; }
.check-item:hover { background: var(--surface-2); }
.check-item.done { background: var(--green-bg); border-color: #bbf7d0; }
.check-box { width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--border-2); display: grid; place-items: center; flex: 0 0 auto; color: transparent; }
.check-item.done .check-box { background: var(--green); border-color: var(--green); color: #fff; }
.check-item.done .check-label { text-decoration: line-through; color: var(--text-2); }
.check-label { font-weight: 600; }

/* progress */
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg,var(--green),#22c55e); border-radius: 999px; transition: width .3s; }

/* empty */
.empty { text-align: center; padding: 40px 20px; color: var(--text-3); }
.empty .ic { width: 44px; height: 44px; opacity: .4; margin-bottom: 10px; }

/* misc */
.row-flex { display: flex; align-items: center; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.muted { color: var(--text-3); }
.mt-8{margin-top:8px}.mt-16{margin-top:16px}.mt-24{margin-top:24px}
.crit-tag { display:inline-flex;align-items:center;gap:5px;font-size:12.5px;font-weight:700 }

/* toast */
.toast-wrap { position: fixed; bottom: 22px; inset-inline-start: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--brand-900); color: #fff; padding: 13px 18px; border-radius: 12px;
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px; font-weight: 600;
  transform: translateY(20px); opacity: 0; transition: .25s; max-width: 380px;
}
.toast.show { transform: none; opacity: 1; }
.toast .ic { color: var(--accent); }
.toast.good .ic { color: #4ade80; }

/* notif dropdown */
.notif-panel {
  position: absolute; top: 56px; inset-inline-end: 26px; width: 360px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); z-index: 60;
  overflow: hidden; display: none;
}
.notif-panel.open { display: block; }
.notif-head { padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 700; display:flex; align-items:center; }
.notif-item { display: flex; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: none; }
.notif-ic { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: 0 0 auto; }
.notif-item .n-text { font-size: 13.5px; font-weight: 600; }
.notif-item .n-time { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
