* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f4f5f7;
    color: #1f2937;
}
.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }

.topnav {
    background: #ffffff;
    color: #111827;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    border-bottom: 3px solid #e63946;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.nav-brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 10px; color: #111827; }
.nav-logo { height: 34px; width: auto; border-radius: 4px; }
.nav-links a {
    color: #111827;
    text-decoration: none;
    margin-right: 20px;
    font-size: 14px;
}
.nav-links a:hover { color: #e63946; }
.nav-user { display: flex; align-items: center; gap: 12px; font-size: 14px; color: #111827; }
.logout-link { color: #dc2626; text-decoration: none; }

.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }

.login-box {
    max-width: 380px;
    margin: 80px auto;
    background: #fff;
    padding: 32px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.login-box h1 { font-size: 20px; margin-bottom: 20px; text-align: center; }
.login-logo { display: block; max-width: 150px; margin: 0 auto 16px; }

input[type=text], input[type=email], input[type=password], input[type=tel], textarea, select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 14px;
}
label { font-size: 13px; font-weight: 600; color: #374151; display: block; margin-bottom: 4px; }
.input-with-action { display: flex; gap: 8px; align-items: flex-start; }
.input-with-action input { flex: 1; margin-bottom: 14px; }
.input-with-action a.btn-sm { white-space: nowrap; text-decoration: none; }
button, .btn {
    background: #e63946;
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}
button:hover, .btn:hover { background: #c62d39; }
.btn-secondary { background: #6b7280; }
.btn-secondary:hover { background: #4b5563; }
.btn-danger { background: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.cards { display: flex; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.card {
    background: #fff;
    border-radius: 10px;
    padding: 18px 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    flex: 1;
    min-width: 130px;
}
.card .num { font-size: 26px; font-weight: 700; }
.card .label { font-size: 13px; color: #6b7280; margin-top: 4px; }
.card-link {
    text-decoration: none;
    color: inherit;
    display: block;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.card-link:hover {
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.page-header h1 { font-size: 22px; margin: 0; }

table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 12px 14px; font-size: 14px; border-bottom: 1px solid #eee; }
th { background: #f9fafb; color: #6b7280; font-size: 12px; text-transform: uppercase; }
tr:hover { background: #fafafa; }
a.row-link { color: #111827; text-decoration: none; font-weight: 600; }
a.row-link:hover { text-decoration: underline; }

.badge {
    color: #fff;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.source-tag {
    background: #eef2ff;
    color: #4338ca;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
}

.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filters input, .filters select { margin-bottom: 0; width: auto; min-width: 160px; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.panel { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); margin-bottom: 20px; }
.panel h2 { font-size: 15px; margin-top: 0; margin-bottom: 14px; color: #374151; }
.note-item { border-bottom: 1px solid #f1f1f1; padding: 10px 0; font-size: 14px; }
.note-meta { color: #9ca3af; font-size: 12px; margin-top: 3px; }

.fb-thread {
    max-height: 320px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 2px;
}
.fb-bubble {
    max-width: 75%;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.4;
}
.fb-in {
    background: #eef0f3;
    color: #111827;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.fb-out {
    background: #2563eb;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.fb-bubble-meta {
    font-size: 11px;
    opacity: 0.65;
    margin-top: 3px;
}
.fb-bubble-image {
    max-width: 100%;
    border-radius: 10px;
    display: block;
    margin-bottom: 4px;
}
.nav-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
}
.nav-badge {
    background: #dc2626;
    color: #fff;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 3px;
}
.avatar-placeholder {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}
.followup-alert {
    background: #fef3c7;
    color: #92400e;
    padding: 10px 24px;
    font-size: 14px;
}
.followup-alert a { color: #92400e; font-weight: 600; }
.star-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    vertical-align: middle;
}
.followup-card { margin-bottom: 16px; }
.followup-card-due { border-left: 4px solid #dc2626; }
.followup-when {
    background: #eef2ff;
    color: #3730a3;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    margin: 10px 0;
    display: inline-block;
}
.followup-when-due { background: #fee2e2; color: #991b1b; }

.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.modal-visible { display: flex; }
.modal-box {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    max-width: 520px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}
.modal-box h2 { margin-top: 0; }
.modal-reminder-row {
    border-bottom: 1px solid #eee;
    padding: 12px 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}
.modal-reminder-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.modal-reminder-actions form { display: flex; gap: 6px; align-items: center; }

.attachment-preview-box {
    max-width: 700px;
    width: 92%;
    max-height: 88vh;
    padding: 0;
    display: flex;
    flex-direction: column;
    transition: max-width 0.15s ease;
}
.attachment-preview-box.attachment-preview-expanded {
    max-width: 1400px;
    width: 96vw;
    max-height: 96vh;
}
.attachment-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    font-weight: 600;
}
.attachment-preview-actions { display: flex; gap: 10px; align-items: center; }
.attachment-preview-actions button,
.attachment-preview-actions a {
    background: #f3f4f6;
    border: none;
    border-radius: 6px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #374151;
    cursor: pointer;
    font-size: 15px;
}
.attachment-preview-actions button:hover,
.attachment-preview-actions a:hover { background: #e5e7eb; }
.attachment-preview-body {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    background: #f9fafb;
}
.attachment-preview-image {
    max-width: 100%;
    max-height: 80vh;
    display: block;
}
.attachment-preview-iframe {
    width: 100%;
    height: 80vh;
    border: none;
}

.tz-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 6px;
}
.tz-badge-confirmed { background: #dcfce7; color: #166534; }
.tz-badge-guess { background: #fef3c7; color: #92400e; }

.emoji-bar { display: flex; gap: 4px; margin: 6px 0; }
.lead-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 8px;
    object-fit: cover;
}
.read-tick { font-size: 11px; margin-left: 3px; }
.emoji-btn {
    background: #f3f4f6;
    border: none;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 16px;
    cursor: pointer;
}
.emoji-btn:hover { background: #e5e7eb; }
.fb-send-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.attach-label {
    cursor: pointer;
    display: inline-block;
}
.fb-attachment-name { font-size: 12px; color: #6b7280; flex: 1; }

.attachment-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.attachment-thumb {
    display: block;
    width: 110px;
    text-decoration: none;
    color: #374151;
}
.attachment-thumb img {
    width: 110px;
    height: 110px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    display: block;
}
.attachment-file-icon {
    width: 110px;
    height: 110px;
    background: #f3f4f6;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
}
.attachment-thumb-label {
    font-size: 12px;
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 700px) {
    .detail-grid { grid-template-columns: 1fr; }
    .nav-links { display: none; }
}

/* ======================================================================
   Kwickshop CRM interface refresh v3
   Shared visual language based on the Kwickshop finance application UI.
   ====================================================================== */
:root {
    --ks-navy: #0b356d;
    --ks-navy-dark: #092a56;
    --ks-navy-soft: #eaf1fb;
    --ks-red: #ea3345;
    --ks-red-dark: #c92535;
    --ks-gold: #ffbf2f;
    --ks-bg: #edf2f7;
    --ks-panel: #ffffff;
    --ks-border: #d9e2ec;
    --ks-text: #10233f;
    --ks-muted: #64748b;
    --ks-success: #15803d;
    --ks-warning: #b45309;
    --ks-danger: #c62828;
    --ks-shadow: 0 12px 32px rgba(15, 45, 82, 0.08);
    --ks-shadow-soft: 0 4px 14px rgba(15, 45, 82, 0.06);
    --ks-radius: 14px;
}
html { background: var(--ks-bg); }
body.crm-body {
    background:
        radial-gradient(circle at 12% 0%, rgba(11,53,109,.06), transparent 26rem),
        var(--ks-bg);
    color: var(--ks-text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--ks-navy); }
.container { max-width: 1240px; padding: 28px 24px 56px; }

/* Top navigation */
.topnav {
    position: sticky;
    top: 0;
    z-index: 200;
    padding: 0;
    background: rgba(255,255,255,.97);
    border-bottom: 1px solid rgba(11,53,109,.12);
    box-shadow: 0 3px 16px rgba(15,45,82,.07);
    backdrop-filter: blur(14px);
}
.topnav::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    height: 3px;
    background: linear-gradient(90deg, var(--ks-red), #ff6a5f 38%, var(--ks-gold));
}
.topnav-inner {
    width: 100%;
    max-width: 1420px;
    min-height: 74px;
    margin: 0 auto;
    padding: 0 24px;
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
    align-items: center;
    gap: 24px;
}
.nav-brand { text-decoration: none; gap: 11px; min-width: 0; }
.nav-logo-wrap {
    width: 54px;
    height: 42px;
    border: 1px solid #e7edf4;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: #fff;
    box-shadow: 0 4px 10px rgba(15,45,82,.06);
}
.nav-logo { max-width: 46px; max-height: 30px; height: auto; border-radius: 0; }
.nav-brand-copy { display: flex; flex-direction: column; min-width: 0; }
.nav-brand-copy strong { font-size: 17px; line-height: 1.15; color: var(--ks-navy-dark); }
.nav-brand-copy small { color: var(--ks-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .09em; margin-top: 3px; }
.nav-links { display: flex; align-items: center; justify-content: center; gap: 4px; }
.nav-links a {
    margin: 0;
    padding: 10px 12px;
    border-radius: 9px;
    color: #334155;
    font-weight: 650;
    font-size: 13px;
    white-space: nowrap;
    transition: background .15s ease, color .15s ease, transform .15s ease;
}
.nav-links a:hover { color: var(--ks-navy); background: var(--ks-navy-soft); transform: translateY(-1px); }
.nav-links a.active { color: #fff; background: var(--ks-navy); box-shadow: 0 6px 15px rgba(11,53,109,.22); }
.nav-links a.active .nav-badge { background: #fff; color: var(--ks-red); }
.nav-user { justify-self: end; gap: 14px; }
.nav-profile { display: flex; align-items: center; gap: 8px; text-decoration: none; color: inherit; }
.nav-avatar { width: 34px; height: 34px; border: 2px solid #fff; box-shadow: 0 0 0 2px #dbe5f2; }
.nav-avatar-placeholder { background: var(--ks-navy); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.nav-user-copy { display: flex; flex-direction: column; }
.nav-user-copy strong { font-size: 13px; color: var(--ks-text); line-height: 1.2; }
.nav-user-copy small { color: var(--ks-muted); font-size: 10px; margin-top: 2px; }
.logout-link { color: var(--ks-red); font-size: 12px; font-weight: 700; border-left: 1px solid var(--ks-border); padding-left: 14px; }
.logout-link:hover { color: var(--ks-red-dark); }
.nav-badge { background: var(--ks-red); min-width: 18px; text-align: center; }

.followup-alert { padding: 0; border-bottom: 1px solid #f7d48a; background: #fff7dc; }
.followup-alert-inner { max-width: 1240px; margin: 0 auto; padding: 10px 24px; color: #7c4b00; font-size: 13px; }
.followup-alert-inner a { color: #6b3f00; }
.followup-alert-link { margin-left: 10px; }

/* Page hero matching the application header */
.page-hero {
    background: linear-gradient(120deg, var(--ks-navy) 0%, #0d3c78 58%, #132b48 100%);
    color: #fff;
    border-radius: 18px;
    padding: 25px 28px;
    margin-bottom: 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    box-shadow: 0 16px 34px rgba(9,42,86,.18);
    position: relative;
    overflow: hidden;
}
.page-hero::after {
    content: "";
    position: absolute;
    width: 270px; height: 270px;
    right: -95px; top: -135px;
    border-radius: 50%;
    border: 45px solid rgba(255,255,255,.05);
    pointer-events: none;
}
.page-hero > * { position: relative; z-index: 1; }
.page-eyebrow, .section-kicker {
    display: block;
    color: var(--ks-gold);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    margin-bottom: 7px;
}
.page-hero h1 { margin: 0; font-size: 30px; line-height: 1.12; color: #fff; }
.page-hero p { margin: 8px 0 0; max-width: 720px; color: #dbe8f8; font-size: 14px; line-height: 1.55; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.hero-metrics { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.hero-metrics span {
    min-width: 110px;
    padding: 11px 14px;
    border-radius: 11px;
    border: 1px solid rgba(255,255,255,.2);
    background: rgba(255,255,255,.08);
    color: #dbe8f8;
    font-size: 12px;
}
.hero-metrics strong { display: block; color: #fff; font-size: 20px; line-height: 1; margin-bottom: 5px; }

/* Buttons and fields */
button, .btn {
    border-radius: 9px;
    background: var(--ks-red);
    font-weight: 750;
    box-shadow: 0 4px 10px rgba(234,51,69,.17);
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
button:hover, .btn:hover { background: var(--ks-red-dark); transform: translateY(-1px); box-shadow: 0 7px 16px rgba(234,51,69,.2); }
button:disabled { opacity: .6; cursor: wait; transform: none; box-shadow: none; }
.btn-secondary { background: var(--ks-navy); box-shadow: 0 4px 10px rgba(11,53,109,.16); }
.btn-secondary:hover { background: var(--ks-navy-dark); }
.btn-light { background: #fff; color: var(--ks-navy); box-shadow: none; }
.btn-light:hover { background: #f5f8fc; color: var(--ks-navy-dark); box-shadow: 0 6px 14px rgba(0,0,0,.12); }
.btn-ghost { background: transparent; color: var(--ks-navy); border: 1px solid var(--ks-border); box-shadow: none; }
.btn-ghost:hover { background: var(--ks-navy-soft); box-shadow: none; }
.btn-danger { background: #c62b36; }
.btn-sm { border-radius: 8px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=datetime-local], textarea, select {
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid #cfd9e6;
    border-radius: 8px;
    background: #fff;
    color: var(--ks-text);
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: #7ca0ce; box-shadow: 0 0 0 3px rgba(11,53,109,.1); }
label { color: #28415f; font-weight: 750; }
code { background: #eef3f8; padding: 2px 5px; border-radius: 5px; color: #24476d; }

/* Cards, panels and headings */
.panel {
    border: 1px solid rgba(194,208,224,.78);
    border-radius: var(--ks-radius);
    box-shadow: var(--ks-shadow-soft);
    padding: 22px;
    margin-bottom: 20px;
}
.panel:hover { border-color: #c5d4e6; }
.panel h2 { color: var(--ks-navy-dark); font-size: 17px; }
.panel > h2:first-child {
    border-bottom: 1px solid #e7edf4;
    padding-bottom: 13px;
    margin-bottom: 15px;
}
.panel > p { line-height: 1.65; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.panel-heading h2 { margin: 0; font-size: 19px; color: var(--ks-navy-dark); }
.panel-heading p { margin: 5px 0 0; color: var(--ks-muted); font-size: 13px; line-height: 1.5; }
.compact-heading { align-items: center; }
.section-kicker { color: var(--ks-red); margin-bottom: 5px; }
.text-link { font-size: 13px; font-weight: 750; text-decoration: none; white-space: nowrap; }
.text-link:hover { text-decoration: underline; }
.muted-text { color: var(--ks-muted); }
.text-small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.inline-form { display: inline; margin: 0; }
.empty-state { text-align: center; padding: 34px 18px !important; color: var(--ks-muted); }
.alert { border-radius: 10px; border: 1px solid transparent; box-shadow: none; }
.alert-success { border-color: #b8e5c7; }
.alert-error { border-color: #f1c3c7; }
.alert-warning { background: #fff7df; color: #7a4a00; border-color: #f2d28c; }

/* Statistics */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(135px, 1fr));
    gap: 13px;
    margin-bottom: 22px;
}
.stat-card {
    min-width: 0;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 17px;
    border-radius: 13px;
    border: 1px solid #dbe5ef;
    background: #fff;
    color: var(--ks-text);
    text-decoration: none;
    box-shadow: var(--ks-shadow-soft);
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--ks-shadow); border-color: #acc3df; }
.stat-card-accent { border-top: 3px solid var(--ks-red); padding-top: 15px; }
.stat-icon {
    min-width: 36px;
    height: 28px;
    padding: 0 6px;
    display: grid;
    place-items: center;
    border-radius: 7px;
    background: var(--ks-navy-soft);
    color: var(--ks-navy);
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .03em;
}
.stat-card > div { min-width: 0; }
.stat-number { display: block; font-size: 26px; font-weight: 850; color: var(--ks-navy-dark); line-height: 1; }
.stat-label { display: block; font-size: 12px; font-weight: 800; margin-top: 6px; }
.stat-card small { display: block; color: var(--ks-muted); font-size: 10px; margin-top: 3px; line-height: 1.35; }
.mini-stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.mini-stat { padding: 16px 18px; background: #fff; border: 1px solid var(--ks-border); border-radius: 12px; box-shadow: var(--ks-shadow-soft); display: flex; justify-content: space-between; align-items: center; }
.mini-stat span { color: var(--ks-muted); font-size: 12px; font-weight: 700; }
.mini-stat strong { color: var(--ks-navy); font-size: 22px; }

/* Tables */
.panel-table { padding: 0; overflow: hidden; }
.panel-table > .panel-heading { padding: 21px 22px 4px; }
.table-wrap { width: 100%; overflow-x: auto; }
table.data-table { border-radius: 0; box-shadow: none; min-width: 760px; }
table.data-table th {
    background: #f1f5f9;
    color: #53667d;
    border-bottom: 1px solid #dce5ee;
    font-size: 10px;
    font-weight: 850;
    letter-spacing: .055em;
    padding: 12px 13px;
}
table.data-table td { padding: 13px; border-bottom: 1px solid #e8eef5; vertical-align: middle; font-size: 12px; }
table.data-table tbody tr { transition: background .12s ease; }
table.data-table tbody tr:hover { background: #f7faff; }
table.data-table tbody tr.is-unread { background: #f0f5ff; font-weight: 700; box-shadow: inset 4px 0 0 var(--ks-red); }
table.data-table tbody tr.is-unread:hover { background: #eaf1ff; }
.icon-column { width: 38px; }
.row-link { color: var(--ks-navy-dark) !important; }
.quick-action { text-decoration: none; margin-left: 4px; font-size: 13px; }
.product-cell { min-width: 190px; max-width: 260px; color: #41536a; }
.lead-name-cell { display: flex; align-items: center; gap: 9px; min-width: 150px; }
.lead-name-cell .lead-avatar { margin: 0; flex: 0 0 auto; }
.lead-initial { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--ks-navy-soft); color: var(--ks-navy); font-size: 11px; font-weight: 850; flex: 0 0 auto; }
.badge { display: inline-flex; align-items: center; line-height: 1.3; }
.source-tag { display: inline-flex; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: #eaf1ff; color: #2b55a1; font-weight: 750; }
.star-btn { box-shadow: none; color: #7b8ba0; border-radius: 7px; min-width: 26px; min-height: 26px; }
.star-btn:hover { background: var(--ks-navy-soft); color: var(--ks-navy); transform: none; box-shadow: none; }
.read-state-btn { font-size: 13px !important; }
.log-message { min-width: 420px; line-height: 1.5; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px !important; overflow-wrap: anywhere; }
.log-level { display: inline-flex; padding: 4px 9px; border-radius: 999px; color: #fff; font-weight: 800; font-size: 10px; }
.log-level-error { background: #c62828; }
.log-level-warning { background: #c27a08; }
.log-level-info { background: #2468c9; }

/* Filters */
.filter-panel { padding-bottom: 16px; }
.filters { display: grid; grid-template-columns: minmax(220px, 1.35fr) repeat(4, minmax(145px, .8fr)) auto; gap: 10px; align-items: end; margin: 0; }
.filters > div { min-width: 0; }
.filters label { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 5px; color: #5a6f88; }
.filters input, .filters select { width: 100%; min-width: 0; margin: 0; }
.filter-actions { display: flex; gap: 8px; align-items: center; }
.filter-actions .btn, .filter-actions button { white-space: nowrap; }
.result-count { padding: 6px 10px; border-radius: 999px; background: var(--ks-navy-soft); color: var(--ks-navy); font-size: 11px; font-weight: 800; }

/* Follow-ups */
.followup-section { margin-top: 27px; }
.section-heading { display: flex; justify-content: space-between; margin: 0 3px 13px; }
.section-heading h2 { margin: 0; font-size: 20px; color: var(--ks-navy-dark); }
.section-heading p { margin: 5px 0 0; color: var(--ks-muted); font-size: 13px; }
.followup-card { border-left: 4px solid var(--ks-navy); }
.followup-card-due { border-left-color: var(--ks-red); box-shadow: 0 10px 30px rgba(198,43,54,.1); }
.followup-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.followup-card-header h2 { margin: 0; font-size: 17px; }
.followup-card-header h2 a { text-decoration: none; }
.followup-card-header p { margin: 4px 0 0; color: var(--ks-muted); font-size: 12px; }
.followup-header-actions { display: flex; align-items: center; gap: 8px; }
.followup-when { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; width: 100%; background: #eef4fd; color: var(--ks-navy); border: 1px solid #d5e2f3; }
.followup-when strong { grid-row: 1 / span 2; align-self: center; }
.followup-when span { font-size: 13px; }
.followup-when small { color: #60738b; }
.followup-when-due { background: #fff0f1; color: #a61f2c; border-color: #f0c6cb; }
.followup-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.snooze-form { display: flex; gap: 7px; align-items: center; margin: 0; flex-wrap: wrap; }
.snooze-form select { width: 105px; margin: 0; }
.snooze-form input { width: 120px; margin: 0; }
.recent-notes { margin-top: 15px; border-top: 1px solid #e7edf4; padding-top: 13px; }
.empty-card { text-align: center; padding: 38px; }
.empty-card h3 { margin: 10px 0 5px; color: var(--ks-navy); }
.empty-card p { margin: 0; color: var(--ks-muted); }
.empty-icon { display: inline-grid; place-items: center; min-width: 48px; height: 38px; padding: 0 9px; border-radius: 10px; background: var(--ks-navy-soft); color: var(--ks-navy); font-weight: 900; font-size: 10px; }

/* Settings */
body.page-settings .panel { position: relative; padding-left: 24px; }
body.page-settings .panel::before { content: ""; position: absolute; left: 0; top: 19px; bottom: 19px; width: 4px; border-radius: 0 4px 4px 0; background: linear-gradient(var(--ks-navy), #4f78ad); }
body.page-settings .panel:nth-of-type(3n)::before { background: linear-gradient(var(--ks-red), #ff7b78); }
body.page-settings .panel table { border: 1px solid #e3eaf2; }
body.page-settings .note-item { background: #f7f9fc; border: 1px solid #e3eaf2; border-radius: 9px; padding: 12px; margin-bottom: 8px; }

/* Users */
.users-layout { display: grid; grid-template-columns: 1fr; gap: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid-full { grid-column: 1 / -1; }
.user-details-form { display: grid; grid-template-columns: minmax(135px,.8fr) minmax(200px,1.2fr) auto; gap: 7px; align-items: center; margin: 0; min-width: 490px; }
.user-details-form input, .users-table-panel select { margin: 0; min-height: 38px; }
.you-badge { display: inline-flex; padding: 4px 9px; border-radius: 999px; background: #e8f7ed; color: var(--ks-success); font-size: 10px; font-weight: 800; }

/* Modal refresh */
.modal-overlay { background: rgba(7,25,47,.62); backdrop-filter: blur(3px); }
.modal-box { border-radius: 16px; box-shadow: 0 24px 70px rgba(6,24,45,.28); border: 1px solid rgba(255,255,255,.4); }
.modal-box h2 { color: var(--ks-navy-dark); }
.attachment-preview-header { background: #f5f8fc; color: var(--ks-navy-dark); }

@media (max-width: 1180px) {
    .topnav-inner { grid-template-columns: 1fr auto; }
    .nav-links { grid-row: 2; grid-column: 1 / -1; padding-bottom: 10px; overflow-x: auto; justify-content: flex-start; }
    .nav-user { grid-column: 2; grid-row: 1; }
    .stat-grid { grid-template-columns: repeat(4, 1fr); }
    .filters { grid-template-columns: repeat(3, 1fr); }
    .filter-search { grid-column: span 2; }
}
@media (max-width: 760px) {
    .container { padding: 18px 12px 40px; }
    .topnav-inner { padding: 0 13px; min-height: 66px; gap: 10px; }
    .nav-logo-wrap { width: 47px; height: 38px; }
    .nav-brand-copy small, .nav-user-copy, .logout-link { display: none; }
    .nav-user { gap: 4px; }
    .nav-links { display: flex; gap: 3px; }
    .nav-links a { padding: 8px 10px; font-size: 12px; }
    .page-hero { align-items: flex-start; flex-direction: column; padding: 21px 19px; border-radius: 14px; }
    .page-hero h1 { font-size: 25px; }
    .hero-actions, .hero-metrics { width: 100%; justify-content: flex-start; }
    .hero-actions .btn { flex: 1; text-align: center; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-card { padding: 14px; }
    .mini-stat-row { grid-template-columns: 1fr; }
    .panel { padding: 17px; border-radius: 12px; }
    .panel-heading { flex-direction: column; }
    .filters { grid-template-columns: 1fr; }
    .filter-search { grid-column: auto; }
    .filter-actions { width: 100%; }
    .filter-actions button, .filter-actions .btn { flex: 1; text-align: center; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid-full { grid-column: auto; }
    .followup-card-header { flex-direction: column; }
    .followup-header-actions { width: 100%; }
    .snooze-form { width: 100%; }
    .snooze-form select, .snooze-form input { flex: 1; width: auto; min-width: 110px; }
    .user-details-form { min-width: 560px; }
    .followup-alert-inner { padding: 9px 13px; }
}
@media (max-width: 420px) {
    .stat-grid { grid-template-columns: 1fr; }
    .hero-metrics span { flex: 1; }
}

/* =========================================================
   Global live follow-up popup — v4
   ========================================================= */
.nav-badge-hidden { display: none !important; }

.global-followup-popup {
    position: fixed;
    right: 22px;
    bottom: 22px;
    width: min(430px, calc(100vw - 28px));
    z-index: 5000;
    border: 1px solid rgba(111, 137, 169, .36);
    border-radius: 17px;
    background: #fff;
    color: var(--ks-text, #16293e);
    box-shadow: 0 24px 70px rgba(5, 27, 56, .28), 0 8px 20px rgba(5, 27, 56, .13);
    overflow: hidden;
    opacity: 0;
    transform: translateY(18px) scale(.98);
    transition: opacity .22s ease, transform .22s ease;
}
.global-followup-popup[hidden] { display: none !important; }
.global-followup-popup.is-visible { opacity: 1; transform: translateY(0) scale(1); }
.global-followup-popup.is-busy { opacity: .88; }
.global-followup-accent { height: 5px; background: linear-gradient(90deg, var(--ks-red, #ea3345), #ff6b67 48%, var(--ks-gold, #ffc72c)); }
.global-followup-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 17px 18px 13px;
    color: #fff;
    background: linear-gradient(120deg, var(--ks-navy, #0b356d) 0%, #0e427f 66%, #142e4f 100%);
}
.global-followup-heading { display: flex; align-items: center; gap: 11px; min-width: 0; }
.global-followup-bell {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 11px;
    background: rgba(255, 255, 255, .12);
    font-size: 19px;
    animation: globalFollowupBell 1.4s ease-in-out infinite;
    transform-origin: 50% 10%;
}
.global-followup-kicker { display: block; margin-bottom: 2px; color: #ffd55a; font-size: 9px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.global-followup-header h2 { margin: 0; color: #fff; font-size: 20px; line-height: 1.15; }
.global-followup-position { flex: 0 0 auto; padding: 5px 9px; border: 1px solid rgba(255,255,255,.2); border-radius: 999px; color: #eaf2fc; background: rgba(255,255,255,.08); font-size: 10px; font-weight: 800; }
.global-followup-body { padding: 15px 18px 12px; }
.global-followup-lead-row { display: flex; align-items: center; gap: 11px; }
.global-followup-initial {
    display: grid;
    place-items: center;
    width: 41px;
    height: 41px;
    flex: 0 0 41px;
    border-radius: 12px;
    color: var(--ks-navy, #0b356d);
    background: #eaf2fd;
    font-size: 16px;
    font-weight: 900;
}
.global-followup-lead-row strong { display: block; color: var(--ks-navy-dark, #092a56); font-size: 16px; line-height: 1.25; }
.global-followup-lead-row > div { min-width: 0; }
.global-followup-contact { display: block; }
#global-followup-contact { display: block; margin-top: 3px; color: #6a7e94; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#global-followup-contact a { color: #58708c; text-decoration: none; }
#global-followup-contact a:hover { color: var(--ks-navy, #0b356d); text-decoration: underline; }
.global-followup-due { margin-top: 13px; padding: 9px 11px; border: 1px solid #f2c7cc; border-radius: 9px; background: #fff1f2; color: #a11d2b; font-size: 12px; font-weight: 750; }
.global-followup-note { margin-top: 9px; padding: 9px 11px; border-left: 3px solid #8ba9ce; border-radius: 0 8px 8px 0; background: #f5f8fc; color: #405771; font-size: 12px; line-height: 1.45; }
.global-followup-sound { display: flex; align-items: center; gap: 7px; margin-top: 10px; color: #2d6b42; font-size: 10px; font-weight: 800; }
.global-followup-sound > span { width: 7px; height: 7px; border-radius: 50%; background: #2ca35b; box-shadow: 0 0 0 4px rgba(44,163,91,.12); animation: globalFollowupPulse 1.25s ease-in-out infinite; }
.global-followup-sound.sound-waiting { color: #8a5d08; }
.global-followup-sound.sound-waiting > span { background: #e3a213; box-shadow: 0 0 0 4px rgba(227,162,19,.13); }
.global-followup-error { margin-top: 9px; color: #ad1d2b; font-size: 11px; font-weight: 700; }
.global-followup-controls { display: flex; align-items: stretch; justify-content: space-between; gap: 10px; padding: 0 18px 16px; }
.global-followup-snooze { display: grid; grid-template-columns: 85px 96px auto; gap: 6px; min-width: 0; }
.global-followup-snooze select,
.global-followup-snooze input { width: 100%; min-width: 0; min-height: 38px; height: 38px; margin: 0; padding: 7px 9px; font-size: 11px; }
.global-followup-snooze button,
.global-followup-open { min-height: 38px; margin: 0; white-space: nowrap; }
.global-followup-open { background: var(--ks-red, #ea3345); }
.global-followup-footer { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 8px 12px; border-top: 1px solid #e5ebf2; background: #f7f9fc; color: #64778d; font-size: 10px; font-weight: 700; }
.global-followup-arrow { display: grid; place-items: center; width: 28px; height: 27px; min-height: 0; padding: 0; border-radius: 7px; background: #fff; color: var(--ks-navy, #0b356d); border: 1px solid #d3deea; box-shadow: none; }
.global-followup-arrow:hover { background: #eaf2fd; color: var(--ks-navy-dark, #092a56); box-shadow: none; transform: none; }

@keyframes globalFollowupBell {
    0%, 55%, 100% { transform: rotate(0); }
    62% { transform: rotate(12deg); }
    70% { transform: rotate(-11deg); }
    78% { transform: rotate(8deg); }
    86% { transform: rotate(-5deg); }
    94% { transform: rotate(2deg); }
}
@keyframes globalFollowupPulse {
    0%, 100% { opacity: .62; transform: scale(.9); }
    50% { opacity: 1; transform: scale(1.12); }
}

@media (max-width: 560px) {
    .global-followup-popup { right: 10px; bottom: 10px; width: calc(100vw - 20px); border-radius: 14px; }
    .global-followup-header { padding: 14px; }
    .global-followup-body { padding: 13px 14px 10px; }
    .global-followup-controls { flex-direction: column; padding: 0 14px 14px; }
    .global-followup-snooze { grid-template-columns: .8fr 1fr auto; }
    .global-followup-open { width: 100%; }
}


/* Follow-up sound reliability — v4.1 */
.nav-alert-sound {
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid #d8a423;
    border-radius: 9px;
    background: #fff7d9;
    color: #714b00;
    box-shadow: none;
    font-size: 10px;
    font-weight: 850;
    white-space: nowrap;
}
.nav-alert-sound:hover,
.nav-alert-sound.needs-attention {
    background: #ffeaa0;
    color: #573900;
    box-shadow: 0 0 0 4px rgba(255, 199, 44, .16);
    transform: none;
}
.nav-alert-sound[hidden] { display: none !important; }
.global-followup-sound { flex-wrap: wrap; }
.global-followup-sound .global-followup-sound-dot {
    width: 7px;
    height: 7px;
    flex: 0 0 7px;
    border-radius: 50%;
    background: #2ca35b;
    box-shadow: 0 0 0 4px rgba(44,163,91,.12);
    animation: globalFollowupPulse 1.25s ease-in-out infinite;
}
.global-followup-sound.sound-waiting .global-followup-sound-dot {
    background: #e3a213;
    box-shadow: 0 0 0 4px rgba(227,162,19,.13);
}
.global-followup-sound.sound-error { color: #a11d2b; }
.global-followup-enable-sound {
    min-height: 28px;
    margin: 0 0 0 auto;
    padding: 5px 9px;
    border-radius: 7px;
    background: #efb41e;
    color: #3c2a00;
    box-shadow: none;
    font-size: 10px;
    font-weight: 900;
}
.global-followup-enable-sound:hover {
    background: #ffc72c;
    color: #2f2100;
    box-shadow: none;
    transform: none;
}
.global-followup-enable-sound[hidden] { display: none !important; }
#global-followup-audio { display: none; }
@media (max-width: 760px) {
    .nav-alert-sound { padding: 7px 8px; font-size: 0; }
    .nav-alert-sound::first-letter { font-size: 14px; }
}

/* Follow-up popup refinements — v4.2 */
.global-followup-popup {
    width: min(480px, calc(100vw - 28px));
}
.global-followup-note {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 8px;
}
.global-followup-note[hidden] { display: none !important; }
.global-followup-note-label {
    color: #6d8198;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
    white-space: nowrap;
}
#global-followup-note-text {
    min-width: 0;
    color: #183b66;
    font-size: 12px;
    line-height: 1.4;
    overflow-wrap: anywhere;
}
.global-followup-sound {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center;
    width: 100%;
    min-height: 24px;
    gap: 8px;
    overflow: hidden;
}
.global-followup-sound > .global-followup-sound-dot {
    width: 7px;
    height: 7px;
    flex: 0 0 7px;
}
.global-followup-sound > #global-followup-sound-text {
    width: auto;
    height: auto;
    flex: 1 1 auto;
    min-width: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    animation: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.global-followup-sound.sound-other-tab {
    color: #315d91;
}
.global-followup-sound.sound-other-tab .global-followup-sound-dot {
    background: #3e79bd;
    box-shadow: 0 0 0 4px rgba(62,121,189,.13);
}
.global-followup-enable-sound {
    flex: 0 0 auto;
    margin-left: auto;
}
.global-followup-controls {
    clear: both;
    border-top: 1px solid #edf1f6;
    padding-top: 12px;
}
@media (max-width: 560px) {
    .global-followup-note {
        grid-template-columns: 1fr;
        gap: 3px;
    }
    .global-followup-snooze {
        grid-template-columns: minmax(76px, .8fr) minmax(88px, 1fr) auto;
    }
}

/* =========================================================
   Lead notes timeline — v5.4
   ========================================================= */
.lead-notes-panel {
    padding: 24px;
}
.lead-notes-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding-bottom: 17px;
    margin-bottom: 18px;
    border-bottom: 1px solid #dfe8f2;
}
.lead-notes-heading h2 {
    margin: 2px 0 5px;
    color: var(--ks-navy-dark, #102f55);
    font-size: 21px;
}
.lead-notes-heading p {
    margin: 0;
    color: var(--ks-muted, #66788d);
    font-size: 13px;
    line-height: 1.5;
}
.lead-notes-eyebrow {
    display: block;
    color: var(--ks-red, #ef3340);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .09em;
    text-transform: uppercase;
}
.lead-notes-count {
    flex: 0 0 auto;
    padding: 6px 11px;
    border: 1px solid #cddced;
    border-radius: 999px;
    background: #edf4fc;
    color: var(--ks-navy, #123f76);
    font-size: 11px;
    font-weight: 800;
}
.lead-note-compose {
    margin: 0 0 22px;
    padding: 16px;
    border: 1px solid #d8e3ef;
    border-radius: 13px;
    background: linear-gradient(180deg, #fbfdff 0%, #f6f9fd 100%);
}
.lead-note-compose label {
    display: block;
    margin: 0 0 8px;
    color: var(--ks-navy-dark, #102f55);
    font-size: 13px;
    font-weight: 800;
}
.lead-note-compose textarea {
    min-height: 112px;
    margin: 0;
    padding: 13px 14px;
    border-color: #c7d6e7;
    border-radius: 10px;
    background: #fff;
    color: #16293e;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.55;
    resize: vertical;
}
.lead-note-compose textarea:focus {
    border-color: var(--ks-navy, #123f76);
    box-shadow: 0 0 0 3px rgba(18, 63, 118, .11);
    outline: none;
}
.lead-note-compose-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 11px;
}
.lead-note-compose-footer span {
    color: #718298;
    font-size: 11px;
    line-height: 1.4;
}
.lead-note-submit {
    flex: 0 0 auto;
    min-width: 104px;
}
.lead-notes-list {
    display: grid;
    gap: 12px;
}
.lead-notes-panel .note-item.lead-note-card {
    margin: 0;
    padding: 16px 17px;
    border: 1px solid #dce6f0;
    border-left: 4px solid var(--ks-navy, #123f76);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 5px 16px rgba(14, 48, 86, .055);
    font-size: inherit;
}
.lead-note-card-header {
    display: flex;
    align-items: center;
    gap: 11px;
    padding-bottom: 11px;
    margin-bottom: 12px;
    border-bottom: 1px solid #edf1f5;
}
.lead-note-avatar {
    display: inline-grid;
    place-items: center;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: linear-gradient(145deg, #e7f0fb, #d6e5f7);
    color: var(--ks-navy, #123f76);
    font-size: 14px;
    font-weight: 900;
    text-transform: uppercase;
}
.lead-note-author {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.lead-note-author strong {
    color: var(--ks-navy-dark, #102f55);
    font-size: 14px;
    line-height: 1.25;
}
.lead-note-author span {
    color: #718298;
    font-size: 11px;
    line-height: 1.4;
}
.lead-note-author em {
    margin-left: 4px;
    color: #8a9aab;
    font-style: normal;
}
.lead-note-body {
    color: #1e334a;
    font-size: 16px;
    line-height: 1.65;
    overflow-wrap: anywhere;
    white-space: normal;
}
.lead-notes-empty {
    display: grid;
    justify-items: center;
    gap: 6px;
    padding: 28px 18px;
    border: 1px dashed #cbd8e7;
    border-radius: 12px;
    background: #f8fbff;
    text-align: center;
}
.lead-notes-empty-icon {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: #e5effb;
    color: var(--ks-navy, #123f76);
    font-size: 13px;
    font-weight: 900;
}
.lead-notes-empty strong {
    color: var(--ks-navy-dark, #102f55);
    font-size: 15px;
}
.lead-notes-empty p {
    max-width: 430px;
    margin: 0;
    color: #718298;
    font-size: 12px;
    line-height: 1.5;
}
@media (max-width: 680px) {
    .lead-notes-panel { padding: 18px; }
    .lead-notes-heading { align-items: flex-start; }
    .lead-note-compose-footer { align-items: stretch; flex-direction: column; }
    .lead-note-submit { width: 100%; }
    .lead-note-body { font-size: 15px; }
}
