/* ══════════════════════════════════════════════════════════
   Leads Dashboard — production styles (scoped to .cl-app)
   Aggressive theme reset on the inside so theme typography/colors
   don't leak into the dashboard.
   ══════════════════════════════════════════════════════════ */

.cl-app, .cl-app *, .cl-app *::before, .cl-app *::after { box-sizing: border-box; }

/* Hard reset everything inside .cl-app to neutral defaults */
.cl-app, .cl-app * {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
    letter-spacing: normal !important;
    text-transform: none;
    text-shadow: none !important;
}
.cl-app h1, .cl-app h2, .cl-app h3, .cl-app h4, .cl-app h5, .cl-app h6,
.cl-app p, .cl-app span, .cl-app strong, .cl-app em, .cl-app a,
.cl-app dt, .cl-app dd, .cl-app td, .cl-app th, .cl-app li,
.cl-app input, .cl-app textarea, .cl-app button, .cl-app label, .cl-app div {
    font-family: inherit !important;
    line-height: 1.5;
}
.cl-app h1, .cl-app h2, .cl-app h3, .cl-app h4, .cl-app h5, .cl-app h6 {
    margin: 0 !important;
    padding: 0 !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    background: none !important;
    border: none !important;
    text-decoration: none !important;
}
.cl-app h1 { font-size: 22px !important; line-height: 1.3 !important; }
.cl-app h2 { font-size: 14px !important; line-height: 1.4 !important; }
.cl-app h3 { font-size: 14px !important; line-height: 1.4 !important; }
.cl-app .cl-login h1 { font-size: 26px !important; }
.cl-app .cl-section-head h2 { font-size: 13px !important; color: #0f172a !important; }
.cl-app .cl-stat-num { font-size: 26px !important; line-height: 1 !important; }
.cl-app p { margin: 0; }
.cl-app ul, .cl-app ol { list-style: none; padding: 0; margin: 0; }
.cl-app a { color: inherit; text-decoration: none; }
.cl-app a:hover, .cl-app a:focus { text-decoration: none; }
.cl-app table { border-collapse: collapse; }
.cl-app th { text-align: left; font-weight: 700; }
.cl-app button { font: inherit; cursor: pointer; }
.cl-app input, .cl-app textarea { font: inherit; color: inherit; }

/* Re-uppercase only the section headers that should be uppercase */
.cl-app .cl-section-head h2,
.cl-app .cl-table th,
.cl-app .cl-stat-lbl {
    text-transform: uppercase !important;
    letter-spacing: .5px !important;
}

.cl-app {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --border: #e6e8ef;
    --border-soft: #f0f1f6;
    --text: #0f172a;
    --muted: #64748b;
    --soft: #f1f5f9;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --success: #10b981;
    --success-soft: #d1fae5;
    --warn: #f59e0b;
    --warn-soft: #fef3c7;
    --danger: #ef4444;
    --danger-soft: #fee2e2;
    --radius: 12px;
    --shadow-sm: 0 1px 2px rgba(15,23,42,.04);

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    margin: 0 -20px;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
    font-size: 14px;
}

/* ───── Login ───── */
.cl-login {
    min-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 16px;
    background: var(--bg);
}
.cl-login-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 40px 36px;
    box-shadow: 0 4px 24px rgba(15,23,42,.06);
    text-align: center;
}
.cl-login-badge {
    width: 56px; height: 56px;
    margin: 0 auto 18px;
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
}
.cl-login h1 { margin: 0 0 6px; font-size: 26px; font-weight: 700; }
.cl-login-sub { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
.cl-login-error {
    background: var(--danger-soft); color: var(--danger);
    border-radius: 10px; padding: 10px 14px;
    margin: 0 0 14px; font-size: 13px; font-weight: 500;
}
.cl-login input[type=password] {
    width: 100%; padding: 13px 16px;
    border: 1px solid var(--border); border-radius: 12px;
    font-size: 16px; outline: none;
    transition: border-color .15s, box-shadow .15s;
    margin: 0 0 12px;
    font-family: inherit;
}
.cl-login input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}
.cl-login button {
    width: 100%; padding: 13px 16px; border: 0;
    background: var(--primary); color: #fff;
    border-radius: 12px; font-weight: 600; font-size: 15px;
    cursor: pointer;
    transition: background .15s, transform .05s;
    font-family: inherit;
}
.cl-login button:hover { background: var(--primary-hover); }
.cl-login button:active { transform: translateY(1px); }
.cl-login-hint { margin: 12px 0 0; font-size: 12px; color: var(--muted); }

