/* ─────────────────────────────────────────────────────────────────────────────
   Mode CRM — Stylesheet
   Dark theme · Exo font · Mode brand palette
   ───────────────────────────────────────────────────────────────────────────── */

:root {
    --void:       #0A0A0A;
    --carbon:     #141414;
    --gunmetal:   #1E1E1E;
    --soot:       #1A1A1A;
    --graphite:   #2A2A2A;
    --dark-grey:  #404041;
    --smoke:      #666666;
    --chalk:      #F0F0F0;
    --white:      #FFFFFF;
    --volt:       #C8FF00;
    --volt-hover: #DFFF00;
    --volt-dim:   rgba(200,255,0,0.15);
    --red:        #F44336;
    --orange:     #FF9800;
    --blue:       #2196F3;
    --green:      #00C853;
    --radius:     2px;
    --nav-h:      110px;
    --sidebar-w:  220px;
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
    font-family: 'Exo', sans-serif;
    background: var(--void);
    color: var(--chalk);
    line-height: 1.6;
    min-height: 100vh;
}
a { color: var(--volt); text-decoration: none; }
a:hover { color: var(--volt-hover); }
button { cursor: pointer; font-family: inherit; }
ul { list-style: none; }
img { max-width: 100%; }

/* ── Typography ─────────────────────────────────────────────────────────────── */
h1 { font-size: 22px; font-weight: 600; color: var(--white); }
h2 { font-size: 16px; font-weight: 600; color: var(--white); }
h3 { font-size: 13px; font-weight: 500; color: var(--chalk); text-transform: uppercase; letter-spacing: 0.08em; }
p  { font-size: 14px; color: var(--chalk); }
.label { font-size: 10px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--smoke); }

/* ── Login ──────────────────────────────────────────────────────────────────── */
.crm-login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-wrap { width: 100%; max-width: 380px; padding: 24px; }
.login-card { background: var(--soot); border: 0.5px solid var(--graphite); border-radius: var(--radius); padding: 40px 32px; }
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.login-logo__icon { flex-shrink: 0; }
.login-logo__text { font-size: 14px; font-weight: 600; letter-spacing: 0.2em; color: var(--white); }
.login-sub { font-size: 12px; color: var(--smoke); margin-bottom: 28px; }
.login-hint { font-size: 12px; color: var(--smoke); text-align: center; margin-top: 20px; }
.login-hint a { color: var(--volt); }
.login-form .field { margin-bottom: 16px; }
.login-form .btn { margin-top: 8px; }

/* ── Fields ─────────────────────────────────────────────────────────────────── */
.field { margin-bottom: 12px; }
.field__label { display: block; font-size: 10px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--smoke); margin-bottom: 6px; }
.field__input, .field__select, .field__textarea {
    width: 100%; padding: 10px 12px;
    background: var(--carbon); border: 0.5px solid var(--graphite);
    border-radius: var(--radius); color: var(--chalk);
    font-family: inherit; font-size: 14px; outline: none; transition: border-color 0.15s;
}
.field__input:focus, .field__select:focus, .field__textarea:focus { border-color: var(--volt); }
.field__textarea { min-height: 80px; resize: vertical; }
.field__select { appearance: none; cursor: pointer; }

/* Chrome autofill override */
.field__input:-webkit-autofill,
.field__input:-webkit-autofill:hover,
.field__input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--carbon) inset !important;
    -webkit-text-fill-color: var(--chalk) !important;
    caret-color: var(--chalk);
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 20px; border: none; border-radius: var(--radius);
    font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
    transition: all 0.15s; cursor: pointer; text-decoration: none;
}
.btn--primary { background: var(--volt); color: var(--void); }
.btn--primary:hover { background: var(--volt-hover); color: var(--void); }
.btn--ghost { background: transparent; border: 0.5px solid var(--graphite); color: var(--chalk); }
.btn--ghost:hover { border-color: var(--volt); color: var(--volt); }
.btn--danger { background: var(--red); color: var(--white); }
.btn--sm { padding: 6px 14px; font-size: 10px; }
.btn--full { width: 100%; }

