:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --border: #e1e7ef;
    --text: #162033;
    --muted: #667085;
    --primary: #155eef;
    --primary-dark: #0f3b9f;
    --success: #067647;
    --warning: #b54708;
    --danger: #b42318;
    --shadow: 0 14px 34px rgba(16, 24, 40, 0.08);
    --sidebar: #111827;
    --sidebar-soft: #1f2937;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, Arial, Helvetica, sans-serif;
}

a {
    color: var(--primary);
}

.app-body {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px;
    background: var(--sidebar);
    color: #ffffff;
    overflow: hidden;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
    min-height: 44px;
}

.brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 8px;
    background: var(--primary);
    font-weight: 800;
}

.brand strong,
.brand small {
    display: block;
}

.brand-copy {
    min-width: 0;
}

.brand small,
.side-foot span {
    color: #a9b4c7;
}

.sidebar-toggle {
    display: inline-grid;
    width: 38px;
    height: 38px;
    min-height: 38px;
    margin-left: auto;
    place-items: center;
    gap: 4px;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
}

.sidebar-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: #ffffff;
}

.side-nav {
    display: grid;
    gap: 8px;
}

.side-nav a,
.side-foot a {
    color: #dbe4f0;
    text-decoration: none;
}

.side-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border-radius: 8px;
}

.nav-icon {
    display: inline-grid;
    width: 26px;
    height: 26px;
    flex: 0 0 26px;
    place-items: center;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    font-size: 12px;
    font-weight: 800;
}

.side-nav a.active,
.side-nav a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.side-foot {
    position: absolute;
    right: 22px;
    bottom: 22px;
    left: 22px;
    display: grid;
    gap: 8px;
    font-size: 13px;
}

.side-undo-form {
    display: grid;
    gap: 10px;
    margin-top: 18px;
    padding: 12px;
    border: 1px solid rgba(251, 146, 60, 0.45);
    border-radius: 8px;
    background: rgba(251, 146, 60, 0.12);
}

.side-undo-form span {
    color: #fed7aa;
    font-size: 12px;
    line-height: 1.4;
}

.side-undo-form button {
    width: 100%;
    min-height: 34px;
    border-color: #fb923c;
    background: #fb923c;
    color: #111827;
    font-weight: 800;
}

.app-shell {
    min-width: 0;
}

.sidebar-collapsed {
    grid-template-columns: 76px minmax(0, 1fr);
}

.sidebar-collapsed .sidebar {
    padding: 18px 12px;
}

.sidebar-collapsed .brand {
    justify-content: center;
    flex-wrap: wrap;
}

.sidebar-collapsed .brand-mark {
    width: 38px;
    height: 38px;
}

.sidebar-collapsed .brand-copy,
.sidebar-collapsed .nav-label,
.sidebar-collapsed .side-foot span,
.sidebar-collapsed .side-undo-form span {
    display: none;
}

.sidebar-collapsed .sidebar-toggle {
    margin-left: 0;
}

.sidebar-collapsed .side-nav a {
    justify-content: center;
    padding: 10px;
}

.sidebar-collapsed .side-foot {
    right: 12px;
    left: 12px;
}

.sidebar-collapsed .side-foot a,
.sidebar-collapsed .side-undo-form button {
    padding-right: 6px;
    padding-left: 6px;
    font-size: 0;
}

.sidebar-collapsed .side-foot a::after {
    content: "Out";
    font-size: 12px;
}

.sidebar-collapsed .side-undo-form button::after {
    content: "Undo";
    font-size: 12px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 22px 32px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 10px 28px rgba(16, 24, 40, 0.04);
}

.topbar.glass {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
}

.topbar h1 {
    margin: 6px 0;
    font-size: 29px;
    line-height: 1.15;
    letter-spacing: 0;
}

.topbar p {
    margin: 0;
    color: var(--muted);
    max-width: 760px;
    line-height: 1.5;
}

.breadcrumb {
    color: var(--muted);
    font-size: 13px;
    text-decoration: none;
}