/* ───── Header ───── */
.cl-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}
.cl-header-inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.cl-brand { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: 17px; }
.cl-brand-dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}
.cl-header-right { display: flex; align-items: center; gap: 16px; font-size: 13px; }
.cl-header-count { color: var(--muted); }
.cl-logout, .cl-back {
    color: var(--muted); text-decoration: none;
    padding: 7px 13px; border-radius: 8px;
    transition: background .15s, color .15s;
    font-weight: 500;
}
.cl-logout:hover, .cl-back:hover { background: var(--soft); color: var(--text); }
.cl-back { color: var(--text); }

/* ───── Main ───── */
.cl-main {
    max-width: 1320px;
    margin: 0 auto;
    padding: 28px;
}

/* ───── Stats ───── */
.cl-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 22px;
}
.cl-stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
}
.cl-stat-row { display: flex; align-items: center; justify-content: space-between; }
.cl-stat-num { font-size: 26px; font-weight: 700; line-height: 1; }
.cl-stat-lbl { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; margin-top: 8px; }
.cl-stat-ico { width: 36px; height: 36px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 17px; }
.cl-stat-ico-warn { background: var(--warn-soft); }
.cl-stat-ico-ok   { background: var(--success-soft); }
.cl-stat-ico-new  { background: var(--primary-soft); }
.cl-stat-ico-all  { background: var(--soft); }

