/* جرد البلي — تصميم عملي للمخزن: أزرار كبيرة، خط واضح، ألوان هادية */
:root {
  --navy: #1e3a5f;
  --navy-dark: #152a45;
  --amber: #f59e0b;
  --amber-dark: #b45309;
  --green: #15803d;
  --green-bg: #dcfce7;
  --red: #b91c1c;
  --red-bg: #fee2e2;
  --orange: #c2410c;
  --orange-bg: #ffedd5;
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #d1d5db;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 17px; line-height: 1.55; padding-bottom: 110px;
}
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 20px; margin: 0; }
h3 { font-size: 17px; margin: 18px 0 6px; }
button, input, select, textarea { font: inherit; }
button { min-height: 48px; cursor: pointer; }

.topbar {
  background: var(--navy); color: #fff; padding: 14px 16px;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 20;
}
.subtitle { margin: 0; font-size: 13px; opacity: .85; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.badge {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 700; background: #16a34a; color: #fff;
}
.badge.off { background: var(--amber-dark); }

main { max-width: 760px; margin: 0 auto; padding: 12px 14px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 4px 0 12px; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 6px; text-align: center;
}
.stat-num { display: block; font-size: 26px; font-weight: 800; line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-ok .stat-num { color: var(--green); }
.stat-defect .stat-num { color: var(--orange); }
.stat-expired .stat-num { color: var(--red); }

.toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
#search {
  width: 100%; padding: 12px 14px; font-size: 17px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--card);
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 8px 18px; min-height: 44px; font-weight: 700;
}
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.list { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; display: flex; gap: 12px; align-items: flex-start; cursor: pointer;
  text-align: start; width: 100%;
}
.card img.thumb { width: 76px; height: 76px; object-fit: cover; border-radius: 10px; background: #e5e7eb; flex-shrink: 0; }
.card .no-thumb {
  width: 76px; height: 76px; border-radius: 10px; background: #e5e7eb; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 26px; color: var(--muted);
}
.card-body { flex: 1; min-width: 0; }
.card-title { font-size: 19px; font-weight: 800; }
.card-meta { font-size: 14px; color: var(--muted); margin-top: 2px; }
.card-notes { font-size: 14px; margin-top: 4px; }
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; margin-top: 6px;
}
.pill-ok { background: var(--green-bg); color: var(--green); }
.pill-defect { background: var(--orange-bg); color: var(--orange); }
.pill-expired { background: var(--red-bg); color: var(--red); }
.pill-age { background: #e0e7ff; color: #3730a3; margin-inline-start: 6px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.fab {
  position: fixed; bottom: 18px; inset-inline-start: 50%; transform: translateX(50%);
  background: var(--amber); color: #1f2937; border: none; border-radius: 999px;
  padding: 14px 26px; font-size: 19px; font-weight: 800; min-height: 60px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,.3); z-index: 30;
}
[dir="rtl"] .fab { transform: translateX(50%); }

.btn {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  border-radius: 10px; padding: 10px 16px; font-weight: 700;
}
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-accent { background: var(--amber); color: #1f2937; border-color: var(--amber-dark); }
.btn-danger { background: var(--red-bg); color: var(--red); border-color: #fecaca; }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); min-height: 40px; padding: 6px 12px; font-size: 14px; }
.btn-big { width: 100%; font-size: 18px; padding: 14px; }
.btn:disabled { opacity: .45; cursor: default; }

.sheet {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-card {
  background: var(--bg); width: 100%; max-width: 760px; max-height: 92vh;
  overflow-y: auto; border-radius: 18px 18px 0 0; padding: 16px 16px 28px;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.sheet-head .btn-ghost { color: var(--text); border-color: var(--border); }

.photo-box { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 14px; }
#photoPreview { width: 100%; max-height: 300px; object-fit: contain; border-radius: 10px; background: #111827; }
.hint { font-size: 14px; color: var(--muted); margin: 6px 0 10px; }
.photo-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crop-box { margin-top: 12px; }
.crop-area { position: relative; touch-action: none; user-select: none; }
.crop-area img { width: 100%; display: block; border-radius: 10px; }
.crop-rect {
  position: absolute; border: 3px solid var(--amber); background: rgba(245,158,11,.15);
  pointer-events: none;
}
.ocr-status { font-size: 15px; font-weight: 700; margin: 10px 0 0; min-height: 22px; }
.ocr-raw {
  background: #111827; color: #d1fae5; border-radius: 10px; padding: 10px;
  font-size: 13px; white-space: pre-wrap; word-break: break-word; max-height: 140px; overflow: auto;
}

form label { display: block; font-weight: 700; margin-bottom: 12px; font-size: 15px; }
form input, form select, form textarea {
  display: block; width: 100%; margin-top: 4px; padding: 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--card); font-size: 17px;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.decode {
  background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 10px;
  padding: 10px 12px; margin-bottom: 12px; font-size: 15px;
}
.decode .warn-inline { color: var(--amber-dark); font-weight: 700; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
.form-actions .btn-big { flex: 1; }

.ref-body { font-size: 16px; }
.ref-body ul { padding-inline-start: 20px; }
.warn {
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; padding: 10px 12px;
}
.year-table { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; font-size: 14px; }
.year-table div { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }
.year-table b { color: var(--navy); }
.sources { font-size: 14px; color: var(--muted); }

@media (max-width: 480px) {
  .row { grid-template-columns: 1fr; }
  .topbar-actions .btn-ghost { font-size: 13px; padding: 6px 8px; }
}

/* ======== خطة 2027 ======== */
.plan-table-wrap { overflow-x: auto; margin-top: 10px; }
.plan-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.plan-table th, .plan-table td { border: 1px solid var(--border); padding: 6px 8px; text-align: center; }
.plan-table th { background: var(--navy); color: #fff; }
.plan-table td:first-child { font-weight: 700; text-align: right; }
.diff-neg { color: #b91c1c; font-weight: 700; }
.diff-pos { color: #15803d; font-weight: 700; }
.motor-results { margin-top: 10px; }
.motor-card { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.motor-ton { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.motor-plant { font-size: 12px; font-weight: 400; color: var(--muted); }
.motor-brg { font-size: 14px; padding: 2px 0; }
#planSearch { display: block; width: 100%; margin-top: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 16px; }

/* ======== أوفلاين ======== */
.offline-status { font-size: 14px; font-weight: 700; margin: 8px 0 0; color: var(--amber-dark); }
.offline-status.ready { color: #15803d; }
.offline-list { font-size: 14px; padding-inline-start: 20px; max-height: 220px; overflow: auto; }
.offline-list li { margin-bottom: 4px; word-break: break-all; }
.item-no-line { white-space: pre-line; }
