/* LeadFlow CRM - application stylesheet (no external dependencies) */
:root {
    --sidebar-bg: #0f172a;
    --sidebar-fg: #cbd5e1;
    --sidebar-active: #1e293b;
    --accent: #4f46e5;
    --accent-dark: #4338ca;
    --accent-soft: #eef2ff;
    --bg: #f4f6fb;
    --card: #ffffff;
    --border: #e5e7eb;
    --text: #111827;
    --muted: #6b7280;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
/* The hidden attribute always wins over display rules of classes (.btn, .toast, …). */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
code { font-family: var(--mono); font-size: .9em; background: #f3f4f6; padding: 1px 4px; border-radius: 4px; }
.icon { width: 18px; height: 18px; flex-shrink: 0; vertical-align: -4px; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 248px; background: var(--sidebar-bg); color: var(--sidebar-fg); display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 40; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px; color: #fff; font-weight: 700; font-size: 16px; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 13px; letter-spacing: .5px; }
.nav { display: flex; flex-direction: column; padding: 8px 12px; gap: 2px; flex: 1; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px; color: var(--sidebar-fg); font-weight: 500; }
.nav-link:hover { background: var(--sidebar-active); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--accent); color: #fff; }
.nav-logout { padding: 12px; border-top: 1px solid #1e293b; }
.nav-button { width: 100%; background: none; border: 0; cursor: pointer; font: inherit; text-align: left; }
.main { flex: 1; margin-left: 248px; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px; padding: 14px 28px; background: rgba(255,255,255,.92); border-bottom: 1px solid var(--border); backdrop-filter: blur(6px); }
.page-title { font-size: 18px; font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-toggle { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; cursor: pointer; color: var(--text); }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.topbar-user-text { display: flex; flex-direction: column; line-height: 1.2; }
.topbar-user-text small { color: var(--muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.content { padding: 24px 28px 48px; max-width: 1500px; width: 100%; }
.sidebar-backdrop { display: none; }

/* ---------- Grid helpers ---------- */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-2-1 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.grid-dashboard { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); gap: 20px; align-items: start; margin-bottom: 20px; }
.grid-dashboard > .card { margin-bottom: 0; }
.work-layout { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
.assign-layout { display: grid; grid-template-columns: minmax(0, 560px) minmax(220px, 300px); gap: 20px; align-items: start; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.grid-2 > .card, .grid-2-1 > .card, .stack > .card, .work-layout > .card { margin-bottom: 0; }
.grid-2, .grid-2-1, .work-layout, .assign-layout { margin-bottom: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { font-size: 16px; font-weight: 650; }
.h3 { font-size: 14px; font-weight: 650; margin: 18px 0 8px; }
.assign-card { max-width: 760px; }

/* ---------- Stats ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stats-grid-compact { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.stat { display: flex; flex-direction: column; gap: 6px; padding: 16px; background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--muted); border-radius: var(--radius); color: var(--text); box-shadow: var(--shadow); }
a.stat:hover { text-decoration: none; border-color: #c7d2fe; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat-value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-primary { border-left-color: var(--accent); }
.stat-neutral { border-left-color: #94a3b8; }
.stat-blue { border-left-color: #2563eb; }
.stat-amber { border-left-color: #d97706; }
.stat-purple { border-left-color: #9333ea; }
.stat-teal { border-left-color: #0d9488; }
.stat-green { border-left-color: #16a34a; }
.stat-indigo { border-left-color: #4338ca; }
.stat-dark-green { border-left-color: #166534; }
.stat-red { border-left-color: #dc2626; }

/* Lead bank summary */
.bank-summary { display: flex; align-items: stretch; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.bank-figure { flex: 1 1 160px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.bank-figure span { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.bank-figure strong { font-size: 30px; font-variant-numeric: tabular-nums; }
.bank-summary-large .bank-figure strong { font-size: 38px; }
.bank-available { background: #ecfdf5; border-color: #a7f3d0; }
.bank-available strong { color: #047857; }
.bank-actions { display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.bank-summary-vertical { flex-direction: column; }
.bank-inline { margin: 14px 0; padding: 12px 16px; background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: 8px; color: #065f46; }

/* ---------- Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: #f9fafb; white-space: nowrap; }
.table tbody tr:hover { background: #fafbff; }
.table tfoot th { background: #f9fafb; }
.table-compact th, .table-compact td { padding: 7px 10px; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.details-cell { max-width: 340px; word-break: break-word; }
.reason { color: #b91c1c; min-width: 220px; }
.empty { color: var(--muted); text-align: center; padding: 20px !important; }
p.empty { text-align: left; padding: 0 !important; }
.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: #f1f5f9; color: #334155; border: 1px solid transparent; }
.badge-neutral { background: #f1f5f9; color: #475569; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-indigo { background: #e0e7ff; color: #3730a3; }
.badge-unassigned { background: #f1f5f9; color: #475569; }
.badge-assigned { background: #dbeafe; color: #1e40af; }
.badge-working { background: #fef3c7; color: #92400e; }
.badge-report-requested { background: #f3e8ff; color: #6b21a8; }
.badge-report-ready { background: #ccfbf1; color: #115e59; }
.badge-completed { background: #dcfce7; color: #166534; }
.badge-submitted-to-admin { background: #e0e7ff; color: #3730a3; }
.badge-admin-received { background: #166534; color: #fff; }
.badge-report-none { background: #f8fafc; color: #94a3b8; border-color: #e2e8f0; }
.badge-report-pending { background: #f3e8ff; color: #6b21a8; }
.badge-report-processing { background: #ffedd5; color: #9a3412; }
.badge-report-ready, .badge-report-completed { background: #ccfbf1; color: #115e59; }
.badge-report-cancelled { background: #fee2e2; color: #991b1b; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: #f3e8ff; color: #6b21a8; font-weight: 600; font-size: 13px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; line-height: 1.3; white-space: nowrap; }
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn:disabled, .btn[aria-busy="true"] { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f3f4f6; color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }
.btn-block { width: 100%; }
.link { font-weight: 600; font-size: 13px; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-weight: 600; font-size: 13px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=search], input[type=date], input[type=file], select, textarea {
    width: 100%; padding: 9px 11px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; font: inherit; color: var(--text);
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, .nav-link:focus-visible { outline: 2px solid #a5b4fc; outline-offset: 1px; border-color: var(--accent); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.check { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; cursor: pointer; }
.check input { margin-top: 3px; width: 16px; height: 16px; }
.check span { display: flex; flex-direction: column; }
.check small { color: var(--muted); }
.checkbox-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 4px 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.filters select, .filters input[type=text], .filters input[type=date] { width: auto; min-width: 150px; }
.search { position: relative; flex: 1 1 260px; display: flex; align-items: center; }
.search .icon { position: absolute; left: 10px; color: var(--muted); }
.search input { padding-left: 34px; }
.inline-label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.checklist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.assign-option { border: 1px solid var(--border); border-radius: 10px; padding: 6px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.assign-option:has(input[type=radio]:checked) { border-color: var(--accent); background: var(--accent-soft); }
.online-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; margin-right: 6px; vertical-align: 1px; }
.online-dot.on { background: #16a34a; }
.locked-file { position: relative; border: 1px solid var(--border); border-radius: 8px; padding: 18px; background: #f9fafb; overflow: hidden; min-height: 220px; }
.locked-file-lines { filter: blur(5px); user-select: none; pointer-events: none; display: flex; flex-direction: column; gap: 12px; }
.locked-file-lines span { display: block; height: 12px; border-radius: 6px; background: #cbd5e1; }
.locked-file-lines span:nth-child(3n) { width: 55%; } .locked-file-lines span:nth-child(3n+1) { width: 90%; } .locked-file-lines span:nth-child(3n+2) { width: 75%; }
.locked-file-message { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; }
.locked-file-card { display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: 360px; padding: 16px 20px; text-align: center; color: var(--text); background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 4px 16px rgba(15, 23, 42, .08); }
.locked-file-card .icon { width: 26px; height: 26px; color: var(--accent); }

/* ---------- Alerts ---------- */
.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid transparent; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.alert.inline { display: inline-block; margin: 0; }
.big-message { font-size: 16px; }

/* ---------- Tabs & pager ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tab { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.pager-info { color: var(--muted); font-size: 13px; }
.pager-links { display: flex; gap: 4px; flex-wrap: wrap; }
.pager-links a, .pager-links span { min-width: 32px; padding: 5px 9px; border: 1px solid var(--border); border-radius: 6px; text-align: center; font-size: 13px; background: #fff; }
.pager-links a:hover { background: var(--accent-soft); text-decoration: none; }
.pager-links .current { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.pager-size label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.pager-size select { width: auto; padding: 5px 8px; }

/* ---------- Details ---------- */
.details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; margin: 0; }
.details > div { display: flex; flex-direction: column; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.details-single { grid-template-columns: 1fr; }
.details-single > div { flex-direction: row; justify-content: space-between; gap: 12px; align-items: center; }
.details dt { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.details dd { margin: 0; word-break: break-word; }
.details-single dd { text-align: right; }
.lead-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.lead-name { font-size: 22px; font-weight: 700; margin-top: 2px; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.confirm-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding-top: 6px; }

/* ---------- Files, sales file, editor ---------- */
.file-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.file-list li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; flex-wrap: wrap; }
.file-list li > div:nth-child(2) { flex: 1; min-width: 160px; word-break: break-word; }
.file-actions { display: flex; gap: 6px; }
.report-ready { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: #0f766e; background: #ccfbf1; padding: 6px 12px; border-radius: 8px; margin-bottom: 12px; }
.sales-file { border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin-bottom: 12px; }
.sales-file-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.sales-file-content { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 13px; background: #f9fafb; border: 1px solid var(--border); border-radius: 8px; padding: 14px; max-height: 640px; overflow: auto; }
.editor { min-height: 520px; resize: vertical; font-family: var(--mono); font-size: 13.5px; line-height: 1.6; padding: 14px; }
.editor-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.editor-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Pitch ---------- */
.nav-badge { margin-left: auto; background: #f59e0b; color: #111827; font-size: 10.5px; font-weight: 700; line-height: 1; padding: 4px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; }
.pitch-tabs { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 8px; }
.tab-new { display: inline-block; margin-left: 4px; background: #f59e0b; color: #111827; font-size: 10px; font-weight: 700; line-height: 1; padding: 3px 6px; border-radius: 999px; text-transform: uppercase; vertical-align: 1px; }
.pitch-head h2 { font-size: 18px; }
.pitch-frame { display: block; width: 100%; height: 78vh; min-height: 480px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.pitch-image { display: block; max-width: 100%; height: auto; margin: 0 auto; border: 1px solid var(--border); border-radius: 8px; }
.pitch-empty { text-align: center; padding: 40px 20px; }
.pitch-empty > .icon { width: 40px; height: 40px; color: var(--accent); }
.pitch-empty h2 { margin: 10px 0 6px; font-size: 18px; }
.pitch-empty .btn { margin-top: 12px; }
.pitch-download { display: flex; gap: 14px; align-items: flex-start; padding: 18px; border: 1px dashed var(--border); border-radius: 8px; background: #f9fafb; }
.pitch-download > .icon { width: 32px; height: 32px; color: var(--accent); flex-shrink: 0; }
.pitch-download p { margin: 6px 0 12px; }
.pitch-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.pitch-list li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; flex-wrap: wrap; }
.pitch-info { flex: 1; min-width: 200px; word-break: break-word; }
.pitch-order { display: flex; flex-direction: column; gap: 2px; }
.pitch-order .btn { padding: 2px 6px; }
.pitch-order .btn:disabled { opacity: .3; cursor: default; }
/* Word document shown on the Pitch page (HTML produced by DocumentPreview) */
.doc { max-width: 900px; font-size: 15px; line-height: 1.65; color: var(--text); word-break: break-word; }
.doc p, .doc li, .doc td { white-space: pre-wrap; }
.doc p { margin: 0 0 .7em; }
.doc h2, .doc h3, .doc h4, .doc h5 { font-weight: 700; line-height: 1.3; margin: 1.1em 0 .5em; }
.doc h2 { font-size: 24px; } .doc h3 { font-size: 20px; } .doc h4 { font-size: 17px; } .doc h5 { font-size: 15px; }
.doc > :first-child { margin-top: 0; }
.doc .doc-gap { height: .5em; margin: 0; }
.doc .doc-center { text-align: center; } .doc .doc-right { text-align: right; }
.doc-list { margin: 0 0 .7em 1.4em; padding: 0; }
.doc-list li { margin: .15em 0; }
.doc-lvl-1 { margin-left: 1.5em !important; } .doc-lvl-2 { margin-left: 3em !important; } .doc-lvl-3 { margin-left: 4.5em !important; }
.doc-lvl-4, .doc-lvl-5, .doc-lvl-6, .doc-lvl-7, .doc-lvl-8 { margin-left: 6em !important; }
.doc-table { border-collapse: collapse; margin: 0 0 1em; min-width: 50%; }
.doc-table td { border: 1px solid #cbd5e1; padding: 6px 10px; vertical-align: top; }
.doc-table td p { margin: 0; }
.doc mark { background: #fef08a; }
.doc-text { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 13.5px; line-height: 1.6; background: #f9fafb; border: 1px solid var(--border); border-radius: 8px; padding: 16px; }

/* ---------- Create / edit lead form ---------- */
.form-card { max-width: 900px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; margin-bottom: 8px; }
.form-grid .field { margin: 0; }
.field-wide { grid-column: 1 / -1; }
.inline-form { display: inline; }

/* ---------- Instant search ---------- */
[data-live-results] { transition: opacity .15s; }
[data-live-results][aria-busy="true"] { opacity: .55; }

/* ---------- Notifications (lead pick-up, new report requests, chat) ---------- */
.toast-stack { position: fixed; top: 74px; right: 16px; z-index: 60; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; position: relative; display: flex; align-items: center; gap: 12px; padding: 14px 34px 14px 14px; background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 10px; box-shadow: 0 10px 30px rgba(15, 23, 42, .18); }
.toast > .icon { width: 26px; height: 26px; flex-shrink: 0; color: #d97706; }
.toast-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.toast-text .small { color: var(--muted); }
.toast form { margin: 0; }
.toast-pickup { border-left-color: #f59e0b; padding-right: 14px; }
.toast-pulse { animation: toast-pulse .9s ease-in-out 2; }
@keyframes toast-pulse { 50% { transform: scale(1.03); box-shadow: 0 12px 34px rgba(245, 158, 11, .45); } }
.toast-close { position: absolute; top: 6px; right: 8px; border: 0; background: transparent; font-size: 18px; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 4px; }

/* ---------- Report chat ---------- */
.chat-dock { position: fixed; right: 16px; bottom: 16px; z-index: 55; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.chat-dock-btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border: 0; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 600; font-size: 14px; cursor: pointer; box-shadow: 0 8px 24px rgba(79, 70, 229, .35); }
.chat-dock-btn:hover { background: var(--accent-dark); }
.count-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: #ef4444; color: #fff; font-size: 11.5px; font-weight: 700; }
.chat-panel { order: -1; display: flex; flex-direction: column; width: min(400px, calc(100vw - 32px)); height: min(560px, calc(100vh - 110px)); background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 20px 50px rgba(15, 23, 42, .25); overflow: hidden; }
.chat-panel[hidden] { display: none; }
.chat-panel-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); background: #f9fafb; }
.chat-panel-head strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.chat-list[hidden] { display: none; }
.chat-thread { text-align: left; width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; cursor: pointer; color: var(--text); font: inherit; }
.chat-thread:hover { border-color: var(--accent); background: var(--accent-soft); }
.chat-thread-top { display: flex; justify-content: space-between; gap: 8px; }
.chat-thread-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-thread-unread { border-left: 4px solid #ef4444; }
.chat-thread-unread strong::after { content: " •"; color: #ef4444; }
.chat-thread-closed { opacity: .7; }
.chat-thread-last { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-panel-body { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 10px; gap: 8px; }
.chat-panel-body[hidden] { display: none; }
.chat-inline { display: flex; flex-direction: column; gap: 8px; }
.chat-inline .chat-messages { max-height: 380px; min-height: 140px; }
.chat-messages { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 10px; background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; }
.chat-msg { max-width: 85%; align-self: flex-start; padding: 8px 12px; border-radius: 12px; background: #fff; border: 1px solid var(--border); }
.chat-msg-mine { align-self: flex-end; background: var(--accent-soft); border-color: #c7d2fe; }
.chat-msg-system { align-self: center; max-width: 95%; background: transparent; border: 0; padding: 2px 6px; text-align: center; color: var(--muted); font-size: 12.5px; }
.chat-msg-head { font-size: 12.5px; margin-bottom: 2px; }
.chat-msg-body { white-space: pre-wrap; word-break: break-word; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; }
.chat-form[hidden] { display: none; }
.chat-form textarea { flex: 1; resize: vertical; min-height: 44px; max-height: 160px; }
.chat-error { color: var(--danger); }
.chat-finish { align-self: flex-start; }
.chat-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.chat-actions[hidden] { display: none; }
.sound-toggle { display: inline-flex; align-items: center; gap: 6px; }
.sound-toggle .sound-off, .sound-toggle[aria-pressed="false"] .sound-on { display: none; }
.sound-toggle[aria-pressed="false"] .sound-off { display: inline-flex; color: var(--muted); }
.sound-toggle .sound-on { display: inline-flex; color: var(--accent); }
.idle-warning { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; align-items: center; gap: 14px; width: min(460px, calc(100vw - 32px)); padding: 14px 16px; background: #fff; border: 1px solid #fcd34d; border-left: 4px solid #f59e0b; border-radius: 10px; box-shadow: 0 14px 40px rgba(15, 23, 42, .25); }
.idle-warning-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.save-state.save-ok { color: var(--success); }
.save-state.save-error { color: var(--danger); font-weight: 600; }
.sound-toggle.sound-blocked { border-color: #f59e0b; background: #fffbeb; animation: toast-pulse .9s ease-in-out 3; }
.chat-transcript { border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 10px; background: #f8fafc; display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow-y: auto; }
.chat-transcript .chat-msg { max-width: 100%; }

/* ---------- Activity ---------- */
.activity { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.activity li { display: flex; gap: 10px; align-items: flex-start; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; margin-top: 7px; flex-shrink: 0; }
.activity-lead_assignment, .activity-lead_import { background: var(--accent); }
.activity-lead_submitted, .activity-admin_received, .activity-report_uploaded { background: var(--success); }
.activity-login_failed, .activity-access_denied, .activity-login_locked { background: var(--danger); }

/* ---------- Result banner ---------- */
.result-banner { text-align: center; padding: 20px; background: #ecfdf5; border-radius: 10px; margin-bottom: 18px; }
.result-number { font-size: 44px; font-weight: 800; color: #047857; line-height: 1; }
.result-text { font-size: 16px; margin-top: 6px; }

/* ---------- Modal ---------- */
.modal { border: 0; border-radius: 12px; padding: 24px; width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal::backdrop { background: rgba(15, 23, 42, .55); }
.modal h2 { font-size: 18px; margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ---------- Guest / errors ---------- */
.guest { background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%); }
.guest-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.guest-card { width: 100%; max-width: 420px; background: #fff; border-radius: 14px; padding: 32px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.guest-card:has(.debug) { max-width: 960px; }
.brand-guest { color: var(--text); padding: 0 0 20px; }
.guest-title { font-size: 22px; margin-bottom: 4px; }
.guest-card .form { margin-top: 18px; }
.error-page { text-align: center; padding: 30px 10px; }
.error-code { font-size: 64px; font-weight: 800; color: var(--accent); line-height: 1; }
.error-page h2 { margin: 10px 0 6px; }
.error-page .btn { margin-top: 14px; }
.debug { text-align: left; background: #111827; color: #f9fafb; padding: 14px; border-radius: 8px; overflow: auto; font-size: 12px; max-height: 420px; }
.steps { padding-left: 18px; display: flex; flex-direction: column; gap: 8px; }

/* ---------- Responsive ---------- */
/* Single-column overrides use minmax(0, 1fr) so wide tables scroll inside
   their card instead of stretching the page horizontally. */
@media (max-width: 1400px) {
    .grid-dashboard { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1200px) {
    .grid-2-1 { grid-template-columns: minmax(0, 1fr); }
    .work-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 35; }
    .main { margin-left: 0; }
    .menu-toggle { display: inline-flex; }
    .grid-2 { grid-template-columns: minmax(0, 1fr); }
    .assign-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
    .content { padding: 16px 14px 80px; }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .toast-stack { top: auto; bottom: 76px; right: 16px; }
    .chat-dock { right: 12px; bottom: 12px; }
    .chat-panel { width: calc(100vw - 24px); height: calc(100vh - 90px); }
    .topbar { padding: 10px 14px; }
    .topbar-user-text { display: none; }
    .sound-label { display: none; }
    .details { grid-template-columns: minmax(0, 1fr); }
    .field-row { grid-template-columns: minmax(0, 1fr); }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .stat-value { font-size: 22px; }
    .bank-figure strong, .bank-summary-large .bank-figure strong { font-size: 26px; }
    .filters select, .filters input[type=text], .filters input[type=date] { flex: 1 1 140px; min-width: 0; }
    .editor { min-height: 360px; }
    .guest-card { padding: 22px; }
}
@media print {
    .sidebar, .topbar, .filters, .pager, .btn, form { display: none !important; }
    .main { margin-left: 0; }
}