.header-kicker {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.live-pill,
.header-stat {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 10px;
    border: 1px solid #bbf7d0;
    border-radius: 999px;
    background: #f0fdf4;
    color: var(--success);
    font-size: 12px;
    font-weight: 800;
}

.header-stat {
    gap: 4px;
    border-color: var(--border);
    background: #ffffff;
    color: #344054;
}

.header-stat strong {
    color: var(--text);
}

.top-actions,
.bulk-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.top-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

main,
.content {
    padding: 24px 32px 40px;
}

.metrics,
.lead-hero {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.lead-hero {
    grid-template-columns: 2fr 1fr 1fr;
}

.metrics article,
.panel,
.lead-card,
.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.metrics article,
.lead-card {
    padding: 18px;
}

.metrics span,
.section-head span,
.eyebrow,
.lead-card p,
.source-box span,
.info-grid span {
    color: var(--muted);
    font-size: 13px;
}

.metrics strong {
    display: block;
    margin-top: 8px;
    font-size: 30px;
}

.lead-card h2 {
    margin: 8px 0 14px;
    font-size: 26px;
}

.big-value {
    display: block;
    margin-top: 10px;
    font-size: 20px;
    line-height: 1.3;
}

.primary-contact {
    background: linear-gradient(135deg, #ffffff 0%, #eef4ff 100%);
}

.contact-grid,
.detail-layout,
.info-grid {
    display: grid;
    gap: 14px;
}

.contact-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.contact-action {
    display: grid;
    gap: 5px;
    min-height: 70px;
    text-align: left;
    background: #ffffff;
    color: var(--text);
    border-color: var(--border);
}

.contact-action span {
    color: var(--muted);
    font-size: 12px;
}

.contact-action.copied {
    border-color: var(--success);
    background: #ecfdf3;
}

.detail-layout {
    grid-template-columns: minmax(0, 1.4fr) 420px;
    align-items: start;
}

.panel {
    padding: 18px;
    margin-bottom: 18px;
}

.detail-panel,
.action-panel {
    padding: 22px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.section-head.clean {
    align-items: flex-start;
    border-bottom: 1px solid var(--border);
    padding-bottom: 14px;
}

h2 {
    margin: 0 0 4px;
    font-size: 18px;
}

.info-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.info-grid div {
    min-height: 76px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
}

.info-grid strong {
    display: block;
    margin-top: 7px;
    word-break: break-word;
}

.source-box {
    display: grid;
    gap: 8px;
    margin-top: 14px;
    padding: 14px;
    border-radius: 8px;
    background: #eef4ff;
    word-break: break-word;
}

.stack-form {
    display: grid;
    gap: 14px;
}

.field {
    display: grid;
    gap: 6px;
}

.field label,
.login-box label {
    color: #344054;
    font-size: 13px;
    font-weight: 700;
}

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 10px;
    align-items: end;
}

.filters.advanced {
    grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
}

.filters input[type="search"] {
    grid-column: span 2;
    min-width: min(100%, 260px);
}

.preset-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

input,
select,
textarea,
button,
.button,
.clear,
.chip {
    min-height: 40px;
    border-radius: 8px;
    border: 1px solid #cdd6e1;
    padding: 9px 11px;
    font-size: 14px;
}

textarea {
    min-height: 120px;
    font-family: inherit;
    resize: vertical;
}

button,
.button {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    text-decoration: none;
    cursor: pointer;
}

.button.secondary,
.clear,
.chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #344054;
    text-decoration: none;
    background: #ffffff;
}

.chip {
    border-radius: 999px;
}

.chip.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.analytics-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.report-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.report-metrics article strong {
    font-size: 22px;
    line-height: 1.2;
}

.setting-list {
    display: grid;
    gap: 12px;
}

.setting-list div {
    display: grid;
    gap: 5px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
}

.setting-list span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.setting-list strong,
.setting-list code {
    word-break: break-word;
}

.bar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 0;
    border-top: 1px solid #eef2f6;
}

.bar-row span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: #ffffff;
}

th,
td {
    padding: 12px 10px;
    border-top: 1px solid #eef2f6;
    text-align: left;
    vertical-align: top;
}

.check-cell {
    width: 42px;
    min-width: 42px;
    text-align: center;
    vertical-align: middle;
}

.check-cell input {
    display: inline-grid;
    width: 16px;
    height: 16px;
    min-height: 16px;
    margin: 0;
    padding: 0;
}

th {
    position: sticky;
    top: 0;
    z-index: 2;
    color: #475467;
    background: #f8fafc;
    font-weight: 700;
}

