/* ══════════════════════════════════════════════
   لوحة حجز الحنطة — تصميم فاتح مريح للعين
   ══════════════════════════════════════════════ */
:root {
  --bg:       #f0f4f8;
  --surface:  #ffffff;
  --surface2: #f7f9fc;
  --border:   #dde3ea;
  --border2:  #e8edf2;

  --text:     #1e2d3d;
  --muted:    #5a7184;
  --dim:      #94a3b8;

  --green:    #16a34a;
  --green-bg: #dcfce7;
  --blue:     #2563eb;
  --blue-bg:  #dbeafe;
  --amber:    #d97706;
  --amber-bg: #fef3c7;
  --red:      #dc2626;
  --red-bg:   #fee2e2;
  --purple:   #7c3aed;

  --accent:   #15803d;
  --accent-h: #166534;
  --ok:       var(--green);
  --bad:      var(--red);
  --warn:     var(--amber);

  --shadow:    0 2px 8px rgba(30,45,61,.08), 0 1px 3px rgba(30,45,61,.06);
  --shadow-sm: 0 1px 3px rgba(30,45,61,.07);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", Tahoma, "Cairo", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 15px;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Topbar ─────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
  gap: 8px;
}
.brand {
  font-weight: 700;
  font-size: 1.08em;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-icon { font-size: 1.3em; }

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.topbar-nav a {
  padding: 5px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: .9em;
  transition: color .15s, background .15s;
}
.topbar-nav a:hover {
  color: var(--text);
  background: var(--surface2);
  text-decoration: none;
}
.topbar-nav a.active {
  color: var(--accent);
  background: var(--green-bg);
  font-weight: 600;
}
.topbar-nav a.logout { color: var(--red); }
.topbar-nav a.logout:hover { background: var(--red-bg); }

.scan-nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: .85em;
  cursor: pointer;
  transition: all .15s;
  margin: 0;
}
.scan-nav-btn:hover   { border-color: var(--amber); color: var(--amber); background: var(--amber-bg); }
.scan-nav-btn.running { color: var(--amber); border-color: var(--amber); background: var(--amber-bg); }
.scan-nav-btn.done    { color: var(--green); border-color: var(--green); background: var(--green-bg); }
a.scan-nav-btn        { color: var(--muted); text-decoration: none; }
a.scan-nav-btn:hover  { color: var(--amber); border-color: var(--amber); background: var(--amber-bg); }
a.scan-nav-btn.done   { color: var(--green); border-color: var(--green); background: var(--green-bg); }

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 12px 22px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: .93em;
  z-index: 9999;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
  white-space: nowrap;
  color: var(--text);
}
#toast.show    { transform: translateX(-50%) translateY(0); }
#toast.success { border-color: var(--green); color: var(--green); background: var(--green-bg); }
#toast.error   { border-color: var(--red);   color: var(--red);   background: var(--red-bg); }

/* ── Layout ─────────────────────────────────── */
.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 22px;
}
.page-title { font-size: 1.4em; font-weight: 700; }
.page-sub   { color: var(--muted); font-size: .88em; margin-top: 4px; }

/* ── Cards ──────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.card-sm { padding: 14px 18px; }
.card.highlight { border-color: var(--accent); border-width: 2px; }

/* ── Tiles ──────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin: 18px 0; }
@media (max-width: 560px) { .grid { grid-template-columns: 1fr 1fr; } }

.tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  color: var(--text);
  transition: border-color .15s, transform .1s, box-shadow .15s;
  position: relative;
  overflow: hidden;
}
.tile::before {
  content: '';
  position: absolute;
  top: 0; right: 0; left: 0;
  height: 3px;
  background: var(--tile-color, transparent);
  border-radius: 14px 14px 0 0;
}
.tile:hover {
  border-color: var(--tile-color, var(--border));
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  text-decoration: none;
}
.tile-icon  { font-size: 1.9em; line-height: 1; }
.tile-title { font-weight: 700; font-size: 1em; }
.tile-sub   { color: var(--muted); font-size: .85em; }

.tile-green  { --tile-color: var(--green); }
.tile-blue   { --tile-color: var(--blue); }
.tile-amber  { --tile-color: var(--amber); }
.tile-purple { --tile-color: var(--purple); }
.tile-red    { --tile-color: var(--red); }

/* ── Buttons ────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: 9px;
  font-size: .93em;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s, opacity .15s, box-shadow .15s;
  border: none;
  text-decoration: none;
}
.btn:hover { text-decoration: none; box-shadow: var(--shadow-sm); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-bg); }
.btn-danger  { background: transparent; border: 1.5px solid var(--red); color: var(--red); }
.btn-danger:hover  { background: var(--red-bg); }
.btn-amber   { background: transparent; border: 1.5px solid var(--amber); color: var(--amber); }
.btn-amber:hover   { background: var(--amber-bg); }
.btn-sm   { padding: 5px 12px; font-size: .83em; }
.btn-full { width: 100%; justify-content: center; }

.btn-confirm { display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 20px; border-radius: 9px; font-size: .93em; font-weight: 600;
  cursor: pointer; background: var(--accent); color: #fff; border: none;
  transition: filter .15s; text-decoration: none; }
.btn-confirm:hover { filter: brightness(.93); text-decoration: none; }

/* ── Forms ──────────────────────────────────── */
label { display: block; margin-bottom: 5px; font-weight: 600; font-size: .9em; color: var(--muted); }

