/* ======================================================================
   WhatsApp Inbox V3 — Design System
   ====================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    /* --- Brand palette --- */
    --color-primary: #0F766E;
    --color-primary-light: #14B8A6;
    --color-primary-dark: #0B5A54;
    --color-accent: #14B8A6;
    --color-success: #10B981;
    --color-warning: #F59E0B;
    --color-danger: #EF4444;

    /* --- Neutrals (light mode) --- */
    --surface-0: #FFFFFF;
    --surface-1: #F8FAFA;
    --surface-2: #F1F5F4;
    --surface-3: #E7ECEB;
    --border: #E2E8E7;
    --border-strong: #CBD5D4;
    --text-primary: #0B1615;
    --text-secondary: #5B6B69;
    --text-tertiary: #8B9997;
    --text-on-primary: #FFFFFF;

    --bubble-in: #FFFFFF;
    --bubble-out: #DCFCE4;
    --chat-bg: #EAF2F0;

    /* --- Elevation --- */
    --shadow-sm: 0 1px 2px rgba(15, 23, 22, 0.06);
    --shadow-md: 0 4px 14px rgba(15, 23, 22, 0.08);
    --shadow-lg: 0 12px 32px rgba(15, 23, 22, 0.14);
    --shadow-glass: 0 8px 32px rgba(15, 23, 22, 0.10);

    /* --- Radius --- */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-full: 999px;

    /* --- Spacing scale --- */
    --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
    --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

    /* --- Type --- */
    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;

    /* --- Motion --- */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --dur: 200ms;

    /* --- Layout --- */
    --sidebar-w: 360px;
    --panel-w: 320px;
    --header-h: 64px;
}

[data-theme="dark"] {
    --surface-0: #10201E;
    --surface-1: #0B1615;
    --surface-2: #16302C;
    --surface-3: #1D3C36;
    --border: #1F3D38;
    --border-strong: #2C544C;
    --text-primary: #EAF5F3;
    --text-secondary: #9FB8B3;
    --text-tertiary: #6E8A85;
    --text-on-primary: #FFFFFF;

    --bubble-in: #16302C;
    --bubble-out: #144C42;
    --chat-bg: #0D1E1B;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 14px rgba(0,0,0,0.35);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);
    --shadow-glass: 0 8px 32px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-ui);
    background: var(--surface-1);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font-family: inherit; }
img { max-width: 100%; display: block; }
a { color: inherit; }

/* Visible focus states everywhere */
:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
    border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ======================================================================
   Login page
   ====================================================================== */
.login-page {
    display: flex; align-items: center; justify-content: center;
    height: 100vh;
    background:
        radial-gradient(circle at 20% 20%, rgba(20,184,166,0.15), transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(15,118,110,0.18), transparent 45%),
        var(--surface-1);
    padding: var(--sp-4);
}
.login-box {
    background: var(--surface-0);
    border: 1px solid var(--border);
    padding: var(--sp-8);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 360px;
    backdrop-filter: blur(20px);
}
.login-box h1 {
    font-size: 22px; font-weight: 800; margin-bottom: var(--sp-6);
    color: var(--color-primary);
    letter-spacing: -0.02em;
}
.login-box input {
    width: 100%; padding: 12px 14px; margin-bottom: var(--sp-3);
    border: 1.5px solid var(--border-strong); border-radius: var(--radius-md);
    background: var(--surface-1); color: var(--text-primary);
    font-size: 14px; transition: border-color var(--dur) var(--ease);
}
.login-box input:focus { border-color: var(--color-accent); outline: none; }
.login-box button {
    width: 100%; padding: 12px; background: var(--color-primary); color: #fff;
    border: none; border-radius: var(--radius-md); cursor: pointer; font-weight: 600;
    font-size: 14px; transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.login-box button:hover { background: var(--color-primary-dark); transform: translateY(-1px); }
.error { color: var(--color-danger); margin-bottom: var(--sp-3); font-size: 13px; }

/* ======================================================================
   App shell
   ====================================================================== */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr var(--panel-w);
    height: 100vh;
    background: var(--surface-1);
}
.app.panel-collapsed { grid-template-columns: var(--sidebar-w) 1fr 0; }

