@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@500;600;700&display=swap');

* { box-sizing: border-box; }

:root {
    --font-display: 'Rajdhani', sans-serif;
    --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --accent: #FF7715;
    --accent-hover: #e8630a;
    --accent-soft: #fff1e6;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(16,16,16,0.06);
    --shadow-md: 0 6px 20px rgba(16,16,16,0.08);
    --shadow-lg: 0 16px 48px rgba(16,16,16,0.16);

    --bg: #f2f3f5;
    --surface: #ffffff;
    --surface-alt: #f8f9fb;
    --surface-hover: #eef0f2;
    --border: #e5e7eb;
    --text: #101010;
    --text-muted: #6b7280;
    --text-faint: #9aa0aa;
    --header-bg: #101010;
    --header-text: #f5f5f5;
    --header-text-muted: rgba(245,245,245,0.55);
    --online-color: #15803d;
    --online-bg: #dcfce7;
    --danger: #c0392b;
    --danger-soft: #fdeeee;

    --sidebar-bg: #14161c;
    --sidebar-bg-alt: #1b1e26;
    --sidebar-text: #e7e8ec;
    --sidebar-text-muted: rgba(231,232,236,0.55);
    --sidebar-border: rgba(255,255,255,0.08);
}

[data-theme="dark"] {
    --bg: #0b0b0d;
    --surface: #18191d;
    --surface-alt: #1f2025;
    --surface-hover: #26272d;
    --border: #2c2d33;
    --text: #f2f2f3;
    --text-muted: #a1a3ac;
    --text-faint: #6f7178;
    --header-bg: #000000;
    --header-text: #f5f5f5;
    --header-text-muted: rgba(245,245,245,0.5);
    --online-color: #4ade80;
    --online-bg: rgba(74,222,128,0.15);
    --danger: #ff6b5e;
    --danger-soft: rgba(255,107,94,0.12);

    --sidebar-bg: #000000;
    --sidebar-bg-alt: #131418;
    --sidebar-text: #f2f2f3;
    --sidebar-text-muted: rgba(242,242,243,0.5);
    --sidebar-border: rgba(255,255,255,0.08);
}

html, body { height: 100%; }
body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    transition: background 0.2s ease, color 0.2s ease;
}

/* ---------- Shell: dark sidebar + light main area ---------- */
.shell { display: flex; height: 100vh; overflow: hidden; }

.dark-sidebar {
    width: 216px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    gap: 22px;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
.brand-logo-chip {
    width: 32px; height: 32px; border-radius: 9px; background: #fff;
    display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0;
}
.brand-logo-chip img { width: 24px; height: 24px; object-fit: contain; }
.brand-text { font-family: var(--font-display); font-weight: 700; font-size: 15.5px; letter-spacing: 0.3px; line-height: 1.25; color: var(--sidebar-text); }
.brand-text .accent { color: var(--accent); }
.brand-text .sub { display: block; font-weight: 500; color: var(--sidebar-text-muted); font-size: 11px; letter-spacing: 0.2px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 3px; }
.sidebar-nav .nav-item {
    display: flex; align-items: center; gap: 11px; text-align: left; background: transparent; border: none;
    color: var(--sidebar-text-muted); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13.5px;
    cursor: pointer; transition: background 0.15s ease, color 0.15s ease; font-family: var(--font-body);
}
.sidebar-nav .nav-item .ni-ico { font-size: 15px; width: 18px; text-align: center; }
.sidebar-nav .nav-item:hover { background: var(--sidebar-bg-alt); color: var(--sidebar-text); }
.sidebar-nav .nav-item.active { background: var(--accent); color: #101010; font-weight: 700; }

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--sidebar-border); padding-top: 14px; }
.sidebar-footer .icon-btn {
    background: var(--sidebar-bg-alt); border: none; color: var(--sidebar-text); width: 30px; height: 30px; border-radius: 8px;
    cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; transition: background 0.15s ease;
    align-self: flex-start;
}
.sidebar-footer .icon-btn:hover { background: rgba(255,255,255,0.14); }
.sidebar-user .user-name { font-size: 11.5px; color: var(--sidebar-text-muted); margin-bottom: 8px; }
.sidebar-links { display: flex; flex-direction: column; gap: 6px; }
.sidebar-links a { color: var(--sidebar-text); text-decoration: none; font-size: 12.5px; opacity: 0.85; padding: 2px 0; }
.sidebar-links a:hover { opacity: 1; color: var(--accent); }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100vh; overflow: hidden; }
.topbar-slim {
    display: flex; align-items: center; gap: 14px; padding: 14px 24px; background: var(--surface);
    border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.topbar-title { font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--text); }