input[type=text],
input[type=password],
input[type=number],
select,
textarea {
  width: 100%;
  padding: 10px 13px;
  border-radius: 9px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: .95em;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
input::placeholder { color: var(--dim); }

.form-group { margin-bottom: 16px; }
.form-row { display: grid; gap: 14px; }
.form-row.cols2 { grid-template-columns: 1fr 1fr; }
.form-row.cols3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 600px) {
  .form-row.cols2, .form-row.cols3 { grid-template-columns: 1fr; }
}

.radio-group { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-card {
  flex: 1; min-width: 140px;
  display: flex; align-items: center; gap: 9px;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  font-size: .93em;
  background: var(--surface);
}
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--green-bg); color: var(--green); }
.radio-card input { accent-color: var(--accent); }

/* ── Flash ──────────────────────────────────── */
.flash {
  padding: 11px 16px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: .92em;
  font-weight: 500;
}
.flash-error   { background: var(--red-bg);   color: #991b1b; border: 1px solid #fca5a5; }
.flash-success { background: var(--green-bg); color: #166534; border: 1px solid #86efac; }
.flash-warning { background: var(--amber-bg); color: #92400e; border: 1px solid #fcd34d; }
.flash-info    { background: var(--blue-bg);  color: #1e40af; border: 1px solid #93c5fd; }

/* ── Tables ─────────────────────────────────── */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { padding: 10px 14px; color: var(--muted); font-size: .85em; font-weight: 600;
          text-align: right; border-bottom: 2px solid var(--border); background: var(--surface2); }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border2);
          text-align: right; font-size: .92em; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--surface2); }

/* ── Badges ─────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .8em;
  font-weight: 600;
}
.badge-green { background: var(--green-bg); color: var(--green); border: 1px solid #bbf7d0; }
.badge-blue  { background: var(--blue-bg);  color: var(--blue);  border: 1px solid #bfdbfe; }
.badge-amber { background: var(--amber-bg); color: var(--amber); border: 1px solid #fde68a; }
.badge-red   { background: var(--red-bg);   color: var(--red);   border: 1px solid #fca5a5; }
.badge-dim   { background: #f1f5f9; color: var(--muted); border: 1px solid var(--border); }
.badge.ok  { background: var(--green-bg); color: var(--green); }
.badge.bad { background: var(--red-bg);   color: var(--red); }

/* ── Section headers ────────────────────────── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}
.section-title { font-weight: 700; font-size: 1.05em; }

/* ── Pick buttons ───────────────────────────── */
.pick-btn {
  width: 100%;
  text-align: right;
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: .95em;
  cursor: pointer;
  margin-bottom: 8px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.pick-btn:hover { border-color: var(--blue); background: var(--blue-bg); color: var(--blue); box-shadow: var(--shadow-sm); }

/* ── Status dots ────────────────────────────── */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 6px; }
.dot-green { background: var(--green); }
.dot-amber { background: var(--amber); animation: pulse 1.5s infinite; }
.dot-red   { background: var(--red); }
.dot-dim   { background: var(--dim); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

/* ── Progress bar ───────────────────────────── */
.progress-bar { height: 5px; background: var(--border); border-radius: 4px; overflow: hidden; margin: 8px 0; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--blue), #60a5fa); border-radius: 4px; transition: width .4s; }

/* ── Misc ───────────────────────────────────── */
.action-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state .empty-icon { font-size: 2.8em; margin-bottom: 12px; }
.empty-state p { font-size: .95em; }

.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--border); border-top-color: var(--blue);
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.muted  { color: var(--muted); }
h1 { font-size: 1.5em; font-weight: 700; margin-bottom: 6px; }
h2 { font-size: 1.15em; font-weight: 700; margin: 22px 0 12px; }
h3 { font-size: 1em; font-weight: 700; margin-bottom: 8px; }

/* ── Farmer Autocomplete ───────────────────── */
.farmer-ac-wrap { position: relative; }
.farmer-dd {
  position: absolute; top: 100%; right: 0; left: 0;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow); z-index: 200;
  max-height: 240px; overflow-y: auto; display: none; margin-top: 4px;
}
.farmer-dd-item {
  padding: 10px 14px; cursor: pointer; font-size: .95em;
  border-bottom: 1px solid var(--border2); direction: rtl;
  color: var(--text); transition: background .12s;
}
.farmer-dd-item:last-child { border-bottom: none; }
.farmer-dd-item:hover,
.farmer-dd-item:focus { background: var(--blue-bg); color: var(--blue); outline: none; }
.farmer-dd-hint { padding: 10px 14px; color: var(--muted); font-size: .88em; direction: rtl; }

.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; }
.inline-form .btn { margin: 0; }

.steps { color: var(--muted); font-size: .85em; margin-bottom: 10px; }

.result-ok   { color: var(--green); font-weight: 700; }
.result-warn { color: var(--amber); font-weight: 700; }
.result-bad  { color: var(--red);   font-weight: 700; }

input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.check-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: 10px; cursor: pointer;
  transition: border-color .15s, background .15s;
  margin-bottom: 6px; background: var(--surface);
}
.check-row:hover { border-color: var(--accent); background: var(--green-bg); }
.check-row:has(input:checked) { border-color: var(--accent); background: var(--green-bg); }

/* ── radio-list (farmer pick) ───────────────── */
.radio-list { display: flex; flex-direction: column; gap: 6px; }
.pick-form  { margin: 0; }
