/* WhatsApp Commerce CRM - design system (no framework dependency) */

:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e6eaf0;
    --border-strong: #d7dde5;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #0d9488;
    --primary-600: #0f766e;
    --primary-soft: #ccfbf1;
    --accent: #f59e0b;
    --danger: #dc2626;
    --success: #16a34a;
    --wa-bubble-in: #ffffff;
    --wa-bubble-out: #d9fdd3;
    --wa-bubble-out-text: #0f172a;
    --shadow: 0 1px 2px rgb(15 23 42 / 6%), 0 8px 24px rgb(15 23 42 / 6%);
    --radius: 14px;
    --radius-sm: 10px;
    --sidebar-w: 250px;
}
[data-theme="dark"] {
    --bg: #0b1220;
    --surface: #101a2c;
    --surface-2: #16213a;
    --border: #1e293b;
    --border-strong: #334155;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --primary: #14b8a6;
    --primary-600: #0d9488;
    --primary-soft: #134e4a;
    --wa-bubble-in: #202c42;
    --wa-bubble-out: #005c4b;
    --wa-bubble-out-text: #e8fff4;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 30%);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}
a { color: var(--primary-600); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }
.muted { color: var(--muted); }
.small-text { font-size: 12.5px; }
.ok-text { color: var(--success); font-weight: 600; }
.err-text { color: var(--danger); font-weight: 600; }
.warn-text { color: #b45309; font-weight: 600; }
[data-theme="dark"] .warn-text { color: #fbbf24; }
.break-all { word-break: break-all; }
.hidden { display: none !important; }
.ico { vertical-align: -3px; flex: none; }

/* ---------- App shell ---------- */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
    position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
    background: var(--surface); border-right: 1px solid var(--border); z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 12px; font-weight: 700; font-size: 17px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--primary); color: #fff; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-nav { flex: 1; overflow-y: auto; padding: 4px 10px 10px; }
.nav-section { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 14px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text); font-weight: 500; margin-bottom: 2px; }
.nav-item:hover { background: var(--surface-2); text-decoration: none; }
.nav-item.active { background: var(--primary-soft); color: var(--primary-600); font-weight: 600; }
[data-theme="dark"] .nav-item.active { color: #5eead4; }
.nav-badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.side-footer { border-top: 1px solid var(--border); padding: 10px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700; font-size: 14px; }
.user-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11.5px; color: var(--muted); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
    position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px;
    background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border); padding: 10px 18px; min-height: 58px;
}
.topbar-title { font-size: 17px; font-weight: 700; margin: 0; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
    display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px;
    border: 0; background: transparent; color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.content { padding: 20px 22px 40px; max-width: 1280px; width: 100%; margin: 0 auto; }
.content-full { max-width: none; padding: 0; display: flex; min-height: calc(100vh - 58px); }

/* ---------- Page head ---------- */
.page-head { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h2 { margin: 0; font-size: 20px; }
.page-head p { margin: 2px 0 0; }
.page-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h3 { margin: 0; font-size: 15.5px; }
.link { font-size: 13px; font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 20px 0 8px; }

/* ---------- Stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat-card { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat-ico { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; flex: none; }
.ico-teal { background: #ccfbf1; color: #0f766e; }
.ico-indigo { background: #e0e7ff; color: #4338ca; }
.ico-amber { background: #fef3c7; color: #b45309; }
.ico-green { background: #dcfce7; color: #15803d; }
.ico-red { background: #fee2e2; color: #b91c1c; }
.ico-cyan { background: #cffafe; color: #0e7490; }
[data-theme="dark"] .ico-teal { background: #134e4a; color: #5eead4; }
[data-theme="dark"] .ico-indigo { background: #312e81; color: #a5b4fc; }
[data-theme="dark"] .ico-amber { background: #78350f; color: #fcd34d; }
[data-theme="dark"] .ico-green { background: #14532d; color: #86efac; }
[data-theme="dark"] .ico-red { background: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .ico-cyan { background: #164e63; color: #67e8f9; }
.stat-value { display: block; font-size: 21px; font-weight: 750; line-height: 1.15; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-sub { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.stat-warn { border-color: #fecaca; }
.stat-mini { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; }
.stat-mini strong { font-size: 20px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 7px; border-radius: var(--radius-sm);
    border: 1px solid transparent; padding: 9px 16px; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: background .15s, transform .05s; text-decoration: none !important;
}
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.inline { display: inline; }

/* ---------- Badges & chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 650; padding: 2.5px 9px; border-radius: 999px; white-space: nowrap; }
.badge-slate { background: #e2e8f0; color: #334155; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-amber { background: #fef3c7; color: #b45309; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-indigo { background: #e0e7ff; color: #4338ca; }
.badge-violet { background: #ede9fe; color: #6d28d9; }
.badge-cyan { background: #cffafe; color: #0e7490; }
.badge-sky { background: #e0f2fe; color: #0369a1; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-orange { background: #ffedd5; color: #c2410c; }
[data-theme="dark"] .badge-slate { background: #1e293b; color: #94a3b8; }
[data-theme="dark"] .badge-green { background: #14532d; color: #86efac; }
[data-theme="dark"] .badge-amber { background: #78350f; color: #fcd34d; }
[data-theme="dark"] .badge-red { background: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .badge-indigo { background: #312e81; color: #a5b4fc; }
[data-theme="dark"] .badge-violet { background: #4c1d95; color: #c4b5fd; }
[data-theme="dark"] .badge-cyan { background: #164e63; color: #67e8f9; }
[data-theme="dark"] .badge-sky { background: #0c4a6e; color: #7dd3fc; }
[data-theme="dark"] .badge-blue { background: #1e40af; color: #93c5fd; }
[data-theme="dark"] .badge-orange { background: #7c2d12; color: #fdba74; }

.chip {
    display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong);
    background: var(--surface); color: var(--text); border-radius: 999px; padding: 5px 12px;
    font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip-sm { padding: 1px 8px; font-size: 11.5px; font-weight: 500; }
.chip-primary { border-color: var(--primary); color: var(--primary-600); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: -4px; padding: 4px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.row-link { font-weight: 650; color: var(--text); }
.row-link:hover { color: var(--primary-600); }
.table-actions { white-space: nowrap; text-align: right; }
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); color: var(--text); }
.list-row:hover { background: var(--surface-2); text-decoration: none; }
.list-row:last-child { border-bottom: 0; }
.list-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.list-title { font-weight: 600; font-size: 14px; }
.list-sub { font-size: 12.5px; color: var(--muted); }
.unread-dot { background: var(--success); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }

/* ---------- Forms ---------- */
.form-label { display: block; font-size: 12.5px; font-weight: 650; margin: 12px 0 5px; color: var(--text); }
.form-control {
    width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); font-size: 14px; font-family: inherit;
}
.form-control:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
textarea.form-control { resize: vertical; }
select.form-control { appearance: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .span-2 { grid-column: span 2; }
.input-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.check-label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin-top: 10px; cursor: pointer; }
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.filter-bar { padding: 12px 16px; }
.filter-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.filter-row .form-label { margin-top: 0; }
.searchbar { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 999px; padding: 4px 14px; min-width: 240px; }
.searchbar input { border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13.5px; width: 100%; padding: 6px 0; }
.total-bar { display: flex; align-items: center; gap: 14px; margin-top: 18px; flex-wrap: wrap; }
.total-bar .btn { margin-left: auto; }
.total-value { font-size: 22px; font-weight: 750; }
.total-strong { color: var(--primary-600); font-size: 17px; }
.total-calc { font-size: 12px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; }
.detail-grid > div { display: flex; flex-direction: column; gap: 1px; }
.detail-grid .span-2 { grid-column: span 2; }
.status-row { display: flex; gap: 8px; flex-wrap: wrap; }
.status-row .form-control { flex: 1; min-width: 130px; }
.address-block { line-height: 1.7; margin: 4px 0; }
.tag-editor { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tag-check input { display: none; }
.tag-check span { display: inline-block; border: 1.5px solid var(--tag, #64748b); color: var(--tag, #64748b); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; cursor: pointer; opacity: .75; }
.tag-check input:checked + span { background: var(--tag, #64748b); color: #fff; opacity: 1; }

/* ---------- Alerts / empty / skeleton ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; border-radius: var(--radius-sm); padding: 11px 14px; font-size: 13.5px; margin: 10px 0; }
.alert-success { background: #dcfce7; color: #14532d; }
.alert-error { background: #fee2e2; color: #7f1d1d; }
.alert-warn { background: #fef3c7; color: #78350f; }
.alert-info { background: #e0f2fe; color: #075985; }
[data-theme="dark"] .alert-success { background: #14532d; color: #bbf7d0; }
[data-theme="dark"] .alert-error { background: #7f1d1d; color: #fecaca; }
[data-theme="dark"] .alert-warn { background: #78350f; color: #fde68a; }
[data-theme="dark"] .alert-info { background: #0c4a6e; color: #bae6fd; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 38px 16px; color: var(--muted); }
.empty-state h3 { color: var(--text); margin: 4px 0 0; font-size: 16px; }
.empty-state.small { padding: 18px; }
.skeleton-row { height: 68px; border-radius: var(--radius-sm); margin: 8px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------- Pagination / tabs / check list ---------- */
.pagination { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.page-link { padding: 5px 11px; border-radius: 8px; font-size: 13px; font-weight: 600; border: 1px solid var(--border-strong); color: var(--text); }
.page-link:hover { background: var(--surface-2); text-decoration: none; }
.page-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-dots { border: 0; color: var(--muted); }
.page-info { font-size: 12.5px; color: var(--muted); margin-right: 8px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); margin-bottom: 16px; padding-bottom: 0; }
.tab { padding: 9px 14px; font-size: 13.5px; font-weight: 600; color: var(--muted); border-bottom: 2.5px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary-600); border-bottom-color: var(--primary); }
.check-list { display: flex; flex-direction: column; }
.check-row { display: flex; justify-content: space-between; gap: 14px; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.check-row:last-child { border-bottom: 0; }

/* ---------- Auth ---------- */
.auth-body { background: linear-gradient(160deg, #0f766e 0%, #134e4a 55%, #0b1220 100%); min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-wrap { width: 100%; max-width: 400px; }
.auth-card { background: var(--surface); border-radius: 18px; padding: 28px; box-shadow: 0 24px 60px rgb(0 0 0 / 35%); }
.auth-card .brand { padding: 0 0 4px; }
.auth-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; }
.auth-foot { color: var(--muted); font-size: 11.5px; text-align: center; margin: 16px 0 0; }
.auth-card .btn { margin-top: 16px; }

/* ---------- Inbox ---------- */
.inbox-shell { display: grid; grid-template-columns: 340px minmax(0, 1fr) 320px; width: 100%; min-height: 0; flex: 1; }
.conv-pane { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.conv-search { display: flex; align-items: center; gap: 8px; padding: 12px 14px 6px; }
.search-ico { color: var(--muted); display: grid; place-items: center; }
.conv-search input { width: 100%; border: 0; outline: 0; background: var(--surface-2); border-radius: 999px; padding: 8px 14px; color: var(--text); font-size: 13.5px; }
.conv-filters { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px 10px; scrollbar-width: none; }
.conv-filters::-webkit-scrollbar { display: none; }
.conv-filters .chip { padding: 4px 11px; font-size: 12px; }
.conv-list { flex: 1; overflow-y: auto; padding: 0 8px 12px; }
.conv-item { display: flex; gap: 11px; padding: 11px 10px; border-radius: var(--radius-sm); cursor: pointer; align-items: center; }
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: var(--primary-soft); }
.conv-main { flex: 1; min-width: 0; }
.conv-title-row { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.conv-name { font-weight: 650; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 11px; color: var(--muted); flex: none; }
.conv-preview { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.conv-meta-row { display: flex; gap: 5px; align-items: center; margin-top: 4px; }
.chat-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border); min-height: 58px; }
.chat-head-main { flex: 1; min-width: 0; }
.chat-head-name { font-weight: 700; font-size: 15px; }
.chat-head-sub { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 18px 16px 10px; display: flex; flex-direction: column; gap: 3px; scroll-behavior: smooth; }
.chat-day { align-self: center; background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-size: 11.5px; font-weight: 650; border-radius: 999px; padding: 3px 12px; margin: 12px 0 8px; }
.msg { max-width: min(72%, 460px); padding: 7px 11px 5px; border-radius: 12px; font-size: 14px; position: relative; box-shadow: 0 1px 1px rgb(0 0 0 / 6%); word-wrap: break-word; white-space: pre-wrap; }
.msg-in { align-self: flex-start; background: var(--wa-bubble-in); border-bottom-left-radius: 4px; border: 1px solid var(--border); }
.msg-out { align-self: flex-end; background: var(--wa-bubble-out); color: var(--wa-bubble-out-text); border-bottom-right-radius: 4px; }
.msg-sender { font-size: 10.5px; font-weight: 700; color: var(--primary-600); margin-bottom: 2px; }
[data-theme="dark"] .msg-sender { color: #5eead4; }
.msg-meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.msg-out .msg-meta { color: rgb(0 0 0 / 45%); }
[data-theme="dark"] .msg-out .msg-meta { color: rgb(255 255 255 / 60%); }
.msg-meta svg { display: block; }
.tick-read { color: #53bdeb; }
.msg img.media-img { max-width: 100%; border-radius: 8px; display: block; margin-bottom: 4px; }
.msg .file-card { display: flex; align-items: center; gap: 10px; background: rgb(0 0 0 / 5%); border-radius: 8px; padding: 8px 10px; color: inherit; }
.msg-failed { border: 1px solid #fca5a5; }
.window-note { margin: 0 14px 6px; background: #fef3c7; color: #78350f; font-size: 12.5px; border-radius: 8px; padding: 7px 12px; display: flex; gap: 8px; align-items: center; }
[data-theme="dark"] .window-note { background: #78350f; color: #fde68a; }
.composer { border-top: 1px solid var(--border); background: var(--surface); padding: 8px 12px 10px; position: sticky; bottom: 0; }
.composer-tools { display: flex; gap: 2px; margin-bottom: 4px; }
.tool-btn { display: grid; place-items: center; width: 36px; height: 32px; border: 0; background: transparent; color: var(--muted); border-radius: 8px; cursor: pointer; }
.tool-btn:hover { background: var(--surface-2); color: var(--primary-600); }
.composer-form { display: flex; gap: 8px; align-items: flex-end; }
.composer-form textarea {
    flex: 1; resize: none; border: 1px solid var(--border-strong); background: var(--surface-2);
    color: var(--text); border-radius: 14px; padding: 9px 14px; font-size: 14px; font-family: inherit;
    max-height: 130px; outline: none;
}
.composer-form textarea:focus { border-color: var(--primary); }
.btn-send { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--primary); color: #fff; cursor: pointer; flex: none; }
.btn-send:disabled { opacity: .5; }
.quick-panel { position: absolute; bottom: 100%; left: 12px; right: 12px; margin-bottom: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); max-height: 220px; overflow-y: auto; z-index: 5; }
.quick-item { display: flex; flex-direction: column; gap: 1px; padding: 9px 14px; cursor: pointer; }
.quick-item:hover { background: var(--surface-2); }
.quick-item b { font-size: 12.5px; color: var(--primary-600); }
.quick-item span { font-size: 12.5px; color: var(--muted); }
.composer { position: relative; }
.details-pane { border-left: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.details-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.details-head h3 { margin: 0; font-size: 15px; }
.details-body { flex: 1; overflow-y: auto; padding: 14px 16px; }
.details-section { margin-bottom: 18px; }
.details-section h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.details-kv { display: flex; flex-direction: column; gap: 2px; font-size: 13px; margin-bottom: 6px; }
.details-kv .k { color: var(--muted); font-size: 11.5px; }
.mini-orders a { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 13px; color: var(--text); }
.details-actions { display: flex; flex-direction: column; gap: 8px; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgb(9 14 25 / 55%); display: grid; place-items: center; z-index: 90; padding: 16px; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; box-shadow: 0 24px 60px rgb(0 0 0 / 35%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 8px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 10px 18px 6px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 18px; }
.template-preview { background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-top: 10px; min-height: 42px; white-space: pre-wrap; }

/* ---------- Toasts ---------- */
.toast-region { position: fixed; top: 14px; right: 14px; z-index: 120; display: flex; flex-direction: column; gap: 8px; max-width: min(360px, calc(100vw - 28px)); }
.toast { display: flex; align-items: center; gap: 10px; background: #0f172a; color: #fff; border-radius: 12px; padding: 11px 16px; font-size: 13.5px; box-shadow: 0 12px 30px rgb(0 0 0 / 25%); animation: toast-in .18s ease-out; }
.toast-success { background: #14532d; }
.toast-error { background: #7f1d1d; }
.toast-info { background: #0c4a6e; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- Charts ---------- */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding: 6px 2px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.bar-stack { display: flex; gap: 2px; align-items: flex-end; height: calc(100% - 18px); width: 100%; justify-content: center; }
.bar { width: 12px; border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-leads { background: #14b8a6; }
.bar-orders { background: #f59e0b; }
.bar-label { font-size: 10.5px; color: var(--muted); margin-top: 4px; }
.chart-legend { display: flex; gap: 16px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.dot-teal { background: #14b8a6; }
.dot-amber { background: #f59e0b; }
.status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.status-cell { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--surface-2); border-radius: 10px; padding: 8px 12px; }

/* ---------- Mobile (Android-app style) ---------- */
.bottom-nav, .only-mobile, #moreSheet, .sheet-backdrop { display: none; }
@media (max-width: 1240px) {
    .inbox-shell { grid-template-columns: 340px minmax(0, 1fr); }
    .details-pane { position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 92vw); z-index: 70; box-shadow: var(--shadow); transform: translateX(105%); transition: transform .22s ease; }
    .details-pane.open { transform: none; display: flex; }
}
@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 84vw); transform: translateX(-102%); transition: transform .22s ease; }
    .sidebar.open { transform: none; display: flex; }
    .only-mobile { display: grid !important; }
    .content { padding: 14px 12px 96px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: span 1; }
    .input-pair { grid-template-columns: 1fr 1fr; }
    .bottom-nav {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
        background: var(--surface); border-top: 1px solid var(--border);
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around;
    }
    .bn-item { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; font-weight: 600; color: var(--muted); border: 0; background: none; padding: 4px 12px; position: relative; }
    .bn-item.active { color: var(--primary-600); }
    .bn-dot { position: absolute; top: 2px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); }
    /* Inbox: single column with push navigation */
    .inbox-shell { grid-template-columns: 1fr; }
    .conv-pane { width: 100%; }
    .chat-pane { display: none; }
    .inbox-shell.chat-open .conv-pane { display: none; }
    .inbox-shell.chat-open .chat-pane { display: flex; }
    .msg { max-width: 86%; }
    .sheet-backdrop { position: fixed; inset: 0; background: rgb(9 14 25 / 45%); z-index: 80; }
    .sheet-backdrop.show { display: block; }
    .sheet {
        display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 85;
        background: var(--surface); border-radius: 20px 20px 0 0; padding: 8px 8px calc(18px + env(safe-area-inset-bottom));
        animation: sheet-up .2s ease-out;
    }
    .sheet.open { display: block; }
    .sheet-links a { display: flex; align-items: center; gap: 14px; padding: 14px 16px; font-size: 15px; font-weight: 600; color: var(--text); border-radius: 12px; }
    .sheet-links a:hover { background: var(--surface-2); text-decoration: none; }
    .searchbar { min-width: 0; width: 100%; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .table { font-size: 13px; }
}
@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .page-head { flex-direction: column; align-items: stretch; }
    .page-actions { margin-left: 0; }
    .check-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