@media (max-width: 1199px) {
    .app { grid-template-columns: 320px 1fr var(--panel-w); }
}
@media (max-width: 991px) {
    .app { grid-template-columns: 300px 1fr; }
    .customer-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 90vw); z-index: 40; transform: translateX(100%); transition: transform var(--dur) var(--ease); box-shadow: var(--shadow-lg); }
    .customer-panel.open { transform: translateX(0); }
    .panel-scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 39; opacity: 0; pointer-events: none; transition: opacity var(--dur) var(--ease); }
    .panel-scrim.show { opacity: 1; pointer-events: auto; }
}
@media (max-width: 767px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: fixed; inset: 0; z-index: 10; transform: translateX(0); transition: transform var(--dur) var(--ease); }
    .chat-panel { position: fixed; inset: 0; z-index: 15; transform: translateX(100%); transition: transform var(--dur) var(--ease); }
    body.chat-active .sidebar { transform: translateX(-100%); }
    body.chat-active .chat-panel { transform: translateX(0); }
    .mobile-back-btn { display: inline-flex !important; }
    .desktop-only { display: none !important; }
    .chat-input-area { padding-bottom: max(var(--sp-3), env(safe-area-inset-bottom)); }
}

/* ======================================================================
   Sidebar / conversation list
   ====================================================================== */
.sidebar {
    background: var(--surface-0);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    min-width: 0;
}
.sidebar-header {
    height: var(--header-h);
    padding: 0 var(--sp-4);
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: var(--sp-2); font-weight: 800; font-size: 16px; color: var(--color-primary); letter-spacing: -0.02em; }
.brand svg { color: var(--color-primary); }
.header-actions { display: flex; align-items: center; gap: var(--sp-2); }
.icon-btn {
    width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-full); border: none; background: transparent; color: var(--text-secondary);
    cursor: pointer; transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text-primary); }
.icon-btn.active { background: var(--color-primary); color: #fff; }

.user-menu { position: relative; }
.user-avatar-btn {
    width: 34px; height: 34px; border-radius: var(--radius-full); border: none; cursor: pointer;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    color: #fff; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center;
}
.user-dropdown {
    position: absolute; top: 42px; right: 0; background: var(--surface-0); border: 1px solid var(--border);
    border-radius: var(--radius-md); box-shadow: var(--shadow-lg); min-width: 200px; z-index: 30;
    opacity: 0; transform: translateY(-6px); pointer-events: none; transition: all var(--dur) var(--ease);
    overflow: hidden;
}
.user-dropdown.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.user-dropdown-name { padding: var(--sp-3) var(--sp-4); font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--border); color: var(--text-secondary); }
.user-dropdown a, .user-dropdown button {
    display: flex; align-items: center; gap: var(--sp-2); width: 100%; padding: var(--sp-3) var(--sp-4);
    background: none; border: none; text-align: left; font-size: 13px; color: var(--text-primary); cursor: pointer;
    text-decoration: none;
}
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--surface-2); }