/* ── Alerts ─────────────────────────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; }
.alert--error { background: rgba(244,67,54,0.15); border: 0.5px solid var(--red); color: var(--red); }
.alert--success { background: rgba(0,200,83,0.15); border: 0.5px solid var(--green); color: var(--green); }

/* ── Top Nav — Canonical brand header pattern (see brand/APP-GUIDELINE.md) ─── */
.crm-topnav {
    position: fixed !important; top: 0; left: 0; right: 0;
    height: var(--nav-h) !important; max-height: var(--nav-h);
    background: rgba(10,10,10,0.96); border-bottom: 0.5px solid var(--gunmetal);
    backdrop-filter: blur(8px); z-index: 100;
    display: flex !important; align-items: flex-end !important;
    padding: 16px 24px !important;
    gap: 24px !important;
    overflow: hidden;
}
.crm-topnav__spacer { flex: 1; }

/* Canonical .brand-header__mark pattern — scoped to topnav */
.crm-topnav .brand-header__mark {
    display: flex !important; flex-direction: column !important; align-items: flex-start !important;
    gap: 10px !important; margin-left: 0;
    text-decoration: none;
    max-height: 80px;
}
.crm-topnav .brand-header__mark img {
    height: 64px !important; max-height: 64px !important;
    width: auto !important; max-width: none;
    display: block !important;
}
.crm-topnav .brand-header__name {
    font-size: 13px !important; font-weight: 500 !important; color: var(--smoke) !important;
    letter-spacing: 0.15em !important; text-transform: uppercase !important;
    margin: 0 !important; line-height: 1 !important; padding-left: 0 !important;
    white-space: nowrap;
}

/* Canonical .brand-header__actions pattern — scoped */
.crm-topnav .brand-header__actions {
    display: flex !important; align-items: center !important; gap: 16px !important;
    font-size: 12px; color: var(--smoke);
}
.crm-topnav .brand-header__actions a {
    color: var(--smoke); text-decoration: none;
    font-size: 11px; font-weight: 500; letter-spacing: 0.08em;
    text-transform: uppercase; transition: color 0.15s;
    white-space: nowrap;
}
.crm-topnav .brand-header__actions a:hover { color: var(--volt); }

.crm-topnav__user { font-size: 12px; color: var(--chalk); white-space: nowrap; }
.crm-topnav__role { font-size: 10px; color: var(--smoke); margin-left: 4px; text-transform: lowercase; letter-spacing: 0.04em; }

/* ── Layout ─────────────────────────────────────────────────────────────────── */
.crm-layout { display: flex; padding-top: var(--nav-h); min-height: 100vh; }

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.crm-sidebar {
    position: fixed; top: var(--nav-h); left: 0; bottom: 0;
    width: var(--sidebar-w); background: var(--carbon);
    border-right: 0.5px solid var(--gunmetal); padding: 20px 0;
    overflow-y: auto;
}
.crm-sidebar__section { padding: 0 16px; margin-bottom: 24px; }
.crm-sidebar__label { font-size: 9px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dark-grey); margin-bottom: 8px; }
.crm-sidebar__item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px; border-radius: var(--radius);
    font-size: 13px; color: var(--smoke); transition: all 0.12s; cursor: pointer; text-decoration: none;
}
.crm-sidebar__item:hover { color: var(--chalk); background: var(--gunmetal); }
.crm-sidebar__item.is-active { color: var(--volt); background: var(--volt-dim); }
.crm-sidebar__count { font-size: 11px; color: var(--dark-grey); }
.crm-sidebar__icon { width: 16px; height: 16px; opacity: 0.5; margin-right: 8px; }

