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

:root {
    /* Backgrounds — slight navy tint, still dark for long sales sessions */
    --bg-dark:       #0a1224;
    --bg-card:       #14213d;
    --bg-card-hover: #1c2e57;
    --bg-sidebar:    #08101e;
    --border:        #1f2d4c;
    --text:          #e6ecf5;
    --text-muted:    #64748b;
    --text-dim:      #94a3b8;

    /* Brand palette — matches the public site */
    --navy:          #1E3A8A;
    --navy-dark:     #14266E;
    --blue-bright:   #2563EB;
    --orange:        #EA580C;
    --orange-dark:   #C2410C;

    /* Primary action color is orange (matches website CTAs).
       Secondary "info" color is bright blue (matches the logo cube top). */
    --accent:        #EA580C;
    --accent-hover:  #C2410C;
    --accent-glow:   rgba(234, 88, 12, 0.16);
    --info:          #2563EB;
    --info-glow:     rgba(37, 99, 235, 0.18);

    --green:         #10b981;
    --yellow:        #f59e0b;
    --red:           #ef4444;
    --purple:        #8b5cf6;
    --radius:        8px;
    --shadow:        0 4px 24px rgba(0,0,0,0.4);
}

body { background: var(--bg-dark); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; line-height: 1.6; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ─── Layout ────────────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ─── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
    width: 220px; min-height: 100vh; background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 20px 16px; border-bottom: 1px solid var(--border);
}
.brand-icon { font-size: 24px; color: var(--accent); }
.brand-logo  { width: 34px; height: 34px; object-fit: contain; flex-shrink: 0; }
.brand-text { font-size: 13px; font-weight: 700; color: var(--text); line-height: 1.3; }
.brand-text small { font-size: 11px; color: var(--text-muted); font-weight: 400; }

.nav-links { list-style: none; padding: 12px 0; flex: 1; overflow-y: auto; }
.nav-section {
    font-size: 10px; font-weight: 700; letter-spacing: .12em;
    color: var(--text-muted); padding: 16px 16px 6px; text-transform: uppercase;
}
.nav-link {
    display: block; padding: 9px 16px; color: var(--text-dim);
    font-size: 13px; border-left: 3px solid transparent;
    transition: all .15s;
}
.nav-link:hover { background: var(--accent-glow); color: var(--text); border-left-color: var(--accent); }
.nav-link.active { background: var(--accent-glow); color: var(--accent); border-left-color: var(--accent); font-weight: 600; }

