/* Elmalek Market — staff inbox. Cairo font, calm RTL theme. */
:root {
  --bg: #F3F5F4;
  --chat-bg: #EEF1EF;
  --surface: #FFFFFF;
  --surface-alt: #F1F4F3;
  --sidebar: #FFFFFF;
  --border: #DDE4E2;
  --text: #15201E;
  --text-muted: #4D5E5B;
  --text-faint: #6B7B78;

  --brand: #0E6B63;
  --brand-hover: #0A564F;
  --brand-soft: rgba(14, 107, 99, 0.10);
  --brand-border: rgba(14, 107, 99, 0.30);

  --gold: #B8860B;
  --gold-soft: rgba(201, 162, 39, 0.14);

  --amber: #A85F00;
  --amber-soft: rgba(232, 146, 21, 0.14);
  --amber-border: rgba(232, 146, 21, 0.38);

  --blue: #1D4ED8;
  --blue-soft: rgba(37, 99, 235, 0.10);
  --blue-border: rgba(37, 99, 235, 0.30);

  --danger: #B42318;
  --danger-soft: rgba(217, 45, 32, 0.10);
  --danger-border: rgba(217, 45, 32, 0.34);

  /* Branch colours */
  --zohour: #7C3AED;
  --zohour-soft: rgba(124, 58, 237, 0.10);
  --haseb: #2563EB;
  --haseb-soft: rgba(37, 99, 235, 0.10);

  --bubble-customer: #FFFFFF;
  --bubble-staff: #D9F2EC;
  --bubble-staff-border: #B9E2D8;
  --bubble-bot: #F6F7F7;
  --bubble-note: #FFF6DE;
  --bubble-note-border: #F0D58C;

  --shadow-sm: 0 1px 2px rgba(17, 36, 33, 0.06);
  --shadow: 0 6px 24px rgba(17, 36, 33, 0.08);
  --radius: 14px;
}