/* ── Main content ───────────────────────────────────────────────────────────── */
.crm-main { flex: 1; margin-left: var(--sidebar-w); padding: 24px; max-width: 1200px; }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card { background: var(--soot); border: 0.5px solid var(--graphite); border-radius: var(--radius); padding: 20px; }
.card__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card__title { font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--white); }

/* ── Stat cards ─────────────────────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--soot); border: 0.5px solid var(--graphite); border-radius: var(--radius); padding: 20px; }
.stat-card__value { font-size: 28px; font-weight: 700; color: var(--white); line-height: 1.2; }
.stat-card__value--volt { color: var(--volt); }
.stat-card__label { font-size: 10px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--smoke); margin-top: 4px; }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    text-align: left; padding: 10px 12px;
    font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--dark-grey); border-bottom: 0.5px solid var(--graphite);
}
.data-table td { padding: 12px; font-size: 13px; color: var(--chalk); border-bottom: 0.5px solid var(--gunmetal); }
.data-table tr:hover td { background: var(--carbon); }
.data-table a { color: var(--chalk); }
.data-table a:hover { color: var(--volt); }

/* ── Toolbar ────────────────────────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.toolbar__left { display: flex; align-items: center; gap: 12px; }
.toolbar__right { display: flex; align-items: center; gap: 8px; }

.search-box {
    display: flex; align-items: center;
    background: var(--carbon); border: 0.5px solid var(--graphite); border-radius: var(--radius);
    overflow: hidden;
}
.search-box__input {
    background: transparent; border: none; color: var(--chalk);
    padding: 8px 12px; font-family: inherit; font-size: 13px; outline: none; width: 260px;
}
.search-box__btn {
    background: var(--graphite); border: none; color: var(--smoke);
    padding: 8px 14px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
    text-transform: uppercase; cursor: pointer; transition: all 0.15s;
}
.search-box__btn:hover { background: var(--volt); color: var(--void); }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block; padding: 3px 8px; border-radius: var(--radius);
    font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
}
.badge--lead       { background: rgba(102,102,102,0.2); color: #999; }
.badge--qualified  { background: rgba(0,200,83,0.15);   color: var(--green); }
.badge--proposal   { background: rgba(255,152,0,0.15);  color: var(--orange); }
.badge--negotiation { background: rgba(33,150,243,0.15); color: var(--blue); }
.badge--won        { background: var(--volt-dim);        color: var(--volt); }
.badge--lost       { background: rgba(244,67,54,0.15);  color: var(--red); }

.badge--source {
    background: var(--graphite); color: var(--smoke); font-size: 9px;
}

/* ── Pipeline / Kanban ──────────────────────────────────────────────────────── */
.pipeline { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; min-height: 70vh; }
.pipeline-col {
    min-width: 260px; flex: 1; background: var(--carbon);
    border: 0.5px solid var(--gunmetal); border-radius: var(--radius);
    display: flex; flex-direction: column;
}
.pipeline-col__header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; border-bottom: 0.5px solid var(--gunmetal);
}
.pipeline-col__title { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; }
.pipeline-col__count { font-size: 11px; color: var(--smoke); }
.pipeline-col__total { font-size: 10px; color: var(--dark-grey); }
.pipeline-col__body { flex: 1; padding: 8px; min-height: 100px; }
.pipeline-col__body.drag-over { background: var(--volt-dim); }

.deal-card {
    background: var(--soot); border: 0.5px solid var(--graphite); border-radius: var(--radius);
    padding: 14px; margin-bottom: 8px; cursor: grab; transition: all 0.12s;
}
.deal-card:active { cursor: grabbing; }
.deal-card:hover { border-color: var(--volt); }
.deal-card.dragging { opacity: 0.4; }
.deal-card__title { font-size: 13px; font-weight: 500; color: var(--white); margin-bottom: 4px; }
.deal-card__company { font-size: 11px; color: var(--smoke); margin-bottom: 8px; }
.deal-card__footer { display: flex; align-items: center; justify-content: space-between; }
.deal-card__value { font-size: 14px; font-weight: 700; color: var(--volt); }
.deal-card__date { font-size: 10px; color: var(--dark-grey); }

