:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #d1d5db;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --success: #059669;
  --danger: #dc2626;
  --warn: #d97706;
  --gray: #64748b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Tahoma, sans-serif;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
h1, h2 { margin: 0 0 6px; }
p { margin: 0; color: var(--muted); }
main { padding: 20px 24px 50px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
}
.hidden { display: none !important; }
.grid { display: grid; gap: 12px; }
.settings-grid { grid-template-columns: repeat(2, minmax(230px, 1fr)); }
label { display: grid; gap: 6px; font-weight: 700; color: #374151; }
input, select {
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus {
  outline: 2px solid rgba(79, 70, 229, 0.25);
  border-color: var(--primary);
}
button {
  height: 40px;
  border: 0;
  border-radius: 9px;
  padding: 0 16px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
button:hover { background: var(--primary-dark); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.secondary { background: #e5e7eb; color: #111827; }
button.secondary:hover { background: #d1d5db; }
.nav-btn { height: 40px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; border-radius: 9px; padding: 0 16px; background: #0f766e; color: #fff; font-weight: 700; }
.nav-btn:hover { background: #115e59; }
button.success { background: var(--success); }
button.danger { background: var(--danger); }
.actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.actions.wrap { flex-wrap: wrap; }
.status-box { display: flex; gap: 10px; align-items: center; }
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 8px 12px;
  color: #fff;
  font-weight: 700;
  min-width: 95px;
  justify-content: center;
}
.badge.gray { background: var(--gray); }
.badge.green { background: var(--success); }
.badge.red { background: var(--danger); }
.message { color: var(--muted); font-weight: 700; }
.message.error { color: var(--danger); }
.message.success { color: var(--success); }
.section-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.batch-controls { display: grid; grid-template-columns: 1fr 1fr 1.2fr auto 1.2fr auto 2fr auto; gap: 10px; align-items: end; }
.batch-controls label { font-size: 13px; }
.batch-controls select { min-width: 220px; }
.batch-info {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.info-box {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #f9fafb;
}
.info-box b { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.table-wrap { overflow: auto; max-height: calc(100vh - 250px); border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 1250px; direction: rtl; }
th, td { border-bottom: 1px solid var(--border); padding: 8px; vertical-align: middle; }
th { position: sticky; top: 0; background: #eef2ff; z-index: 2; text-align: right; }
td.num, th.num { text-align: center; direction: ltr; }
td.product { font-weight: 700; min-width: 280px; }
td.wh { direction: ltr; font-weight: 700; }
.cell-input { width: 100%; min-width: 90px; height: 34px; }
.small-input { min-width: 70px; }
.status-cell { min-width: 160px; font-size: 12px; }
.row-saved { background: #ecfdf5; }
.row-error { background: #fef2f2; }
.row-pending { background: #fffbeb; }

/* Quantity-based coloring requested for receiving rows.
   These rules appear after saved/error so the quantity color is the main row color. */
.row-qty-full { background: #fee2e2 !important; }      /* received >= demand */
.row-qty-partial { background: #dbeafe !important; }   /* received < demand */
.row-qty-zero { background: #f3f4f6 !important; }      /* received = 0 */
.row-demand-zero { display: none; }
.link-btn { display: inline-block; text-decoration: none; background: #e5e7eb; color: #111827; padding: 8px 10px; border-radius: 8px; font-weight: 700; }
.inline-btn { height: 34px; padding: 0 10px; }
.legend { display: flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 700; flex-wrap: wrap; }
.dot { width: 10px; height: 10px; display: inline-block; border-radius: 999px; }
.dot.saved { background: var(--success); }
.dot.error { background: var(--danger); }
.dot.pending { background: var(--warn); }
.dot.qty-full { background: #ef4444; }
.dot.qty-partial { background: #3b82f6; }
.dot.qty-zero { background: #9ca3af; }
.line-tools { display: grid; grid-template-columns: minmax(260px, 1fr) auto auto; gap: 10px; align-items: end; margin-bottom: 12px; }
.line-tools label { font-size: 13px; }
.toast {
  position: fixed;
  bottom: 20px;
  left: 20px;
  background: #111827;
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0,0,0,.25);
  z-index: 20;
  max-width: 520px;
}
@media (max-width: 1200px) {
  .batch-controls { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
}
@media (max-width: 900px) {
  .topbar, .section-header { flex-direction: column; align-items: stretch; }
  .settings-grid, .batch-controls, .batch-info, .line-tools { grid-template-columns: 1fr; }
  main { padding: 12px; }
}


/* Internal Odoo connection settings are managed through login/config, not shown to end users */
#settingsBtn, #settingsPanel, a[href*="settings=1"] { display: none !important; }
