/* Front desk inbox — three panes on a desk, list → thread on a tablet. */
.ibx { display: grid; grid-template-columns: minmax(300px, 360px) minmax(0, 1fr) minmax(260px, 320px); gap: 0; height: calc(100vh - 96px); min-height: 520px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--panel); }
.ibx .muted { color: var(--muted); }
.ibx .tiny { font-size: 12px; }

/* List */
.ibx-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--bg); }
.ibx-list-head { padding: 12px 12px 8px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.ibx-list-head h2 { margin: 0; font-size: 18px; }
.ibx-search { width: 100%; min-height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; }
.ibx-tabs { display: flex; gap: 4px; overflow-x: auto; }
.ibx-tab { flex: 0 0 auto; min-height: 34px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.ibx-tab.on { background: var(--panel-2); color: var(--text); border-color: #ef7d22; }
.ibx-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--panel-2); color: var(--text); font-size: 11px; display: inline-flex; align-items: center; justify-content: center; }
.ibx-count.hot { background: #ef7d22; color: #fff; }
.ibx-rows { overflow-y: auto; flex: 1; }
.ibx-group { position: sticky; top: 0; z-index: 1; padding: 6px 14px; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); background: var(--bg); border-bottom: 1px solid var(--line); }
.ibx-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; min-height: 64px; }
.ibx-row:hover { background: var(--panel); }
.ibx-row.on { background: var(--panel-2); box-shadow: inset 3px 0 0 #ef7d22; }
.ibx-row-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ibx-row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ibx-name { all: unset; cursor: pointer; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ibx-name:hover { text-decoration: underline; color: #ef7d22; }
.ibx-name.big { font-size: 17px; font-weight: 800; }
.ibx-row.unread .ibx-name { font-weight: 800; }
.ibx-time { flex: 0 0 auto; font-size: 12px; color: var(--muted); }
.ibx-row.unread .ibx-time { color: #ef7d22; font-weight: 700; }
.ibx-preview { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ibx-row.unread .ibx-preview { color: var(--text); }
.ibx-ch { margin-right: 4px; }
.ibx-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.ibx-chip { all: unset; cursor: pointer; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.ibx-chip.open { border-color: #2f6fb3; color: #8ab8ec; }
.ibx-chip.owing { border-color: #e2563b; color: #f08a74; }
.ibx-chip.paid { border-color: #1f8a4c; color: #5fd38e; }
.ibx-chip.wait { border-color: #f0a020; color: #f6b955; cursor: default; }
.ibx-dot { min-width: 10px; height: 10px; border-radius: 999px; background: #ef7d22; margin-top: 6px; color: #fff; font-size: 10px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; padding: 0 3px; }
.ibx-dot:not(:empty) { min-width: 18px; height: 18px; }
.ibx-avatar { --h: 210; width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; color: #fff; background: hsl(var(--h) 45% 38%); flex: 0 0 auto; }
.ibx-avatar.lg { width: 48px; height: 48px; font-size: 17px; }
.ibx-empty { padding: 24px 16px; text-align: center; color: var(--muted); }

/* Thread */
.ibx-thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.ibx-thread.empty { align-items: center; justify-content: center; }
.ibx-placeholder { text-align: center; color: var(--muted); }
.ibx-ph-icon { font-size: 42px; opacity: .5; }
.ibx-thread-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.ibx-thread-who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ibx-thread-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ibx-back { display: none; min-width: 44px; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--text); font-size: 18px; }
.ibx-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.ibx-day { text-align: center; margin: 8px 0; }
.ibx-day span { font-size: 11px; font-weight: 700; color: var(--muted); padding: 3px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); }
.ibx-msg { display: flex; flex-direction: column; max-width: min(78%, 620px); }
.ibx-msg.in { align-self: flex-start; }
.ibx-msg.out { align-self: flex-end; align-items: flex-end; }
.ibx-bubble { padding: 9px 13px; border-radius: 16px; white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
.ibx-msg.in .ibx-bubble { background: var(--panel-2); color: var(--text); border-bottom-left-radius: 4px; }
.ibx-msg.out .ibx-bubble { background: #2f6fb3; color: #fff; border-bottom-right-radius: 4px; }
.ibx-msg.failed .ibx-bubble { background: #7a2b1f; }
.ibx-meta { font-size: 11px; color: var(--muted); margin-top: 3px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ibx-link { all: unset; cursor: pointer; color: #ef7d22; font-weight: 700; }
.ibx-compose { border-top: 1px solid var(--line); padding: 8px 12px 10px; background: var(--panel); display: flex; flex-direction: column; gap: 6px; }
.ibx-quick { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.ibx-qr { flex: 0 0 auto; min-height: 32px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
.ibx-compose-row { display: flex; gap: 8px; align-items: stretch; }
.ibx-compose-row textarea { flex: 1; min-height: 52px; max-height: 160px; resize: vertical; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
.ibx-send { display: flex; flex-direction: column; gap: 6px; }
.ibx-send button { min-height: 44px; padding: 0 14px; border-radius: 10px; font-weight: 800; }
.ibx-compose-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ibx-compose-tools .visit-pick select { min-height: 36px; }

/* Customer panel */
.ibx-side { border-left: 1px solid var(--line); overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.ibx-side.empty { background: var(--bg); }
.ibx-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.ibx-card h3 { margin: 0 0 2px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ibx-card-head { display: flex; gap: 10px; align-items: center; }
.ibx-contact { color: var(--text); text-decoration: none; font-size: 14px; }
.ibx-owing { font-weight: 800; color: #f08a74; }
.ibx-wide { width: 100%; min-height: 44px; border-radius: 10px; margin-top: 4px; }
.ibx-visit { all: unset; cursor: pointer; display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }
.ibx-visit:hover { border-color: #ef7d22; }
.ibx-visit.open { border-left: 4px solid #2f6fb3; }
.ibx-visit-top, .ibx-visit-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.ibx-stage { font-size: 11px; font-weight: 700; color: var(--muted); }
.ibx-stage.open { color: #8ab8ec; }
.ibx-veh { font-size: 13px; padding: 4px 0; border-bottom: 1px dashed var(--line); }

/* Tablets and phones: list, then the thread (customer panel goes under the header). */
@media (max-width: 1099px) {
  .ibx { grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); }
  .ibx-side { display: none; }
}
@media (max-width: 820px) {
  .ibx { grid-template-columns: 1fr; height: calc(100vh - 150px); }
  .ibx.thread-open .ibx-list { display: none; }
  .ibx:not(.thread-open) .ibx-thread { display: none; }
  .ibx-back { display: inline-flex; align-items: center; justify-content: center; }
}

/* Live alerts */
.dal-stack { position: fixed; top: 14px; right: 14px; z-index: 10000; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 28px)); }
.dal-card { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; padding: 12px 12px 12px 14px; border-radius: 14px; background: #fff; color: #10203f; box-shadow: 0 14px 40px rgba(0,0,0,.35); border-left: 6px solid #2f6fb3; animation: dalIn .3s cubic-bezier(.2,1.2,.4,1); transition: opacity .25s, transform .25s; }
.dal-card.out { opacity: 0; transform: translateX(30px); }
.dal-card.message { border-left-color: #ef7d22; }
.dal-card.confirmed { border-left-color: #1f8a4c; }
.dal-card.cancelled, .dal-card.change_request { border-left-color: #e2563b; }
.dal-icon { font-size: 26px; line-height: 1; padding-top: 2px; }
.dal-title { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: #44557a; display: flex; justify-content: space-between; gap: 8px; }
.dal-time { font-weight: 600; text-transform: none; letter-spacing: 0; }
.dal-name { all: unset; cursor: pointer; font-size: 16px; font-weight: 800; color: #10203f; }
.dal-name:hover { text-decoration: underline; }
.dal-text { font-size: 14px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.dal-actions { margin-top: 8px; }
.dal-open { min-height: 38px; padding: 0 14px; border-radius: 10px; border: 0; background: #ef7d22; color: #fff; font: inherit; font-weight: 800; cursor: pointer; }
.dal-x { all: unset; cursor: pointer; width: 32px; height: 32px; text-align: center; line-height: 32px; border-radius: 8px; color: #6b7a99; }
.dal-x:hover { background: #eef1f7; }
.dal-sound { position: fixed; right: 14px; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 9999; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-weight: 700; box-shadow: 0 6px 18px rgba(0,0,0,.25); cursor: pointer; }
.dal-sound.on { min-width: 40px; padding: 0; opacity: .7; }
@media (min-width: 900px) { .dal-sound { bottom: 16px; } }
@keyframes dalIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .dal-card { animation: none; } }
