/* CRM Cem — styles */
:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --border: #e5e7eb;
    --text: #111827;
    --text-muted: #6b7280;
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #eef2ff;
    --danger: #ef4444;
    --success: #10b981;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-lg: 0 10px 30px rgba(16, 24, 40, 0.14);
    --sidebar-w: 250px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

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

.sidebar {
    width: var(--sidebar-w);
    background: #111827;
    color: #e5e7eb;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
    transition: transform 0.25s ease;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 20px 22px;
    font-size: 20px; font-weight: 700; color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand svg { color: var(--primary); }
.sidebar-nav { flex: 1; padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px;
    border-radius: 9px;
    color: #cbd5e1;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.sidebar-footer { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-name { color: #fff; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-link { color: #9ca3af; font-size: 12px; }
.logout-link:hover { color: #fff; }

.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.4); z-index: 40;
}
.sidebar-overlay.show { display: block; }

.main {
    flex: 1; margin-left: var(--sidebar-w);
    padding: 24px;
    min-width: 0;
}

.topbar {
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 24px;
}
.topbar-title { font-size: 22px; font-weight: 700; flex: 1; }
.hamburger { display: none; color: var(--text); }

/* ------------------------------------------------------------------ Views */
.view { animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px;
    display: flex; gap: 14px; align-items: flex-start;
    box-shadow: var(--shadow);
}
.kpi-icon {
    width: 44px; height: 44px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: var(--primary-light); color: var(--primary);
    flex-shrink: 0;
}
.kpi-body { display: flex; flex-direction: column; }
.kpi-value { font-size: 24px; font-weight: 700; line-height: 1.1; }
.kpi-label { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.kpi-sub { color: var(--text-muted); font-size: 12px; opacity: 0.8; }

/* ------------------------------------------------------------------ Charts */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-box { position: relative; height: 280px; }

/* ------------------------------------------------------------------ Panels */
.panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.panel-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-head .panel-title { margin-bottom: 0; }
.panel-tools { display: flex; gap: 10px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ Inputs */
.input {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--border); border-radius: 8px;
    font-size: 14px; font-family: inherit; color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.search-input { min-width: 200px; }
.select-input { width: auto; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.field-full { grid-column: 1 / -1; }

/* ------------------------------------------------------------------ Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 16px; border-radius: 8px;
    font-size: 14px; font-weight: 600;
    transition: background 0.15s, transform 0.05s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: #f9fafb; }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ------------------------------------------------------------------ Table */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); font-weight: 600; }
.table tbody tr:hover { background: #f9fafb; }
.ta-right { text-align: right; }
.cell-company { font-weight: 600; }
.cell-sub { color: var(--text-muted); font-size: 12px; }
.cell-value { font-weight: 600; }
.empty { text-align: center; color: var(--text-muted); padding: 30px !important; }

.icon-btn {
    padding: 6px; border-radius: 7px; color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--primary-light); color: var(--primary); }
.icon-btn-danger:hover { background: #fee2e2; color: var(--danger); }

.badge {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600;
}

/* ------------------------------------------------------------------ Pagination */
.pagination {
    display: flex; align-items: center; gap: 10px;
    margin-top: 16px; justify-content: flex-end; flex-wrap: wrap;
}
.pagination-info { color: var(--text-muted); margin-right: auto; }
.pagination-current { font-weight: 600; }

/* ------------------------------------------------------------------ Pipeline */
.pipeline-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: start; }
.pipeline-col {
    background: #eef0f3; border-radius: var(--radius); padding: 12px;
    min-height: 200px;
}
.pipeline-col-head {
    display: flex; align-items: center; gap: 8px;
    font-weight: 600; font-size: 14px; margin-bottom: 12px;
}
.dot { width: 9px; height: 9px; border-radius: 50%; }
.count {
    margin-left: auto; background: var(--surface); color: var(--text-muted);
    border-radius: 999px; padding: 1px 9px; font-size: 12px;
}
.pipeline-col-body { display: flex; flex-direction: column; gap: 8px; }
.pipeline-card {
    background: var(--surface); border-radius: 9px; padding: 12px;
    cursor: pointer; box-shadow: var(--shadow);
    transition: transform 0.1s;
}
.pipeline-card:hover { transform: translateY(-1px); }
.pc-company { font-weight: 600; }
.pc-contact { color: var(--text-muted); font-size: 12px; }
.pc-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.pc-value { font-weight: 600; font-size: 13px; }
.pipeline-empty { color: var(--text-muted); font-size: 12px; text-align: center; padding: 12px; }

/* ------------------------------------------------------------------ Modal */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(17, 24, 39, 0.5);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.modal {
    background: var(--surface); border-radius: 14px;
    width: 100%; max-width: 560px; max-height: 90vh; overflow: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 18px; font-weight: 700; }
.modal-close { color: var(--text-muted); padding: 4px; border-radius: 7px; }
.modal-close:hover { background: #f3f4f6; color: var(--text); }
.modal-body { padding: 20px 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 8px; }

/* ------------------------------------------------------------------ Toasts */
.toast-container {
    position: fixed; bottom: 22px; right: 22px; z-index: 200;
    display: flex; flex-direction: column; gap: 10px;
}
.toast {
    padding: 12px 18px; border-radius: 9px;
    color: #fff; font-weight: 500; font-size: 14px;
    box-shadow: var(--shadow-lg); animation: toastIn 0.25s ease;
}
.toast-out { opacity: 0; transform: translateY(6px); transition: opacity 0.3s, transform 0.3s; }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ Auth */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #111827; padding: 20px; }
.auth-wrap { width: 100%; max-width: 400px; }
.auth-card {
    background: var(--surface); border-radius: 16px; padding: 34px;
    box-shadow: var(--shadow-lg);
}
.auth-logo {
    width: 60px; height: 60px; border-radius: 14px;
    background: var(--primary-light); color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 18px;
}
.auth-card h1 { font-size: 22px; text-align: center; }
.auth-sub { color: var(--text-muted); text-align: center; margin: 6px 0 22px; font-size: 14px; }
.auth-card form .btn { margin-top: 8px; }

/* ------------------------------------------------------------------ Skeleton */
.skeleton { background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; min-height: 84px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ------------------------------------------------------------------ Responsive */
@media (max-width: 1100px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .chart-grid { grid-template-columns: 1fr; }
    .pipeline-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; padding: 16px; }
    .hamburger { display: inline-flex; }
    .topbar { flex-wrap: wrap; }
    .topbar-title { font-size: 19px; }
    #btnNewClient span { display: none; }
    #btnNewClient { padding: 9px 12px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .pipeline-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .search-input { min-width: 100%; }
    .panel-tools { width: 100%; }
    .panel-tools .input { flex: 1; }
    .toast-container { left: 16px; right: 16px; }
}