/* ───── Toolbar ───── */
.cl-toolbar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.cl-search-wrap { flex: 1; min-width: 260px; position: relative; }
.cl-search-wrap::before {
    content: '🔍';
    position: absolute;
    left: 14px; top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    opacity: .5;
    pointer-events: none;
}
.cl-search-wrap input {
    width: 100%;
    padding: 11px 14px 11px 38px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    font-size: 14px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    font-family: inherit;
}
.cl-search-wrap input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.cl-filters {
    display: flex; gap: 2px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 3px;
}
.cl-filter {
    background: transparent;
    border: 0;
    padding: 7px 14px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    transition: background .15s, color .15s;
    font-family: inherit;
}
.cl-filter:hover { color: var(--text); }
.cl-filter-active { background: var(--primary) !important; color: #fff !important; }

/* ───── Table ───── */
.cl-table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.cl-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.cl-table th {
    background: #fafbfc;
    color: var(--muted);
    font-weight: 600;
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.cl-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}
.cl-table tbody tr {
    cursor: pointer;
    transition: background .12s;
    text-decoration: none;
    color: var(--text);
}
.cl-table tbody tr:hover { background: #fafbfc; }
.cl-table tbody tr:last-child td { border-bottom: 0; }
.cl-table a.cl-row-link { color: inherit; text-decoration: none; display: contents; }

.cl-status-col { width: 60px; padding-left: 20px !important; }
.cl-dot {
    display: inline-block;
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--muted);
}
.cl-dot-new { background: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.cl-dot-pending { background: var(--warn); }
.cl-dot-done { background: var(--success); }
.cl-dot-incomplete { background: #94a3b8; }

.cl-badge-new {
    display: inline-block;
    background: var(--primary); color: #fff;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .5px;
    margin-right: 6px;
    vertical-align: middle;
}
.cl-badge-incomplete {
    display: inline-block;
    background: #94a3b8; color: #fff;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .5px;
    margin-right: 6px;
    vertical-align: middle;
}
.cl-tr-incomplete { background: rgba(148,163,184,.04); }

/* Sortable column headers */
.cl-th-sort {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 26px !important;
    transition: color .15s, background .15s;
}
.cl-th-sort:hover { color: var(--text); background: #f5f6fa; }
.cl-th-sort::after {
    content: '↕';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    opacity: .3;
    font-size: 11px;
    font-weight: 700;
}
.cl-th-sort-asc::after { content: '↑'; opacity: 1; color: var(--primary); }
.cl-th-sort-desc::after { content: '↓'; opacity: 1; color: var(--primary); }
.cl-th-sort-asc, .cl-th-sort-desc { color: var(--text); }

.cl-case-num {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    color: var(--text);
    background: var(--soft);
    padding: 3px 8px;
    border-radius: 5px;
    font-weight: 600;
}

.cl-name-cell { display: flex; align-items: center; gap: 11px; }
.cl-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
    overflow: hidden;
}
.cl-avatar img { width: 100%; height: 100%; object-fit: cover; }
.cl-name-text { font-weight: 600; }
.cl-name-sub { color: var(--muted); font-size: 12px; margin-top: 1px; word-break: break-word; }
.cl-table-amount { font-variant-numeric: tabular-nums; font-weight: 500; white-space: nowrap; }
.cl-table-files { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 13px; }
.cl-table-time { color: var(--muted); font-size: 13px; white-space: nowrap; }
.cl-tr-done { opacity: .55; }
.cl-tr-done:hover { opacity: 1; }

.cl-empty {
    padding: 60px 20px;
    text-align: center;
    color: var(--muted);
}

/* ───── Detail Hero ───── */
.cl-detail-hero {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 28px;
    margin-bottom: 18px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
}
.cl-detail-hero h1 { font-size: 22px; font-weight: 700; margin: 0 0 6px; }
.cl-detail-hero-meta {
    display: flex; gap: 14px; flex-wrap: wrap;
    color: var(--muted); font-size: 13px;
    align-items: center;
}
.cl-detail-hero-meta .cl-case-num { font-size: 12px; }
.cl-detail-hero-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.cl-processed-by { font-size: 12px; color: var(--muted); }

.cl-toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; }
.cl-toggle input { display: none; }
.cl-toggle-slider {
    width: 42px; height: 24px;
    background: #cbd5e1;
    border-radius: 999px;
    position: relative;
    transition: background .2s;
}
.cl-toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 18px; height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.cl-toggle input:checked + .cl-toggle-slider { background: var(--success); }
.cl-toggle input:checked + .cl-toggle-slider::after { transform: translateX(18px); }
.cl-toggle-label { font-size: 14px; font-weight: 500; }

/* ───── Detail Grid ───── */
.cl-detail-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 18px;
    align-items: start;
}
@media (max-width: 1024px) {
    .cl-detail-grid { grid-template-columns: 1fr; }
    .cl-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ───── Section ───── */
.cl-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.cl-section-head {
    padding: 14px 22px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #fafbfc;
}
.cl-section-head h2 {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    margin: 0;
}
.cl-section-body { padding: 18px 22px; }

.cl-pill {
    background: var(--primary-soft);
    color: var(--primary);
    padding: 3px 9px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
}

/* ───── Data tables ───── */
.cl-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.cl-data-table tr:last-child td { border-bottom: 0; }
.cl-data-table td {
    padding: 11px 0;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: top;
    word-break: break-word;
}
.cl-data-table td:first-child {
    width: 220px;
    color: var(--muted);
    font-weight: 500;
    padding-right: 16px;
}
.cl-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 12px; word-break: break-all; }
@media (max-width: 600px) {
    .cl-data-table td { display: block; padding: 4px 0; }
    .cl-data-table td:first-child { width: auto; font-size: 12px; }
    .cl-data-table tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--border-soft); }
    .cl-data-table tr:last-child { border-bottom: 0; }
}