html.dark {
  --bg: #0F1514;
  --chat-bg: #0C1211;
  --surface: #172120;
  --surface-alt: #1D2A28;
  --sidebar: #141D1C;
  --border: #283735;
  --text: #EAF1EF;
  --text-muted: #A6B8B4;
  --text-faint: #7E918D;

  --brand: #3FB5A8;
  --brand-hover: #35A094;
  --brand-soft: rgba(63, 181, 168, 0.15);
  --brand-border: rgba(63, 181, 168, 0.36);

  --gold: #E3B94A;
  --gold-soft: rgba(227, 185, 74, 0.14);

  --amber: #F5B84C;
  --amber-soft: rgba(245, 184, 76, 0.15);
  --amber-border: rgba(245, 184, 76, 0.34);

  --blue: #8AB4FF;
  --blue-soft: rgba(138, 180, 255, 0.14);
  --blue-border: rgba(138, 180, 255, 0.32);

  --danger: #FF8A80;
  --danger-soft: rgba(255, 138, 128, 0.14);
  --danger-border: rgba(255, 138, 128, 0.34);

  --zohour: #B794F6;
  --zohour-soft: rgba(183, 148, 246, 0.15);
  --haseb: #8AB4FF;
  --haseb-soft: rgba(138, 180, 255, 0.15);

  --bubble-customer: #1D2A28;
  --bubble-staff: #154039;
  --bubble-staff-border: #1F5A50;
  --bubble-bot: #1A2422;
  --bubble-note: #2E2615;
  --bubble-note-border: #5A4720;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.36);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; }

.hidden { display: none !important; }

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.btn-full { width: 100%; padding: 12px 16px; font-size: 16px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-soft { background: var(--surface-alt); border-color: var(--border); color: var(--text); }
.btn-soft:hover { border-color: var(--brand-border); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-alt); color: var(--text); }

/* Pills & dots */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 700;
  padding: 1px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
  line-height: 1.8;
}
.pill-teal { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-border); }
.pill-amber { background: var(--amber-soft); color: var(--amber); border-color: var(--amber-border); }
.pill-blue { background: var(--blue-soft); color: var(--blue); border-color: var(--blue-border); }
.pill-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.pill-muted { background: var(--surface-alt); color: var(--text-muted); border-color: var(--border); }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--text-faint); flex-shrink: 0; }
.dot-online { background: #16A34A; box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.18); }
.dot-busy { background: #E89215; }
.dot-offline { background: #9AA8A5; }

/* Branch tag */
.branch-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 700;
  padding: 1px 9px;
  border-radius: 7px;
  white-space: nowrap;
  line-height: 1.8;
}
.branch-tag::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.branch-zohour { color: var(--zohour); background: var(--zohour-soft); }
.branch-haseb { color: var(--haseb); background: var(--haseb-soft); }
.branch-other { color: var(--text-muted); background: var(--surface-alt); }

/* Login */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(1200px 500px at 50% -10%, var(--brand-soft), transparent 70%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 34px 30px 24px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-logo-wrap {
  width: 92px;
  height: 92px;
  margin: 0 auto 14px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--gold-soft);
  background: #fff;
}
.login-logo { width: 100%; height: 100%; object-fit: cover; }
.login-title { margin: 0; font-size: 24px; font-weight: 800; }
.login-sub { margin: 2px 0 24px; font-size: 14px; color: var(--text-muted); }
.login-form { text-align: right; display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 700; }
.field input {
  width: 100%;
  padding: 11px 13px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 15px;
}
.field input:focus { outline: none; border-color: var(--brand); background: var(--surface); }
.login-error {
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  font-size: 13.5px;
  font-weight: 700;
}
.login-footer { margin-top: 16px; }

/* App shell */
.app-shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }

.topbar {
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
}
.topbar-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gold-soft);
  background: #fff;
  flex-shrink: 0;
}
.brand-text { min-width: 0; }
.brand-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.brand-name { margin: 0; font-size: 18px; font-weight: 800; line-height: 1.3; }
.brand-sub { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* My status button */
.status-btn { gap: 8px; padding: 7px 14px; border-radius: 999px; font-size: 14px; }
.status-btn.is-online { background: rgba(22, 163, 74, 0.10); border-color: rgba(22, 163, 74, 0.35); color: #15803D; }
.status-btn.is-busy { background: var(--amber-soft); border-color: var(--amber-border); color: var(--amber); }
.status-btn.is-offline { background: var(--surface-alt); border-color: var(--border); color: var(--text-muted); }
html.dark .status-btn.is-online { color: #4ADE80; }

/* Workspace */
.workspace { flex: 1; min-height: 0; display: flex; overflow: hidden; }

.pane-list {
  width: 360px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.list-controls {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: var(--surface-alt);
  padding: 4px;
  border-radius: 12px;
}
.tab-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 4px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}
.tab-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.tab-count {
  font-size: 12px;
  min-width: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--border);
  color: var(--text-muted);
  line-height: 1.7;
}
.tab-count.has-open { background: var(--danger); color: #fff; }

.filter-row { display: flex; gap: 8px; }
.input-search, .select-inbox {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 11px;
  font-size: 13.5px;
}
.input-search { flex: 1; min-width: 0; }
.select-inbox { max-width: 150px; cursor: pointer; }
.input-search:focus, .select-inbox:focus { outline: none; border-color: var(--brand); background: var(--surface); }

.conv-list { flex: 1; overflow-y: auto; }
.conv-item {
  width: 100%;
  text-align: right;
  padding: 12px 14px;
  border: none;
  border-bottom: 1px solid var(--border);
  border-right: 4px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: flex;
  gap: 11px;
  align-items: flex-start;
  transition: background 0.12s;
}
.conv-item:hover { background: var(--surface-alt); }
.conv-item.active { background: var(--brand-soft); border-right-color: var(--brand); }
.conv-item.is-late { border-right-color: var(--danger); }
.conv-item.active.is-late { border-right-color: var(--danger); }

.conv-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 17px;
  flex-shrink: 0;
}
.conv-avatar.branch-zohour::before, .conv-avatar.branch-haseb::before { display: none; }
.conv-body { flex: 1; min-width: 0; }
.conv-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.conv-name-wrap { display: flex; align-items: center; gap: 6px; min-width: 0; }
.conv-name { font-size: 15px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item.unread .conv-name { color: var(--text); }
.unread-badge {
  min-width: 21px;
  height: 21px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.conv-time { font-size: 12px; color: var(--text-faint); flex-shrink: 0; }
.conv-preview {
  font-size: 13.5px;
  color: var(--text-muted);
  margin: 1px 0 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-item.unread .conv-preview { color: var(--text); font-weight: 600; }
.conv-bottom { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.conv-kind { font-size: 12px; color: var(--text-faint); }
.wait-chip { margin-inline-start: auto; }

/* Chat pane */
.pane-chat { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--chat-bg); }
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
}
.empty-logo { width: 88px; height: 88px; border-radius: 50%; margin-bottom: 14px; border: 3px solid var(--gold-soft); background: #fff; object-fit: cover; }
.chat-empty h2 { margin: 0 0 6px; font-size: 19px; color: var(--text); }
.chat-empty p { margin: 0; font-size: 14px; max-width: 380px; }

.chat-active { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-header {
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.chat-header-info { display: flex; align-items: center; gap: 11px; min-width: 0; }
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  flex-shrink: 0;
}
.avatar::before { display: none !important; }
.chat-title-wrap { min-width: 0; }
.chat-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chat-name { margin: 0; font-size: 17px; font-weight: 800; line-height: 1.35; }
.chat-sub { font-size: 13px; color: var(--text-muted); }
.chat-sub bdi { font-weight: 700; }
.chat-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.status-banner {
  flex-shrink: 0;
  padding: 7px 18px;
  font-size: 13.5px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
}
.status-banner.is-open { background: var(--brand-soft); color: var(--brand); border-bottom-color: var(--brand-border); }
.status-banner.is-bot { background: var(--blue-soft); color: var(--blue); border-bottom-color: var(--blue-border); }

.messages-feed {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.day-sep { align-self: center; font-size: 12.5px; font-weight: 700; color: var(--text-muted); background: var(--surface); border: 1px solid var(--border); padding: 1px 12px; border-radius: 999px; }

.msg-row { display: flex; }
.msg-row.incoming { justify-content: flex-start; }
.msg-row.outgoing { justify-content: flex-end; }
.msg-row.center { justify-content: center; }

.bubble {
  max-width: 70%;
  padding: 8px 13px 6px;
  border-radius: 14px;
  font-size: 15px;
  word-break: break-word;
  box-shadow: var(--shadow-sm);
}
.msg-text { white-space: pre-wrap; }
.bubble-customer { background: var(--bubble-customer); border: 1px solid var(--border); border-top-right-radius: 4px; }
.bubble-bot { background: var(--bubble-bot); border: 1px dashed var(--border); border-top-left-radius: 4px; color: var(--text-muted); }
.bubble-staff { background: var(--bubble-staff); border: 1px solid var(--bubble-staff-border); border-top-left-radius: 4px; }
.bubble-note {
  max-width: 82%;
  background: var(--bubble-note);
  border: 1px solid var(--bubble-note-border);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 14px;
}
.bubble-author { font-size: 12.5px; font-weight: 800; color: var(--brand); margin-bottom: 1px; }
.bubble-bot .bubble-author { color: var(--blue); }
.bubble-meta { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; text-align: left; }

.bot-fold summary {
  cursor: pointer;
  list-style: none;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--blue);
}
.bot-fold summary::-webkit-details-marker { display: none; }
.bot-fold summary .preview { color: var(--text-muted); font-weight: 500; }
.bot-fold[open] summary { margin-bottom: 4px; }

/* Order / handoff card */
.smart-card {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: var(--shadow-sm);
}
.smart-card.handoff { background: var(--bubble-note); border-color: var(--bubble-note-border); }
.smart-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 7px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-weight: 800;
  font-size: 14.5px;
}
.smart-card-body { font-size: 14px; white-space: pre-line; }
.order-lines { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 14px; }
.order-meta {
  background: var(--surface-alt);
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 11px;
  white-space: pre-line;
}
.smart-card-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Attachments */
.att-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.att-img { max-width: 260px; max-height: 240px; border-radius: 10px; border: 1px solid var(--border); cursor: zoom-in; display: block; }
.att-audio { width: 250px; max-width: 100%; height: 38px; }
.att-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

/* Composer */
.composer {
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.composer.note-mode { background: var(--bubble-note); }
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.mode-switch { display: inline-flex; background: var(--surface-alt); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.mode-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 7px;
  cursor: pointer;
}
.mode-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.mode-btn.active.note-mode { background: var(--amber-soft); color: var(--amber); }

.canned-bar { display: flex; align-items: center; gap: 6px; overflow-x: auto; max-width: 100%; }
.canned-label { font-size: 12.5px; color: var(--text-faint); white-space: nowrap; }
.canned-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 3px 11px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.canned-chip:hover { border-color: var(--brand-border); color: var(--brand); }

.composer-input-row { display: flex; align-items: flex-end; gap: 10px; }
#composerInput {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 13px;
  font-size: 15px;
  line-height: 1.6;
}
#composerInput:focus { outline: none; border-color: var(--brand); background: var(--surface); }
.send-btn { padding: 11px 22px; font-size: 15px; }

/* Details pane */
.pane-details {
  width: 300px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.info-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.info-card-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-muted);
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.kv-list { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.kv-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kv-key { color: var(--text-muted); }
.kv-val { font-weight: 700; text-align: left; word-break: break-word; }

.labels-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.label-chip {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 3px 11px;
  border-radius: 999px;
  cursor: pointer;
}
.label-chip.active { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-border); font-weight: 800; }

.select-assignee {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 14px;
}

.shift-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13.5px; padding: 5px 0; }
.shift-row + .shift-row { border-top: 1px dashed var(--border); }
.shift-row .who { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.shift-row.off { opacity: 0.55; }

.empty-state { padding: 34px 16px; text-align: center; color: var(--text-muted); font-size: 14px; }
.empty-state .big { font-size: 30px; display: block; margin-bottom: 4px; }
.empty-state.small { font-size: 13px; }

/* Modals & drawer */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 16, 15, 0.5);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.modal-card {
  width: 100%;
  max-width: 820px;
  max-height: 88vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.modal-header h3 { margin: 0; font-size: 17px; font-weight: 800; }
.modal-sub { margin: 0; font-size: 13px; color: var(--text-muted); }
.modal-header-actions { display: flex; gap: 8px; align-items: center; }
.modal-body { padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.modal-body h4 { margin: 0 0 8px; font-size: 15px; font-weight: 800; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.kpi-box { background: var(--surface-alt); border: 1px solid var(--border); border-radius: 14px; padding: 14px; text-align: center; }
.kpi-num { font-size: 28px; font-weight: 800; line-height: 1.2; }
.kpi-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; font-weight: 600; }

.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { text-align: right; padding: 9px 10px; border-bottom: 1px solid var(--border); }
.data-table th { font-size: 13px; color: var(--text-muted); font-weight: 700; }

.drawer-panel {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 320px;
  max-width: 88vw;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.drawer-body { padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }

.lightbox-wrap { position: relative; max-width: 92vw; max-height: 90vh; }
.lightbox-wrap img { max-width: 90vw; max-height: 84vh; border-radius: 14px; display: block; }
.lightbox-close { position: absolute; top: -42px; left: 0; }

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  background: var(--text);
  color: var(--surface);
  box-shadow: var(--shadow);
  padding: 9px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
}

/* Responsive */
.mobile-only, .mobile-only-details { display: none; }

@media (max-width: 1100px) {
  .pane-details { display: none; }
  .mobile-only-details { display: inline-flex; }
}

@media (max-width: 780px) {
  .mobile-only { display: inline-flex; }
  .topbar { padding: 8px 10px; gap: 6px; flex-wrap: wrap; }
  .brand-logo { width: 34px; height: 34px; }
  .brand-name { font-size: 15px; white-space: nowrap; }
  .topbar .hide-sm { display: none; }
  .brand-row .pill:not(.pill-danger) { display: none; }
  body:not(.chat-open) .mobile-only-details { display: none; }
  .topbar-actions { gap: 4px; }
  .topbar .btn-sm { padding: 6px 8px; }
  .status-btn { padding: 6px 9px; font-size: 12.5px; }
  .pane-list { width: 100%; border-left: none; }
  .pane-chat { display: none; width: 100%; }
  .workspace.mobile-chat-open .pane-list { display: none; }
  .workspace.mobile-chat-open .pane-chat { display: flex; }
  .chat-header { padding: 8px 10px; flex-wrap: wrap; }
  .chat-actions { width: 100%; }
  .chat-actions .btn { flex: 1; }
  .messages-feed { padding: 14px 12px; }
  .composer { padding: 8px 10px 10px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .bubble { max-width: 88%; }
}

/* Order number, handover, manager alerts */
.order-no-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.order-no-row strong { font-size: 17px; }
.input-order { flex: 1; min-width: 0; border: 1px solid var(--border); background: var(--surface-alt); color: var(--text); border-radius: 9px; padding: 7px 10px; font-size: 14px; }
.input-order:focus, .input-area:focus { outline: none; border-color: var(--brand); background: var(--surface); }
.input-area { width: 100%; resize: vertical; border: 1px solid var(--border); background: var(--surface-alt); color: var(--text); border-radius: 10px; padding: 8px 11px; font-size: 14px; font-weight: 500; }
.btn-block { width: 100%; }
.hint-text { margin: 0 0 8px; font-size: 13px; color: var(--text-muted); }
.status-banner.is-handover { background: var(--amber-soft); color: var(--amber); border-bottom-color: var(--amber-border); }
.handover-card { max-width: 460px; }
.handover-card .modal-body { gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.warn-box { padding: 9px 12px; border-radius: 10px; background: var(--amber-soft); border: 1px solid var(--amber-border); color: var(--amber); font-size: 13.5px; font-weight: 700; }
.details-form { display: flex; flex-direction: column; gap: 6px; }
.details-form .input-order { width: 100%; font-family: inherit; resize: vertical; }
.details-form-actions { display: flex; gap: 6px; }
.order-total-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.order-total-label { font-size: 13px; font-weight: 700; color: var(--text-muted); white-space: nowrap; }
.order-stage-btns { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.order-stage-btns .btn { width: 100%; }
.order-stage-btns .btn.is-stage-active { border-color: var(--brand-border); box-shadow: inset 0 0 0 1px var(--brand-border); }
.order-print-btn { margin-top: 2px; }
.attention-row { cursor: pointer; transition: background 0.12s; }
.attention-row:hover { background: var(--surface-alt); }
