/* SHAAN Ops — Brand tokens: Forest Green #4B6743, Navy #21387F, Terracotta #E66E3E, Pale Mint #D5FFD2, Ink #20261F */
:root {
  --green: #4B6743;
  --navy: #21387F;
  --terra: #E66E3E;
  --mint: #D5FFD2;
  --ink: #20261F;
  --bg: #F7F8F5;
  --card: #fff;
  --border: #DDE3D6;
  --muted: #6B7A62;
  --radius: 8px;
  --fs: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "IBM Plex Sans Arabic", sans-serif; background: var(--bg); color: var(--ink); font-size: var(--fs); direction: rtl; }
h3,h4 { margin: 16px 0 8px; font-size:1.05em; color: var(--green); }

button.ghost { background:none; border:1px solid var(--border); color:var(--ink); padding:5px 10px; border-radius:var(--radius); cursor:pointer; font-family:inherit; font-size:var(--fs); }
button.ghost:hover { border-color:var(--green); color:var(--green); }
button.alt { background:var(--navy); color:#fff; border:none; padding:6px 12px; border-radius:var(--radius); cursor:pointer; font-family:inherit; font-size:var(--fs); }
button.alt:hover { opacity:.9; }

/* Sync */
#syncmsg { text-align:center; font-size:.85em; color:var(--muted); padding:4px; min-height:20px; }

/* Main */
main { max-width:1180px; margin:0 auto; padding:20px 24px 40px; }
.tab { display:none; }
.tab.on { display:block; }

/* Filters */
.filters { display:flex; flex-wrap:wrap; gap:8px; align-items:center; margin-bottom:12px; }
.filters label { display:flex; align-items:center; gap:4px; font-size:.9em; }
input, select { border:1px solid var(--border); border-radius:var(--radius); padding:6px 10px; font-family:inherit; font-size:var(--fs); background:#fff; color:var(--ink); }
input:focus, select:focus { outline:2px solid var(--green); }
button[type=submit], button:not(.ghost):not(.alt):not(.call-action):not(.move-btn):not([data-tab]):not(.icon-btn):not(.wa-chip) {
  background:var(--green); color:#fff; border:none; padding:6px 14px; border-radius:var(--radius); cursor:pointer; font-family:inherit; font-size:var(--fs);
}
button:not(.ghost):not(.alt):not(.call-action):not(.move-btn):not([data-tab]):not(.icon-btn):not(.wa-chip):hover { opacity:.9; }

/* Grid KPIs */
.grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(140px,1fr)); gap:10px; margin-bottom:16px; }
.kpi { background:var(--card); border:1px solid var(--border); border-radius:var(--radius); padding:12px; text-align:center; }
.kpi b { display:block; font-size:1.4em; color:var(--navy); }
.kpi span { font-size:.8em; color:var(--muted); }

