/* ================= tokens ================= */
:root {
    --bg: #f0f2f5;
    --panel: #ffffff;
    --panel-2: #f7f8fa;
    --text: #1c1e21;
    --muted: #65676b;
    --border: #e4e6eb;
    --border-strong: #ced0d4;
    --hover: #f2f3f5;
    --active: #ebf3ff;
    --primary: #0866ff;
    --primary-dark: #0556d6;
    --primary-soft: #e7f0ff;
    --ok: #2e9b4a;
    --ok-soft: #e3f5e8;
    --warn: #b26a00;
    --warn-soft: #fff4d6;
    --danger: #e41e3f;
    --danger-soft: #fde8eb;
    --purple: #7b4dff;
    --purple-soft: #f0eaff;
    --bubble-in: #f0f2f5;
    --bubble-ai: linear-gradient(135deg, #0866ff 0%, #4f6bff 100%);
    --bubble-agent: linear-gradient(135deg, #6b4dff 0%, #9b5cff 100%);
    --rail: #0f1b2d;
    --rail-text: #9aa7bd;
    --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .04);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .14);
    --radius: 12px;
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b0f14;
        --panel: #151a21;
        --panel-2: #1b2129;
        --text: #e4e6eb;
        --muted: #9aa3ae;
        --border: #262d36;
        --border-strong: #353d48;
        --hover: #1e252e;
        --active: #17283f;
        --primary: #3d8bff;
        --primary-dark: #2b78ef;
        --primary-soft: #16263d;
        --ok: #4cc26a;
        --ok-soft: #13291b;
        --warn: #f0b545;
        --warn-soft: #2d2412;
        --danger: #ff5c77;
        --danger-soft: #331820;
        --purple: #a98bff;
        --purple-soft: #231c3a;
        --bubble-in: #232a33;
        --rail: #070a0e;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
    }
}

/* ================= base ================= */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.02em; }
h2 { font-size: 16px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
h3 { margin: 0; font-size: 16px; }
code { background: var(--panel-2); border: 1px solid var(--border); padding: 2px 6px; border-radius: 6px; font-size: 12.5px; word-break: break-all; }
.muted { color: var(--muted); }
small { font-size: 12px; font-weight: normal; }
.error { color: var(--danger); }
.grow { flex: 1; }
[hidden] { display: none !important; }

/* ================= controls ================= */
input, select, textarea {
    font: inherit; width: 100%; padding: 9px 12px; margin-top: 6px;
    border: 1px solid var(--border-strong); border-radius: 8px; background: var(--panel); color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 14px; }
label .muted, label small { font-weight: normal; }
.check { display: flex; align-items: center; gap: 8px; font-weight: normal; margin-top: 8px; }
.check input { width: auto; margin: 0; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 8px;
    border: 1px solid transparent; cursor: pointer; white-space: nowrap; text-decoration: none !important;
    transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--panel); border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: var(--hover); }
