/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --sidebar-bg:   #000000;
    --accent:       #000000;
    --accent-hover: #222222;
    --success:      #1a7a3f;
    --warning:      #b45309;
    --danger:       #b91c1c;
    --bg:           #f4f4f4;
    --card:         #ffffff;
    --border:       #e0e0e0;
    --text:         #111111;
    --text-muted:   #666666;
    --shadow:       0 1px 3px rgba(0,0,0,.07), 0 4px 12px rgba(0,0,0,.05);
    --radius:       8px;
    --sidebar-w:    220px;
    --font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
img, svg { display: block; }

/* ── App Shell ── */
.app-shell { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.logo-mark {
    width: 32px; height: 32px;
    background: #ffffff;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 18px; color: #000000;
    font-family: Georgia, 'Times New Roman', serif;
    flex-shrink: 0;
}

.logo-text { color: #fff; font-weight: 600; font-size: 15px; letter-spacing: .3px; }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    color: rgba(255,255,255,.55);
    font-size: 14px;
    border-left: 3px solid transparent;
    transition: all .15s;
    cursor: pointer;
    text-decoration: none;
}

.nav-item:hover { color: #fff; background: rgba(255,255,255,.07); text-decoration: none; }
.nav-item.active { color: #fff; border-left-color: #ffffff; background: rgba(255,255,255,.1); }
.nav-item svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }

.sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid rgba(255,255,255,.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.user-name { color: rgba(255,255,255,.5); font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.btn-logout { background: none; border: 1px solid rgba(255,255,255,.2); color: rgba(255,255,255,.55);
    padding: 4px 10px; border-radius: 4px; font-size: 12px; cursor: pointer; transition: all .15s; }
.btn-logout:hover { border-color: rgba(255,255,255,.5); color: #fff; }

/* ── Main Content ── */
.main-content { margin-left: var(--sidebar-w); flex: 1; padding: 28px 32px; min-height: 100vh; }

/* ── Page Header ── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.page-header h1 { font-size: 22px; font-weight: 600; }
.page-actions { display: flex; gap: 10px; }

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: 6px; border: none;
    font-size: 14px; font-weight: 500; cursor: pointer;
    transition: all .15s; text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: #000000; color: #fff; }
.btn-primary:hover { background: #222222; }
.btn-secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ── Cards ── */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-body { padding: 20px; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 8px 12px;
    border: 1px solid var(--border); border-radius: 6px;
    font-size: 14px; color: var(--text); background: #fff;
    transition: border-color .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: #000000;
    box-shadow: 0 0 0 3px rgba(0,0,0,.08);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.required { color: #000000; font-weight: 700; }

/* ── Alerts ── */
.alert { padding: 10px 14px; border-radius: 6px; font-size: 14px; margin-top: 8px; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* ── Score Badge ── */
.score-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 50%;
    font-weight: 700; font-size: 13px; color: #fff;
    flex-shrink: 0;
}
.score-high   { background: #1a7a3f; }
.score-medium { background: #b45309; }
.score-low    { background: #6b7280; }
.score-sm { width: 30px; height: 30px; font-size: 11px; }

/* ── Confidence Dots ── */
.conf-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.conf-confirmed { background: #1a7a3f; }
.conf-estimated { background: #b45309; }
.conf-unknown   { background: #d1d5db; }

/* ── Stats Bar ── */
.stats-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.stat-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px 14px; border-left: 3px solid #000; display: flex; align-items: center; gap: 10px; }
.stat-value { font-size: 20px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }

/* ── Pipeline Filters ── */
.pipeline-filters { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.pipeline-filters select {
    padding: 7px 12px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 13px; background: var(--card); color: var(--text); cursor: pointer;
}

/* ── Kanban ── */
.kanban-board {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 12px;
    min-height: 400px;
}
.kanban-col {
    flex: 0 0 175px;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 200px);
}
.kanban-col-header {
    padding: 7px 10px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}
.kanban-col-count { background: #000; color: #fff; padding: 1px 6px; border-radius: 10px; font-size: 10px; }
.kanban-cards { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.kanban-loading { display: flex; align-items: center; justify-content: center; width: 100%; color: var(--text-muted); font-size: 14px; }

/* ── Lead Card ── */
.lead-card {
    background: var(--card);
    border-radius: 5px;
    padding: 8px 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    cursor: grab;
    transition: box-shadow .15s, transform .1s;
    border: 1px solid transparent;
}
.lead-card:hover { box-shadow: var(--shadow); border-color: var(--border); }
.lead-card.dragging { opacity: .5; transform: rotate(2deg); cursor: grabbing; }
.lead-card-top { display: flex; align-items: flex-start; gap: 6px; margin-bottom: 4px; }
.lead-card-name { font-weight: 600; font-size: 12px; flex: 1; line-height: 1.3; }
.lead-card-domain { font-size: 10px; color: var(--text-muted); margin-bottom: 4px; }
.lead-card-criteria { display: flex; flex-wrap: wrap; gap: 3px; }
.criteria-badge {
    font-size: 10px; padding: 2px 6px; border-radius: 3px;
    background: #f0f0f0; color: #333333;
    border: 1px solid #d0d0d0;
    white-space: nowrap;
}
.lead-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.lead-card-days { font-size: 10px; color: var(--text-muted); }

/* ── Modal ── */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.modal-box {
    position: relative; background: var(--card); border-radius: var(--radius);
    box-shadow: 0 8px 40px rgba(0,0,0,.2); width: 520px; max-width: calc(100vw - 32px);
    max-height: calc(100vh - 40px); overflow-y: auto;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 14px; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 17px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-muted); line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }
.modal-box form > .form-group, .modal-box form > .form-row, .modal-box form > .alert { padding: 0 20px; }
.modal-box form > .form-group:first-of-type { padding-top: 20px; }

/* ── Toast ── */
#toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 300; }
.toast {
    background: #111111; color: #fff; padding: 12px 18px; border-radius: 8px;
    font-size: 14px; box-shadow: 0 4px 16px rgba(0,0,0,.25);
    animation: slideIn .2s ease;
    max-width: 340px;
}
.toast.success { background: #166534; }
.toast.error   { background: #991b1b; }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Tables ── */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); padding: 10px 12px; text-align: left; border-bottom: 2px solid #000; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafafa; }

/* ── Tabs ── */
.tabs { border-bottom: 2px solid var(--border); display: flex; gap: 0; margin-bottom: 24px; }
.tab-btn { background: none; border: none; padding: 10px 18px; font-size: 14px; font-weight: 500; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: #000000; border-bottom-color: #000000; font-weight: 600; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Toggle Switch ── */
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: #d1d5db; border-radius: 22px; cursor: pointer; transition: .2s; }
.toggle-slider::before { content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; left: 3px; bottom: 3px; transition: .2s; }
.toggle input:checked + .toggle-slider { background: #000000; }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── Login Page ── */
.login-page { background: #000000; display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-container { background: var(--card); border-radius: 12px; padding: 36px 40px; width: 380px; box-shadow: 0 8px 60px rgba(0,0,0,.4); }
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.login-logo .logo-mark { width: 40px; height: 40px; font-size: 22px; }
.login-logo .logo-text { font-size: 20px; font-weight: 700; color: var(--text); }
.login-form .btn-primary { margin-top: 8px; padding: 11px; }

/* ── Skeleton Loader ── */
.skeleton { background: linear-gradient(90deg, #ebebeb 25%, #e0e0e0 50%, #ebebeb 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 4px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Utility ── */
.text-muted { color: var(--text-muted); }
.hidden { display: none; }
.text-sm { font-size: 13px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