/* ───── Gallery ───── */
.cl-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
}
.cl-gallery-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 9px;
    overflow: hidden;
    background: var(--soft);
    display: block;
    text-decoration: none;
    transition: transform .15s, box-shadow .15s;
}
.cl-gallery-item:hover { transform: scale(1.04); box-shadow: 0 4px 12px rgba(15,23,42,.12); }
.cl-gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ───── File list ───── */
.cl-filelist { list-style: none; padding: 0; margin: 0; }
.cl-filelist li { margin-bottom: 6px; }
.cl-filelist li:last-child { margin-bottom: 0; }
.cl-filelist a {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 14px;
    background: var(--soft);
    border-radius: 9px;
    text-decoration: none;
    color: var(--text);
    font-size: 13px;
    transition: background .15s, color .15s, border-color .15s;
    border: 1px solid transparent;
}
.cl-filelist a:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.cl-file-icon {
    width: 32px; height: 32px;
    background: var(--surface);
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.cl-file-name { flex: 1; word-break: break-all; font-weight: 500; }
.cl-file-size { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* ───── Notes ───── */
.cl-notes-section { position: sticky; top: 76px; }
.cl-note-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.cl-note-form input,
.cl-note-form textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 10px 12px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    background: var(--surface);
    resize: vertical;
    transition: border-color .15s, box-shadow .15s;
}
.cl-note-form input:focus,
.cl-note-form textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.cl-note-form button {
    background: var(--primary); color: #fff;
    border: 0; padding: 10px 14px; border-radius: 9px;
    cursor: pointer; font-weight: 600; font-size: 13px;
    transition: background .15s;
    font-family: inherit;
}
.cl-note-form button:hover { background: var(--primary-hover); }
.cl-note-form button:disabled { opacity: .5; cursor: not-allowed; }

.cl-notes-list { display: flex; flex-direction: column; gap: 9px; }
.cl-notes-empty {
    text-align: center;
    padding: 16px;
    color: var(--muted);
    font-size: 13px;
    background: var(--soft);
    border-radius: 9px;
}
.cl-note {
    background: var(--warn-soft);
    border-radius: 9px;
    padding: 11px 13px;
    position: relative;
    border-left: 3px solid var(--warn);
}
.cl-note-head {
    display: flex; justify-content: space-between; gap: 10px;
    font-size: 12px; margin-bottom: 5px;
}
.cl-note-head strong { font-weight: 600; }
.cl-note-head span { color: var(--muted); }
.cl-note-body { font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.cl-note-del {
    position: absolute; top: 6px; right: 6px;
    background: transparent; border: 0;
    color: var(--muted); cursor: pointer;
    font-size: 11px; padding: 4px 6px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity .15s, color .15s, background .15s;
    font-family: inherit;
}
.cl-note:hover .cl-note-del { opacity: 1; }
.cl-note-del:hover { color: var(--danger); background: rgba(239,68,68,.1); }

/* ───── Mini info ───── */
.cl-mini-info {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 14px;
    font-size: 12px;
    margin: 0;
}
.cl-mini-info dt { color: var(--muted); font-weight: 500; }
.cl-mini-info dd { color: var(--text); font-weight: 500; text-align: right; word-break: break-all; margin: 0; }

/* ───── Conversation thread ───── */
.cl-thread { display: flex; flex-direction: column; gap: 12px; }
.cl-thread-item {
    padding: 12px 14px;
    background: var(--soft);
    border-radius: 10px;
    border-left: 3px solid var(--primary);
}
.cl-thread-head {
    display: flex; justify-content: space-between; gap: 10px;
    margin-bottom: 6px; font-size: 13px;
}
.cl-thread-head strong { font-weight: 600; }
.cl-thread-head span { color: var(--muted); }
.cl-thread-body { font-size: 13px; line-height: 1.5; }
.cl-thread-body p { margin: 4px 0; }
.cl-thread-reply {
    margin-top: 10px;
    padding: 9px 11px;
    background: var(--surface);
    border-radius: 8px;
    font-size: 13px;
}
.cl-thread-reply-lbl {
    display: block;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 4px;
}

/* ───── Mobile ───── */
@media (max-width: 720px) {
    .cl-app { margin: 0 -15px; }
    .cl-main { padding: 18px 14px; }
    .cl-stats { grid-template-columns: repeat(2, 1fr); }
    .cl-table { font-size: 13px; }
    .cl-table th, .cl-table td { padding: 10px 12px; }
    .cl-hide-mobile { display: none !important; }
    .cl-detail-hero { padding: 16px 18px; }
    .cl-detail-hero h1 { font-size: 19px; }
    .cl-section-body { padding: 14px 16px; }
    .cl-section-head { padding: 12px 16px; }
}