.sidebar-footer {
    padding: 14px 16px; border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.sidebar-user { font-size: 12px; color: var(--text-dim); font-weight: 500; }
.logout-link { font-size: 12px; color: var(--text-muted); }
.logout-link:hover { color: var(--red); }

/* ─── Main Content ──────────────────────────────────────────────────────── */
.main-content { margin-left: 220px; flex: 1; max-width: 1400px; transition: margin-left .18s ease; }
.main-inner   { padding: 24px 32px; }

/* Collapsed-sidebar mode — toggle via topbar hamburger, persisted in localStorage */
body.sidebar-collapsed .sidebar     { transform: translateX(-100%); }
body.sidebar-collapsed .main-content { margin-left: 0; max-width: 100%; }
.sidebar { transition: transform .18s ease; }

/* Top bar across every CRM page */
.topbar {
    position: sticky; top: 0; z-index: 80;
    background: linear-gradient(110deg, var(--navy-dark) 0%, var(--navy) 100%);
    border-bottom: 1px solid var(--border);
    padding: 10px 28px;
    display: flex; align-items: center; justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.topbar-toggle {
    background: transparent; border: 1px solid rgba(255,255,255,.18);
    border-radius: 6px; padding: 6px 9px; cursor: pointer;
    display: inline-flex; flex-direction: column; gap: 3px; margin-right: 12px;
    transition: background .12s, border-color .12s;
}
.topbar-toggle:hover { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.3); }
.topbar-toggle span { display: block; width: 16px; height: 2px; background: var(--text); border-radius: 2px; }

.topbar-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.topbar-brand img { width: 32px; height: 32px; object-fit: contain; }
.topbar-brand span { display: flex; flex-direction: column; line-height: 1.05; }
.topbar-brand strong { color: var(--orange); font-size: 1rem; }
.topbar-brand small  { color: rgba(255,255,255,.72); font-size: .72rem; margin-top: 2px; }
.topbar-brand:hover strong { color: #f97316; }

.topbar-right { display: flex; align-items: center; gap: 18px; }
.topbar-link { color: rgba(255,255,255,.78); font-size: .85rem; text-decoration: none; }
.topbar-link:hover { color: #fff; }
.topbar-user { color: rgba(255,255,255,.86); font-size: .85rem; }
.topbar-logout { color: var(--orange); font-size: .85rem; text-decoration: none; font-weight: 600; }
.topbar-logout:hover { color: #fb923c; }

/* ─── Flash Messages ────────────────────────────────────────────────────── */
.flash {
    padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px;
    font-size: 13px; font-weight: 500; border: 1px solid;
}
.flash-success { background: rgba(16,185,129,.1); border-color: var(--green); color: var(--green); }
.flash-error   { background: rgba(239,68,68,.1);  border-color: var(--red);   color: var(--red); }
.flash-info    { background: var(--accent-glow);   border-color: var(--accent); color: var(--accent); }

/* ─── Page Header ───────────────────────────────────────────────────────── */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px;
}
.page-title  { font-size: 22px; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.detail-header { margin-bottom: 24px; }
.detail-title  { font-size: 26px; font-weight: 700; color: var(--text); }

/* ─── Cards ─────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px;
}
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 16px; margin-bottom: 24px; }
.card-title { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 12px; }

/* ─── Stat Cards ────────────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 14px; margin-bottom: 28px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
a.stat-link { display: block; text-decoration: none; color: inherit; transition: border-color .12s, transform .12s, box-shadow .12s; }
a.stat-link:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(234,88,12,0.16); }

a.vertical-tile, a.industry-tile {
    display: block; text-decoration: none; color: inherit;
    background: var(--bg-dark); border: 1px solid var(--border);
    border-radius: 8px; padding: 10px 16px; min-width: 120px;
    transition: border-color .12s, transform .12s, box-shadow .12s;
}
a.industry-tile { padding: 14px 20px; text-align: center; min-width: 140px; }
a.vertical-tile:hover, a.industry-tile:hover {
    border-color: var(--accent); transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(234,88,12,0.16);
}
.stat-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; }
.stat-value { font-size: 30px; font-weight: 700; color: var(--text); line-height: 1.1; margin-top: 4px; }
.stat-value.accent { color: var(--accent); }
.stat-value.green  { color: var(--green); }
.stat-value.yellow { color: var(--yellow); }

/* ─── Buttons ───────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: var(--radius); border: none;
    font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s;
    text-decoration: none; white-space: nowrap;
}
.btn-primary   { background: var(--accent);  color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--bg-card); color: var(--text-dim); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-card-hover); color: var(--text); }
.btn-success   { background: var(--green);   color: #fff; }
.btn-success:hover { opacity: .88; }
.btn-danger    { background: var(--red);     color: #fff; }
.btn-danger:hover  { opacity: .88; }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-group { display: flex; gap: 8px; align-items: center; }

/* ─── Tables ────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left; font-size: 11px; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .08em;
    padding: 10px 14px; border-bottom: 1px solid var(--border);
}
td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-card-hover); }

/* ─── Forms ─────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .06em; }
.form-control {
    width: 100%; padding: 9px 12px;
    background: var(--bg-dark); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-size: 13px;
    transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--accent); }
textarea.form-control { min-height: 100px; resize: vertical; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input { width: 16px; height: 16px; accent-color: var(--accent); }
.form-actions { display: flex; gap: 10px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }

/* ─── Badges ────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block; padding: 2px 9px; border-radius: 99px;
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
}
.badge-blue   { background: rgba(59,130,246,.15); color: var(--accent); }
.badge-green  { background: rgba(16,185,129,.15); color: var(--green); }
.badge-yellow { background: rgba(245,158,11,.15); color: var(--yellow); }
.badge-red    { background: rgba(239,68,68,.15);  color: var(--red); }
.badge-purple { background: rgba(139,92,246,.15); color: var(--purple); }
.badge-gray   { background: rgba(100,116,139,.15); color: var(--text-muted); }

/* ─── Score Bar ─────────────────────────────────────────────────────────── */
.score-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.score-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--accent), var(--green)); }

/* ─── Filter Bar ────────────────────────────────────────────────────────── */
.filter-bar {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px 16px;
    display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap;
}
.filter-bar label { font-size: 12px; color: var(--text-muted); font-weight: 600; }

/* ─── Pipeline Board ────────────────────────────────────────────────────── */
.pipeline-board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; }
.pipeline-col {
    min-width: 220px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px; flex-shrink: 0;
}
.pipeline-col-header { font-size: 12px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; }
.pipeline-col-count  { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.pipeline-deal-card {
    background: var(--bg-dark); border: 1px solid var(--border); border-radius: 6px;
    padding: 10px 12px; margin-bottom: 8px;
}
.pipeline-deal-name  { font-size: 12px; font-weight: 600; color: var(--text); }
.pipeline-deal-co    { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.pipeline-deal-value { font-size: 13px; font-weight: 700; color: var(--accent); margin-top: 6px; }

/* ─── Detail Sections ───────────────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.detail-section { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.detail-section h3 { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 14px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.info-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--text-muted); font-weight: 500; }
.info-value { color: var(--text); font-weight: 500; text-align: right; }

/* ─── Activity Feed ─────────────────────────────────────────────────────── */
.activity-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: none; }
a.activity-link { text-decoration: none; color: inherit; transition: background .12s, padding .12s; border-radius: 6px; margin: 0 -8px; padding-left: 8px; padding-right: 8px; }
a.activity-link:hover { background: var(--accent-glow); }
a.activity-link:hover .activity-subject { color: var(--accent); }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; margin-top: 5px; }
.activity-body { flex: 1; }
.activity-subject { font-size: 13px; font-weight: 500; color: var(--text); }
.activity-meta   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ─── Lead Cards ────────────────────────────────────────────────────────── */
.lead-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px; margin-bottom: 12px;
    display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start;
}
.lead-card:hover { border-color: var(--accent); }
.lead-name  { font-size: 15px; font-weight: 700; color: var(--text); }
.lead-meta  { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.lead-init  { font-size: 12px; color: var(--text-dim); margin-top: 8px; line-height: 1.5; }
.lead-score-box { text-align: center; }
.lead-score-num { font-size: 28px; font-weight: 700; color: var(--accent); line-height: 1; }
.lead-score-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }

/* ─── Template Detail ───────────────────────────────────────────────────── */
.template-body {
    background: var(--bg-dark); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px;
    font-family: 'Courier New', monospace; font-size: 13px;
    white-space: pre-wrap; line-height: 1.8; color: var(--text-dim);
}

/* ─── Login Page ────────────────────────────────────────────────────────── */
body.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

/* Top-left brand block on the login page — clickable, links back to the marketing site */
.login-page-brand {
    position: absolute; top: 22px; left: 24px;
    display: flex; align-items: center; gap: 12px;
    text-decoration: none; color: var(--text);
}
.login-page-brand img { width: 38px; height: 38px; object-fit: contain; }
.login-page-brand span { display: flex; flex-direction: column; line-height: 1.1; }
.login-page-brand strong { color: var(--orange); font-size: 1.02rem; }
.login-page-brand small  { color: var(--text-muted); font-size: .76rem; margin-top: 2px; }

.login-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 40px; width: 360px; box-shadow: var(--shadow); }
.login-brand     { font-size: 40px; color: var(--accent); text-align: center; margin-bottom: 8px; }
.login-brand-img { display: block; width: 60px; height: 60px; object-fit: contain; margin: 0 auto 10px; }
.login-title    { font-size: 20px; font-weight: 700; text-align: center; color: var(--text); }
.login-subtitle { font-size: 12px; color: var(--text-muted); text-align: center; margin-bottom: 28px; margin-top: 4px; }

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .brand-text, .nav-section, .sidebar-user, .logout-link { display: none; }
    .main-content { margin-left: 60px; }
    .main-inner   { padding: 16px; }
    .topbar { padding: 8px 16px; }
    .topbar-link { display: none; }
    .detail-grid, .form-row { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