#conn-status {
    font-family: var(--font-body); font-size: 10px; font-weight: 700; padding: 3px 10px; border-radius: 12px;
    background: var(--surface-hover); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px;
}
#conn-status.live { background: var(--online-bg); color: var(--online-color); }

.app-body { flex: 1; display: flex; padding: 16px 24px 24px; min-height: 0; }

.layout {
    flex: 1; display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    overflow: hidden; min-width: 0; box-shadow: var(--shadow-md); position: relative;
    max-width: 1500px; margin: 0 auto;
}
#list-col { width: 300px; border-right: 1px solid var(--border); display: flex; flex-direction: column; transition: width 0.18s ease; }
#list-col.kanban-mode { width: auto; flex: 1 1 auto; }
#list { flex: 1; overflow-y: auto; }

.s-item { padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.12s ease; }
.s-item:hover { background: var(--surface-hover); }
.s-item.active { background: var(--accent-soft); border-left: 3px solid var(--accent); }
[data-theme="dark"] .s-item.active { background: rgba(255,119,21,0.12); }
.s-item .s-name { font-weight: 600; font-size: 14px; }
.s-item .s-sub { color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; margin-top: 2px; }
.s-item .s-preview { color: var(--text-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.s-item .s-badge { background: var(--accent); color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 11px; float: right; font-weight: 600; }
.s-item .s-assign { font-size: 11px; color: var(--accent); float: right; font-weight: 600; }
.s-returning { font-size: 9px; color: #2271b1; text-transform: uppercase; margin-left: 4px; font-weight: 700; }
[data-theme="dark"] .s-returning { color: #6cb4f0; }
.empty-list { padding: 32px 16px; color: var(--text-faint); font-size: 13px; text-align: center; }

.kanban-board { display: flex; gap: 10px; height: 100%; overflow-x: auto; padding: 12px; }
.kanban-col { flex: 1 1 220px; min-width: 178px; display: flex; flex-direction: column; background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.kanban-col-header { padding: 10px 11px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-muted); border-bottom: 1px solid var(--border); background: var(--surface); display: flex; justify-content: space-between; align-items: center; }
.kanban-count { background: var(--text); color: var(--surface); border-radius: 10px; padding: 1px 7px; font-size: 10.5px; font-weight: 700; }
[data-theme="dark"] .kanban-count { background: var(--accent); color: #101010; }
.kanban-col-body { flex: 1; overflow-y: auto; padding: 7px; }
.kanban-col-body .s-item { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 7px; background: var(--surface); }
.kanban-col-body .s-item.active { border-color: var(--accent); }

#middle { flex: 1; display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--border); }
#left-banner { display: none; background: var(--accent-soft); color: #a35b1f; padding: 9px 16px; font-size: 12.5px; border-bottom: 1px solid var(--border); font-weight: 600; }
[data-theme="dark"] #left-banner { color: #ffb37a; }
#messages { flex: 1; overflow-y: auto; padding: 18px; background: var(--surface-alt); }
.m { margin-bottom: 10px; max-width: 70%; padding: 9px 13px; border-radius: var(--radius-md); font-size: 13.5px; position: relative; line-height: 1.45; box-shadow: var(--shadow-sm); }
.m.agent { background: var(--text); color: var(--surface); margin-left: auto; border-bottom-right-radius: 3px; }
[data-theme="dark"] .m.agent { background: var(--accent); color: #101010; }
.m.visitor { background: var(--surface); color: var(--text); margin-right: auto; border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.m a { color: inherit; text-decoration: underline; }
.m code { background: rgba(255,255,255,0.15); padding: 1px 4px; border-radius: 3px; font-size: 12px; }
.m.visitor code { background: rgba(0,0,0,0.06); }
.read-check { display: block; font-size: 10px; color: #7fd6a0; margin-top: 3px; text-align: right; }

#composer-toolbar { display: flex; gap: 4px; padding: 8px 10px 0; }
.fmt-btn { background: var(--surface-hover); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); padding: 3px 9px; font-size: 12px; cursor: pointer; }
.fmt-btn:hover { background: var(--border); }
#composer-wrap { position: relative; }
.canned-dropdown { display: none; position: absolute; bottom: 100%; left: 10px; right: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); max-height: 180px; overflow-y: auto; margin-bottom: 6px; z-index: 10; }
.canned-item { padding: 9px 12px; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--border); }
.canned-item:last-child { border-bottom: none; }
.canned-item:hover { background: var(--accent-soft); }
.shortcut-tag { background: var(--surface-hover); padding: 1px 5px; border-radius: 4px; font-size: 10.5px; color: var(--text-muted); }

#inputrow { display: none; border-top: 1px solid var(--border); padding: 10px; gap: 8px; background: var(--surface); }
#inputrow textarea { flex: 1; height: 44px; resize: none; padding: 9px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-family: inherit; background: var(--surface-alt); color: var(--text); }
#inputrow textarea:focus { outline: none; border-color: var(--accent); }
#inputrow button { border: none; border-radius: var(--radius-sm); padding: 0 18px; font-weight: 700; cursor: pointer; font-family: var(--font-body); }
#send { background: var(--accent); color: #fff; }
#send:hover { background: var(--accent-hover); }

#detail { width: 288px; flex-shrink: 0; padding: 18px; overflow-y: auto; font-size: 13px; background: var(--surface); }
.d-row { margin-bottom: 14px; }
.d-label { color: var(--text-faint); font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 3px; font-weight: 600; }
.d-value { font-size: 13px; word-break: break-word; }
.d-value a { color: var(--accent); }
.d-name-row { display: flex; align-items: center; justify-content: space-between; }
.pencil-btn { background: none; border: none; cursor: pointer; font-size: 15px; padding: 0 4px; }
.placeholder { color: var(--text-faint); padding: 16px; }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 11.5px; font-weight: 600; }
.wa-link { text-decoration: none; margin-left: 4px; }

.visit-item { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.visit-item:last-child { border-bottom: none; }
.visit-item .v-date { color: var(--text); font-weight: 600; }
.visit-item .v-meta { color: var(--text-muted); }
.past-visits-toggle { cursor: pointer; color: var(--accent); font-size: 11.5px; background: none; border: none; padding: 0; margin-top: 4px; font-weight: 600; }
.past-visits-list { display: none; margin-top: 8px; }
.past-visits-list.open { display: block; }

.edit-form label { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-faint); margin: 12px 0 4px; font-weight: 600; }
.edit-form label:first-child { margin-top: 0; }
.edit-form input, .edit-form textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; font-family: inherit; background: var(--surface-alt); color: var(--text); }
.edit-form input:focus, .edit-form textarea:focus { outline: none; border-color: var(--accent); }
.edit-form textarea { height: 56px; resize: none; }
.edit-form .field-error { color: var(--danger); font-size: 11px; margin-top: 3px; display: none; }
.edit-form .form-actions { display: flex; gap: 8px; margin-top: 16px; }
.edit-form .form-actions button { flex: 1; padding: 9px; border: none; border-radius: var(--radius-sm); font-weight: 700; cursor: pointer; font-size: 12.5px; font-family: var(--font-body); }
.edit-form .save-btn { background: var(--accent); color: #fff; }
.edit-form .save-btn:hover { background: var(--accent-hover); }
.edit-form .cancel-btn { background: var(--surface-hover); color: var(--text); }

#toast-container { position: fixed; top: 20px; right: 20px; z-index: 999999; display: flex; flex-direction: column; gap: 10px; width: 320px; }
.toast { background: var(--surface); color: var(--text); border-radius: var(--radius-md); padding: 14px; box-shadow: var(--shadow-lg); border-left: 4px solid var(--accent); border: 1px solid var(--border); }
.toast .t-title { font-weight: 700; margin-bottom: 4px; }
.toast .t-sub { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.toast button { background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm); padding: 6px 12px; cursor: pointer; font-weight: 600; font-size: 12px; }

/* ---------- Live Visitor Map ---------- */
#map-view { display: none; flex-direction: column; flex: 1; min-width: 0; padding: 22px 26px; }
.map-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.map-header h2 { font-family: var(--font-display); font-size: 19px; margin: 0 0 4px; color: var(--text); }
.map-sub { font-size: 12.5px; color: var(--text-muted); margin: 0; max-width: 46ch; }
.map-count { font-family: var(--font-body); font-size: 11px; font-weight: 700; padding: 5px 12px; border-radius: 14px; background: var(--online-bg); color: var(--online-color); white-space: nowrap; }
.map-canvas-wrap { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; }
#map-svg { width: 100%; height: 100%; max-height: 100%; }
.map-ring { fill: none; stroke: var(--border); stroke-width: 1; stroke-dasharray: 4 6; }
.map-hub { fill: var(--surface-alt); stroke: var(--border); stroke-width: 1.5; }
.map-hub-text { font-family: var(--font-display); font-weight: 700; font-size: 22px; fill: var(--text); }
.map-dot-g { cursor: pointer; }
.map-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; animation: map-pulse 2.4s ease-in-out infinite; }
.map-dot.has-chat { fill: var(--online-color); }
.map-flag { font-size: 14px; }
@keyframes map-pulse {
    0%, 100% { r: 9; opacity: 1; }
    50% { r: 11; opacity: 0.85; }
}
.map-popover {
    position: absolute; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg); padding: 12px 14px; min-width: 180px; z-index: 20;
}
.map-popover .mp-name { font-weight: 700; font-size: 13.5px; margin-bottom: 2px; }
.map-popover .mp-loc { font-size: 11.5px; color: var(--text-muted); margin-bottom: 10px; }
.map-popover .mp-open { width: 100%; background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm); padding: 7px; font-weight: 700; font-size: 12px; cursor: pointer; }
.map-popover .mp-open:hover { background: var(--accent-hover); }
.map-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 14px; font-size: 11.5px; color: var(--text-muted); }
.map-legend span { display: flex; align-items: center; gap: 6px; }
.map-ring-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.map-ring-dot.r1 { opacity: 0.35; } .map-ring-dot.r2 { opacity: 0.55; } .map-ring-dot.r3 { opacity: 0.78; } .map-ring-dot.r4 { opacity: 1; }
.layout.map-mode #map-view { display: flex; }

