:root {
    --bg: #f3f5f8;
    --card: #ffffff;
    --text: #18212f;
    --muted: #6b7280;
    --line: #e5e7eb;
    --nav: #101827;
    --accent: #1473e6;
    --success: #16803a;
    --danger: #b42318;
    --warning: #b26a00;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
    background: var(--bg);
}

a { color: inherit; }

.auth-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-card {
    width: min(430px, 100%);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 20px 50px rgba(16, 24, 39, .10);
}

.brand {
    font-weight: 800;
    letter-spacing: .08em;
    color: var(--accent);
}

.brand.large {
    font-size: 22px;
    line-height: 1.1;
    padding: 22px 20px;
    color: white;
}

h1 { margin: 12px 0 8px; }
.muted { color: var(--muted); }

label {
    display: block;
    margin: 18px 0 7px;
    font-weight: 700;
}

input, select {
    width: 100%;
    border: 1px solid #cfd5df;
    border-radius: 9px;
    padding: 11px 12px;
    background: white;
}

.button {
    display: inline-block;
    border: 0;
    border-radius: 9px;
    padding: 12px 16px;
    text-decoration: none;
    cursor: pointer;
    font-weight: 700;
}

.button.primary {
    background: var(--accent);
    color: white;
}

.button.full {
    width: 100%;
    text-align: center;
    margin-top: 22px;
}

.notice {
    margin: 16px 0;
    padding: 12px;
    border-radius: 9px;
    background: #eef4ff;
}

.notice.error { background: #fff0ee; color: var(--danger); }
.notice.success { background: #eefbf2; color: var(--success); }

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 230px 1fr;
}

.sidebar {
    background: var(--nav);
    color: #d8dfeb;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.sidebar nav {
    padding: 8px 12px;
    flex: 1;
}

.sidebar nav a {
    display: block;
    text-decoration: none;
    padding: 11px 12px;
    border-radius: 8px;
    margin: 3px 0;
}

.sidebar nav a:hover,
.sidebar nav a.active {
    background: rgba(255,255,255,.10);
    color: white;
}

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,.12);
    padding: 18px;
    font-size: 13px;
}

.sidebar-footer a {
    display: inline-block;
    margin-top: 8px;
    color: white;
}

.main { padding: 24px; min-width: 0; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.topbar h1 { margin: 0; font-size: 26px; }
.topbar p { margin: 5px 0 0; color: var(--muted); }

.status-pill {
    background: #eaf3ff;
    color: #0f5eb9;
    padding: 8px 12px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 13px;
}

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

.kpi {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 18px;
}

.kpi span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.kpi strong { font-size: 30px; }

.map-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 16px;
}

.map-card,
.intel-panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    min-height: 650px;
}

.map-toolbar {
    min-height: 62px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    gap: 10px;
}

.map-toolbar > div {
    display: flex;
    gap: 8px;
}

.map-toolbar select {
    width: auto;
    min-width: 145px;
}

#map { height: 587px; width: 100%; }

.intel-panel { padding: 22px; }

.empty-state {
    display: grid;
    place-content: center;
    height: 100%;
    text-align: center;
    color: var(--muted);
}

.intel-header {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.intel-header h2 { margin: 4px 0; }
.intel-header p { margin: 0; color: var(--muted); }

.eyebrow {
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: 11px;
    font-weight: 800;
    color: var(--accent);
}

.priority-badge {
    white-space: nowrap;
    height: fit-content;
    background: #fff4df;
    color: #8a5100;
    border-radius: 999px;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 700;
}

.intel-section {
    padding: 16px 0;
    border-bottom: 1px solid var(--line);
}

.intel-section h3 {
    margin: 0 0 12px;
    font-size: 15px;
}

dl {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 9px 12px;
    margin: 0;
    font-size: 14px;
}

dt { color: var(--muted); }
dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

.recommendation {
    border-bottom: 0;
    background: #f7fbff;
    margin: 15px -8px 0;
    padding: 16px;
    border-radius: 10px;
}

.custom-marker {
    width: 18px;
    height: 18px;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,.30);
}

.marker-customer { background: #1f9d55; }
.marker-prospect { background: #2878d0; }
.marker-followup { background: #e4a11b; }
.marker-priority { background: #d93025; }

.toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    padding: 12px 16px;
    background: #111827;
    color: white;
    border-radius: 9px;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: .2s ease;
}

.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1050px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .map-layout { grid-template-columns: 1fr; }
    .intel-panel { min-height: 400px; }
}

@media (max-width: 760px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { min-height: auto; }
    .sidebar nav { display: none; }
    .main { padding: 14px; }
    .kpi-grid { grid-template-columns: 1fr; }
    .map-toolbar { align-items: stretch; flex-direction: column; }
    .map-toolbar > div { flex-direction: column; }
    .map-toolbar select { width: 100%; }
}