/* ── Timeline ───────────────────────────────────────────────────────────────── */
.timeline { position: relative; padding-left: 24px; }
.timeline::before {
    content: ''; position: absolute; left: 7px; top: 0; bottom: 0;
    width: 1px; background: var(--graphite);
}
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-item__dot {
    position: absolute; left: -20px; top: 4px;
    width: 10px; height: 10px; border-radius: 50%; background: var(--graphite);
    border: 2px solid var(--void);
}
.timeline-item__dot--email_sent     { background: var(--volt); }
.timeline-item__dot--email_received { background: var(--blue); }
.timeline-item__dot--call           { background: var(--orange); }
.timeline-item__dot--meeting        { background: var(--green); }
.timeline-item__dot--note           { background: var(--smoke); }
.timeline-item__dot--deal_created   { background: var(--volt); }
.timeline-item__dot--deal_stage_change { background: var(--blue); }
.timeline-item__dot--deal_won       { background: var(--volt); }
.timeline-item__dot--deal_lost      { background: var(--red); }
.timeline-item__dot--task           { background: var(--orange); }

.timeline-item__header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.timeline-item__type { font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--smoke); }
.timeline-item__time { font-size: 10px; color: var(--dark-grey); }
.timeline-item__subject { font-size: 13px; color: var(--white); font-weight: 500; }
.timeline-item__body { font-size: 13px; color: var(--smoke); margin-top: 4px; white-space: pre-wrap; }
.timeline-item__user { font-size: 10px; color: var(--dark-grey); margin-top: 4px; }

/* ── Contact detail ─────────────────────────────────────────────────────────── */
.detail-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.detail-header__name { font-size: 24px; font-weight: 700; color: var(--white); }
.detail-header__meta { font-size: 13px; color: var(--smoke); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; }
.detail-field { }
.detail-field__label { font-size: 10px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--dark-grey); margin-bottom: 2px; }
.detail-field__value { font-size: 14px; color: var(--chalk); }

/* ── Modals ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
    z-index: 500; align-items: center; justify-content: center;
}
.modal-overlay.is-open { display: flex; }
.modal {
    background: var(--soot); border: 0.5px solid var(--graphite); border-radius: var(--radius);
    width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; padding: 28px;
}
.modal__title { font-size: 16px; font-weight: 600; color: var(--white); margin-bottom: 20px; }
.modal__actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── Tabs ───────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 0.5px solid var(--graphite); margin-bottom: 20px; }
.tab {
    padding: 10px 16px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--smoke); cursor: pointer;
    border-bottom: 2px solid transparent; transition: all 0.15s;
}
.tab:hover { color: var(--chalk); }
.tab.is-active { color: var(--volt); border-bottom-color: var(--volt); }

/* ── Empty state ────────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--smoke); }
.empty-state__icon { font-size: 48px; margin-bottom: 12px; opacity: 0.3; }
.empty-state__text { font-size: 14px; }

/* ── Task list ──────────────────────────────────────────────────────────────── */
.task-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 0.5px solid var(--gunmetal); }
.task-item__check { margin-top: 3px; accent-color: var(--volt); cursor: pointer; }
.task-item__title { font-size: 13px; color: var(--chalk); flex: 1; }
.task-item__title--done { text-decoration: line-through; color: var(--smoke); }
.task-item__due { font-size: 10px; color: var(--dark-grey); }
.task-item__due--overdue { color: var(--red); }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .crm-sidebar { display: none; }
    .crm-main { margin-left: 0; }
    .detail-grid { grid-template-columns: 1fr; }
    .stats-row { grid-template-columns: 1fr 1fr; }
    .pipeline { flex-direction: column; }
    .pipeline-col { min-width: auto; }
}