/* ---------- Standalone pages (login, agents, canned-replies) ---------- */
.auth-wrap { min-height: calc(100vh - 60px); display: flex; align-items: center; justify-content: center; }
.auth-card { background: var(--surface); border-radius: var(--radius-lg); padding: 40px; width: 360px; max-width: calc(100vw - 32px); box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.auth-card h1 { font-family: var(--font-display); font-size: 21px; margin: 0 0 4px; letter-spacing: 0.3px; }
.auth-card p.sub { color: var(--text-muted); font-size: 13px; margin: 0 0 24px; }
.auth-card label { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 6px; margin-top: 16px; }
.auth-card input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; background: var(--surface-alt); color: var(--text); }
.auth-card input:focus { outline: none; border-color: var(--accent); }
.auth-card button { width: 100%; margin-top: 24px; padding: 12px; background: var(--text); color: var(--surface); border: none; border-radius: var(--radius-sm); font-weight: 700; font-size: 14px; cursor: pointer; letter-spacing: 0.5px; font-family: var(--font-body); }
[data-theme="dark"] .auth-card button { background: var(--accent); color: #101010; }
.auth-card button:hover { background: var(--accent); color: #fff; }
.auth-card .error, .msg.err { background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-top: 16px; }
.auth-logo { display: flex; justify-content: center; margin-bottom: 18px; }
.auth-logo img { width: 56px; height: 56px; object-fit: contain; }

.wrap { max-width: 820px; margin: 28px auto; padding: 0 24px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 26px; margin-bottom: 20px; box-shadow: var(--shadow-md); }
.card h2 { margin: 0 0 16px; font-size: 17px; font-family: var(--font-display); font-weight: 700; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 8px; border-bottom: 1px solid var(--border); vertical-align: top; color: var(--text); }
th { color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; font-weight: 700; }
.body-preview { color: var(--text-muted); max-width: 320px; }
button.link { background: none; border: none; color: var(--danger); cursor: pointer; padding: 0; font-size: 13px; }
.role-owner { color: var(--accent); font-weight: 700; font-size: 11px; text-transform: uppercase; }
.role-agent { color: var(--text-muted); font-size: 11px; text-transform: uppercase; }
.status-active { color: var(--online-color); }
.status-inactive { color: var(--text-faint); }
form.inline { display: inline; }
label { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 6px; margin-top: 14px; }
input, textarea { font-family: var(--font-body); }
.wrap input[type=text], .wrap input[type=email], .wrap textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; background: var(--surface-alt); color: var(--text); }
.wrap input:focus, .wrap textarea:focus { outline: none; border-color: var(--accent); }
.wrap textarea { height: 90px; resize: vertical; }
.wrap button[type=submit] { margin-top: 18px; padding: 10px 22px; background: var(--text); color: var(--surface); border: none; border-radius: var(--radius-sm); font-weight: 700; cursor: pointer; font-family: var(--font-body); }
[data-theme="dark"] .wrap button[type=submit] { background: var(--accent); color: #101010; }
.wrap button[type=submit]:hover { background: var(--accent); color: #fff; }
.msg { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; }
.msg.ok { background: var(--online-bg); color: var(--online-color); }
.hint { color: var(--text-faint); font-size: 12px; margin-top: 4px; }
.subtabs { display: flex; gap: 6px; padding: 10px; border-bottom: 1px solid var(--border); }
.subtab { background: var(--surface-alt); border: 1px solid var(--border); color: var(--text-muted); border-radius: 20px; padding: 5px 14px; font-size: 12.5px; cursor: pointer; font-family: var(--font-body); }
.subtab.active { background: var(--text); color: var(--surface); border-color: var(--text); font-weight: 600; }
[data-theme="dark"] .subtab.active { background: var(--accent); color: #101010; border-color: var(--accent); }

.tier-filter-bar { padding: 10px; border-bottom: 1px solid var(--border); }
.tier-filter-bar select { width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; font-family: inherit; background: var(--surface-alt); color: var(--text); }
.tier-filter-bar select:focus { outline: none; border-color: var(--accent); }

@media (max-width: 900px) {
    .dark-sidebar { width: 64px; padding: 14px 8px; }
    .brand-text, .sidebar-nav .ni-label, .sidebar-user { display: none; }
    .sidebar-nav .nav-item { justify-content: center; padding: 10px; }
}

/* ---------- Chat Transfer ---------- */
#transfer-row { display: flex; align-items: flex-start; justify-content: flex-end; margin-top: -6px; }
.transfer-pending-tag { font-size: 11.5px; color: var(--text-faint); font-style: italic; }
#transfer-box { width: 100%; }
.transfer-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px; }
.transfer-form select { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; font-family: inherit; background: var(--surface); color: var(--text); }
.transfer-note { width: 100%; height: 50px; resize: none; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; font-family: inherit; background: var(--surface); color: var(--text); }
.transfer-note:focus, .transfer-form select:focus { outline: none; border-color: var(--accent); }
.transfer-empty { font-size: 12px; color: var(--text-faint); margin-top: 8px; }

#transfer-modal-overlay {
    position: fixed; inset: 0; background: rgba(8,8,10,0.55); z-index: 999998;
    align-items: center; justify-content: center;
}
#transfer-modal {
    background: var(--surface); border-radius: var(--radius-lg); padding: 26px; width: 380px; max-width: calc(100vw - 32px);
    box-shadow: var(--shadow-lg); border: 1px solid var(--border);
}
.tm-title { font-family: var(--font-display); font-weight: 700; font-size: 16px; margin-bottom: 14px; color: var(--text); }
.tm-actions { display: flex; gap: 10px; margin-top: 16px; }
.tm-actions button { flex: 1; padding: 10px; border: none; border-radius: var(--radius-sm); font-weight: 700; cursor: pointer; font-size: 13px; font-family: var(--font-body); }
/* ---------- CRM deal fields ---------- */
.edit-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.edit-form-row label { margin-top: 12px; }
.edit-form select { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; font-family: inherit; background: var(--surface-alt); color: var(--text); }
.edit-form select:focus { outline: none; border-color: var(--accent); }
.deal-value { font-weight: 700; color: var(--text); margin-left: 4px; }
.stage-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; }
.stage-badge.stage-new { background: var(--surface-hover); color: var(--text-muted); }
.stage-badge.stage-quoted { background: var(--accent-soft); color: var(--accent-hover); }
[data-theme="dark"] .stage-badge.stage-quoted { background: rgba(255,119,21,0.18); color: var(--accent); }
.stage-badge.stage-negotiating { background: rgba(37,99,235,0.12); color: #2563eb; }
[data-theme="dark"] .stage-badge.stage-negotiating { background: rgba(96,165,250,0.16); color: #60a5fa; }
.stage-badge.stage-won { background: var(--online-bg); color: var(--online-color); }
.stage-badge.stage-lost { background: var(--danger-soft); color: var(--danger); }