tbody tr:hover {
    background: #f8fbff;
}

.source {
    max-width: 280px;
    word-break: break-word;
}

.badge,
.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    background: #eef4ff;
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
}

.status-pill.contacted,
.status-pill.qualified {
    background: #f0f9ff;
    color: #026aa2;
}

.status-pill.converted {
    background: #ecfdf3;
    color: var(--success);
}

.status-pill.not-interested,
.status-pill.spam,
.badge.warn {
    background: #fff6ed;
    color: var(--warning);
}

.badge.warn {
    margin-left: 6px;
}

.copy,
.small {
    min-height: 28px;
    padding: 4px 8px;
    font-size: 12px;
}

.copy {
    margin-right: 6px;
    background: #f8fafc;
    color: #344054;
    border-color: var(--border);
}

.mini-chart {
    display: flex;
    align-items: end;
    gap: 8px;
    min-height: 140px;
    padding-top: 12px;
}

.chart-bar {
    position: relative;
    display: flex;
    align-items: start;
    justify-content: center;
    width: 100%;
    min-width: 12px;
    background: linear-gradient(180deg, var(--primary), #84adff);
    border-radius: 6px 6px 0 0;
    color: #ffffff;
    font-size: 11px;
    padding-top: 4px;
}

.chart-bar:hover::after {
    position: absolute;
    right: 50%;
    bottom: calc(100% + 8px);
    z-index: 5;
    width: max-content;
    max-width: 220px;
    padding: 7px 9px;
    border-radius: 7px;
    background: #101828;
    color: #ffffff;
    content: attr(data-tooltip);
    font-size: 12px;
    transform: translateX(50%);
    box-shadow: var(--shadow);
}

.table-filter-bar {
    display: grid;
    grid-template-columns: minmax(260px, 420px);
    gap: 8px;
    margin-bottom: 12px;
}

.table-filter-bar input {
    min-height: 34px;
    padding: 7px 9px;
    font-size: 12px;
}

th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

th.sortable::after {
    content: " ↕";
    color: #98a2b3;
    font-weight: 700;
}

th.sortable.sort-asc::after {
    content: " ↑";
    color: var(--primary);
}

th.sortable.sort-desc::after {
    content: " ↓";
    color: var(--primary);
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 14px;
    color: var(--muted);
}

.pagination > div {
    display: flex;
    align-items: center;
    gap: 10px;
}

.timeline {
    display: grid;
    gap: 12px;
}

.timeline-item {
    display: grid;
    grid-template-columns: 18px 1fr;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
}

.dot {
    width: 10px;
    height: 10px;
    margin-top: 5px;
    border-radius: 50%;
    background: var(--primary);
}

.timeline-item p {
    margin: 0 0 6px;
}

.timeline-item span,
.timeline-empty span,
.muted {
    color: var(--muted);
    font-size: 13px;
}

.timeline-empty {
    display: grid;
    gap: 4px;
    padding: 18px;
    border: 1px dashed #cdd6e1;
    border-radius: 8px;
    background: var(--surface-soft);
}

.login-body {
    display: grid;
    min-height: 100vh;
    place-items: center;
    background: radial-gradient(circle at top, #e0eaff, var(--bg) 42%);
}

.login-box {
    width: min(420px, calc(100% - 32px));
    padding: 30px;
}

.login-box h1 {
    margin: 0 0 6px;
}

.login-box p {
    color: var(--muted);
}

.login-box form {
    display: grid;
    gap: 12px;
}

.alert {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 14px;
}

.alert.danger {
    background: #fef3f2;
    color: var(--danger);
}

.alert.success {
    background: #ecfdf3;
    color: var(--success);
}

.empty {
    color: var(--muted);
    text-align: center;
}

@media (max-width: 1280px) {
    .filters.advanced,
    .analytics-grid,
    .report-grid,
    .detail-layout,
    .info-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .table-filter-bar {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .app-body {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
    }

    .side-foot {
        position: static;
        margin-top: 20px;
    }

    .metrics,
    .grid,
    .filters,
    .filters.advanced,
    .lead-hero,
    .detail-layout,
    .info-grid,
    .contact-grid {
        grid-template-columns: 1fr;
    }

    .table-filter-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 700px) {
    .topbar,
    main,
    .content {
        padding-left: 16px;
        padding-right: 16px;
    }
}