.btn-soft { background: var(--purple-soft); color: var(--purple); }
.btn-soft:hover { filter: brightness(.97); }
.btn-ok { background: var(--ok-soft); color: var(--ok); }
.btn-danger { background: var(--panel); border-color: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn.loading { animation: pulse-bg 1s infinite alternate; }

.icon-btn {
    position: relative; display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 50%; border: none; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.on { background: var(--ok-soft); color: var(--ok); }
.icon-btn.on-warn { background: var(--danger-soft); color: var(--danger); }

[data-tip] { position: relative; }
[data-tip]:hover::after {
    content: attr(data-tip); position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%);
    background: #1c1e21; color: #fff; font-size: 12px; font-weight: 500; padding: 5px 9px; border-radius: 6px;
    white-space: nowrap; pointer-events: none; z-index: 50;
}

.tag { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 10px; background: var(--hover); color: var(--muted); }
.tag-ad { background: var(--primary-soft); color: var(--primary); }
.tag-human { background: var(--danger-soft); color: var(--danger); }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-muted { background: var(--panel-2); }
.tag-label { background: var(--purple-soft); color: var(--purple); }
.tag-label[data-label="Ordered"], .tag-label[data-label="Delivered"] { background: var(--ok-soft); color: var(--ok); }
.tag-label[data-label="Follow up"] { background: var(--warn-soft); color: var(--warn); }
.tag-label[data-label="Complaint"] { background: var(--danger-soft); color: var(--danger); }
.badge { background: var(--danger); color: #fff; border-radius: 10px; font-size: 10.5px; font-weight: 700; padding: 1px 6px; margin-left: 4px; }

.state { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 12px; }
.state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.state-on { background: var(--ok-soft); color: var(--ok); }
.state-paused { background: var(--warn-soft); color: var(--warn); }
.state-off { background: var(--panel-2); color: var(--muted); }

/* ================= app shell ================= */
.has-rail { padding-left: 72px; }
.main { min-height: 100%; display: flex; flex-direction: column; }

.rail {
    position: fixed; inset: 0 auto 0 0; width: 72px; z-index: 30;
    background: var(--rail); display: flex; flex-direction: column; align-items: center; padding: 14px 0;
}
.rail-logo {
    width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: #fff;
    background: linear-gradient(135deg, #0866ff, #a033ff); margin-bottom: 22px;
}
.rail-nav { display: flex; flex-direction: column; gap: 6px; }
.rail-nav a, .rail-btn {
    width: 56px; padding: 8px 0 6px; border-radius: 12px; color: var(--rail-text);
    display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600;
    background: none; border: none; cursor: pointer; text-decoration: none !important;
}
.rail-nav a:hover, .rail-btn:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.rail-nav a.active { background: rgba(61, 139, 255, .18); color: #fff; }
.rail-nav a.active svg { color: #5fa0ff; }
.rail-nav [data-tip]:hover::after, .rail-btn[data-tip]:hover::after { top: 50%; left: calc(100% + 10px); transform: translateY(-50%); }
.rail-bottom { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.rail-user {
    width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
    background: #2a3a55; color: #fff; font-weight: 700; font-size: 13px;
}

.flash { padding: 10px 20px; font-weight: 500; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-err { background: var(--danger-soft); color: var(--danger); }
.flash-warn { background: var(--warn-soft); color: var(--warn); }

/* ================= avatars ================= */
.avatar {
    width: 48px; height: 48px; border-radius: 50%; object-fit: cover; flex-shrink: 0; display: block;
}
.avatar-letter {
    display: inline-grid; place-items: center; font-weight: 700; font-size: 15px; color: #fff;
    background: linear-gradient(135deg, hsl(var(--h, 210) 70% 58%), hsl(calc(var(--h, 210) + 40) 70% 48%));
}
.avatar-stack { position: relative; display: inline-block; width: 48px; height: 48px; flex-shrink: 0; }
.avatar-stack > * { position: absolute; inset: 0; width: 100%; height: 100%; }
.avatar.xs, .avatar-stack.xs { width: 28px; height: 28px; font-size: 11px; }
.avatar.xl, .avatar-stack.xl { width: 84px; height: 84px; font-size: 28px; }
.avatar-wrap { position: relative; display: inline-flex; flex-shrink: 0; }

.ch-icon, .ch-badge { display: inline-block; border-radius: 50%; flex-shrink: 0; }
.ch-icon { width: 16px; height: 16px; vertical-align: -3px; }
.ch-badge { position: absolute; right: -2px; bottom: -2px; width: 20px; height: 20px; border: 2px solid var(--panel); }
.ch-messenger { background: radial-gradient(circle at 30% 110%, #0099ff, #a033ff 70%, #ff5280 100%); }
.ch-messenger::after { content: ""; display: block; width: 100%; height: 100%; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='white' d='M17.5 8.6 14.4 13.5c-.5.8-1.5 1-2.3.4L9.7 12.2a.6.6 0 0 0-.7 0l-3.3 2.5c-.4.3-1-.2-.7-.7L8.1 9.1c.5-.8 1.5-1 2.3-.4l2.4 1.8c.2.2.5.2.7 0l3.3-2.5c.5-.3 1 .2.7.6z'/%3E%3C/svg%3E") center / 70% no-repeat; }
.ch-instagram { background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fd5949 45%, #d6249f 60%, #285aeb 90%); }
.ch-whatsapp { background: #25d366; }

/* ================= inbox ================= */
.inbox-page { height: 100vh; overflow: hidden; }
.inbox-page .main { height: 100vh; min-height: 0; }

.inbox-head { background: var(--panel); border-bottom: 1px solid var(--border); padding: 0 20px; }
.channel-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-top: 10px; }
.channel {
    display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 8px 8px 0 0;
    font: inherit; font-weight: 600; color: var(--muted); background: none; border: none; cursor: pointer; white-space: nowrap;
    border-bottom: 3px solid transparent;
}
.channel:hover:not(.disabled) { background: var(--hover); color: var(--text); }
.channel.active { color: var(--primary); border-bottom-color: var(--primary); }
.channel.disabled { cursor: default; opacity: .55; }
.channel em { font-style: normal; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 8px; background: var(--ok-soft); color: var(--ok); }
.channel .count { background: var(--danger); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; }

.stats { display: flex; align-items: center; gap: 10px; padding: 12px 0; overflow-x: auto; scrollbar-width: none; }
.stat {
    display: flex; align-items: baseline; gap: 8px; padding: 8px 14px; border-radius: 10px;
    background: var(--panel-2); border: 1px solid var(--border); white-space: nowrap;
}
.stat-num { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.stat-label { font-size: 12.5px; color: var(--muted); }
.stat-ai .stat-num { color: var(--primary); }
.stat-warn .stat-num { color: var(--danger); }
.ai-pill {
    margin-left: auto; display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 20px;
    font-size: 12.5px; white-space: nowrap; color: var(--text); text-decoration: none !important; border: 1px solid var(--border);
}
.ai-pill.on { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.ai-pill.off { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 0 currentColor; }
.ai-pill.on .pulse { animation: pulse 2s infinite; }

.inbox { flex: 1; display: flex; min-height: 0; background: var(--panel); }

/* list */
.list-pane { width: 360px; flex-shrink: 0; display: flex; flex-direction: column; border-right: 1px solid var(--border); min-height: 0; }
.list-tools { display: flex; gap: 8px; padding: 12px 12px 6px; }
.search { position: relative; flex: 1; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { margin: 0; padding-left: 33px; border-radius: 20px; background: var(--panel-2); border-color: transparent; }
.list-tools select { width: 130px; margin: 0; border-radius: 20px; background: var(--panel-2); border-color: transparent; }
.chips { display: flex; gap: 6px; padding: 6px 12px 10px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.chip {
    font: inherit; font-size: 12.5px; font-weight: 500; padding: 5px 11px; border-radius: 16px;
    border: 1px solid var(--border-strong); background: var(--panel); color: var(--text); cursor: pointer; display: inline-flex; align-items: center;
}
.chip:hover { background: var(--hover); }
.chip.active { background: var(--primary-soft); border-color: transparent; color: var(--primary); font-weight: 600; }
.chip-select { width: auto; margin: 0; padding: 5px 26px 5px 11px; }

.conv-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.conv { display: flex; gap: 12px; padding: 10px; cursor: pointer; border-radius: 10px; align-items: center; position: relative; }
.conv + .conv { margin-top: 2px; }
.conv:hover { background: var(--hover); }
.conv.active { background: var(--active); }
.conv-body { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; gap: 8px; }
.conv-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14px; }
.conv-top time { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.conv-text { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 2px 0 5px; }
.conv.unread .conv-top strong, .conv.unread .conv-text { font-weight: 700; color: var(--text); }
.conv.unread .conv-top time { color: var(--primary); font-weight: 600; }
.by-ai { color: var(--primary); font-weight: 600; }
.conv-meta { font-size: 12px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.page-name { color: var(--muted); max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: 2px; }
.dot { background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; border-radius: 10px; min-width: 20px; padding: 2px 6px; text-align: center; }
.list-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 50px 20px; text-align: center; }

.skeleton { pointer-events: none; }
.skeleton .avatar { background: var(--hover); }
.sk { display: block; height: 11px; border-radius: 6px; background: var(--hover); margin: 6px 0; animation: pulse-bg 1.2s infinite alternate; }
.w60 { width: 60%; } .w90 { width: 90%; }

/* chat */
.chat-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); }
.empty-chat { margin: auto; text-align: center; max-width: 340px; padding: 20px; }
.empty-chat h3 { margin: 14px 0 6px; font-size: 18px; }
.empty-chat p { margin: 0; line-height: 1.5; }
.empty-art {
    width: 96px; height: 96px; margin: 0 auto; border-radius: 28px; display: grid; place-items: center; font-size: 44px;
    background: linear-gradient(135deg, var(--primary-soft), var(--purple-soft));
}
.empty-art.small { width: 64px; height: 64px; border-radius: 20px; font-size: 30px; margin-bottom: 8px; }

.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px 10px 18px; border-bottom: 1px solid var(--border); }
.chat-head .who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-head .who strong { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .who span { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .avatar, .chat-head .avatar-stack { width: 40px; height: 40px; font-size: 14px; }
.chat-head .back { display: none; }

.switch {
    display: inline-flex; align-items: center; gap: 8px; margin: 0 6px 0 0; padding: 6px 12px 6px 8px; border-radius: 20px;
    font-size: 12.5px; cursor: pointer; white-space: nowrap; background: var(--panel-2); border: 1px solid var(--border);
}
.switch input { appearance: none; width: 34px; height: 20px; margin: 0; padding: 0; border-radius: 10px; background: var(--border-strong); border: none; position: relative; cursor: pointer; transition: background .15s; box-shadow: none; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { transform: translateX(14px); }
.switch.paused { background: var(--warn-soft); border-color: transparent; color: var(--warn); }

.banner { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.banner > div { display: flex; flex-direction: column; min-width: 0; }
.banner .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.banner-ad { background: var(--panel-2); }
.banner-ad img { width: 42px; height: 42px; object-fit: cover; border-radius: 8px; }
.ad-icon { width: 42px; height: 42px; border-radius: 8px; display: grid; place-items: center; background: var(--primary-soft); font-size: 20px; flex-shrink: 0; }
.banner-warn { background: var(--warn-soft); color: var(--warn); justify-content: space-between; font-weight: 500; }

.messages { flex: 1; overflow-y: auto; padding: 16px 24px; display: flex; flex-direction: column; }
.messages .empty { margin: auto; }
.day { text-align: center; margin: 16px 0 10px; }
.day span { font-size: 12px; color: var(--muted); background: var(--panel-2); padding: 3px 10px; border-radius: 10px; }
.msg { display: flex; gap: 8px; max-width: 72%; margin-top: 10px; animation: rise .18s ease-out; }
.msg.grouped { margin-top: 2px; }
.msg.grouped .meta { display: none; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar { width: 28px; flex-shrink: 0; align-self: flex-end; margin-bottom: 18px; }
.msg.grouped .msg-avatar { margin-bottom: 0; }
.msg-col { display: flex; flex-direction: column; min-width: 0; }
.msg.out .msg-col { align-items: flex-end; }
.bubble { padding: 9px 14px; border-radius: 18px; line-height: 1.45; overflow-wrap: anywhere; font-size: 14.5px; }
.msg.in .bubble { background: var(--bubble-in); border-bottom-left-radius: 6px; }
.msg.out .bubble { background: var(--bubble-ai); color: #fff; border-bottom-right-radius: 6px; box-shadow: 0 2px 6px rgba(8, 102, 255, .18); }
.msg.agent .bubble, .msg.business_suite .bubble { background: var(--bubble-agent); box-shadow: 0 2px 6px rgba(107, 77, 255, .18); }
.msg.out .bubble a { color: #fff; text-decoration: underline; }
.msg.failed .bubble { opacity: .5; }
.meta { font-size: 11.5px; color: var(--muted); margin-top: 4px; padding: 0 4px; }
.ai-chip { display: inline-block; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 10.5px; padding: 1px 6px; border-radius: 6px; }
.att-img { max-width: 240px; max-height: 240px; border-radius: 14px; display: block; }
.att { display: inline-block; padding: 8px 12px; border-radius: 12px; background: var(--bubble-in); }

.composer { border-top: 1px solid var(--border); padding: 10px 16px 8px; }
.window-note { font-size: 13px; color: var(--warn); background: var(--warn-soft); padding: 8px 12px; border-radius: 8px; margin-bottom: 8px; }
.quick-replies { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 8px; }
.quick {
    font: inherit; font-size: 12.5px; padding: 5px 12px; border-radius: 16px; white-space: nowrap; cursor: pointer;
    border: 1px solid var(--primary-soft); background: var(--primary-soft); color: var(--primary); font-weight: 500;
}
.quick:hover { border-color: var(--primary); }
.composer-box {
    display: flex; align-items: flex-end; gap: 8px; padding: 6px 6px 6px 14px; border-radius: 22px;
    background: var(--panel-2); border: 1px solid var(--border);
}
.composer-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.composer-box textarea { margin: 0; padding: 7px 0; border: none; background: none; resize: none; box-shadow: none; max-height: 160px; }
.composer-box .btn { border-radius: 18px; padding: 7px 12px; }
.send-btn { width: 36px; height: 36px; padding: 0 !important; border-radius: 50% !important; }
.composer-hint { font-size: 11.5px; padding: 6px 4px 0; }

/* details */
.details-pane {
    width: 320px; flex-shrink: 0; border-left: 1px solid var(--border); overflow-y: auto; padding: 22px 20px;
    background: var(--panel); position: relative;
}
.details-closed .details-pane { display: none; }
.details-close { position: absolute; top: 10px; right: 10px; display: none; }
.profile { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.profile h3 { margin-top: 8px; font-size: 18px; }
.profile .muted { font-size: 12.5px; display: inline-flex; gap: 6px; align-items: center; }
.d-section { padding: 16px 0; border-bottom: 1px solid var(--border); }
.d-section:last-child { border-bottom: none; }
.d-section h4 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: flex; justify-content: space-between; }
.d-section p { margin: 0; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; margin: 0; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; font-weight: 500; }
.ad-card { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--border); }
.ad-card img { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; }
.ad-card div { display: flex; flex-direction: column; gap: 2px; font-size: 13px; min-width: 0; }
.label-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.label-toggle {
    font: inherit; font-size: 12.5px; padding: 5px 11px; border-radius: 14px; cursor: pointer;
    border: 1px dashed var(--border-strong); background: none; color: var(--muted);
}
.label-toggle:hover { border-style: solid; color: var(--text); }
.label-toggle.on { border: 1px solid transparent; background: var(--purple-soft); color: var(--purple); font-weight: 600; }
.label-toggle.on::before { content: "✓ "; }
.notes { margin: 0; font-size: 13px; background: var(--panel-2); }
.save-state { text-transform: none; letter-spacing: 0; font-weight: 500; }

/* ================= other pages ================= */
.container { max-width: 1040px; width: 100%; margin: 0 auto; padding: 28px 24px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 0; }
.card { background: var(--panel); border-radius: var(--radius); padding: 22px; margin-bottom: 16px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.card.empty { text-align: center; color: var(--muted); }
.card-icon { width: 30px; height: 30px; border-radius: 8px; display: inline-grid; place-items: center; font-size: 15px; background: var(--primary-soft); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row input { margin-top: 0; }
.row-end { justify-content: flex-end; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 20px; }
.kv { display: grid; grid-template-columns: max-content 1fr auto; gap: 12px 16px; margin: 0; align-items: center; }
.kv dt { font-weight: 600; }
.kv dd { margin: 0; }
.setup ol { padding-left: 20px; line-height: 1.8; margin: 0; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.step { padding: 14px; border-radius: 10px; background: var(--panel); border: 1px solid var(--border); }
.step b { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-size: 12px; margin-bottom: 6px; }
.step.done b { background: var(--ok-soft); color: var(--ok); }
.step p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.test-result { margin-top: 14px; padding: 14px; background: var(--panel-2); border-radius: 10px; white-space: pre-wrap; border: 1px solid var(--border); }
.copy { cursor: pointer; }

.pages-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.page-card { margin: 0; display: flex; flex-direction: column; }
.page-card form:last-of-type { margin-top: auto; }
.page-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.page-card-head h2 { margin: 0 0 2px; }
.page-card-head .avatar, .page-card-head .avatar-stack { width: 46px; height: 46px; border-radius: 12px; }
.page-card-head .avatar-letter { border-radius: 12px; }

.provider-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.provider { position: relative; margin: 0; cursor: pointer; }
.provider input { position: absolute; opacity: 0; pointer-events: none; }
.provider span {
    display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: 10px; border: 2px solid var(--border);
    font-weight: 600; height: 100%;
}
.provider span small { color: var(--muted); }
.provider span i { font-style: normal; font-size: 22px; }
.provider input:checked + span { border-color: var(--primary); background: var(--primary-soft); }

.center-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; background: radial-gradient(circle at 20% 20%, var(--primary-soft), transparent 50%), radial-gradient(circle at 80% 80%, var(--purple-soft), transparent 50%), var(--bg); }
.center-page .main { width: 100%; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 400px; padding: 32px; box-shadow: var(--shadow-lg); }
.login-card h1 { margin: 16px 0 4px; }
.login-card p { margin: 0 0 24px; }
.login-card .rail-logo { margin: 0; width: 52px; height: 52px; border-radius: 16px; }

/* ================= animation ================= */
@keyframes pulse { 0% { box-shadow: 0 0 0 0 currentColor; } 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes pulse-bg { from { opacity: 1; } to { opacity: .55; } }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ================= responsive ================= */
@media (max-width: 1199px) {
    .details-pane { position: fixed; top: 0; right: 0; bottom: 0; z-index: 40; box-shadow: var(--shadow-lg); }
    .details-close { display: inline-flex; }
}
@media (max-width: 900px) {
    .steps, .provider-grid { grid-template-columns: 1fr 1fr; }
    .pages-grid { grid-template-columns: 1fr; }
    .list-pane { width: 300px; }
}
@media (max-width: 760px) {
    .has-rail { padding-left: 0; padding-bottom: 60px; }
    .inbox-page.has-rail { padding-bottom: 0; }
    .inbox-page .main { height: calc(100vh - 60px); }
    .rail { inset: auto 0 0 0; width: auto; height: 60px; flex-direction: row; padding: 0 12px; justify-content: space-around; }
    .rail .rail-logo, .rail-user { display: none; }
    .rail-nav { flex-direction: row; gap: 4px; }
    .rail-bottom { margin: 0; }
    [data-tip]:hover::after { display: none; }
    .inbox-head { padding: 0 12px; }
    .stats { padding: 8px 0; gap: 6px; }
    .stat { padding: 6px 10px; }
    .stat-num { font-size: 16px; }
    .ai-pill { margin-left: 0; }
    .list-pane { width: 100%; border-right: none; }
    .chat-pane { display: none; }
    .inbox.show-chat .list-pane { display: none; }
    .inbox.show-chat .chat-pane { display: flex; }
    .main:has(.inbox.show-chat) .inbox-head { display: none; }
    /* An open chat takes the whole screen, like the Messenger app. */
    body:has(.inbox.show-chat) .rail { display: none; }
    body:has(.inbox.show-chat) .main { height: 100vh; }
    .chat-head { padding: 8px; gap: 6px; }
    .chat-head .back { display: inline-flex; }
    .switch-label { display: none; }
    .switch { padding: 6px; margin: 0; }
    .details-pane { width: 100%; }
    .messages { padding: 12px; }
    .msg { max-width: 86%; }
    .composer-hint { display: none; }
    .composer-box .btn-soft { padding: 7px 10px; font-size: 0; }
    .composer-box .btn-soft::before { content: "✨"; font-size: 15px; }
    .grid-2, .grid-3, .steps, .provider-grid { grid-template-columns: 1fr; }
    .kv { grid-template-columns: 1fr; }
    .container { padding: 20px 14px 40px; }
}

/* ================= team ================= */
.form-sub { font-size: 14px; margin: 18px 0 10px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-width: 640px; }
.page-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.page-check { margin: 0; cursor: pointer; position: relative; }
.page-check input { position: absolute; opacity: 0; pointer-events: none; }
.page-check span {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
    border: 2px solid var(--border); font-weight: 600; position: relative;
}
.page-check .avatar { width: 30px; height: 30px; border-radius: 8px; font-size: 12px; }
.page-check input:checked + span { border-color: var(--primary); background: var(--primary-soft); }
.page-check input:checked + span::after { content: "✓"; position: absolute; right: 12px; color: var(--primary); font-weight: 800; }
.page-check input:focus-visible + span { box-shadow: 0 0 0 3px var(--primary-soft); }
.team-table td { vertical-align: middle; }
.team-table th:first-child, .team-table td:first-child { padding-left: 20px; }
.team-table .actions { text-align: right; padding-right: 20px; }
.member { display: flex; align-items: center; gap: 12px; }
.member .avatar { width: 38px; height: 38px; font-size: 14px; }
.row-disabled { opacity: .55; }
.page-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.page-team { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: -4px 0 12px; font-size: 13px; }
.page-chip { display: inline-block; font-size: 11.5px; font-weight: 500; padding: 2px 8px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); }

/* ================= products ================= */
.container-wide { max-width: 1240px; }
.toolbar { display: flex; gap: 10px; margin-bottom: 18px; }
.toolbar .search { max-width: 360px; }
.toolbar select { width: 220px; margin: 0; border-radius: 20px; }
.toolbar .search input { background: var(--panel); border-color: var(--border-strong); }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.product-card {
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
    color: var(--text); text-decoration: none !important; box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s;
}
.product-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.product-card.inactive { opacity: .6; }
.product-cover { position: relative; aspect-ratio: 1; background: var(--panel-2); display: grid; place-items: center; }
.product-cover img, .product-cover video { width: 100%; height: 100%; object-fit: cover; }
.no-media { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 30px; color: var(--muted); }
.no-media small { font-size: 12px; }
.media-count { position: absolute; right: 8px; top: 8px; background: rgba(0, 0, 0, .65); color: #fff; font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 10px; }
.media-count.left { right: auto; left: 8px; }
.play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 26px; text-shadow: 0 2px 8px rgba(0, 0, 0, .5); pointer-events: none; }
.product-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.price { color: var(--ok); font-weight: 700; font-size: 13.5px; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.media-grid:empty { display: none; }
.media-tile { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; margin: 0; background: var(--panel-2); border: 1px solid var(--border); }
.media-tile img, .media-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-tile .remove {
    position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 8px; font-size: 12px; font-weight: 600;
    background: linear-gradient(transparent, rgba(0, 0, 0, .75)); color: #fff; display: flex; align-items: center; gap: 6px; cursor: pointer;
}
.media-tile .remove input { width: auto; margin: 0; }
.media-tile:has(input:checked) { outline: 3px solid var(--danger); }
.media-tile:has(input:checked) img, .media-tile:has(input:checked) video { opacity: .4; }
.media-tile.new { outline: 2px dashed var(--primary); }
.dropzone {
    display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 28px; margin: 0; cursor: pointer;
    border: 2px dashed var(--border-strong); border-radius: 12px; text-align: center; font-weight: normal; transition: background .15s, border-color .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone input { display: none; }
.dz-icon { font-size: 26px; }

/* product picker in the chat */
.product-picker {
    border: 1px solid var(--border); border-radius: 14px; margin-bottom: 8px; background: var(--panel);
    box-shadow: var(--shadow-lg); max-height: 340px; display: flex; flex-direction: column; overflow: hidden;
}
.picker-head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--border); }
.picker-head strong { white-space: nowrap; }
.picker-head input { margin: 0; padding: 6px 12px; border-radius: 16px; background: var(--panel-2); border-color: transparent; }
.picker-list { overflow-y: auto; padding: 6px; }
.picker-empty { padding: 24px; text-align: center; }
.picker-item {
    display: grid; grid-template-columns: 1fr auto; grid-template-areas: "info actions" "media media";
    gap: 8px 12px; align-items: center; padding: 10px; border-radius: 10px;
}
.picker-item + .picker-item { border-top: 1px solid var(--border); }
.picker-item:hover { background: var(--hover); }
.picker-info { grid-area: info; display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.picker-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-media { grid-area: media; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; }
.picker-actions { grid-area: actions; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.thumb { position: relative; width: 56px; height: 56px; flex-shrink: 0; border-radius: 8px; overflow: hidden; border: none; padding: 0; cursor: pointer; background: var(--panel-2); }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .play { font-size: 16px; }
.thumb-send { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(8, 102, 255, .8); color: #fff; font-size: 11.5px; font-weight: 700; opacity: 0; transition: opacity .12s; }
.thumb:hover .thumb-send, .thumb.sending .thumb-send { opacity: 1; }
.thumb.sending .thumb-send { animation: pulse-bg .6s infinite alternate; }
.upload-progress { font-size: 12.5px; color: var(--primary); background: var(--primary-soft); padding: 6px 12px; border-radius: 8px; margin-bottom: 8px; animation: pulse-bg 1s infinite alternate; }
.small { font-size: 12px; }
.composer-box .icon-btn { width: 34px; height: 34px; flex-shrink: 0; cursor: pointer; margin: 0; }
.composer-box label.icon-btn { display: inline-flex; }
video.att-img { background: #000; }

@media (max-width: 760px) {
    .role-grid { grid-template-columns: 1fr; }
    .team-table thead { display: none; }
    .team-table tr { display: grid; grid-template-columns: 1fr auto; padding: 12px 0; border-bottom: 1px solid var(--border); }
    .team-table td { border: none; padding: 4px 14px; }
    .team-table td:nth-child(4) { display: none; }
    .toolbar { flex-direction: column; }
    .toolbar select { width: 100%; }
    .product-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .picker-item { grid-template-columns: 1fr; grid-template-areas: "info" "media" "actions"; }
    .picker-actions { justify-content: flex-start; }
    .picker-head strong { display: none; }
}

/* ================= orders ================= */
.num { text-align: right; white-space: nowrap; }
.filters { flex-wrap: wrap; align-items: center; }
.filters select { width: auto; min-width: 150px; }
.custom-range { display: inline-flex; align-items: center; gap: 6px; }
.custom-range input { margin: 0; width: 150px; }

.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi {
    display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border-radius: var(--radius);
    background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--text);
}
.kpi-link { text-decoration: none !important; }
.kpi-link:hover { border-color: var(--primary); }
.kpi-label { font-size: 12.5px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi-num { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.kpi-sub { font-size: 12px; color: var(--muted); }

.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.dash-grid .card { margin-bottom: 16px; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.chart-head h2 { margin: 0; }

/* Single-series bar chart: one hue, rounded data end on a shared baseline, recessive grid. */
.bar-chart { position: relative; height: 210px; display: flex; gap: 8px; padding-top: 10px; }
.bar-grid {
    display: flex; flex-direction: column; justify-content: space-between; height: calc(100% - 22px);
    font-size: 11px; color: var(--muted); text-align: right; min-width: 18px;
}
.bars {
    flex: 1; display: grid; grid-template-columns: repeat(14, 1fr); gap: 2px; height: 100%;
    background: linear-gradient(var(--border) 1px, transparent 1px) 0 0 / 100% calc((100% - 22px) / 2);
}
.bar-col { position: relative; display: flex; flex-direction: column; align-items: center; outline: none; cursor: default; }
.bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; border-bottom: 1px solid var(--border-strong); }
.bar { width: min(70%, 28px); background: var(--primary); border-radius: 4px 4px 0 0; transition: filter .12s; }
.bar-col:hover .bar, .bar-col:focus .bar { filter: brightness(1.15); }
.bar-x { font-size: 11px; color: var(--muted); height: 22px; line-height: 22px; }
.bar-x.today { color: var(--text); font-weight: 600; }
.bar-tip {
    position: absolute; bottom: calc(100% - 4px); left: 50%; transform: translateX(-50%); z-index: 5;
    display: none; flex-direction: column; gap: 2px; white-space: nowrap; font-size: 12px;
    background: var(--panel); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
    padding: 8px 10px; border-radius: 8px; pointer-events: none;
}
.bar-col:hover .bar-tip, .bar-col:focus .bar-tip { display: flex; }
.bar-col:first-child .bar-tip { left: 0; transform: none; }
.bar-col:last-child .bar-tip { left: auto; right: 0; transform: none; }
.table-view { margin-top: 10px; font-size: 13px; }
.table-view summary { cursor: pointer; color: var(--muted); }
.table-view table { margin-top: 8px; }

.top-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.top-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.top-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-bar { height: 6px; background: var(--panel-2); border-radius: 3px; margin: 5px 0 3px; overflow: hidden; }
.top-bar span { display: block; height: 100%; background: var(--primary); border-radius: 3px; }

.status-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 4px 0 12px; }
.status-tabs a {
    display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 18px; white-space: nowrap;
    color: var(--text); font-weight: 500; font-size: 13px; text-decoration: none !important; border: 1px solid transparent;
}
.status-tabs a:hover { background: var(--panel); border-color: var(--border); }
.status-tabs a.active { background: var(--panel); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.status-tabs a > span:last-child { font-size: 11.5px; color: var(--muted); background: var(--panel-2); border-radius: 10px; padding: 0 7px; }

/* Order status: colour is always paired with the status name. */
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; background: var(--muted); }
.s-pending { --s: var(--warn); --s-soft: var(--warn-soft); }
.s-confirmed { --s: var(--primary); --s-soft: var(--primary-soft); }
.s-shipped { --s: var(--purple); --s-soft: var(--purple-soft); }
.s-delivered { --s: var(--ok); --s-soft: var(--ok-soft); }
.s-cancelled { --s: var(--muted); --s-soft: var(--panel-2); }
.s-returned { --s: var(--danger); --s-soft: var(--danger-soft); }
.status-dot[class*="s-"] { background: var(--s); }
.status-badge {
    display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px;
    border-radius: 12px; background: var(--s-soft); color: var(--s); vertical-align: middle;
}
.status-select {
    width: auto; margin: 0; padding: 5px 28px 5px 10px; font-size: 12.5px; font-weight: 600; border-radius: 14px;
    background-color: var(--s-soft); color: var(--s); border-color: transparent; cursor: pointer;
}

.table-scroll { overflow-x: auto; }
.orders-table { min-width: 880px; }
.orders-table td { vertical-align: top; }
.orders-table th:first-child, .orders-table td:first-child { padding-left: 18px; }
.orders-table .actions { text-align: right; white-space: nowrap; padding-right: 18px; }
.orders-table .actions .icon-btn { width: 30px; height: 30px; text-decoration: none; }
.order-no { font-weight: 700; }
.clamp { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { margin-top: 12px; display: flex; justify-content: center; }

/* item editor (order page and chat dialog) */
.item-head, .item-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px 70px 110px 36px; gap: 8px; align-items: center; }
.item-head { font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 0 4px; }
.item-row { padding: 6px 0; border-top: 1px solid var(--border); }
.item-row input, .item-row select { margin: 0; }
.item-product { display: flex; flex-direction: column; gap: 4px; }
.item-product select { font-size: 13px; padding: 6px 10px; }
.subtotal-row { display: flex; justify-content: flex-end; gap: 16px; padding: 10px 46px 0 0; border-top: 1px solid var(--border); margin-top: 8px; }
.items-editor [data-add-item] { margin-top: 8px; }
.totals { display: flex; justify-content: flex-end; align-items: flex-end; gap: 16px; margin-top: 14px; flex-wrap: wrap; }
.totals label { margin: 0; width: 160px; }
.grand-total { display: flex; flex-direction: column; align-items: flex-end; min-width: 140px; }
.grand-total strong { font-size: 22px; letter-spacing: -.02em; }
h1 .status-badge { font-size: 13px; margin-left: 8px; }

/* dialog */
.dialog {
    width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 40px); padding: 0; border: none; border-radius: 16px;
    background: var(--panel); color: var(--text); box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgba(10, 16, 28, .45); }
.dialog-form { display: flex; flex-direction: column; max-height: calc(100vh - 40px); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { margin: 0; }
.dialog-body { padding: 16px 18px; overflow-y: auto; }
.dialog-foot { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--border); }
.dialog-foot .grand-total { margin-right: auto; align-items: flex-start; }

.mini-order {
    display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; margin-bottom: 6px; border-radius: 8px;
    background: var(--panel-2); border: 1px solid var(--border); color: var(--text); font-size: 12.5px; text-decoration: none !important;
}
.mini-order:hover { border-color: var(--primary); }
.mini-order > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-order-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.mini-order .status-badge { font-size: 10.5px; padding: 1px 7px; }
.chat-head .order-btn { padding: 6px 12px; }

@media (max-width: 1100px) {
    .kpis { grid-template-columns: repeat(3, 1fr); }
    .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .kpis { grid-template-columns: 1fr 1fr; }
    .kpi-num { font-size: 20px; }
    .filters select, .filters .search { width: 100%; max-width: none; }
    .chat-head .order-btn { font-size: 0; padding: 6px 8px; }
    .chat-head .order-btn::first-letter { font-size: 16px; }
    .item-head { display: none; }
    .item-row { grid-template-columns: minmax(0, 1fr) 64px minmax(72px, auto); grid-template-areas: "p p x" "price qty line"; }
    .item-row .item-product { grid-area: p; }
    .item-row [data-remove-item] { grid-area: x; justify-self: end; }
    .item-row [data-price] { grid-area: price; min-width: 0; }
    .item-row [data-qty] { grid-area: qty; min-width: 0; }
    .item-row [data-line] { grid-area: line; text-align: right; white-space: nowrap; font-size: 12.5px; }
    .subtotal-row { padding-right: 0; }
    .totals label { width: calc(50% - 8px); }
}