.search-box { padding: var(--sp-3) var(--sp-4); position: sticky; top: 0; background: var(--surface-0); z-index: 5; }
.search-input-wrap { position: relative; }
.search-input-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); pointer-events: none; }
.search-box input {
    width: 100%; padding: 9px 12px 9px 36px; border-radius: var(--radius-full); border: 1.5px solid var(--border);
    background: var(--surface-1); color: var(--text-primary); font-size: 13px; outline: none;
    transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.search-box input:focus { border-color: var(--color-accent); background: var(--surface-0); }

.filter-tabs { display: flex; gap: var(--sp-2); padding: 0 var(--sp-4) var(--sp-3); overflow-x: auto; scrollbar-width: none; }
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab {
    flex-shrink: 0; padding: 6px 13px; border: 1.5px solid var(--border); background: var(--surface-0);
    color: var(--text-secondary); border-radius: var(--radius-full); font-size: 12px; font-weight: 600; cursor: pointer;
    transition: all var(--dur) var(--ease);
}
.filter-tab:hover { border-color: var(--color-accent); color: var(--text-primary); }
.filter-tab.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.label-filter-bar { display: flex; flex-wrap: wrap; gap: var(--sp-2); padding: 0 var(--sp-4) var(--sp-3); }
.label-chip {
    display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: var(--radius-full);
    border: 1.5px solid var(--border-strong); font-size: 11px; font-weight: 600; cursor: pointer; color: var(--text-secondary);
    transition: all var(--dur) var(--ease); background: var(--surface-0);
}
.label-chip:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.label-chip.active { background: var(--surface-2); color: var(--text-primary); border-color: currentColor; }
.label-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

.conversation-list-scroll { flex: 1; overflow-y: auto; padding: var(--sp-2) var(--sp-2) var(--sp-4); }

.conversation-item {
    display: flex; gap: var(--sp-3); padding: var(--sp-3); border-radius: var(--radius-md); cursor: pointer;
    transition: background var(--dur) var(--ease); position: relative; margin-bottom: 2px;
}
.conversation-item:hover { background: var(--surface-2); }
.conversation-item.active { background: var(--surface-3); }
.conversation-item.active::before {
    content: ''; position: absolute; left: -2px; top: 14px; bottom: 14px; width: 3px;
    background: var(--color-primary); border-radius: var(--radius-full);
}

.avatar {
    width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; position: relative;
    background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary));
    color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px;
}
.avatar .online-dot {
    position: absolute; bottom: -1px; right: -1px; width: 11px; height: 11px; border-radius: 50%;
    background: var(--color-success); border: 2px solid var(--surface-0);
}