/* Chips */
.chips { display:flex; flex-wrap:wrap; gap:6px; margin-bottom:12px; }
.chip { background:var(--mint); color:var(--ink); border-radius:12px; padding:4px 10px; font-size:.85em; }
.chip b { color:var(--green); margin-right:4px; }
.chip-sm { background:var(--terra); color:#fff; border-radius:8px; padding:2px 6px; font-size:.75em; margin-right:4px; }

/* Dash row */
.dash-row { display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-top:12px; }
@media(max-width:600px){.dash-row{grid-template-columns:1fr;}}

/* Alert */
.alert-warning { background:#FFF3CD; border:1px solid #FBBF24; color:#92400E; padding:10px 14px; border-radius:var(--radius); margin-top:8px; }
.muted { color:var(--muted); font-size:.9em; }

/* Cards (queue) */
.card { background:var(--card); border:1px solid var(--border); border-radius:var(--radius); padding:12px; margin-bottom:10px; }
.card-head { display:flex; gap:10px; flex-wrap:wrap; align-items:center; margin-bottom:8px; }
.card-actions { display:flex; flex-wrap:wrap; gap:6px; margin-bottom:8px; }
.card-phone { display:flex; gap:10px; }
.dot { width:10px; height:10px; border-radius:50%; flex-shrink:0; }
.dot-new { background:#6EE7B7; }
.dot-retry { background:#FCD34D; }
.dot-hot { background:var(--terra); }

/* Call action buttons */
.call-action { padding:5px 10px; border:none; border-radius:var(--radius); cursor:pointer; font-family:inherit; font-size:.85em; }
.call-action.confirmed { background:var(--green); color:#fff; }
.call-action.canceled { background:#EF4444; color:#fff; }
.call-action.no_answer, .call-action.busy { background:#FCD34D; color:var(--ink); }
.call-action.rejected { background:#F97316; color:#fff; }
.call-action.postponed { background:var(--navy); color:#fff; }
.call-action.wrong_number { background:#6B7280; color:#fff; }

/* Move buttons */
.move-btn { background:var(--bg); border:1px solid var(--border); color:var(--ink); font-size:.8em; padding:4px 8px; border-radius:6px; cursor:pointer; margin:2px; }
.move-btn:hover { border-color:var(--green); }

/* Tables */
table { width:100%; border-collapse:collapse; background:var(--card); border-radius:var(--radius); overflow:hidden; }
th { background:var(--ink); color:#fff; text-align:right; padding:8px 12px; font-size:.85em; font-weight:600; }
td { padding:8px 12px; border-bottom:1px solid var(--border); font-size:.9em; }
.order-row:hover td { background:var(--mint); }

/* Stage badges */
.stage { font-size:.8em; padding:2px 8px; border-radius:8px; background:var(--mint); }
.stage-delivered { background:var(--green); color:#fff; }
.stage-canceled, .stage-returned { background:#FEE2E2; color:#991B1B; }
.stage-shipped, .stage-out_for_delivery { background:#DBEAFE; color:#1D4ED8; }
.stage-confirmed, .stage-ready { background:#D1FAE5; color:#065F46; }
.stage-unreachable { background:#F3F4F6; color:#6B7280; }

/* Dialog */
dialog { border:none; border-radius:var(--radius); padding:20px; max-width:600px; width:90%; box-shadow:0 20px 60px rgba(0,0,0,.2); direction:rtl; }
dialog::backdrop { background:rgba(0,0,0,.4); }
dialog h3 { margin-bottom:8px; color:var(--navy); }
dialog p { margin-bottom:6px; font-size:.9em; }
dialog h4 { color:var(--green); margin:12px 0 4px; }
dialog ul { list-style:none; padding:0; }
dialog li { font-size:.85em; color:var(--muted); padding:2px 0; }

.row{display:flex;gap:6px;flex-wrap:wrap;margin-top:8px;align-items:center}
.tag{font-size:12px;border-radius:6px;padding:1px 7px;background:var(--mint);color:var(--green)}
.tag.warn{background:#FDEBE3;color:#9A3F1B}
.tag.ok{background:#E3F2E8;color:#1F6B3A}
.tag.bad{background:#F9E0E0;color:#9B1C1C}

/* ── login + user menu ── */
.login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #F4F6F3; z-index: 50; }
.login[hidden] { display: none; }
.login-card { display: flex; flex-direction: column; gap: 10px; width: min(340px, calc(100vw - 32px)); background: #fff;
  padding: 24px; border-radius: 12px; box-shadow: 0 6px 24px rgba(32,38,31,.12); }
.login-card .brand { font-size: 1.6rem; text-align: center; }
.warn-text { color: #B3261E; min-height: 1em; margin: 0; }
.me[hidden], [hidden] { display: none !important; }
.login-card .brand { color: #4B6743; }
.reason-list { display: grid; gap: 8px; margin: 12px 0; min-width: 260px; }
.pick td.qty { font-size: 1.6rem; font-weight: 700; width: 64px; text-align: center; }
.pick td { font-size: 1.1rem; }
.pack-actions button { font-size: 1.05rem; padding: 10px 16px; }
.addr-form { display: grid; gap: 8px; max-width: 520px; }
.chip.warn { background: #FDE7DC; color: #B3261E; }
tr.flash { background: #D5FFD2; }
/* picking list: shown over the page, and alone when printed */
#print-area { display: none; }
body.print-mode #print-area { display: block; position: fixed; inset: 0; overflow: auto; background: #fff; padding: 16px; z-index: 40; }
.pick-order { break-inside: avoid; margin: 8px 0; padding: 6px 0; border-bottom: 1px solid #ddd; }
@media print {
  body.print-mode > :not(#print-area) { display: none !important; }
  body.print-mode #print-area { position: static; padding: 0; }
  .no-print { display: none !important; }
}
.secret { font-family: monospace; font-size: 1.1rem; background: #F4F6F3; padding: 4px 8px; border-radius: 6px; user-select: all; }
tr.avoid td { background: #FDE7DC; }
.lbl.on { background: #D5FFD2; border-color: #4B6743; }
.note { background: #FFF8E1; padding: 6px 8px; border-radius: 6px; margin: 4px 0; }
.rule-edit { display: grid; gap: 6px; padding: 6px 0; }

/* ══ Shell: light sidebar (right, RTL) + top bar ════════════════════════════ */
:root { --side-w: 248px; --wa-green: #00A884; --wa-bubble-out: #D9FDD3; --wa-bg: #EFEAE2; --wa-panel: #F0F2F5; --wa-line: #E9EDEF;
  --nav-ink: #37433A; --nav-active: #E4EEE2; --nav-hover: #F2F5F0; }
.mi { font-family: "Material Symbols Rounded"; font-weight: normal; font-style: normal; font-size: 1.25em; line-height: 1;
  letter-spacing: normal; text-transform: none; display: inline-block; white-space: nowrap; direction: ltr; vertical-align: -0.22em;
  -webkit-font-smoothing: antialiased; font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24; user-select: none; }
button .mi, a .mi { pointer-events: none; }
body { padding-right: var(--side-w); min-height: 100vh; }
#side { position: fixed; top: 0; right: 0; bottom: 0; width: var(--side-w); background: #fff; color: var(--nav-ink);
  border-left: 1px solid var(--border); display: flex; flex-direction: column; z-index: 30; overflow-y: auto; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 12px; }
.side-head .brand { font-size: 1.3em; color: var(--green); }
.side-head .brand span { color: var(--terra); }
#side nav { display: flex; flex-direction: column; gap: 2px; padding: 4px 12px; flex: 1; }
.nav-group { display: flex; flex-direction: column; gap: 2px; margin-top: 14px; }
.nav-group > span { font-size: .72em; font-weight: 600; color: #8A9585; padding: 4px 14px; letter-spacing: .03em; }
#side nav button { display: flex; align-items: center; gap: 14px; width: 100%; text-align: right; background: none; border: none;
  color: var(--nav-ink); padding: 10px 14px; border-radius: 12px; cursor: pointer; font-family: inherit; font-size: 14.5px; font-weight: 600; }
#side nav button .mi { font-size: 22px; color: #3F4B42; }
#side nav button:hover { background: var(--nav-hover); }
#side nav button.on { background: var(--nav-active); color: var(--green); }
#side nav button.on .mi { color: var(--green); }
#side nav button b { margin-right: auto; background: var(--terra); color: #fff; border-radius: 10px; padding: 0 7px; font-size: .72em; line-height: 18px; }
#side nav button b:empty { display: none; }
#side nav button[data-tab="inbox"] b { background: var(--wa-green); }
.me { border-top: 1px solid var(--border); padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 8px; color: var(--nav-ink); }
.me-who { display: flex; align-items: center; gap: 10px; }
.me-who b { display: block; color: var(--ink); }
.me-who small { color: #8A9585; }
.me label { font-size: .85em; display: flex; gap: 6px; align-items: center; color: #5B6858; }
.me-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.me-actions .ghost { font-size: 12px; padding: 3px 9px; border-radius: 8px; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 24px;
  background: rgba(247,248,245,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--border); }
.topbar h1 { font-size: 1.2em; color: var(--ink); flex: 1; font-weight: 600; }
.topbar #sync { display: inline-flex; align-items: center; gap: 6px; }
.icon-btn { background: none; border: none; font-size: 18px; line-height: 1; padding: 7px; border-radius: 50%; cursor: pointer;
  color: #54656F; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn .mi { font-size: 24px; vertical-align: middle; }
.icon-btn:hover { background: rgba(0,0,0,.06); }
.only-mobile { display: none; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 14px; flex-shrink: 0; background: var(--green); }
.avatar.big { width: 96px; height: 96px; font-size: 32px; }
#me-avatar { width: 36px; height: 36px; font-size: 13px; background: var(--green); }
.card { border-radius: 12px; box-shadow: 0 1px 2px rgba(32,38,31,.05); }
table { border-radius: 12px; box-shadow: 0 1px 2px rgba(32,38,31,.05); }
th { background: #EEF2EA; color: var(--ink); }
.kpi { border-radius: 12px; }
button .mi, .tag .mi, .chip .mi, h3 .mi, h4 .mi, p .mi, .alert-warning .mi { font-size: 1.15em; margin-left: 3px; }
.dot-on { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--wa-green); margin-left: 4px; }
.wa-empty-logo .mi { font-size: 64px; color: #8696A0; }
.wa-preview .mi { font-size: 16px; color: #53BDEB; vertical-align: -3px; }
.wa-send .mi { font-size: 22px; }
.bell-ic .mi { color: #54656F; } .bell-ic.problem .mi { color: #D93025; } .bell-ic.chat .mi { color: var(--wa-green); }
@media (max-width: 900px) {
  body { padding-right: 0; }
  #side { transform: translateX(100%); transition: transform .2s ease; box-shadow: -8px 0 24px rgba(0,0,0,.18); }
  body.side-open #side { transform: none; }
  #side-shade { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 25; display: none; }
  body.side-open #side-shade { display: block; }
  .only-mobile { display: inline-flex; }
  .topbar { padding: 10px 12px; }
  main { padding: 12px 12px 32px; }
}

/* ══ Inbox: WhatsApp Web look ═══════════════════════════════════════════════ */
body.full-tab main { max-width: none; padding: 0; }
.wa { display: grid; grid-template-columns: 360px 1fr; height: calc(100vh - 57px); background: #fff; border-top: 1px solid var(--wa-line); }
.wa.info-open { grid-template-columns: 360px 1fr 320px; }
.wa-list { display: flex; flex-direction: column; border-left: 1px solid var(--wa-line); min-height: 0; background: #fff; }
.wa-list-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 8px; }
.wa-list-head b { font-size: 1.15em; }
.wa-hours { font-size: .8em; color: #667781; }
.wa-search { padding: 4px 12px 8px; }
.wa-search input { width: 100%; background: var(--wa-panel); border: none; border-radius: 8px; padding: 9px 14px; }
.wa-search input:focus { outline: 2px solid var(--wa-green); }
.wa-chips { display: flex; gap: 6px; padding: 0 12px 8px; overflow-x: auto; scrollbar-width: none; }
.wa-chip { border: none; background: var(--wa-panel); color: #54656F; border-radius: 16px; padding: 5px 12px; font-family: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.wa-chip.on { background: #E7FCE3; color: #008069; font-weight: 600; }
.wa-convs { overflow-y: auto; flex: 1; }
.wa-conv { display: flex; gap: 12px; padding: 10px 14px; cursor: pointer; align-items: center; }
.wa-conv:hover { background: #F5F6F6; }
.wa-conv.on { background: var(--wa-panel); }
.wa-conv-body { flex: 1; min-width: 0; border-bottom: 1px solid var(--wa-line); padding-bottom: 10px; }
.wa-conv-top, .wa-conv-bottom { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.wa-conv-top b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-conv-top small { color: #667781; font-size: 12px; flex-shrink: 0; }
.wa-conv-top small.fresh { color: var(--wa-green); font-weight: 600; }
.wa-preview { color: #667781; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.wa-unread { background: var(--wa-green); color: #fff; border-radius: 10px; min-width: 20px; height: 20px; font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; font-weight: 600; }
.wa-fail { background: #F15C6D; color: #fff; border-radius: 50%; width: 18px; height: 18px; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; }
.wa-labels { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.wa-labels span { font-size: 11px; background: #FFF4E5; color: #9A5B00; border-radius: 6px; padding: 0 6px; }
.wa-none { color: #667781; text-align: center; padding: 30px 16px; }
.wa-chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; background-color: var(--wa-bg);
  background-image: radial-gradient(rgba(75,103,67,.07) 1px, transparent 1px), radial-gradient(rgba(230,110,62,.05) 1px, transparent 1px);
  background-size: 22px 22px, 34px 34px; background-position: 0 0, 11px 17px; }
.wa-empty { margin: auto; text-align: center; max-width: 420px; color: #667781; padding: 24px; }
.wa-empty-logo { font-size: 56px; }
.wa-empty h2 { color: #41525D; font-weight: 400; margin: 12px 0 8px; font-size: 1.6em; }
.wa-chat-head { display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: var(--wa-panel); border-bottom: 1px solid var(--wa-line); }
.wa-chat-head .avatar { width: 40px; height: 40px; }
.wa-who { flex: 1; min-width: 0; }
.wa-who b { display: block; }
.wa-who small { color: #667781; font-size: 12px; direction: ltr; unicode-bidi: plaintext; }
.wa-back { display: none; }
.wa-msgs { flex: 1; overflow-y: auto; padding: 16px 6% 10px; display: flex; flex-direction: column; gap: 3px; }
.wa-day { text-align: center; margin: 10px 0 6px; }
.wa-day span { background: #fff; color: #54656F; font-size: 12px; padding: 4px 12px; border-radius: 8px; box-shadow: 0 1px .5px rgba(11,20,26,.13); }
.wa-bubble { position: relative; max-width: min(65%, 560px); padding: 6px 9px 8px; border-radius: 8px; box-shadow: 0 1px .5px rgba(11,20,26,.13);
  font-size: 14.2px; line-height: 1.45; word-wrap: break-word; }
.wa-text { white-space: pre-wrap; }
/* RTL like WhatsApp in Arabic: the customer on the right, us on the left */
.wa-bubble.in { align-self: flex-start; background: #fff; border-top-right-radius: 0; }
.wa-bubble.out { align-self: flex-end; background: var(--wa-bubble-out); border-top-left-radius: 0; }
.wa-bubble.in + .wa-bubble.in, .wa-bubble.out + .wa-bubble.out { border-radius: 8px; }
.wa-tpl { font-size: 11.5px; color: #008069; margin-bottom: 2px; }
.wa-meta { font-size: 11px; color: #667781; text-align: left; margin-top: 2px; direction: ltr; }
.tick { font-style: normal; color: #8696A0; letter-spacing: -3px; margin-left: 2px; }
.tick.read { color: #53BDEB; }
.tick.fail { color: #F15C6D; font-weight: 700; letter-spacing: 0; }
.wa-err { font-size: 12px; color: #B3261E; margin-top: 4px; }
.wa-compose { display: flex; align-items: flex-end; gap: 8px; padding: 8px 12px; background: var(--wa-panel); }
.wa-compose textarea { flex: 1; resize: none; border: none; border-radius: 8px; padding: 10px 12px; font-family: inherit; font-size: 15px;
  max-height: 140px; background: #fff; }
.wa-compose textarea:focus { outline: none; }
.wa-send { width: 42px; height: 42px; border-radius: 50%; border: none; background: var(--wa-green) !important; color: #fff;
  font-size: 18px; cursor: pointer; transform: scaleX(-1); flex-shrink: 0; padding: 0 !important; }
.wa-qr { background: #fff; border-top: 1px solid var(--wa-line); max-height: 220px; overflow-y: auto; }
.wa-qr button { display: flex; gap: 10px; width: 100%; text-align: right; border: none; background: none !important; color: var(--ink) !important;
  padding: 8px 16px !important; cursor: pointer; font-family: inherit; border-radius: 0 !important; }
.wa-qr button:hover { background: var(--wa-panel) !important; }
.wa-qr button b { color: #008069; flex-shrink: 0; }
.wa-qr button span { color: #54656F; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-qr p { padding: 10px 16px; }
.wa-closed { background: #FFF8E1; border-top: 1px solid #F3E2B3; padding: 10px 16px; font-size: 13.5px; color: #6B5300; }
.wa-info { background: #fff; border-right: 1px solid var(--wa-line); overflow-y: auto; }
.wa-info-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--wa-panel); }
.wa-info-card { text-align: center; padding: 24px 16px; border-bottom: 8px solid var(--wa-panel); }
.wa-info-card h3 { color: var(--ink); margin: 12px 0 4px; font-size: 1.2em; }
.wa-info-card p { color: #667781; }
.wa-info-sec { padding: 12px 16px; border-bottom: 8px solid var(--wa-panel); }
.wa-info-sec h4 { color: #008069; margin: 0 0 8px; font-size: .9em; }
.wa-order { display: flex; gap: 8px; align-items: center; padding: 6px 0; color: var(--ink); text-decoration: none; }
.wa-info .note { display: flex; flex-direction: column; gap: 2px; }
@media (max-width: 1100px) { .wa.info-open { grid-template-columns: 300px 1fr; } .wa-info { position: fixed; inset: 0 auto 0 0; width: min(340px, 100vw); z-index: 35; box-shadow: 8px 0 24px rgba(0,0,0,.2); } }
@media (max-width: 900px) {
  .wa, .wa.info-open { grid-template-columns: 1fr; height: calc(100vh - 53px); }
  .wa .wa-chat { display: none; }
  .wa.chat-open .wa-list { display: none; }
  .wa.chat-open .wa-chat { display: flex; }
  .wa-back { display: inline-flex; }
  .wa-bubble { max-width: 85%; }
  .wa-msgs { padding: 12px 10px; }
}
/* the inbox fills the window under the top bar, whatever banners are shown above it */
body.full-tab { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
body.full-tab main { flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; }
body.full-tab #inbox.on { flex: 1; min-height: 0; display: flex; flex-direction: column; }
body.full-tab .wa { flex: 1; height: auto; min-height: 0; }
body.full-tab .alert-warning { margin: 6px 12px; }

/* 🔔 notifications */
.bell-wrap { position: relative; }
#bell { position: relative; }
#bell b { position: absolute; top: 0; left: 0; background: var(--terra); color: #fff; font-size: 11px; border-radius: 9px; min-width: 18px; height: 18px; line-height: 18px; text-align: center; padding: 0 4px; }
#bell b:empty { display: none; }
.bell-panel { position: absolute; left: 0; top: 44px; width: min(360px, calc(100vw - 24px)); max-height: 70vh; overflow-y: auto; background: #fff;
  border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(32,38,31,.18); z-index: 40; }
.bell-head { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.bell-item { display: flex; gap: 10px; padding: 10px 16px; border-bottom: 1px solid #F0F2EE; cursor: default; }
.bell-item[data-order] { cursor: pointer; }
.bell-item:hover { background: #F7F8F5; }
.bell-item.new { background: #F1FBEF; }
.bell-item p { color: #54656F; font-size: 13px; margin-top: 2px; }
.bell-item small { color: #8A9585; font-size: 11.5px; }
/* phones: a wide table scrolls inside itself, the page never gets wider than the screen */
@media (max-width: 900px) {
  table { display: block; overflow-x: auto; white-space: nowrap; max-width: 100%; }
  .dash-row > * { min-width: 0; }
  .filters input, .filters select { max-width: 100%; }
}

/* order history */
li.ev { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid #F0F2EE; list-style: none; }
li.ev .ev-ic { color: var(--green); font-size: 20px; margin-top: 1px; }
li.ev small { display: block; font-size: 11.5px; }

/* daily report */
.report-card summary { cursor: pointer; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.report-text { white-space: pre-wrap; font-family: inherit; background: #F7F8F5; border-radius: 10px; padding: 12px 14px; margin: 10px 0; line-height: 1.7; }
.install-btn { display: inline-flex; align-items: center; gap: 6px; justify-content: center; font-size: 13px; }

/* work guide */
#guide { max-width: 640px; }
.guide-head { display: flex; justify-content: space-between; align-items: center; }
#guide-body ol { padding-right: 20px; margin: 4px 0 10px; }
#guide-body li { margin: 6px 0; line-height: 1.6; color: var(--ink); font-size: .95em; }
#guide .wa-chips { padding: 6px 0 4px; }
#wa-ai-btn .mi { color: #7A5C99; }
#wa-ai-btn.busy .mi { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* system health */
.health summary { cursor: pointer; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.health-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-right: auto; }
.hp { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; padding: 2px 8px; border-radius: 12px; }
.hp .mi { font-size: 16px; }
.hp.ok { background: #E3F2E8; color: #1F6B3A; } .hp.bad { background: #F9E0E0; color: #9B1C1C; } .hp.off { background: #EEF0EC; color: #6B7A62; }

/* top-bar search */
.search-wrap { position: relative; display: flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; padding: 0 10px; flex: 0 1 380px; }
.search-wrap .mi { color: #8A9585; }
.search-wrap input { border: none; padding: 8px 2px; flex: 1; min-width: 0; background: none; }
.search-wrap input:focus { outline: none; }
.search-res { position: absolute; top: 42px; right: 0; left: 0; background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(32,38,31,.16); z-index: 45; max-height: 60vh; overflow-y: auto; min-width: 300px; }
.sr { padding: 9px 14px; border-bottom: 1px solid #F0F2EE; cursor: pointer; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.sr:hover { background: #F7F8F5; }
@media (max-width: 900px) { .search-wrap { order: 5; flex-basis: 100%; } .topbar { flex-wrap: wrap; } }

/* confirmation card: script + secondary outcomes */
details.script { margin: 6px 0 8px; background: #F7F8F5; border-radius: 10px; padding: 6px 12px; }
details.script summary { cursor: pointer; color: var(--green); font-weight: 600; }
details.script ol { padding-right: 18px; margin: 6px 0; line-height: 1.8; }
details.script p { font-size: .85em; line-height: 1.7; }
details.more-outcomes { display: inline-block; }
details.more-outcomes summary { cursor: pointer; list-style: none; padding: 5px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: .85em; color: var(--muted); }
details.more-outcomes[open] { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; margin-top: 6px; }
.card-phone { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.card-phone a, .card-phone button { display: inline-flex; align-items: center; gap: 4px; }

/* folded sections (settings, team, dashboard, order dialog) */
details.set-sec, details.od-sec { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 0 14px; margin: 10px 0; }
details.set-sec > summary, details.od-sec > summary { cursor: pointer; padding: 12px 0; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 6px; }
details.set-sec[open] > summary, details.od-sec[open] > summary { border-bottom: 1px solid var(--border); margin-bottom: 10px; }
details.set-sec[open], details.od-sec[open] { padding-bottom: 12px; }
.od-head h3 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.od-head p { margin: 4px 0; }
.od-actions { padding: 6px 0 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }

/* ══ Design system v2 (2026-10-29) ═════════════════════════════════════════════
   Neutral surfaces (zinc-like, slightly warm), brand green for primary actions, Terracotta (#E66E3E,
   SHAAN's own orange) for active indicators, focus and highlights. Dark mode = same tokens, other values.
   Set by <html data-theme="light|dark"> (remembered per device, default follows the system). */
:root {
  --accent: #E66E3E; --accent-soft: #FDEEE7;
  --bg: #F6F6F4; --card: #FFFFFF; --card-2: #FAFAF9; --border: #E5E5E2; --border-strong: #D4D4CF;
  --ink: #1F2420; --muted: #6E7470; --nav-ink: #3A403B; --nav-active: #F1F3EF; --nav-hover: #F5F5F3;
  --ok: #16A34A; --ok-soft: #E8F6EC; --warn: #D97706; --warn-soft: #FEF3E2; --bad: #DC2626; --bad-soft: #FDECEC;
  --shadow: 0 1px 2px rgba(20,24,20,.04), 0 1px 1px rgba(20,24,20,.03); --shadow-lg: 0 10px 30px rgba(20,24,20,.10);
  --radius: 10px; --radius-xl: 14px;
}
:root[data-theme="dark"] {
  --bg: #0E100F; --card: #17191A; --card-2: #1C1F1E; --border: #2A2E2C; --border-strong: #3A3F3C;
  --ink: #ECEEEC; --muted: #9AA19C; --nav-ink: #C9CEC9; --nav-active: #212624; --nav-hover: #1C201E;
  --green: #7FA673; --navy: #8EA3E6; --mint: #1E2B1E; --accent-soft: #3A2318;
  --ok: #4ADE80; --ok-soft: #13261A; --warn: #FBBF24; --warn-soft: #2C2212; --bad: #F87171; --bad-soft: #2E1616;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
  --wa-panel: #1C1F1E; --wa-line: #2A2E2C; --wa-bg: #111413; --wa-bubble-out: #1F3A2A;
  color-scheme: dark;
}
body { background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }

/* surfaces follow the tokens (they were hard-coded white / light green) */
#side, .card, .kpi, table, dialog, .bell-panel, .search-res, .login-card, .search-wrap, details.set-sec, details.od-sec,
.wa, .wa-list, .wa-info, .wa-compose textarea, .wa-qr, .wa-day span, .wa-bubble.in { background: var(--card); color: var(--ink); }
input, select, textarea { background: var(--card); color: var(--ink); border-color: var(--border); }
.topbar { background: color-mix(in srgb, var(--bg) 88%, transparent); border-bottom-color: var(--border); }
th { background: var(--card-2); color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); }
td { border-bottom-color: var(--border); }
.order-row:hover td, .sr:hover, .bell-item:hover, .wa-conv:hover { background: var(--nav-hover); }
.login { background: var(--bg); }
.report-text, details.script, .secret, .note { background: var(--card-2); color: var(--ink); }
.wa-chat-head, .wa-compose, .wa-info-head { background: var(--wa-panel); }
.bell-item.new { background: var(--ok-soft); }
.bell-head, .bell-item, .sr, li.ev { border-color: var(--border); }
.me, #side { border-color: var(--border); }
.me-who b, .wa-conv-top b { color: var(--ink); }
button.ghost, a.ghost { color: var(--ink); border-color: var(--border); background: transparent; }
button.ghost:hover, a.ghost:hover { border-color: var(--accent); color: var(--accent); }
a.btn-link { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border: 1px solid var(--border);
  border-radius: var(--radius); text-decoration: none; font-size: var(--fs); white-space: nowrap; }
.card, table, details.set-sec, details.od-sec { border-color: var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow); }

/* sidebar: the active page gets a terracotta bar */
#side nav button { position: relative; }
#side nav button.on { background: var(--nav-active); color: var(--ink); }
#side nav button.on .mi { color: var(--accent); }
#side nav button.on::before { content: ""; position: absolute; right: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--accent); }
#side nav button .mi { color: var(--muted); }
#side nav button b { background: var(--accent); }

/* KPI cards: one clean grid, never overflowing */
.grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi { position: relative; text-align: right; padding: 14px 16px 12px; border: 1px solid var(--border); border-radius: var(--radius-xl);
  box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; min-width: 0; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.kpi b { display: block; font-size: clamp(1.25em, 2.2vw, 1.6em); font-weight: 700; color: var(--ink); line-height: 1.2;
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.kpi b small { font-size: .55em; color: var(--muted); font-weight: 500; }
.kpi > span { display: block; font-size: .82em; color: var(--muted); margin-top: 4px; overflow-wrap: anywhere; }
.kpi > small { display: block; font-size: .72em; color: var(--muted); margin-top: 6px; line-height: 1.5; overflow-wrap: anywhere; }
.kpi-ic { position: absolute; left: 12px; top: 12px; font-style: normal; width: 30px; height: 30px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center; background: var(--card-2); color: var(--muted); }
.kpi-ic .mi { font-size: 18px; margin: 0; }
.kpi.good b { color: var(--ok); } .kpi.good .kpi-ic { background: var(--ok-soft); color: var(--ok); }
.kpi.warn b { color: var(--warn); } .kpi.warn .kpi-ic { background: var(--warn-soft); color: var(--warn); }
.kpi.bad b { color: var(--bad); } .kpi.bad .kpi-ic { background: var(--bad-soft); color: var(--bad); }
.kpi.bad { border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }

/* dashboard filters: quick ranges + dates + downloads on one line, wrapping cleanly */
.dash-filters { gap: 10px; }
.range-chips { display: inline-flex; gap: 4px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.range-chip { background: transparent !important; color: var(--muted) !important; border: none; padding: 5px 10px !important;
  border-radius: 7px !important; font-size: .85em !important; cursor: pointer; }
.range-chip.on, .range-chip:hover { background: var(--accent-soft) !important; color: var(--accent) !important; }
.dl-group { display: inline-flex; gap: 6px; flex-wrap: wrap; margin-right: auto; }

/* system status: glowing dots, green / yellow / red */
.hp { position: relative; gap: 6px; padding: 3px 10px 3px 9px; border: 1px solid var(--border); background: var(--card); color: var(--ink); }
.hp .mi { display: none; }
.hp::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.hp.ok { background: var(--card); color: var(--ink); } .hp.ok::before { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft), 0 0 8px var(--ok); }
.hp.warn::before { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft), 0 0 8px var(--warn); }
.hp.bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, var(--border)); }
.hp.bad::before { background: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 25%, transparent), 0 0 10px var(--bad); animation: pulse 1.6s ease-in-out infinite; }
.hp.off { background: transparent; color: var(--muted); } .hp.off::before { background: var(--border-strong); }
@keyframes pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .hp.bad::before { animation: none; } .kpi { transition: none; } }

/* toasts */
#toasts { position: fixed; bottom: 18px; left: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 36px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; background: var(--card); color: var(--ink); border: 1px solid var(--border);
  border-inline-start: 4px solid var(--ok); border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow-lg); font-size: .9em;
  opacity: 0; transform: translateY(8px); transition: opacity .2s ease, transform .2s ease; overflow-wrap: anywhere; }
.toast.in { opacity: 1; transform: none; }
.toast .mi { color: var(--ok); margin: 0; flex-shrink: 0; }
.toast.error { border-inline-start-color: var(--bad); } .toast.error .mi { color: var(--bad); }
.toast.warn { border-inline-start-color: var(--warn); } .toast.warn .mi { color: var(--warn); }
.toast.info { border-inline-start-color: var(--accent); } .toast.info .mi { color: var(--accent); }

/* top bar controls */
.refresh-sel { padding: 5px 8px; font-size: .85em; border-radius: 9px; max-width: 150px; }

/* RTL text never overflows its box */
.card, .kpi, td, .wa-conv-body, .bell-item, .chip { overflow-wrap: anywhere; }
.chip { background: var(--mint); color: var(--ink); }
.stage { background: var(--mint); color: var(--ink); }
.tag { background: var(--mint); }

/* tablets and phones: sidebar collapses, top bar wraps, controls stay reachable */
@media (max-width: 1100px) { .hide-sm { display: none; } }
@media (max-width: 900px) {
  .refresh-sel { max-width: 120px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dl-group { margin-right: 0; }
  .range-chips { flex-wrap: wrap; }
  #toasts { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}
@media (max-width: 330px) { .grid { grid-template-columns: 1fr; } }
.topbar h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
@media (max-width: 900px) { .topbar h1 { font-size: 1.05em; } .kpi { padding: 12px; } .kpi-ic { width: 26px; height: 26px; } }
.alert-warning { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 45%, transparent); color: var(--ink); }
.alert-warning .mi { color: var(--warn); }
.wa-closed { background: var(--warn-soft); border-top-color: var(--border); color: var(--ink); }
.wa-preview, .wa-conv-top small, .wa-hours, .wa-who small, .wa-meta, .wa-none { color: var(--muted); }
.wa-chip { background: var(--wa-panel); color: var(--muted); }
.wa-search input { background: var(--wa-panel); color: var(--ink); }
.wa-info-card, .wa-info-sec { border-bottom-color: var(--wa-panel); }
@media (max-width: 900px) {
  .topbar h1 { min-width: 92px; flex: 1 1 92px; }
  .refresh-sel { max-width: 92px; padding: 5px 4px; font-size: .78em; }
}
