/* ================================================
   Oslo — CRM Dashboard
   Dark theme with forest pastel green accent
   ================================================ */

@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;0,6..72,600;1,6..72,400&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    --bg-canvas: #F7F6F3;
    --bg-surface: #FFFFFF;
    --bg-surface-hover: #FAFAF8;
    --bg-surface-raised: #F0EFEC;
    --bg-inset: #EEEDEA;
    --border: #E5E4E0;
    --border-light: #EEEDEA;
    --text-primary: #111111;
    --text-secondary: #6B6B6B;
    --text-dim: #9B9B9B;
    --accent: #7BAF8A;
    --accent-hover: #6B9F7A;
    --accent-dim: rgba(123, 175, 138, 0.15);
    --success: #2D7A3A;
    --success-bg: #E8F5EA;
    --warning: #8A6D00;
    --warning-bg: #FFF8E1;
    --danger: #C62828;
    --danger-bg: #FFEBEE;
    --info: #1565C0;
    --info-bg: #E3F2FD;
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-serif: 'Newsreader', Georgia, 'Times New Roman', serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
    --transition: 0.2s cubic-bezier(0.32,0.72,0,1);
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-canvas);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--text-primary); text-decoration: none; transition: opacity var(--transition); }
a:hover { opacity: 0.7; }

/* ---- Navbar ---- */
.navbar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}
.nav-brand {
    display: flex;
    align-items: center;
}
.nav-logo { height: 28px; }
.nav-links { display: flex; gap: 4px; }
.nav-link {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition);
}
.nav-link:hover { background: var(--bg-surface-raised); color: var(--text-primary); opacity: 1; }
.nav-link.active { background: var(--accent); color: white; }

/* ---- Main ---- */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* ---- Page Header ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}
.page-title {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    font-weight: 500;
}
.header-actions { display: flex; gap: 8px; align-items: center; }

/* ---- Period Tabs ---- */
.period-tabs {
    display: flex;
    gap: 2px;
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
}
.period-tab {
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border: none;
    background: none;
    transition: all var(--transition);
}
.period-tab:hover { color: var(--text-primary); }
.period-tab.active { background: var(--bg-surface-raised); color: var(--text-primary); box-shadow: var(--shadow-sm); }

/* ---- Buttons ---- */
.btn {
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-sans);
}
.btn:hover { background: var(--bg-surface-raised); }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Stats Grid ---- */
.stats-section { margin-bottom: 2.5rem; }
.section-title {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    margin-bottom: 1rem;
}

.setter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
}

.setter-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}
.setter-card:hover { box-shadow: var(--shadow-md); }

.setter-name {
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--accent);
}

.stat-rows { display: flex; flex-direction: column; gap: 0.5rem; }
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}
.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.stat-value {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 600;
}
.stat-rate {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-left: 6px;
}

/* ---- Team Totals ---- */
.team-totals {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2.5rem;
    box-shadow: var(--shadow-sm);
}
.totals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1.5rem;
}
.total-item { text-align: center; }
.total-value {
    font-family: var(--font-mono);
    font-size: 1.8rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--accent);
}
.total-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 2px;
}
.total-rate {
    font-size: 0.72rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

/* ---- Conversion Funnel ---- */
.funnel-section { margin-bottom: 2.5rem; }
.funnel-bar-container {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}
.funnel-step {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 0;
}
.funnel-step + .funnel-step { border-top: 1px solid var(--border-light); }
.funnel-label {
    width: 120px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.funnel-bar-track {
    flex: 1;
    height: 28px;
    background: var(--bg-inset);
    border-radius: 6px;
    overflow: hidden;
}
.funnel-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 6px;
    transition: width 0.6s cubic-bezier(0.32,0.72,0,1);
    min-width: 2px;
    opacity: 0.85;
}
.funnel-count {
    width: 60px;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}

/* ---- Pipeline Board ---- */
.pipeline-section { margin-bottom: 2.5rem; }
.pipeline-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}
.pipeline-column {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all var(--transition);
}
.pipeline-column:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.pipeline-count {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 600;
    line-height: 1.2;
}
.pipeline-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 4px;
}
.pipeline-column.stage-new .pipeline-count { color: var(--info); }
.pipeline-column.stage-booked .pipeline-count { color: var(--accent); }
.pipeline-column.stage-won .pipeline-count { color: var(--accent); }
.pipeline-column.stage-lost .pipeline-count { color: var(--danger); }
.pipeline-column.stage-noshow .pipeline-count { color: var(--warning); }

/* ---- Recent Calls Table ---- */
.calls-section { margin-bottom: 2.5rem; }
.calls-table-wrap {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.calls-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.calls-table th {
    background: var(--bg-surface-raised);
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}
.calls-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}
.calls-table tr:last-child td { border-bottom: none; }
.calls-table tr:hover td { background: var(--bg-surface-hover); }
.duration-badge {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--bg-inset);
}

/* ---- Pipeline Detail ---- */
.leads-list {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.lead-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.lead-item:last-child { border-bottom: none; }
.lead-name { font-weight: 500; font-size: 0.9rem; }
.lead-date { font-size: 0.78rem; color: var(--text-dim); font-family: var(--font-mono); }

/* ---- Sync Status ---- */
.sync-status {
    font-size: 0.78rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 6px;
}
.sync-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    display: inline-block;
}
.sync-dot.stale { background: var(--warning); }
.sync-dot.error { background: var(--danger); }

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-dim);
}
.empty-state h2 {
    font-family: var(--font-serif);
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}
.empty-state p { font-size: 0.9rem; margin-bottom: 1.5rem; }

/* ---- Loading Spinner ---- */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Login Page ---- */
.login-body { background: var(--bg-canvas); }
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.login-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 3rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}
.login-brand {
    margin-bottom: 2rem;
}
.login-logo {
    height: 36px;
}
.login-error {
    background: var(--danger-bg);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}
.login-form { display: flex; flex-direction: column; gap: 1.25rem; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}
.form-group input {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: var(--font-sans);
    background: var(--bg-canvas);
    color: var(--text-primary);
    transition: border-color var(--transition);
    outline: none;
}
.form-group input:focus {
    border-color: var(--accent);
}
.login-btn {
    width: 100%;
    padding: 12px;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .main-content { padding: 1rem; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 1rem; }
    .setter-grid { grid-template-columns: 1fr; }
    .pipeline-board { grid-template-columns: repeat(2, 1fr); }
    .totals-grid { grid-template-columns: repeat(3, 1fr); }
}
