/* Waraq Anab CK Orders — brand: sage green #788c74, beige #cbcbbf */
:root {
  --green: #5f7259;
  --green-2: #788c74;
  --green-soft: #e7ece4;
  --beige: #cbcbbf;
  --beige-soft: #f3f2ec;
  --ink: #1f2a1d;
  --ink-2: #55604f;
  --line: #dcddd3;
  --card: #ffffff;
  --bg: #f6f5f0;
  --warn: #b45309;
  --warn-soft: #fef3e2;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --good: #2e7d32;
  --good-soft: #e6f4e7;
  --info: #1f5f8b;
  --info-soft: #e5f0f8;
  --radius: 12px;
  --tap: 48px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Tahoma, "Noto Sans Arabic", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
a { color: var(--green); }
h1 { font-size: 1.35rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 1.25rem 0 .5rem; }
h3 { font-size: 1rem; margin: 0 0 .25rem; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  padding: 8px 16px; background: var(--green); color: #fff; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 600; white-space: nowrap; }
.brand img { background: #fff; border-radius: 8px; padding: 2px; }
.topnav { display: flex; gap: 4px; }
.topnav a { color: #e9eee6; text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 500; }
.topnav a.on, .topnav a:hover { background: rgba(255,255,255,.16); color: #fff; }
.who { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.who-name { font-size: .9rem; opacity: .92; }
.pill { color: #fff; text-decoration: none; border: 1px solid rgba(255,255,255,.55); padding: 4px 10px; border-radius: 999px; font-size: .85rem; white-space: nowrap; }
.pill.ghost { border-color: transparent; opacity: .85; }
@media (max-width: 640px) {
  .brand span, .who-name { display: none; }
  .topbar { gap: 8px; }
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 16px; }
.wrap.narrow { max-width: 560px; padding-bottom: 160px; }
.flash { max-width: 528px; margin: 12px 16px 0; margin-inline: max(16px, calc(50% - 264px)); background: var(--good-soft); color: var(--good); padding: 10px 14px; border-radius: 10px; font-weight: 500; }

/* cards & lists */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 12px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

/* buttons & inputs */
button, .btn { font: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; font-weight: 600; }
.btn.primary, button.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover, button.primary:hover { background: #52644d; }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn.block, button.block { width: 100%; }
.btn.sm, button.sm { min-height: 36px; padding: 0 12px; font-size: .9rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; background: #fff; min-height: var(--tap); width: 100%; }
textarea { min-height: 80px; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid #a9bfa3; outline-offset: 1px; }
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .95rem; }
.field + .field { margin-top: 14px; }
.error { background: var(--bad-soft); color: var(--bad); padding: 10px 14px; border-radius: 10px; font-weight: 500; }
.note { background: var(--info-soft); color: var(--info); padding: 10px 14px; border-radius: 10px; font-size: .92rem; }
.note.warn { background: var(--warn-soft); color: var(--warn); }

/* status chips */
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; background: var(--beige-soft); color: var(--ink-2); }
.chip.submitted { background: var(--info-soft); color: var(--info); }
.chip.acknowledged { background: var(--warn-soft); color: var(--warn); }
.chip.dispatched { background: #efe6fb; color: #5b2d9a; }
.chip.received { background: var(--good-soft); color: var(--good); }
.chip.rush { background: var(--bad); color: #fff; }

/* bottom nav (shop) */
.bottomnav { position: fixed; bottom: 0; inset-inline: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 10px; color: var(--ink-2);
  text-decoration: none; font-size: .78rem; font-weight: 600; }
.bottomnav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bottomnav a.on { color: var(--green); }
.bottomnav a.soon { opacity: .4; }

/* login */
.login { max-width: 380px; margin: 8vh auto 0; padding: 16px; }
.login .logo { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 20px; text-align: center; }
.login .logo img { width: 64px; height: 64px; }
.lang-switch { text-align: center; margin-top: 16px; }

/* shop today */
.hero { background: var(--green); color: #fff; border-radius: var(--radius); padding: 18px; }
.hero .muted { color: #dfe7dc; }
.hero .btn { background: #fff; color: var(--green); border-color: #fff; margin-top: 12px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { width: 72px; flex: none; font-size: .85rem; color: var(--ink-2); }
.alertbox { display: flex; align-items: center; gap: 12px; background: #efe6fb; color: #5b2d9a; padding: 12px 14px; border-radius: 10px; text-decoration: none; font-weight: 600; }

/* order screen */
.targets { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.target { flex: none; text-align: start; min-height: 56px; flex-direction: column; align-items: flex-start; gap: 0; padding: 6px 14px; }
.target small { font-weight: 500; color: var(--ink-2); font-size: .78rem; }
.target.on { background: var(--green); border-color: var(--green); color: #fff; }
.target.on small { color: #e3eadf; }
.target.rush.on { background: var(--bad); border-color: var(--bad); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--beige-soft); border-radius: 10px; padding: 4px; gap: 4px; margin: 12px 0; }
.tabs button { min-height: 40px; border: 0; background: transparent; }
.tabs button.on { background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.search { position: sticky; top: 56px; z-index: 5; background: var(--bg); padding: 8px 0; }
.section { margin-top: 8px; border: 1px solid var(--line); background: #fff; border-radius: var(--radius); overflow: hidden; }
.section > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; font-weight: 700; background: var(--beige-soft); }
.section > summary::-webkit-details-marker { display: none; }
.section > summary .count { font-weight: 600; font-size: .8rem; color: #fff; background: var(--green-2); border-radius: 999px; padding: 1px 8px; }
.prod { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); }
.prod .pname { flex: 1; min-width: 0; }
.prod .pname b { display: block; font-weight: 600; }
.prod .pname span { font-size: .8rem; color: var(--ink-2); }
.prod.has { background: var(--green-soft); }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; flex: none; }
.stepper button { min-height: 44px; width: 44px; padding: 0; border: 0; border-radius: 0; font-size: 1.3rem; color: var(--green); }
.stepper input { width: 52px; min-height: 44px; border: 0; border-inline: 1px solid var(--line); border-radius: 0; text-align: center; padding: 0; font-weight: 700; }
.sticky-foot { position: fixed; inset-inline: 0; bottom: 62px; z-index: 15; padding: 8px 16px; pointer-events: none; }
.sticky-foot .btn { pointer-events: auto; max-width: 528px; margin: 0 auto; display: flex; box-shadow: 0 6px 18px rgba(31,42,29,.25); }
.sheet-bg { position: fixed; inset: 0; background: rgba(20,25,18,.45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet table { width: 100%; border-collapse: collapse; }
.sheet td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
.sheet td.q { text-align: end; font-weight: 700; width: 64px; }
.dept-head td { background: var(--beige-soft); font-weight: 700; font-size: .9rem; }
.big { color: var(--warn); font-size: .78rem; display: block; font-weight: 600; }

/* receive */
.rline { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.rline input { width: 80px; text-align: center; font-weight: 700; flex: none; }
.rline .sent { width: 48px; text-align: center; color: var(--ink-2); flex: none; }

/* CK dashboard */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar select, .toolbar input { width: auto; min-height: 40px; padding: 6px 10px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.seg a { padding: 8px 14px; text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: .9rem; border-inline-end: 1px solid var(--line); }
.seg a:last-child { border-inline-end: 0; }
.seg a.on { background: var(--green); color: #fff; }
.livedot { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--ink-2); margin-inline-start: auto; }
.livedot i { width: 10px; height: 10px; border-radius: 50%; background: var(--good); display: inline-block; }
.livedot.off i { background: var(--warn); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { font-size: 1.5rem; display: block; }
.stat span { font-size: .85rem; color: var(--ink-2); }
table.grid { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.grid th, table.grid td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid th { background: var(--beige-soft); font-size: .82rem; text-transform: uppercase; letter-spacing: .02em; color: var(--ink-2); }
table.grid tr.group td { background: var(--green-soft); font-weight: 700; color: var(--green); }
table.grid tr.rushrow td { background: var(--bad-soft); }
table.grid tr.new td { animation: flashrow 2.5s ease-out; }
table.grid td.n, table.grid th.n { text-align: end; font-variant-numeric: tabular-nums; }
table.grid tr.click { cursor: pointer; }
table.grid tr.click:hover td { background: #fafaf6; }
.late { color: var(--warn); font-weight: 600; }
@keyframes flashrow { from { background: #fff3b0; } to { background: transparent; } }
.dline input.qty { width: 90px; text-align: end; font-weight: 700; min-height: 40px; }
.dline input.reason { min-height: 40px; }
.dline td.short { background: var(--warn-soft); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 16px; margin: 12px 0 16px; }
.meta div span { display: block; font-size: .8rem; color: var(--ink-2); }
.matrix th.b, .matrix td.b { text-align: center; }
.matrix td.tot, .matrix th.tot { font-weight: 800; background: var(--green-soft); text-align: center; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; align-items: start; }
.toast { position: fixed; top: 70px; inset-inline-end: 16px; z-index: 50; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.25); font-weight: 600; }

@media print {
  .topbar, .bottomnav, .toolbar, .actions, .noprint, .flash { display: none !important; }
  body { background: #fff; }
  .wrap { max-width: none; padding: 0; }
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .field { margin: 0; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

/* CK screens on phones: wrap the top bar instead of pushing the page sideways */
html, body { max-width: 100%; overflow-x: hidden; }
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; row-gap: 4px; padding: 6px 12px; }
  .topnav { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .topnav a { padding: 6px 10px; white-space: nowrap; }
  .toolbar > * { flex: 1 1 auto; }
  .toolbar .livedot { flex: 0 0 auto; }
  #board, .table-scroll { overflow-x: auto; }
  table.grid th, table.grid td { padding: 8px; }
  .search { top: 0; }
}
/* order ringer */
.ringbar { position: fixed; inset-inline: 12px; bottom: 12px; z-index: 55; display: flex; align-items: center; gap: 10px;
  max-width: 640px; margin: 0 auto; padding: 10px 14px; border-radius: 12px; background: var(--info); color: #fff;
  box-shadow: 0 10px 28px rgba(0,0,0,.28); animation: ringpulse 1.2s ease-in-out infinite; }
.ringbar.rush { background: var(--bad); }
.ringbar b { font-size: 1.3rem; }
.ringbar .bell { font-size: 1.3rem; animation: ringshake 1.2s ease-in-out infinite; display: inline-block; }
.ringbar .btn, .ringbar button { background: #fff; color: var(--ink); border-color: #fff; }
@keyframes ringpulse { 50% { box-shadow: 0 10px 34px rgba(0,0,0,.45); } }
@keyframes ringshake { 0%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(-16deg); } 20%, 40% { transform: rotate(16deg); } 50% { transform: rotate(0); } }
body.has-ringbar main { padding-bottom: 96px; }
body.has-ringbar .sticky-foot { bottom: 130px; }

/* accept & print */
.printframe { position: absolute; width: 0; height: 0; border: 0; visibility: hidden; }
td.rowact { white-space: nowrap; text-align: end; }
td.rowact form.inline { display: inline; }
td.rowact .btn { margin-inline-start: 4px; }

/* 1.4: drivers, delivery photos, differences */
.driverbox { display: flex; align-items: center; gap: 10px; background: #f3f5f1; border: 1px solid #dfe4da; border-radius: 10px; padding: 8px 10px; margin: 10px 0 4px; }
.driverbox > span { font-size: 22px; }
.xline select { font-size: 15px; padding: 6px 8px; min-height: 40px; }
.xline .chip { flex: none; }
.diffbox { border-top: 1px dashed #cbcbbf; margin-top: 12px; padding-top: 8px; }
.diffbox .preview { display: block; max-width: 100%; max-height: 220px; margin-top: 8px; border-radius: 8px; }
.photos { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.photos img { width: 110px; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid #dfe4da; }
.photos.big img { width: 100%; max-width: 360px; height: auto; max-height: 360px; object-fit: contain; background: #f3f5f1; }
.diffgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 360px); gap: 14px; margin-top: 10px; }
@media (max-width: 760px) { .diffgrid { grid-template-columns: 1fr; } }
.diffcard { margin-bottom: 14px; }
table.mini td.short { background: var(--warn-soft); }
