/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-family: 'Inter', system-ui, -apple-system, sans-serif; font-size: 15px; line-height: 1.6; color: #0f172a; background: #f8fafc; -webkit-font-smoothing: antialiased; }

/* ── Login ── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 40px; max-width: 400px; width: 100%; }
.login-card h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; }
.login-card p.sub { color: #64748b; font-size: 0.875rem; margin-bottom: 24px; }
.login-card .form-group { margin-bottom: 16px; }
.login-card .btn { width: 100%; margin-top: 8px; }
.login-toggle { text-align: center; margin-top: 16px; font-size: 0.85rem; color: #64748b; }
.login-toggle a { color: #3b82f6; cursor: pointer; text-decoration: none; }
.login-error { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; padding: 10px 14px; border-radius: 5px; font-size: 0.85rem; margin-bottom: 16px; display: none; }
.login-hint { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; padding: 10px 14px; border-radius: 5px; font-size: 0.8rem; margin-bottom: 16px; }

/* ── Layout ── */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #fff; border-right: 1px solid #e2e8f0; display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-brand { padding: 20px 24px; font-weight: 700; font-size: 1.1rem; border-bottom: 1px solid #e2e8f0; letter-spacing: -0.02em; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 24px; font-size: 0.875rem; color: #64748b; cursor: pointer; border: none; background: none; width: 100%; text-align: left; font-family: inherit; transition: background 0.15s, color 0.15s; }
.nav-item:hover { background: #f1f5f9; color: #0f172a; }
.nav-item.active { background: #f1f5f9; color: #0f172a; font-weight: 500; border-left: 3px solid #0f172a; padding-left: 21px; }
.nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }
.sidebar-footer { padding: 16px 24px; border-top: 1px solid #e2e8f0; font-size: 0.8rem; }
.sidebar-footer .user-name { font-weight: 600; color: #0f172a; }
.sidebar-footer .user-role { color: #94a3b8; }
.sidebar-footer .logout-btn { margin-top: 8px; color: #dc2626; cursor: pointer; display: inline-block; font-size: 0.8rem; }

.main { flex: 1; padding: 32px; overflow-y: auto; }
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.page-header p { color: #64748b; font-size: 0.875rem; margin-top: 2px; }

/* ── Cards ── */
.card { background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; padding: 24px; margin-bottom: 20px; }
.card-title { font-size: 1rem; font-weight: 600; margin-bottom: 16px; }

/* ── KPI ── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; padding: 20px; }
.kpi-label { font-size: 0.75rem; font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase; color: #94a3b8; margin-bottom: 8px; }
.kpi-value { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; color: #0f172a; }
.kpi-sub { font-size: 0.8rem; color: #64748b; margin-top: 4px; }

/* ── Pipeline ── */
.pipeline-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.pipeline-stage { background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; padding: 16px; text-align: center; }
.pipeline-stage .stage-name { font-size: 0.8rem; font-weight: 500; color: #64748b; margin-bottom: 6px; }
.pipeline-stage .stage-count { font-size: 1.5rem; font-weight: 700; }
.pipeline-stage .stage-value { font-size: 0.8rem; color: #64748b; margin-top: 2px; }

/* ── Table ── */
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th { text-align: left; padding: 10px 16px; font-weight: 500; color: #64748b; border-bottom: 2px solid #e2e8f0; }
td { padding: 11px 16px; border-bottom: 1px solid #f1f5f9; color: #0f172a; }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f8fafc; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 99px; font-size: 0.75rem; font-weight: 500; }
.badge-prospekt { background: #f1f5f9; color: #64748b; }
.badge-aktiv { background: #dcfce7; color: #15803d; }
.badge-vilande { background: #fef3c7; color: #b45309; }
.badge-ny { background: #dbeafe; color: #1d4ed8; }
.badge-kvalificerad { background: #e0e7ff; color: #4338ca; }
.badge-förhandling { background: #fef3c7; color: #b45309; }
.badge-vunnen { background: #dcfce7; color: #15803d; }
.badge-förlorad { background: #fee2e2; color: #b91c1c; }
.badge-samtal { background: #dbeafe; color: #1d4ed8; }
.badge-möte { background: #f3e8ff; color: #7c3aed; }
.badge-mejl { background: #f1f5f9; color: #64748b; }
.badge-admin { background: #dcfce7; color: #15803d; }
.badge-säljare { background: #dbeafe; color: #1d4ed8; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; font-size: 0.85rem; font-weight: 500; font-family: inherit; border-radius: 5px; border: 1px solid transparent; cursor: pointer; transition: background 0.15s, border-color 0.15s; white-space: nowrap; }
.btn-primary { background: #0f172a; color: #fff; }
.btn-primary:hover { background: #1e293b; }
.btn-secondary { background: #fff; color: #0f172a; border-color: #e2e8f0; }
.btn-secondary:hover { background: #f1f5f9; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-label { font-size: 0.85rem; font-weight: 500; color: #0f172a; }
input, select, textarea { width: 100%; padding: 9px 12px; font-size: 0.875rem; font-family: inherit; color: #0f172a; background: #fff; border: 1px solid #e2e8f0; border-radius: 5px; transition: border-color 0.15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.12); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Filters ── */
.filters { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input { width: auto; min-width: 160px; }
.filters .search { flex: 1; min-width: 200px; }

/* ── Detail ── */
.detail-back { margin-bottom: 16px; }
.detail-back a { color: #64748b; cursor: pointer; font-size: 0.85rem; text-decoration: none; }
.detail-back a:hover { color: #0f172a; }
.detail-header { margin-bottom: 24px; }
.detail-header h2 { font-size: 1.5rem; font-weight: 700; }
.detail-header .meta { color: #64748b; font-size: 0.875rem; margin-top: 4px; }
.detail-section { margin-bottom: 28px; }
.detail-section h3 { font-size: 1rem; font-weight: 600; margin-bottom: 12px; }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.3); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 24px; }
.modal { background: #fff; border-radius: 8px; padding: 32px; max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto; }
.modal h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; }

/* ── Misc ── */
.text-muted { color: #64748b; }
.text-right { text-align: right; }
.empty-state { text-align: center; padding: 48px 24px; color: #94a3b8; }
.empty-state p { font-size: 0.9rem; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; padding: 12px 16px; border-radius: 5px; font-size: 0.85rem; margin-bottom: 16px; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; padding: 12px 16px; border-radius: 5px; font-size: 0.85rem; margin-bottom: 16px; }

@media (max-width: 768px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; }
  .sidebar-brand { border-bottom: none; border-right: 1px solid #e2e8f0; }
  .sidebar-nav { flex-direction: row; }
  .sidebar-footer { display: none; }
  .main { padding: 16px; }
  .pipeline-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row, .form-row3 { grid-template-columns: 1fr; }
}