/* ══════════════════════════════════════════════════
   CPC CRM — Design System
   Navy/Gold monochromatic · System-aware dark/light
   Based on "Design for Developers" (Twarog & Moller)
   ══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@700&family=Inter:wght@400;600;700&display=swap');

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --elevated: #FFFFFF;
  --text-primary: #0B1120;
  --text-secondary: #5C6B82;
  --accent: #B8941E;
  --accent-hover: #A07D15;
  --accent-subtle: rgba(184, 148, 30, 0.1);
  --success: #34D399;
  --success-subtle: rgba(52, 211, 153, 0.1);
  --warning: #FBBF24;
  --warning-subtle: rgba(251, 191, 36, 0.1);
  --danger: #EF4444;
  --danger-subtle: rgba(239, 68, 68, 0.08);
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.15);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-elevated: 0 4px 16px rgba(0, 0, 0, 0.12);
  --shadow-modal: 0 8px 32px rgba(0, 0, 0, 0.2);
  --nav-bg: rgba(255, 255, 255, 0.92);
  --nav-inactive: #9CA3AF;
  --nav-active: #B8941E;
  --outbound: #3B82F6;
  --inbound: #10B981;
  --system-event: #6B7280;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  --font-display: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 20px;
  --text-xl: 28px;
  --weight-normal: 400;
  --weight-medium: 600;
  --weight-bold: 700;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 200ms;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B1120;
    --surface: #141E33;
    --elevated: #1A2844;
    --text-primary: #F0F2F5;
    --text-secondary: #8894AA;
    --accent: #D4AF37;
    --accent-hover: #E5C158;
    --accent-subtle: rgba(212, 175, 55, 0.12);
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.15);
    --shadow-card: none;
    --shadow-elevated: none;
    --shadow-modal: 0 -4px 32px rgba(0, 0, 0, 0.5);
    --nav-bg: rgba(11, 17, 32, 0.92);
    --nav-inactive: #4B5563;
    --nav-active: #D4AF37;
  }
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { font-family: var(--font-body); font-size: var(--text-sm); line-height: 1.5; color: var(--text-primary); background: var(--bg); overflow-x: hidden; min-height: 100vh; min-height: 100dvh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.text-xl { font-family: var(--font-display); font-size: var(--text-xl); font-weight: var(--weight-bold); line-height: 1.2; letter-spacing: -0.02em; }
.text-lg { font-family: var(--font-display); font-size: var(--text-lg); font-weight: var(--weight-bold); line-height: 1.3; }
.text-base { font-size: var(--text-base); font-weight: var(--weight-medium); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-muted { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.font-bold { font-weight: var(--weight-bold); }
.font-medium { font-weight: var(--weight-medium); }

.screen { padding: var(--space-lg); padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)); min-height: 100vh; min-height: 100dvh; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-lg); margin-bottom: var(--space-md); box-shadow: var(--shadow-card); transition: border-color var(--duration) var(--ease); }
.card-title { font-size: var(--text-xs); font-weight: var(--weight-bold); color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: var(--space-md); display: flex; align-items: center; gap: var(--space-sm); }

.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--nav-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-top: 1px solid var(--border); z-index: 100; padding: 6px 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
.nav-tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; color: var(--nav-inactive); font-size: 10px; font-weight: var(--weight-medium); cursor: pointer; border: 0; background: none; transition: color var(--duration) var(--ease); position: relative; }
.nav-tab.active { color: var(--nav-active); }
.nav-tab svg { width: 22px; height: 22px; }
.nav-badge { position: absolute; top: 0; right: calc(50% - 18px); background: var(--danger); color: #fff; font-size: 9px; padding: 1px 5px; border-radius: var(--radius-full); font-weight: var(--weight-bold); }

.fab { position: fixed; bottom: calc(70px + env(safe-area-inset-bottom, 0px)); right: var(--space-lg); width: 52px; height: 52px; border-radius: 50%; background: var(--accent); color: #000; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(0,0,0,0.3); z-index: 90; transition: transform var(--duration) var(--ease), background var(--duration) var(--ease); }
.fab:hover { background: var(--accent-hover); }
.fab:active { transform: scale(0.92); }
.fab svg { width: 24px; height: 24px; }
.fab-menu { position: fixed; bottom: calc(130px + env(safe-area-inset-bottom, 0px)); right: var(--space-lg); display: flex; flex-direction: column; gap: var(--space-sm); z-index: 91; }
.fab-item { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-sm) var(--space-md); background: var(--elevated); border: 1px solid var(--border); border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--text-primary); cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-elevated); transition: background var(--duration) var(--ease); }
.fab-item:hover { background: var(--surface); }

.search-bar { width: 100%; padding: var(--space-md) var(--space-lg); border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--surface); color: var(--text-primary); font-family: var(--font-body); font-size: var(--text-sm); outline: none; transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease); }
.search-bar:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); }
.search-bar::placeholder { color: var(--text-secondary); }

.stage-badge { display: inline-flex; align-items: center; gap: var(--space-xs); font-size: var(--text-xs); font-weight: var(--weight-medium); padding: 3px 10px; border-radius: var(--radius-full); white-space: nowrap; }

.contact-card { display: flex; align-items: center; padding: var(--space-md) 0; border-bottom: 1px solid var(--border); cursor: pointer; transition: background var(--duration) var(--ease); }
.contact-card:hover { background: var(--accent-subtle); }
.contact-card:active { opacity: 0.8; }
.contact-card:last-child { border-bottom: none; }
.contact-info { flex: 1; min-width: 0; }
.contact-name { font-size: var(--text-sm); font-weight: var(--weight-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-summary { font-size: var(--text-xs); color: var(--text-secondary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn { padding: var(--space-sm) var(--space-lg); border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface); color: var(--text-primary); font-family: var(--font-body); font-size: var(--text-xs); font-weight: var(--weight-medium); cursor: pointer; transition: all var(--duration) var(--ease); display: inline-flex; align-items: center; gap: var(--space-xs); }
.btn:hover { border-color: var(--border-strong); }
.btn:active { transform: scale(0.97); opacity: 0.8; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #000; }
.btn-primary:hover { background: var(--accent-hover); }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); z-index: 200; display: flex; align-items: flex-end; justify-content: center; opacity: 0; pointer-events: none; transition: opacity var(--duration) var(--ease); }
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-sheet { background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0; width: 100%; max-width: 500px; max-height: 70vh; overflow-y: auto; padding: var(--space-xl); padding-bottom: calc(var(--space-xl) + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--border-strong); transform: translateY(100%); transition: transform 300ms var(--ease); }
.modal-overlay.open .modal-sheet { transform: translateY(0); }
.modal-sheet h3 { font-family: var(--font-display); font-size: var(--text-base); font-weight: var(--weight-bold); margin-bottom: var(--space-lg); }
.modal-sheet input, .modal-sheet select, .modal-sheet textarea { width: 100%; padding: var(--space-md); border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--bg); color: var(--text-primary); font-family: var(--font-body); font-size: var(--text-sm); margin-bottom: var(--space-md); outline: none; transition: border-color var(--duration) var(--ease); }
.modal-sheet input:focus, .modal-sheet select:focus, .modal-sheet textarea:focus { border-color: var(--accent); }

.metric-card { text-align: center; padding: var(--space-md) var(--space-sm); border-radius: var(--radius-md); background: var(--bg); border: 1px solid var(--border); }
.metric-value { font-family: var(--font-display); font-size: var(--text-lg); font-weight: var(--weight-bold); letter-spacing: -0.02em; }
.metric-label { font-size: 10px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; font-weight: var(--weight-medium); }

.timeline-item { padding: var(--space-sm) 0 var(--space-sm) 18px; border-left: 2px solid var(--border); position: relative; font-size: var(--text-xs); }
.timeline-item::before { content: ''; position: absolute; left: -5px; top: 12px; width: 8px; height: 8px; border-radius: 50%; border: 2px solid var(--bg); }
.timeline-item.outbound::before { background: var(--outbound); }
.timeline-item.inbound::before { background: var(--inbound); }
.timeline-item.system::before { background: var(--system-event); }
.timeline-date { color: var(--text-secondary); font-size: 10px; font-weight: var(--weight-medium); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.w-full { width: 100%; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-md { margin-bottom: var(--space-md); }
.hidden { display: none; }

@media (min-width: 640px) {
  .screen { padding: var(--space-xl); padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }
}
@media (min-width: 1024px) {
  .screen { padding: var(--space-2xl); padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)); max-width: 1200px; margin: 0 auto; }
  .grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-md); }
  .desktop-2col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-xl); }
}

/* ── Logo ── */
.crm-logo { opacity: 0.9; }
@media (prefers-color-scheme: light) {
  .crm-logo { filter: invert(1); }
}