.conv-main { flex: 1; min-width: 0; }
.conv-top-row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-2); }
.conv-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-primary); }
.conv-time { font-size: 11px; color: var(--text-tertiary); flex-shrink: 0; }
.conv-bottom-row { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); margin-top: 2px; }
.conv-preview { font-size: 12.5px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.typing-preview { color: var(--color-success); font-style: italic; }
.unread-badge {
    background: var(--color-primary); color: #fff; font-size: 10.5px; font-weight: 700; padding: 1px 7px;
    border-radius: var(--radius-full); flex-shrink: 0; min-width: 18px; text-align: center;
}
.conv-labels { display: flex; gap: 3px; margin-top: 4px; }
.conv-labels .label-dot { width: 6px; height: 6px; }
.assigned-chip {
    display: inline-flex; align-items: center; gap: 3px; margin-top: 4px; font-size: 10px; font-weight: 600;
    background: var(--surface-2); color: var(--text-secondary); padding: 2px 7px; border-radius: var(--radius-full);
}

/* Skeleton loading */
.skeleton-item { display: flex; gap: var(--sp-3); padding: var(--sp-3); }
.skeleton-circle { width: 44px; height: 44px; border-radius: 50%; }
.skeleton-line { height: 10px; border-radius: 4px; margin-bottom: 6px; }
.skeleton-circle, .skeleton-line {
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
    background-size: 400% 100%; animation: skeleton-shimmer 1.4s ease infinite;
}
@keyframes skeleton-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.empty-state { color: var(--text-tertiary); text-align: center; margin-top: var(--sp-10); font-size: 13.5px; padding: var(--sp-5); line-height: 1.5; }
.empty-state svg { margin: 0 auto var(--sp-3); display: block; opacity: 0.5; }

/* ======================================================================
   Chat panel
   ====================================================================== */
.chat-panel { display: flex; flex-direction: column; min-width: 0; background: var(--chat-bg); }
.chat-panel.empty { align-items: center; justify-content: center; }
.chat-empty-hint { text-align: center; color: var(--text-tertiary); }
.chat-empty-hint svg { opacity: 0.35; margin-bottom: var(--sp-3); }

.chat-header {
    height: var(--header-h); padding: 0 var(--sp-4); background: var(--surface-0); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; gap: var(--sp-3);
}
.chat-header-left { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.mobile-back-btn {
    display: none; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: var(--radius-full);
    border: none; background: none; color: var(--text-primary); cursor: pointer; flex-shrink: 0;
}
.chat-header-name-wrap { min-width: 0; cursor: pointer; }
.chat-header-name { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header-sub { font-size: 11.5px; color: var(--text-tertiary); }
.typing-indicator-text { color: var(--color-success); font-style: italic; font-size: 11.5px; }
.chat-header-right { display: flex; align-items: center; gap: var(--sp-2); flex-shrink: 0; }

.assign-select {
    padding: 6px 10px; border-radius: var(--radius-full); border: 1.5px solid var(--border); background: var(--surface-1);
    color: var(--text-primary); font-size: 12px; font-weight: 600; cursor: pointer; max-width: 140px;
}

/* Popover */
.popover {
    position: absolute; top: 60px; right: var(--sp-4); background: var(--surface-0); border: 1px solid var(--border);
    border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: var(--sp-3); z-index: 25; min-width: 220px;
    opacity: 0; transform: translateY(-6px) scale(0.98); pointer-events: none; transition: all var(--dur) var(--ease);
}
.popover.show { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.popover-row { display: flex; align-items: center; gap: var(--sp-2); padding: 6px 4px; font-size: 13px; cursor: pointer; border-radius: var(--radius-sm); }
.popover-row:hover { background: var(--surface-2); }
.new-label-row { border-top: 1px solid var(--border); margin-top: var(--sp-2); padding-top: var(--sp-3); gap: 6px; }
.new-label-row input[type="text"] { flex: 1; padding: 6px 8px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); font-size: 12px; }
.new-label-row input[type="color"] { width: 28px; height: 28px; border: none; border-radius: 6px; padding: 0; background: none; cursor: pointer; }
.new-label-row button { padding: 6px 10px; border-radius: var(--radius-sm); border: none; background: var(--color-primary); color: #fff; cursor: pointer; font-size: 12px; font-weight: 600; }

/* Messages */
.chat-body { flex: 1; display: flex; overflow: hidden; position: relative; }
.chat-messages {
    flex: 1; overflow-y: auto; padding: var(--sp-6) var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-2);
    background-image: radial-gradient(circle, rgba(15,118,110,0.045) 1px, transparent 1px);
    background-size: 18px 18px;
}
.msg-day-divider { align-self: center; background: var(--surface-0); color: var(--text-tertiary); font-size: 11px; font-weight: 600;
    padding: 4px 12px; border-radius: var(--radius-full); margin: var(--sp-3) 0; box-shadow: var(--shadow-sm); }

.msg {
    max-width: 62%; padding: 9px 13px; border-radius: var(--radius-lg); font-size: 14px; line-height: 1.45;
    word-wrap: break-word; box-shadow: var(--shadow-sm); animation: msg-fade-in var(--dur) var(--ease);
    position: relative;
}
@keyframes msg-fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.msg-in { align-self: flex-start; background: var(--bubble-in); border-bottom-left-radius: 4px; color: var(--text-primary); }
.msg-out { align-self: flex-end; background: var(--bubble-out); border-bottom-right-radius: 4px; color: var(--text-primary); }
.msg-time { font-size: 10px; color: var(--text-tertiary); margin-top: 3px; display: flex; justify-content: flex-end; gap: 4px; align-items: center; }
.msg-status-failed { color: var(--color-danger); font-weight: 600; }
.ticks { font-size: 13px; line-height: 1; }
.ticks-sent, .ticks-delivered { color: var(--text-tertiary); }
.ticks-read { color: #53BDEB; }
.msg-caption { margin-top: 5px; }

.msg-media-image { max-width: 280px; border-radius: var(--radius-sm); cursor: zoom-in; transition: opacity var(--dur) var(--ease); }
.msg-media-image:hover { opacity: 0.92; }
.msg-media-video { max-width: 280px; border-radius: var(--radius-sm); background: #000; }
.msg-media-doc {
    display: flex; align-items: center; gap: var(--sp-3); text-decoration: none; color: var(--text-primary);
    background: var(--surface-1); padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm); min-width: 200px;
}
.msg-media-doc .doc-icon {
    width: 36px; height: 36px; border-radius: var(--radius-sm); background: var(--color-danger); color: #fff;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.doc-name { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta { font-size: 10.5px; color: var(--text-tertiary); }

.audio-player { display: flex; align-items: center; gap: var(--sp-2); min-width: 220px; }
.audio-play-btn {
    width: 32px; height: 32px; border-radius: 50%; background: var(--color-primary); color: #fff; border: none;
    display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.audio-waveform { flex: 1; display: flex; align-items: center; gap: 2px; height: 24px; }
.audio-waveform span { width: 2.5px; background: var(--text-tertiary); border-radius: 2px; opacity: 0.6; }
.audio-player audio { display: none; }

.reply-quote { border-left: 3px solid var(--color-primary); background: rgba(15,118,110,0.08); border-radius: 6px; padding: 5px 9px; margin-bottom: 5px; font-size: 12px; color: var(--text-secondary); }

/* AI suggestion + typing placeholder */
.ai-suggestion-bar {
    background: linear-gradient(90deg, rgba(20,184,166,0.10), rgba(15,118,110,0.06));
    border-top: 1px solid var(--border); padding: var(--sp-3) var(--sp-4); font-size: 13px; display: flex;
    align-items: center; gap: var(--sp-3);
}
.ai-suggestion-text { flex: 1; color: var(--text-primary); }
.ai-suggestion-bar button { padding: 5px 12px; border-radius: var(--radius-full); border: none; cursor: pointer; font-size: 12px; font-weight: 600; }
#ai-insert-btn { background: var(--color-primary); color: #fff; }
#ai-dismiss-btn { background: var(--surface-2); color: var(--text-secondary); }
.ai-error { color: var(--color-danger); }

/* Composer */
.chat-input-area { display: flex; align-items: flex-end; padding: var(--sp-3) var(--sp-4); background: var(--surface-0); gap: var(--sp-2); border-top: 1px solid var(--border); }
.chat-input-area .icon-btn { flex-shrink: 0; }
.composer-textarea {
    flex: 1; resize: none; max-height: 120px; padding: 10px 14px; border-radius: var(--radius-lg); border: 1.5px solid var(--border);
    background: var(--surface-1); color: var(--text-primary); outline: none; font-size: 14px; line-height: 1.4;
    transition: border-color var(--dur) var(--ease);
}
.composer-textarea:focus { border-color: var(--color-accent); }
.send-btn {
    width: 40px; height: 40px; border-radius: 50%; background: var(--color-primary); color: #fff; border: none;
    cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    transition: background var(--dur) var(--ease), transform 100ms var(--ease);
}
.send-btn:hover { background: var(--color-primary-dark); }
.send-btn:active { transform: scale(0.92); }
.send-btn:disabled { background: var(--text-tertiary); cursor: not-allowed; }

.media-caption-bar { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); background: var(--surface-0); border-top: 1px solid var(--border); }
.media-caption-bar input { flex: 1; padding: 10px 14px; border-radius: var(--radius-full); border: 1.5px solid var(--border); background: var(--surface-1); color: var(--text-primary); }
.media-caption-bar button { padding: 8px 16px; border-radius: var(--radius-full); border: none; cursor: pointer; font-weight: 600; font-size: 13px; }
#send-media-btn { background: var(--color-primary); color: #fff; }
#cancel-media-btn { background: var(--surface-2); color: var(--text-secondary); }
#media-filename-label { font-size: 12px; color: var(--text-secondary); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ======================================================================
   Customer info panel (right)
   ====================================================================== */
.customer-panel { background: var(--surface-0); border-left: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.customer-panel-header { height: var(--header-h); display: flex; align-items: center; justify-content: space-between; padding: 0 var(--sp-4); border-bottom: 1px solid var(--border); flex-shrink: 0; font-weight: 700; font-size: 14px; }
.customer-panel-scroll { flex: 1; overflow-y: auto; padding: var(--sp-5) var(--sp-4); }
.customer-profile { text-align: center; margin-bottom: var(--sp-6); }
.customer-profile .avatar { width: 72px; height: 72px; font-size: 24px; margin: 0 auto var(--sp-3); }
.customer-profile-name { font-weight: 700; font-size: 16px; }
.customer-profile-phone { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; font-family: var(--font-mono); }

.panel-section { margin-bottom: var(--sp-6); }
.panel-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); margin-bottom: var(--sp-3); }
.panel-row { display: flex; justify-content: space-between; align-items: center; padding: var(--sp-2) 0; font-size: 13px; }
.panel-row-label { color: var(--text-secondary); }

.notes-list { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.note-item { background: #FFF8E1; border-radius: var(--radius-sm); padding: var(--sp-2) var(--sp-3); font-size: 12.5px; }
[data-theme="dark"] .note-item { background: #33280F; }
.note-meta { font-size: 10.5px; color: var(--text-tertiary); margin-bottom: 3px; }
.notes-input-area textarea { width: 100%; height: 56px; padding: var(--sp-2); border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); resize: none; font-size: 12.5px; }
.notes-input-area button { margin-top: var(--sp-2); width: 100%; padding: 8px; background: var(--color-primary); color: #fff; border: none; border-radius: var(--radius-sm); cursor: pointer; font-size: 12.5px; font-weight: 600; }

.panel-close-btn { display: none; }
@media (max-width: 991px) { .panel-close-btn { display: inline-flex; } }

/* Customer panel becomes a bottom sheet on mobile */
@media (max-width: 767px) {
    .customer-panel {
        top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 78vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0; border-left: none; border-top: 1px solid var(--border);
        transform: translateY(100%);
    }
    .customer-panel.open { transform: translateY(0); }
}

/* ======================================================================
   Modal (templates)
   ====================================================================== */
.modal { position: fixed; inset: 0; background: rgba(11,22,21,0.5); display: flex; align-items: center; justify-content: center; z-index: 50; backdrop-filter: blur(2px); }
.modal-content { background: var(--surface-0); border-radius: var(--radius-lg); width: min(460px, 92vw); max-height: 82vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.modal-header { padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 15px; }
.modal-header button { background: none; border: none; cursor: pointer; color: var(--text-secondary); display: flex; }
.template-list { padding: var(--sp-3) var(--sp-5) var(--sp-5); overflow-y: auto; }
.template-item { border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--sp-3); margin-bottom: var(--sp-3); }
.template-name { font-weight: 700; font-size: 13px; }
.template-lang { font-weight: 500; color: var(--text-tertiary); }
.template-body { font-size: 12.5px; color: var(--text-secondary); margin: var(--sp-2) 0; }
.template-var-input { width: 100%; padding: 7px 9px; margin-bottom: var(--sp-2); border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); font-size: 12.5px; }
.template-send-btn { padding: 7px 16px; background: var(--color-primary); color: #fff; border: none; border-radius: var(--radius-full); cursor: pointer; font-size: 12.5px; font-weight: 600; }

/* ======================================================================
   Lightbox
   ====================================================================== */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.9); display: flex; align-items: center; justify-content: center; z-index: 60; cursor: zoom-out; }
.lightbox img { max-width: 90vw; max-height: 90vh; border-radius: 4px; transition: transform var(--dur) var(--ease); cursor: zoom-in; }
.lightbox img.zoomed { transform: scale(1.6); cursor: zoom-out; }
.lightbox-close { position: absolute; top: 20px; right: 24px; color: #fff; background: rgba(255,255,255,0.12); border: none; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; }

/* ======================================================================
   Scrollbars
   ====================================================================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

.desktop-only { }
@media (min-width: 768px) { .mobile-back-btn { display: none; } }
