:root {
    --bg: #f4f7fb;
    --surface: #fff;
    --text: #172033;
    --muted: #68758b;
    --primary: #3457d5;
    --primary-dark: #263d91;
    --border: #dfe6f0;
    --danger: #a62b2b;
    --danger-bg: #fff1f1;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 7px; }
.muted { color: var(--muted); line-height: 1.55; }
.brand { font-size: 20px; font-weight: 850; letter-spacing: -.4px; }

.auth-page {
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: min(440px, 100%);
    padding: 38px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: 0 22px 60px rgba(28, 48, 89, .1);
}

.auth-card .brand { margin-bottom: 36px; color: var(--primary); }

.form {
    display: grid;
    gap: 18px;
    margin-top: 28px;
}

label {
    display: grid;
    gap: 7px;
    color: #344057;
    font-size: 14px;
    font-weight: 700;
}

input {
    height: 48px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font: inherit;
}
textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    resize: vertical;
    color: var(--text);
    font: inherit;
}
textarea:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(52, 87, 213, .12);
}
select {
    height: 48px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    font: inherit;
}
.field-hint {
    margin: -8px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

input:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(52, 87, 213, .12);
}

button {
    height: 48px;
    border: 0;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

button:hover { background: var(--primary-dark); }

.alert {
    padding: 13px 15px;
    margin: 18px 0;
    border-radius: 10px;
    background: var(--danger-bg);
    color: var(--danger);
}
.alert-success { background: #edf9f1; color: #176b3a; }
.instance-list {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px 16px;
    margin: 18px 0;
    border: 1px solid #f0dca4;
    border-radius: 10px;
    background: #fff9e8;
    color: #6e5208;
}
.instance-option {
    width: auto;
    height: auto;
    padding: 7px 11px;
    border: 1px solid #e4ca7c;
    border-radius: 999px;
    background: #fff;
    color: #6e5208;
    font-size: 13px;
}
.instance-option:hover { background: #fff4cf; }

.app-shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
    display: flex;
    flex-direction: column;
    width: 250px;
    min-width: 0;
    max-width: 250px;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow: hidden;
    padding: 30px 22px;
    background: #18213a;
    color: #fff;
}
.sidebar-brand {
    display: grid;
    gap: 4px;
    padding: 0 12px 22px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-brand strong { font-size: 18px; }
.sidebar-brand small { color: #8190aa; }
.sidebar-menu {
    display: grid;
    gap: 5px;
    min-width: 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 14px 0;
    scrollbar-width: thin;
    scrollbar-color: #46536d transparent;
}
.sidebar-menu::-webkit-scrollbar { width: 6px; height: 0; }
.sidebar-menu::-webkit-scrollbar-track { background: transparent; }
.sidebar-menu::-webkit-scrollbar-thumb { border-radius: 999px; background: #46536d; }
.sidebar-menu .sidebar-link,
.sidebar-menu .sidebar-child,
.sidebar-group summary {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 40px;
    padding: 0 12px;
    border-radius: 9px;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    overflow: hidden;
}
.sidebar-menu .sidebar-link > span:last-child,
.sidebar-menu .sidebar-child > span:last-child,
.sidebar-group summary > span:nth-child(2) {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-menu .sidebar-link::before,
.sidebar-menu .sidebar-child::before { display: none; }
.sidebar-menu .sidebar-link:hover,
.sidebar-menu .sidebar-child:hover,
.sidebar-group summary:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-menu .sidebar-link.active,
.sidebar-menu .sidebar-child.active {
    background: #3457d5;
    color: #fff;
    box-shadow: 0 6px 16px rgba(52, 87, 213, .28);
}
.menu-icon {
    display: inline-grid;
    width: 18px;
    flex: 0 0 18px;
    place-items: center;
}
.menu-divider { height: 1px; margin: 9px 0; background: rgba(255,255,255,.1); }
.sidebar-group summary { list-style: none; }
.sidebar-group summary::-webkit-details-marker { display: none; }
.sidebar-group[open] summary { background: rgba(255,255,255,.05); color: #fff; }
.sidebar-group .chevron { margin-left: auto; transition: transform .2s; }
.sidebar-group[open] .chevron { transform: rotate(180deg); }
.sidebar-children {
    display: grid;
    gap: 3px;
    padding: 6px 0 8px 20px;
    margin-left: 12px;
    border-left: 1px solid rgba(255,255,255,.1);
    overflow: hidden;
}
.sidebar-menu .sidebar-child { min-height: 36px; font-size: 12px; }
.sidebar-menu .sidebar-child.active {
    background: rgba(52,87,213,.22);
    color: #dce5ff;
    box-shadow: none;
}
.sidebar-menu .sidebar-link:not(.active) .menu-icon,
.sidebar-group summary .menu-icon,
.sidebar-menu .sidebar-child:not(.active) .menu-icon {
    color: #fff;
}
.sidebar-menu .sidebar-link > span,
.sidebar-menu .sidebar-child > span,
.sidebar-group summary > span {
    color: #fff;
}
.sidebar nav.sidebar-menu a.sidebar-link,
.sidebar nav.sidebar-menu a.sidebar-child,
.sidebar nav.sidebar-menu details.sidebar-group > summary,
.sidebar nav.sidebar-menu a.sidebar-link span,
.sidebar nav.sidebar-menu a.sidebar-child span,
.sidebar nav.sidebar-menu details.sidebar-group > summary span {
    color: #fff !important;
    opacity: 1 !important;
}
.sidebar-menu .sidebar-link:not(.active):hover,
.sidebar-menu .sidebar-child:not(.active):hover {
    color: #fff;
}
.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 12px 0;
    margin-top: auto;
    border-top: 1px solid rgba(255,255,255,.1);
    color: #8190aa;
    font-size: 11px;
    flex: 0 0 auto;
}
.sidebar-footer a { color: #d2d9e5; text-decoration: none; font-size: 18px; }
.module-placeholder { min-height: 220px; display: grid; align-content: center; text-align: center; }
.sidebar .sidebar-menu a.sidebar-link::before,
.sidebar .sidebar-menu a.sidebar-child::before {
    display: none;
    content: none;
}
.pipeline-page { min-width: 0; }
.pipeline-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}
.pipeline-heading h1 { margin-bottom: 4px; }
.pipeline-heading p { margin: 0; color: var(--muted); }
.pipeline-heading-actions { display: flex; gap: 12px; }
.pipeline-heading-actions select { min-width: 220px; }
.pipeline-heading-actions button {
    width: auto;
    padding: 0 20px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
}
.pipeline-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}
.pipeline-metrics article {
    display: grid;
    gap: 8px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
}
.pipeline-metrics span { color: var(--muted); }
.pipeline-metrics strong { color: var(--primary); font-size: 25px; }
.pipeline-filters {
    display: grid;
    grid-template-columns: minmax(250px, 1fr) 190px 210px auto auto;
    gap: 12px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
}
.pipeline-filters button { padding: 0 18px; }
.pipeline-filters a {
    display: inline-flex;
    align-items: center;
    color: var(--primary);
    font-weight: 750;
    text-decoration: none;
}
.pipeline-board {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
    padding-bottom: 14px;
}
.pipeline-column {
    display: grid;
    grid-template-rows: auto 1fr;
    overflow: hidden;
    min-width: 0;
    height: max(420px, calc(100vh - 310px));
    max-height: 680px;
    min-height: 420px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #eef2f8;
}
.pipeline-column * { min-width: 0; }
.pipeline-column > header {
    display: grid;
    gap: 10px;
    padding: 18px;
    color: #fff;
}
.pipeline-column > header > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.pipeline-column > header span {
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(255,255,255,.22);
}
.pipeline-new > header { background: #3d7ee8; }
.pipeline-working > header { background: #e49200; }
.pipeline-won > header { background: #22b65c; }
.pipeline-lost > header { background: #ef4249; }
.pipeline-cards {
    display: grid;
    grid-auto-rows: max-content;
    align-content: start;
    gap: 10px;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 12px;
    scrollbar-width: thin;
    scrollbar-color: #b8c2d3 transparent;
}
.pipeline-cards::-webkit-scrollbar { width: 6px; }
.pipeline-cards::-webkit-scrollbar-track { background: transparent; }
.pipeline-cards::-webkit-scrollbar-thumb { border-radius: 999px; background: #b8c2d3; }
.pipeline-empty { padding: 40px 12px; color: var(--muted); text-align: center; }
.deal-card {
    min-width: 0;
    max-width: 100%;
    height: auto;
    min-height: max-content;
    overflow: hidden;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: #fff;
    box-shadow: 0 5px 16px rgba(28,48,89,.05);
    cursor: grab;
    transition: opacity .15s, transform .15s, box-shadow .15s;
}
.deal-card:active { cursor: grabbing; }
.deal-card.dragging {
    opacity: .45;
    transform: rotate(1deg) scale(.98);
}
.pipeline-cards.drag-over {
    outline: 2px dashed var(--primary);
    outline-offset: -7px;
    background: #e8eefc;
}
.deal-card-heading { display: flex; align-items: center; gap: 10px; }
.deal-card-heading > div:last-child { display: grid; gap: 3px; min-width: 0; }
.deal-card-heading strong,
.deal-card-heading span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.deal-card-heading > div:last-child { max-width: calc(100% - 52px); }
.deal-card-heading span, .deal-card small { color: var(--muted); font-size: 11px; }
.deal-value { margin: 13px 0 7px; color: var(--primary); font-size: 18px; font-weight: 850; }
.deal-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    width: 100%;
    margin-top: 12px;
}
.deal-actions form { width: 100%; }
.deal-actions button,
.deal-actions select {
    width: 100%;
    max-width: 100%;
    height: 36px;
}
.deal-actions button { padding: 0 11px; }
.deal-actions select { padding-inline: 9px 28px; font-size: 12px; }
.deal-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pipeline-modal[hidden] { display: none; }

@media (max-width: 1050px) {
    .pipeline-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pipeline-filters { grid-template-columns: 1fr 1fr; }
    .pipeline-board { gap: 8px; }
    .pipeline-column > header { padding: 14px 10px; }
    .pipeline-column > header strong { font-size: 11px; }
    .pipeline-column > header b { font-size: 13px; }
    .pipeline-cards { padding: 7px; }
    .deal-card { padding: 10px; }
    .deal-card .contact-avatar {
        width: 34px;
        height: 34px;
        flex: 0 0 34px;
    }
    .deal-card-heading strong { font-size: 12px; }
    .deal-value { font-size: 15px; }
}

@media (max-width: 680px) {
    .pipeline-heading { display: grid; }
    .pipeline-heading-actions { display: grid; }
    .pipeline-heading-actions select { min-width: 0; }
    .pipeline-metrics, .pipeline-filters { grid-template-columns: 1fr; }
    .pipeline-board {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .pipeline-column { max-height: 560px; }
}
.leads-page { min-width: 0; }
.leads-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}
.leads-heading h1 { margin-bottom: 5px; }
.leads-heading p { margin: 0; color: var(--muted); }
.leads-heading-actions { display: flex; gap: 9px; }
.leads-heading-actions a,
.leads-heading-actions button {
    display: inline-flex;
    width: auto;
    min-height: 44px;
    align-items: center;
    padding: 0 17px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    font-weight: 750;
    text-decoration: none;
}
.leads-heading-actions button:last-child { border-color: var(--primary); background: var(--primary); color: #fff; }
.lead-metrics {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 15px;
    margin-bottom: 22px;
}
.lead-metrics article {
    position: relative;
    display: grid;
    gap: 6px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
}
.lead-metrics span { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.lead-metrics strong { font-size: 27px; }
.lead-metrics small { color: var(--muted); }
.lead-metrics .hot { background: #fff5f5; }
.lead-metrics .warm { background: #fff9ed; }
.lead-metrics .cold { background: #edf6ff; }
.lead-metric-icon {
    position: absolute;
    top: 16px;
    right: 16px;
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border-radius: 11px;
    background: #edf2ff;
    color: var(--primary);
    font-size: 20px;
    font-style: normal;
    font-weight: 850;
}
.lead-metrics .total .lead-metric-icon { background: #eaf7df; color: #61b900; }
.lead-metrics .hot .lead-metric-icon { background: #ffe1e5; color: #d32638; }
.lead-metrics .warm .lead-metric-icon { background: #fff0ce; color: #cf8200; }
.lead-metrics .cold .lead-metric-icon { background: #dcecff; color: #1472cc; }
.lead-metrics .unassigned .lead-metric-icon { background: #edf1f7; color: #65758c; font-size: 15px; }
.lead-metrics small.positive { color: #139e70; }
.lead-tabs {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    padding: 5px;
    margin-bottom: 18px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
}
.lead-tabs a {
    padding: 10px 16px;
    border-radius: 8px;
    color: var(--muted);
    font-weight: 750;
    text-decoration: none;
    white-space: nowrap;
}
.lead-tabs a.active { background: #edf2ff; color: var(--primary); }
.lead-search {
    display: grid;
    grid-template-columns: 1fr 220px auto;
    gap: 12px;
    margin-bottom: 18px;
}
.lead-search button { padding: 0 20px; }
.lead-list-panel {
    overflow: hidden;
    min-height: 260px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
}
.lead-table-wrap { overflow-x: auto; padding: 10px 18px; }
.lead-empty { display: grid; place-items: center; align-content: center; min-height: 260px; text-align: center; }
.lead-empty div { display: grid; width: 52px; height: 52px; place-items: center; border-radius: 50%; background: #edf2ff; color: var(--primary); font-size: 25px; }
.lead-empty strong { margin-top: 14px; }
.lead-empty p { color: var(--muted); }
.temperature-badge { display: inline-flex; padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.temperature-hot { background: #ffe7e7; color: #b42323; }
.temperature-warm { background: #fff2cf; color: #8d6300; }
.temperature-cold { background: #e4f1ff; color: #2268ae; }
.lead-modal[hidden] { display: none; }

@media (max-width: 1050px) {
    .lead-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
    .leads-heading { display: grid; }
    .leads-heading-actions { flex-wrap: wrap; }
    .lead-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .lead-search { grid-template-columns: 1fr; }
}

@media (max-width: 440px) {
    .pipeline-board { grid-template-columns: 1fr; }
}
.sidebar .brand { padding: 0 12px; margin-bottom: 36px; }
.sidebar nav { display: grid; gap: 6px; }
.sidebar nav a, .sidebar nav span, .logout {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 12px;
    border-radius: 9px;
    color: #bfc8dc;
    text-decoration: none;
}
.sidebar nav a::before,
.logout::before {
    display: inline-grid;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    place-items: center;
    font-size: 15px;
    line-height: 1;
}
.sidebar nav a[href="dashboard.php"]::before { content: "⌂"; }
.sidebar nav a[href="conversations.php"]::before { content: "✉"; }
.sidebar nav a[href="contacts.php"]::before { content: "♙"; }
.sidebar nav a[href="appointments.php"]::before { content: "▣"; }
.sidebar nav a[href="knowledge.php"]::before { content: "▤"; }
.sidebar nav a[href="ai.php"]::before { content: "✦"; }
.sidebar nav a[href="integrations.php"]::before { content: "⌁"; }
.sidebar nav a[href="users.php"]::before { content: "♙"; }
.sidebar nav a[href="settings.php"]::before { content: "⚙"; }
.sidebar nav a[href="reports.php"]::before { content: "▥"; }
.sidebar nav a[href="system.php"]::before { content: "✓"; }
.logout::before { content: "↪"; }
.sidebar nav .active { background: rgba(255,255,255,.1); color: #fff; font-weight: 750; }
.sidebar nav span { opacity: .65; }
.logout { margin-top: auto; }
.content { padding: clamp(24px, 5vw, 54px); }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 36px; }
.eyebrow {
    margin-bottom: 7px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 850;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.avatar {
    display: grid;
    width: 48px;
    height: 48px;
    place-items: center;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-weight: 850;
}
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.metric, .welcome-panel {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 10px 28px rgba(28, 48, 89, .05);
}
.metric { display: grid; gap: 14px; padding: 24px; }
.metric span { color: var(--muted); font-size: 14px; }
.metric strong { font-size: 34px; }
.welcome-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 28px;
    margin-top: 22px;
}
.welcome-panel h2 { margin-bottom: 8px; }
.welcome-panel p:last-child { margin-bottom: 0; }
.status {
    padding: 7px 11px;
    border-radius: 999px;
    background: #fff5d8;
    color: #83600a;
    font-size: 13px;
    font-weight: 750;
}
.status-active { background: #e6f7ec; color: #176b3a; }
.settings-panel {
    display: grid;
    grid-template-columns: minmax(220px, .75fr) minmax(320px, 1.25fr);
    gap: 42px;
    padding: 30px;
    margin-bottom: 22px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 10px 28px rgba(28, 48, 89, .05);
}
.integration-form { margin-top: 0; }
.form-actions { display: flex; gap: 12px; }
.form-actions { flex-wrap: wrap; }
.form-actions button { padding: 0 20px; }
.secondary-button {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
}
.secondary-button:hover { background: var(--bg); }
.webhook-panel { align-items: center; }
.webhook-panel code {
    overflow-wrap: anywhere;
    padding: 14px;
    border-radius: 10px;
    background: var(--bg);
    color: var(--primary-dark);
}
.qr-panel { align-items: center; }
.qr-panel img {
    width: min(320px, 100%);
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
}
.conversation-layout {
    display: grid;
    grid-template-columns: minmax(420px, 1.15fr) minmax(300px, .85fr);
    gap: 22px;
    align-items: start;
}
.compose-panel { grid-template-columns: 1fr; gap: 18px; margin: 0; }
.conversation-list {
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 10px 28px rgba(28, 48, 89, .05);
}
.conversation-item {
    display: grid;
    grid-template-columns: 42px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 15px 0;
    border-top: 1px solid var(--border);
}
.conversation-item p {
    overflow: hidden;
    max-width: 260px;
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.conversation-item > span {
    color: var(--muted);
    font-size: 12px;
}
.contact-avatar {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 50%;
    background: #e9eefc;
    color: var(--primary);
    font-weight: 850;
}
.knowledge-layout {
    display: grid;
    grid-template-columns: minmax(360px, .85fr) minmax(420px, 1.15fr);
    gap: 22px;
    align-items: start;
}
.knowledge-form-panel { grid-template-columns: 1fr; gap: 18px; margin: 0; }
.knowledge-list {
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 10px 28px rgba(28, 48, 89, .05);
}
.knowledge-item {
    padding: 20px 0;
    border-top: 1px solid var(--border);
}
.knowledge-item h3 { margin: 0 0 9px; }
.knowledge-item > p {
    margin: 14px 0;
    color: var(--muted);
    line-height: 1.6;
}
.knowledge-item-heading,
.knowledge-actions {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.knowledge-actions { justify-content: flex-start; }
.small-button {
    width: auto;
    height: 36px;
    padding: 0 12px;
    font-size: 13px;
}
.danger-button { background: #fff1f1; color: var(--danger); }
.danger-button:hover { background: #ffe4e4; }
.text-link, .link-button {
    color: var(--primary);
    font-weight: 750;
    text-decoration: none;
}
.link-button {
    display: inline-flex;
    min-height: 48px;
    align-items: center;
}
.empty-state {
    padding: 28px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    color: var(--muted);
    text-align: center;
}
.empty-state p { margin: 8px 0 0; }
.ai-layout {
    display: grid;
    grid-template-columns: minmax(380px, 1fr) minmax(360px, 1fr);
    gap: 22px;
    align-items: start;
}
.ai-settings-panel { grid-template-columns: 1fr; gap: 18px; margin: 0; }
.ai-test-panel {
    padding: 30px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 10px 28px rgba(28, 48, 89, .05);
}
.ai-answer {
    padding: 18px;
    margin-top: 22px;
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    background: #f0f4ff;
}
.ai-answer p { margin: 8px 0 0; line-height: 1.65; }
.provider-tabs {
    display: flex;
    gap: 8px;
    margin: -12px 0 24px;
}
.provider-tabs a {
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-weight: 750;
    text-decoration: none;
}
.provider-tabs a.active {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}
.compact-metrics { margin-bottom: 22px; }
.compact-metrics .metric { padding: 20px; }
.compact-metrics .metric strong { font-size: 28px; }
.crm-panel {
    padding: 26px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 10px 28px rgba(28, 48, 89, .05);
}
.crm-filters {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 230px auto auto;
    gap: 12px;
    align-items: center;
    margin-bottom: 24px;
}
.crm-filters button { padding: 0 20px; }
.contact-table-wrap { overflow-x: auto; }
.contact-table { width: 100%; border-collapse: collapse; }
.contact-table th,
.contact-table td {
    padding: 15px 12px;
    border-top: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}
.contact-table th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.contact-table td:first-child { display: grid; gap: 4px; min-width: 220px; }
.contact-table td:first-child span { color: var(--muted); font-size: 13px; }
.lead-badge {
    display: inline-flex;
    padding: 7px 10px;
    border-radius: 999px;
    background: #edf1f7;
    color: #4f5e74;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}
.lead-qualified { background: #e8f0ff; color: #2750b5; }
.lead-customer { background: #e6f7ec; color: #176b3a; }
.lead-lost { background: #fff1f1; color: var(--danger); }
.modal-backdrop {
    position: fixed;
    z-index: 20;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, .55);
}
.contact-modal {
    width: min(560px, 100%);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    padding: 28px;
    border-radius: 18px;
    background: var(--surface);
    box-shadow: 0 24px 70px rgba(0, 0, 0, .22);
}
.modal-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}
.modal-close {
    color: var(--muted);
    font-size: 30px;
    line-height: 1;
    text-decoration: none;
}
.agenda-layout {
    display: grid;
    grid-template-columns: minmax(360px, .85fr) minmax(440px, 1.15fr);
    gap: 22px;
    align-items: start;
}
.agenda-heading { margin-bottom: 22px; }
.agenda-heading h1 { margin-bottom: 5px; }
.agenda-heading p { margin: 0; color: var(--muted); }
.agenda-tabs {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    padding: 5px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
}
.agenda-tabs button,
.agenda-tabs a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font-weight: 750;
    text-decoration: none;
}
.agenda-tabs button.active,
.agenda-tabs a.active { background: #edf2ff; color: var(--primary); }
.agenda-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 16px;
}
.agenda-summary > div { display: flex; flex-wrap: wrap; gap: 9px; }
.agenda-summary span {
    padding: 9px 13px;
    border-radius: 999px;
    background: #fff;
    color: var(--muted);
}
.agenda-summary button { width: auto; padding: 0 20px; }
.calendar-filters {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
}
.calendar-filters > div { display: flex; gap: 9px; }
.calendar-view-tabs { padding: 4px; border-radius: 9px; background: var(--bg); }
.calendar-view-tabs button { width: auto; padding: 0 15px; background: transparent; color: var(--muted); }
.calendar-view-tabs button.active { background: #fff; color: var(--text); }
.calendar-integration {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 17px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    text-decoration: none;
}
.calendar-integration small { color: var(--primary); }
.calendar-panel {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
}
.calendar-navigation {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    padding: 14px;
    border-bottom: 1px solid var(--border);
}
.calendar-navigation > div { display: flex; gap: 8px; }
.calendar-navigation a {
    display: inline-grid;
    min-width: 40px;
    min-height: 40px;
    place-items: center;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text);
    text-decoration: none;
}
.calendar-navigation h2 { margin: 0; text-align: center; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-weekday {
    padding: 12px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    text-align: center;
}
.calendar-day {
    position: relative;
    min-height: 125px;
    padding: 10px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.calendar-day.outside { background: #f8fafc; color: #aeb8c8; }
.calendar-day.today .calendar-day-number {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
}
.calendar-day-number { font-weight: 800; }
.calendar-events { display: grid; gap: 5px; margin-top: 8px; }
.calendar-events a {
    overflow: hidden;
    padding: 5px 7px;
    border-radius: 6px;
    background: #e8eefc;
    color: var(--primary);
    font-size: 10px;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.calendar-events small { color: var(--muted); }
.event-modal[hidden] { display: none; }
.calendar-list-view {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
}
.calendar-list-view > h2 { padding: 18px; margin: 0; border-bottom: 1px solid var(--border); }
.agenda-list-day {
    display: grid;
    grid-template-columns: 180px 1fr;
    border-bottom: 1px solid var(--border);
}
.agenda-list-day > header { display: grid; gap: 5px; padding: 16px; background: #f8fafc; }
.agenda-list-day > header span { color: var(--muted); }
.agenda-list-day > div { display: grid; gap: 8px; padding: 12px 16px; }
.agenda-list-day a {
    display: grid;
    grid-template-columns: 60px 1fr auto;
    gap: 10px;
    padding: 11px;
    border-radius: 9px;
    background: #eef3ff;
    color: var(--text);
    text-decoration: none;
}
.agenda-list-day a span { color: var(--muted); }
.agenda-admin-grid { display: grid; grid-template-columns: .75fr 1.25fr; gap: 20px; }
.agenda-admin-list { display: grid; gap: 9px; margin-top: 18px; }
.agenda-admin-list > form,
.agenda-admin-list > div {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
}
.agenda-admin-list i { width: 14px; height: 42px; border-radius: 8px; }
.agenda-admin-list span { display: grid; gap: 4px; flex: 1; }
.agenda-admin-list small { color: var(--muted); }
.agenda-admin-list button { width: auto; padding: 0 13px; }
.team-link-list { display: grid; gap: 10px; margin-top: 18px; }
.team-link-list > div {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
}
.team-link-list span { display: grid; gap: 4px; min-width: 0; flex: 1; }
.team-link-list small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.team-link-list button { width: auto; padding: 0 16px; }
.google-calendar-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.google-authorize-form, .google-disconnect-form { margin-top: 16px; }
.google-authorize-form button, .google-disconnect-form button { width: 100%; }
@media(max-width:800px){
    .agenda-tabs{grid-template-columns:1fr 1fr}
    .calendar-filters{display:grid}
    .calendar-filters>div{flex-wrap:wrap}
    .agenda-admin-grid{grid-template-columns:1fr}
    .agenda-list-day{grid-template-columns:1fr}
    .google-calendar-grid{grid-template-columns:1fr}
}
.agenda-form-panel { grid-template-columns: 1fr; gap: 18px; margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.agenda-list {
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 10px 28px rgba(28, 48, 89, .05);
}
.appointment-item {
    display: grid;
    grid-template-columns: 70px 1fr;
    gap: 18px;
    padding: 20px 0;
    border-top: 1px solid var(--border);
}
.appointment-past { opacity: .65; }
.appointment-date {
    display: grid;
    align-content: center;
    min-height: 78px;
    border-radius: 12px;
    background: #edf2ff;
    color: var(--primary);
    text-align: center;
}
.appointment-date strong { font-size: 25px; }
.appointment-date span { font-size: 11px; font-weight: 850; }
.appointment-date small { margin-top: 4px; color: var(--muted); }
.appointment-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}
.appointment-heading h3 { margin: 0 0 5px; }
.appointment-heading p,
.appointment-notes { color: var(--muted); line-height: 1.5; }
.appointment-notes { margin: 12px 0; }
.appointment-confirmed { background: #e8f0ff; color: #2750b5; }
.appointment-completed { background: #e6f7ec; color: #176b3a; }
.appointment-cancelled { background: #fff1f1; color: var(--danger); }
.conversation-item {
    color: inherit;
    text-decoration: none;
}
.conversation-item.selected {
    margin-inline: -12px;
    padding-inline: 12px;
    border-radius: 10px;
    background: #edf2ff;
}
.inbox-layout {
    display: grid;
    grid-template-columns: minmax(280px, .7fr) minmax(480px, 1.3fr);
    gap: 22px;
    height: calc(100vh - 190px);
    min-height: 560px;
}
.inbox-sidebar,
.chat-panel {
    height: 100%;
    min-height: 0;
}
.inbox-sidebar { overflow-y: auto; }
.inbox-list-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}
.icon-button {
    width: 42px;
    min-width: 42px;
    height: 42px;
    font-size: 24px;
}
.chat-panel {
    display: grid;
    grid-template-rows: auto 1fr auto;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 10px 28px rgba(28, 48, 89, .05);
}
.chat-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}
.chat-heading > div:nth-child(2) { display: grid; gap: 3px; }
.chat-heading span { color: var(--muted); font-size: 13px; }
.chat-contact-link { margin-left: auto; }
.message-thread {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding: 24px;
    background: #f7f9fc;
}
.message-bubble {
    width: fit-content;
    max-width: min(76%, 620px);
    padding: 11px 14px 8px;
    border: 1px solid var(--border);
    border-radius: 14px 14px 14px 4px;
    background: #fff;
}
.message-bubble.outbound {
    align-self: flex-end;
    border-color: #ccd8ff;
    border-radius: 14px 14px 4px 14px;
    background: #eaf0ff;
}
.message-bubble p { margin: 0; line-height: 1.5; }
.message-bubble footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 5px;
    color: var(--muted);
    font-size: 10px;
}
.chat-compose {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    padding: 16px;
    border-top: 1px solid var(--border);
}
.chat-compose textarea { min-height: 48px; max-height: 120px; }
.chat-compose button { align-self: end; padding: 0 24px; }
.chat-empty { align-self: center; margin: 24px; }
.compose-modal-backdrop[hidden] { display: none; }
.button-reset {
    width: auto;
    height: auto;
    padding: 0;
    border: 0;
    background: transparent;
}
.button-reset:hover { background: transparent; }
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.sync-button {
    width: auto;
    padding: 0 16px;
}
.inbox-page {
    --inbox-bg: #f4f7fb;
    --inbox-panel: #ffffff;
    --inbox-panel-soft: #eef2f8;
    --inbox-border: #dfe6f0;
    --inbox-text: #172033;
    --inbox-muted: #68758b;
    --inbox-accent: #3457d5;
    background: var(--inbox-bg);
    width: 100%;
    min-width: 0;
}
.inbox-page .app-shell {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    width: 100%;
    min-width: 0;
}
.inbox-page .sidebar { display: flex; }
.inbox-page .inbox-content {
    display: block;
    width: 100%;
    max-width: none;
    min-width: 0;
    padding: 22px 18px 0;
    background: var(--inbox-bg);
    color: var(--inbox-text);
}
.inbox-page .topbar { margin-bottom: 12px; }
.inbox-page .topbar {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 74px;
}
.inbox-page .topbar > div:first-child {
    width: auto;
    min-width: 260px;
    max-width: none;
}
.inbox-page .topbar .eyebrow { color: var(--primary); }
.inbox-page .topbar h1 { font-size: 22px; }
.inbox-page .topbar .muted { color: var(--inbox-muted); }
.inbox-page .alert { margin: 10px 0; }
.inbox-tabs {
    display: inline-flex;
    gap: 3px;
    padding: 3px;
    margin-bottom: 12px;
    border: 1px solid var(--inbox-border);
    border-radius: 9px;
    background: var(--inbox-panel);
}
.inbox-tabs button,
.inbox-tabs a {
    height: 30px;
    padding: 0 14px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--inbox-muted);
    font-size: 12px;
    font-weight: 750;
    text-decoration: none;
}
.inbox-tabs .active { background: var(--primary); color: #fff; }
.inbox-page .inbox-layout {
    width: 100%;
    max-width: none;
    grid-template-columns: minmax(270px, 25%) minmax(420px, 50%) minmax(260px, 25%);
    gap: 0;
    height: calc(100vh - 135px);
    min-height: 600px;
    border: 1px solid var(--inbox-border);
    border-radius: 12px 12px 0 0;
    overflow: hidden;
}
.inbox-page .conversation-list,
.inbox-page .chat-panel,
.contact-details {
    border: 0;
    border-radius: 0;
    background: var(--inbox-panel);
    box-shadow: none;
    color: var(--inbox-text);
}
.inbox-page .inbox-sidebar {
    padding: 0;
    border-right: 1px solid var(--inbox-border);
}
.inbox-page .inbox-list-heading {
    gap: 9px;
    padding: 9px;
    border-bottom: 1px solid var(--inbox-border);
}
.conversation-search {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 8px;
    min-width: 0;
    height: 38px;
    padding: 0 10px;
    border-radius: 8px;
    background: var(--inbox-panel-soft);
    color: var(--inbox-muted);
}
.conversation-search input {
    min-width: 0;
    height: 36px;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--inbox-text);
    font-size: 12px;
}
.inbox-page .icon-button {
    width: 38px;
    min-width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--inbox-accent);
    color: #fff;
}
.conversation-filters {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
    padding: 8px;
    border-bottom: 1px solid var(--inbox-border);
}
.conversation-filters button {
    height: 30px;
    padding: 0 5px;
    border-radius: 7px;
    background: transparent;
    color: var(--inbox-muted);
    font-size: 8px;
    text-transform: uppercase;
}
.conversation-filters button.active { background: #e7edfb; color: var(--primary); }
.conversation-filters span {
    padding: 1px 5px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
}
.inbox-page .conversation-item {
    grid-template-columns: 42px 1fr;
    padding: 13px;
    border-top: 0;
    border-bottom: 1px solid var(--inbox-border);
    color: var(--inbox-text);
}
.inbox-page .conversation-item > span { display: none; }
.inbox-page .conversation-item p { color: #8aa4d4; }
.inbox-page .conversation-item.selected {
    margin: 0;
    padding: 13px;
    border-left: 3px solid var(--inbox-accent);
    border-radius: 0;
    background: #e8eefc;
}
.inbox-page .contact-avatar {
    background: #e7edfb;
    color: var(--primary);
}
.inbox-page .chat-panel { border-right: 1px solid var(--inbox-border); }
.inbox-page .chat-heading {
    min-height: 58px;
    padding: 8px 16px;
    border-bottom-color: var(--inbox-border);
}
.inbox-page .chat-heading span { color: var(--inbox-muted); }
.online-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 4px;
    border-radius: 50%;
    background: #16d392;
}
.chat-tools { display: flex; gap: 5px; margin-left: auto; }
.chat-tools button {
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    color: var(--inbox-muted);
}
.chat-tools button:hover { background: var(--inbox-panel-soft); }
.inbox-page .message-thread {
    background-color: #f7f9fc;
    background-image: radial-gradient(rgba(52,87,213,.05) 1px, transparent 1px);
    background-size: 18px 18px;
}
.inbox-page .message-bubble {
    border-color: var(--inbox-border);
    background: #fff;
    color: var(--inbox-text);
}
.inbox-page .message-bubble.outbound {
    border-color: #213550;
    background: #eaf0ff;
}
.inbox-page .message-bubble footer { color: var(--inbox-muted); }
.inbox-page .chat-compose {
    border-top-color: var(--inbox-border);
    background: var(--inbox-panel);
}
.inbox-page .chat-compose textarea {
    border-color: var(--inbox-border);
    background: #fff;
    color: var(--text);
}
.inbox-page .chat-compose button {
    background: var(--inbox-accent);
    color: #fff;
}
.contact-details {
    min-width: 0;
    overflow-y: auto;
}
.contact-details[hidden] { display: none; }
.chat-contact-trigger {
    display: flex;
    align-items: center;
    gap: 12px;
    width: auto;
    height: auto;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--inbox-text);
    text-align: left;
}
.chat-contact-trigger:hover { background: transparent; }
.chat-contact-trigger > span:last-child { display: grid; gap: 3px; }
.chat-contact-trigger small {
    color: var(--inbox-muted);
    font-size: 12px;
    font-weight: 400;
}
.inbox-page .inbox-layout:not(.contact-open) {
    grid-template-columns: minmax(270px, 28%) minmax(480px, 72%);
}
.inbox-page .inbox-layout.contact-open {
    grid-template-columns: minmax(270px, 25%) minmax(420px, 50%) minmax(260px, 25%);
}
.contact-details > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 58px;
    padding: 0 14px;
    border-bottom: 1px solid var(--inbox-border);
}
.contact-details > header button {
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    color: var(--text);
}
.contact-tabs {
    display: flex;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--inbox-border);
}
.contact-tabs button {
    width: auto;
    height: auto;
    padding: 0;
    background: transparent;
    color: var(--inbox-muted);
    font-size: 10px;
}
.contact-tabs button.active { color: var(--primary); }
.contact-profile { padding: 28px 18px 22px; text-align: center; }
.profile-avatar {
    display: grid;
    width: 68px;
    height: 68px;
    margin: 0 auto 12px;
    place-items: center;
    border-radius: 50%;
    background: #e7edfb;
    color: var(--primary);
    font-size: 20px;
    font-weight: 850;
}
.contact-profile h3 { margin-bottom: 6px; }
.contact-profile p { color: var(--inbox-muted); font-size: 12px; }
.contact-detail-section {
    display: grid;
    gap: 7px;
    padding: 14px;
    border-top: 1px solid var(--inbox-border);
}
.contact-detail-section span {
    color: var(--inbox-muted);
    font-size: 9px;
    text-transform: uppercase;
}
.contact-detail-section strong {
    padding: 10px;
    border: 1px solid var(--inbox-border);
    border-radius: 8px;
    background: var(--inbox-panel-soft);
    font-size: 12px;
}
.contact-detail-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 0 14px 14px;
}
.contact-detail-actions a {
    padding: 10px;
    border: 1px solid var(--inbox-border);
    border-radius: 8px;
    color: var(--text);
    font-size: 11px;
    font-weight: 750;
    text-align: center;
    text-decoration: none;
}
.contact-tab-panel[hidden] { display: none; }
.contact-panel-section {
    padding: 16px 14px;
    border-top: 1px solid var(--inbox-border);
}
.contact-panel-section h3 { margin-bottom: 14px; font-size: 14px; }
.contact-history-item {
    padding: 11px 0;
    border-bottom: 1px solid var(--inbox-border);
}
.contact-history-item p {
    margin: 5px 0;
    color: var(--inbox-muted);
    font-size: 12px;
    line-height: 1.45;
}
.contact-history-item small { color: var(--inbox-muted); font-size: 10px; }
.contact-tag-list { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }
.contact-tag {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 8px 6px 10px;
    border-radius: 999px;
    background: #e8eefc;
    color: var(--primary);
    font-size: 11px;
    font-weight: 750;
}
.contact-tag button {
    width: 18px;
    height: 18px;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--primary);
}
.tag-form { display: grid; gap: 8px; }
.tag-form input { height: 40px; }
.tag-form button { height: 40px; }
.inbox-report-view {
    display: grid;
    gap: 20px;
    width: 100%;
    padding-bottom: 28px;
}
.inbox-report-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}
.inbox-report-metrics article,
.status-distribution {
    border: 1px solid var(--inbox-border);
    border-radius: 12px;
    background: var(--inbox-panel);
    color: var(--inbox-text);
}
.inbox-report-metrics article {
    display: grid;
    gap: 7px;
    min-height: 120px;
    padding: 20px;
}
.inbox-report-metrics span {
    font-size: 12px;
    font-weight: 750;
}
.inbox-report-metrics strong {
    font-size: 27px;
}
.inbox-report-metrics small {
    color: var(--inbox-muted);
}
.status-distribution { padding: 24px; }
.status-distribution h2 { margin-bottom: 5px; }
.status-distribution > div:first-child p {
    margin: 0;
    color: var(--inbox-muted);
}
.status-distribution-list {
    display: grid;
    gap: 18px;
    margin-top: 24px;
}
.status-distribution-row > div:first-child {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
}
.status-track {
    overflow: hidden;
    height: 8px;
    border-radius: 999px;
    background: #e8edf5;
}
.status-fill {
    display: block;
    min-width: 0;
    height: 100%;
    border-radius: inherit;
    background: #9aabc3;
}
.status-fill-bot { background: #8a63dc; }
.status-fill-waiting { background: #e5a13a; }
.status-fill-active { background: #24bf76; }
.status-fill-closed { background: #7190bd; }

@media (max-width: 1050px) {
    .inbox-page .inbox-layout {
        grid-template-columns: minmax(250px, 34%) minmax(420px, 66%);
    }
    .contact-details { display: none; }
    .inbox-page .inbox-layout.contact-open {
        grid-template-columns: minmax(250px, 34%) minmax(420px, 66%);
    }
    .inbox-report-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
    .inbox-page .app-shell { grid-template-columns: 1fr; }
    .inbox-page .sidebar {
        display: flex;
        padding: 20px;
    }
    .inbox-page .inbox-content { padding-inline: 10px; }
    .inbox-page .topbar {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 12px;
    }
    .inbox-page .topbar > div:first-child {
        min-width: 0;
    }
    .inbox-page .topbar .muted {
        max-width: none;
    }
    .inbox-page .inbox-layout {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 0;
    }
    .inbox-page .inbox-sidebar {
        max-height: 280px;
        border-right: 0;
        border-bottom: 1px solid var(--inbox-border);
    }
    .inbox-page .chat-panel { min-height: 560px; border-right: 0; }
    .inbox-page .topbar-actions .sync-button { display: none; }
    .inbox-report-metrics { grid-template-columns: 1fr; }
}
.team-layout {
    display: grid;
    grid-template-columns: minmax(350px, .85fr) minmax(440px, 1.15fr);
    gap: 22px;
    align-items: start;
}
.team-form-panel { grid-template-columns: 1fr; gap: 18px; margin: 0; }
.team-list {
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 10px 28px rgba(28, 48, 89, .05);
}
.team-item {
    display: grid;
    grid-template-columns: 44px 1fr auto auto;
    gap: 14px;
    align-items: center;
    padding: 17px 0;
    border-top: 1px solid var(--border);
}
.team-user-info { display: grid; gap: 4px; }
.team-user-info span,
.team-user-info small { color: var(--muted); }
.team-user-info span { font-size: 13px; }
.team-user-info small { font-size: 11px; }
.team-badges { display: flex; gap: 7px; align-items: center; }
.settings-page-panel {
    padding: 30px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 10px 28px rgba(28, 48, 89, .05);
}
.settings-form { margin: 0; }
.settings-section {
    display: grid;
    grid-template-columns: minmax(240px, .7fr) minmax(340px, 1.3fr);
    gap: 44px;
    padding: 8px 0 30px;
    border-bottom: 1px solid var(--border);
}
.settings-section + .settings-section { padding-top: 30px; }
.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 17px;
    border: 1px solid var(--border);
    border-radius: 12px;
}
.switch-row span { display: grid; gap: 5px; }
.switch-row small { color: var(--muted); font-weight: 400; line-height: 1.4; }
.switch-row input[type="checkbox"] {
    width: 22px;
    height: 22px;
    accent-color: var(--primary);
}
.settings-submit { display: flex; justify-content: flex-end; padding-top: 24px; }
.settings-submit button { width: auto; padding: 0 24px; }
.report-topbar form { min-width: 220px; }
.report-metrics { margin-bottom: 22px; }
.report-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(300px, .7fr);
    gap: 22px;
}
.report-card {
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 10px 28px rgba(28, 48, 89, .05);
}
.report-chart-card { min-width: 0; }
.report-card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}
.chart-legend { display: flex; gap: 13px; color: var(--muted); font-size: 12px; }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.chart-legend i { width: 9px; height: 9px; border-radius: 50%; }
.legend-inbound { background: var(--primary); }
.legend-outbound { background: #93a8e8; }
.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    overflow-x: auto;
    min-height: 240px;
    padding-top: 24px;
}
.bar-day {
    display: grid;
    flex: 1 0 22px;
    gap: 7px;
    align-items: end;
    min-width: 22px;
    text-align: center;
}
.bar-stack {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
    min-height: 180px;
}
.bar { display: block; width: 8px; border-radius: 4px 4px 0 0; }
.inbound-bar { background: var(--primary); }
.outbound-bar { background: #93a8e8; }
.bar-day small { color: var(--muted); font-size: 9px; transform: rotate(-45deg); }
.funnel-list { display: grid; gap: 22px; margin-top: 26px; }
.funnel-row > div:first-child {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}
.progress-track {
    overflow: hidden;
    height: 9px;
    border-radius: 999px;
    background: #edf1f7;
}
.progress-fill { display: block; height: 100%; border-radius: inherit; background: #aab7cd; }
.progress-qualified { background: #5b7de1; }
.progress-customer { background: #38a169; }
.progress-lost { background: #d66a6a; }
.insight-card { grid-column: 1 / -1; }
.insight-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.insight-list > div {
    display: grid;
    gap: 7px;
    padding: 18px;
    border-radius: 12px;
    background: var(--bg);
}
.insight-list strong { color: var(--primary); font-size: 27px; }
.insight-list span { color: var(--muted); line-height: 1.4; }

@media (max-width: 900px) {
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .settings-panel { grid-template-columns: 1fr; gap: 18px; }
    .conversation-layout { grid-template-columns: 1fr; }
    .knowledge-layout { grid-template-columns: 1fr; }
    .ai-layout { grid-template-columns: 1fr; }
    .crm-filters { grid-template-columns: 1fr; }
    .agenda-layout { grid-template-columns: 1fr; }
    .inbox-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    .inbox-sidebar { max-height: 330px; }
    .chat-panel { min-height: 600px; }
    .team-layout { grid-template-columns: 1fr; }
    .settings-section { grid-template-columns: 1fr; gap: 18px; }
    .report-grid { grid-template-columns: 1fr; }
    .insight-list { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 650px) {
    .team-item { grid-template-columns: 44px 1fr; }
    .team-badges { grid-column: 2; }
    .team-item > .text-link { grid-column: 2; }
}

@media (max-width: 520px) {
    .insight-list { grid-template-columns: 1fr; }
    .report-card-heading { display: grid; }
}

@media (max-width: 520px) {
    .form-grid { grid-template-columns: 1fr; }
    .appointment-item { grid-template-columns: 58px 1fr; gap: 12px; }
}

@media (max-width: 680px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { padding: 20px; }
    .sidebar nav { display: none; }
    .sidebar .brand { margin: 0; }
    .logout { position: absolute; right: 20px; top: 16px; }
    .metrics { grid-template-columns: 1fr; }
    .welcome-panel { align-items: flex-start; gap: 18px; }
    .auth-card { padding: 28px 22px; }
}
