/* disk CRM — Design system */
:root {
  --bg: #f6f7fb;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: #1e293b;
  --text: #0f172a;
  --text-soft: #475569;
  --text-mute: #94a3b8;
  --border: #e2e8f0;
  --border-soft: #f1f5f9;
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-soft: #eef2ff;
  --success: #10b981;
  --success-soft: #d1fae5;
  --warning: #f59e0b;
  --warning-soft: #fef3c7;
  --danger: #ef4444;
  --danger-soft: #fee2e2;
  --info: #3b82f6;
  --info-soft: #dbeafe;
  --purple: #a855f7;
  --purple-soft: #f3e8ff;
  --pink: #ec4899;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ============== LOGIN ============== */
.login-body { background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-wrap { width: 100%; max-width: 460px; }
.login-card { background: white; border-radius: 20px; padding: 48px 40px; box-shadow: 0 24px 60px rgba(0,0,0,0.2); }
.login-brand { text-align: center; margin-bottom: 32px; }
.brand-logo { width: 56px; height: 56px; border-radius: 16px; background: linear-gradient(135deg, var(--primary), var(--purple)); color: white; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 16px; box-shadow: 0 8px 16px rgba(99,102,241,0.3); }
.login-brand h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.login-brand p { color: var(--text-soft); margin-top: 4px; }
.login-form label { display: block; margin-bottom: 16px; color: var(--text-soft); font-weight: 500; font-size: 13px; }
.login-form input { display: block; width: 100%; margin-top: 6px; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); transition: border .15s; }
.login-form input:focus { outline: none; border-color: var(--primary); }
.login-foot { text-align: center; margin-top: 24px; color: var(--text-mute); font-size: 12px; }
.alert-error { background: var(--danger-soft); color: var(--danger); padding: 12px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px; }

/* ============== APP LAYOUT ============== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 24px; font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.sb-brand .brand-logo { width: 36px; height: 36px; border-radius: 10px; }
.sb-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); color: #cbd5e1; font-weight: 500; transition: all .15s; }
.nav-item:hover { background: var(--bg-sidebar-hover); color: white; }
.nav-item.active { background: var(--primary); color: white; box-shadow: 0 4px 12px rgba(99,102,241,0.3); }
.sb-foot { border-top: 1px solid #1e293b; padding-top: 16px; margin-top: 16px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--purple)); color: white; display: flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0; }
.user-meta { min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: white; }
.user-email { font-size: 11px; color: var(--text-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-top: 8px; border-radius: var(--radius-sm); color: #cbd5e1; font-size: 13px; transition: all .15s; }
.logout:hover { background: var(--bg-sidebar-hover); color: var(--danger); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { background: white; border-bottom: 1px solid var(--border); padding: 14px 24px; display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 10; }
.topbar h2 { font-size: 18px; font-weight: 700; flex: 1; letter-spacing: -0.3px; }
.topbar-actions { display: flex; gap: 8px; }
.hamburger { display: none; padding: 8px; border-radius: var(--radius-sm); color: var(--text-soft); }
.hamburger:hover { background: var(--bg); }

.view-host { padding: 24px; }
.view-host > section { display: none; }
.view-host > section.active { display: block; animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ============== BUTTONS ============== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: var(--radius-sm); font-weight: 600; font-size: 13px; transition: all .15s; white-space: nowrap; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.3); }
.btn-secondary { background: white; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); border-color: var(--text-mute); }
.btn-ghost { color: var(--text-soft); padding: 6px 10px; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-block { width: 100%; justify-content: center; padding: 12px; }
.btn-sm { padding: 5px 9px; font-size: 12px; }
.btn-icon { padding: 6px; border-radius: 6px; color: var(--text-soft); }
.btn-icon:hover { background: var(--bg); color: var(--text); }

/* ============== CARDS ============== */
.card { background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.card-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border-soft); }
.card-h h3 { font-size: 15px; font-weight: 700; }
.card-b { padding: 20px; }

/* ============== KPI GRID ============== */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi { background: white; border-radius: var(--radius); padding: 20px; border: 1px solid var(--border); transition: all .2s; position: relative; overflow: hidden; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi-icon { width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.kpi-label { font-size: 12px; color: var(--text-soft); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-value { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -0.5px; }
.kpi-sub { font-size: 12px; color: var(--text-mute); margin-top: 4px; }
.kpi-icon.primary { background: var(--primary-soft); color: var(--primary); }
.kpi-icon.success { background: var(--success-soft); color: var(--success); }
.kpi-icon.warning { background: var(--warning-soft); color: var(--warning); }
.kpi-icon.info { background: var(--info-soft); color: var(--info); }
.kpi-icon.purple { background: var(--purple-soft); color: var(--purple); }
.kpi-icon.danger { background: var(--danger-soft); color: var(--danger); }

/* ============== DASHBOARD GRID ============== */
.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
.dash-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.chart-wrap { position: relative; height: 280px; }

/* ============== TABLES ============== */
.table-wrap { background: white; border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }
.table-toolbar { display: flex; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border-soft); align-items: center; flex-wrap: wrap; }
.table-toolbar input[type="search"] { flex: 1; min-width: 200px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.table-toolbar input[type="search"]:focus { outline: none; border-color: var(--primary); }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 10px 16px; font-size: 12px; font-weight: 600; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.4px; background: var(--bg); border-bottom: 1px solid var(--border); }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border-soft); }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--bg); }
.table tbody tr.row-link { cursor: pointer; }
.cell-name { display: flex; align-items: center; gap: 10px; }
.cell-avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--primary-soft), var(--purple-soft)); color: var(--primary-dark); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; flex-shrink: 0; }
.cell-name strong { display: block; font-weight: 600; font-size: 13px; }
.cell-name small { color: var(--text-mute); font-size: 12px; }
.actions-cell { display: flex; gap: 4px; justify-content: flex-end; }

/* ============== BADGES ============== */
.badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.badge-success { background: var(--success-soft); color: #047857; }
.badge-warning { background: var(--warning-soft); color: #b45309; }
.badge-danger { background: var(--danger-soft); color: #b91c1c; }
.badge-info { background: var(--info-soft); color: #1e40af; }
.badge-purple { background: var(--purple-soft); color: #7e22ce; }
.badge-gray { background: var(--border-soft); color: var(--text-soft); }
.badge-primary { background: var(--primary-soft); color: var(--primary-dark); }

/* Score bar */
.score-bar { display: flex; align-items: center; gap: 8px; }
.score-bar-track { flex: 1; max-width: 80px; height: 6px; background: var(--border-soft); border-radius: 3px; overflow: hidden; }
.score-bar-fill { height: 100%; border-radius: 3px; transition: width .3s; }
.score-hot { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.score-warm { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.score-cold { background: linear-gradient(90deg, #94a3b8, #64748b); }
.score-num { font-weight: 600; font-size: 12px; min-width: 28px; }

/* ============== PIPELINE ============== */
.pipeline { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.pipe-col { flex: 0 0 280px; background: var(--bg); border-radius: var(--radius); padding: 12px; }
.pipe-col-h { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 10px; }
.pipe-col-h strong { font-size: 13px; font-weight: 700; text-transform: capitalize; }
.pipe-col-h .pipe-total { font-size: 12px; color: var(--text-soft); }
.pipe-cards { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.pipe-card { background: white; border-radius: 10px; padding: 12px; border: 1px solid var(--border); cursor: grab; transition: all .15s; }
.pipe-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.pipe-card:active { cursor: grabbing; }
.pipe-card.dragging { opacity: 0.4; }
.pipe-card-title { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.pipe-card-sub { color: var(--text-mute); font-size: 12px; margin-bottom: 8px; }
.pipe-card-foot { display: flex; align-items: center; justify-content: space-between; font-size: 12px; }
.pipe-card-amount { font-weight: 700; color: var(--success); }
.pipe-col.drop-target { background: var(--primary-soft); outline: 2px dashed var(--primary); }

/* ============== ACTIVITIES TIMELINE ============== */
.timeline { display: flex; flex-direction: column; gap: 4px; }
.timeline-item { display: flex; gap: 12px; padding: 12px; border-radius: var(--radius-sm); transition: background .12s; }
.timeline-item:hover { background: var(--bg); }
.tl-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tl-icon.call { background: var(--info-soft); color: var(--info); }
.tl-icon.email { background: var(--purple-soft); color: var(--purple); }
.tl-icon.meeting { background: var(--success-soft); color: var(--success); }
.tl-icon.note { background: var(--warning-soft); color: var(--warning); }
.tl-icon.task { background: var(--primary-soft); color: var(--primary); }
.tl-body { flex: 1; min-width: 0; }
.tl-subject { font-weight: 600; font-size: 13px; }
.tl-meta { font-size: 12px; color: var(--text-mute); margin-top: 2px; }
.tl-content { font-size: 13px; color: var(--text-soft); margin-top: 4px; line-height: 1.5; }

/* ============== MODAL ============== */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; animation: fadeIn .15s; }
.modal { background: white; border-radius: var(--radius-lg); width: 100%; max-width: 560px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: scaleIn .2s; }
.modal-lg { max-width: 760px; }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border-soft); }
.modal-h h3 { font-size: 17px; font-weight: 700; }
.modal-b { padding: 22px; overflow-y: auto; }
.modal-f { padding: 14px 22px; border-top: 1px solid var(--border-soft); display: flex; gap: 8px; justify-content: flex-end; background: var(--bg); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ============== FORMS ============== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 12px; font-weight: 600; color: var(--text-soft); }
.form-field input, .form-field select, .form-field textarea {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); transition: border .15s; background: white;
}
.form-field textarea { resize: vertical; min-height: 80px; font-family: inherit; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* ============== TOAST ============== */
#toast-host { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: white; border-radius: var(--radius-sm); padding: 12px 16px; box-shadow: var(--shadow-lg); border-left: 3px solid var(--primary); min-width: 240px; animation: slideIn .25s; font-size: 13px; font-weight: 500; }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
@keyframes slideIn { from { transform: translateX(110%); } to { transform: translateX(0); } }

/* ============== CLIENT DETAIL ============== */
.detail-header { display: flex; gap: 16px; align-items: center; padding: 20px; background: white; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 16px; }
.detail-avatar { width: 56px; height: 56px; border-radius: 16px; background: linear-gradient(135deg, var(--primary), var(--purple)); color: white; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; }
.detail-info h3 { font-size: 20px; font-weight: 700; }
.detail-info .sub { color: var(--text-soft); font-size: 13px; }
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.info-row { display: flex; padding: 10px 0; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.info-row:last-child { border-bottom: none; }
.info-row .lbl { width: 110px; color: var(--text-soft); font-weight: 500; }
.info-row .val { flex: 1; }

/* ============== EMPTY STATE ============== */
.empty { text-align: center; padding: 48px 20px; color: var(--text-mute); }
.empty svg { color: var(--text-mute); margin-bottom: 12px; opacity: 0.6; }
.empty h4 { color: var(--text-soft); margin-bottom: 4px; }

/* ============== SETTINGS ============== */
.settings-section { background: white; border-radius: var(--radius); padding: 24px; border: 1px solid var(--border); margin-bottom: 16px; }
.settings-section h3 { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.settings-section .desc { color: var(--text-soft); margin-bottom: 16px; font-size: 13px; }

/* ============== TAGS ============== */
.tag-chip { display: inline-block; padding: 2px 8px; background: var(--primary-soft); color: var(--primary-dark); border-radius: 6px; font-size: 11px; font-weight: 600; margin-right: 4px; }

/* ============== RESPONSIVE ============== */
@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-grid-3 { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { position: fixed; left: -260px; top: 0; height: 100vh; z-index: 50; transition: left .25s; box-shadow: var(--shadow-lg); }
  .sidebar.open { left: 0; }
  .hamburger { display: inline-flex; }
  .view-host { padding: 14px; }
  .topbar { padding: 12px 14px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 22px; }
  .table th, .table td { padding: 10px 12px; }
  .modal { max-height: 95vh; }
}
@media (max-width: 480px) {
  .kpis { grid-template-columns: 1fr; }
  .table-toolbar { flex-direction: column; align-items: stretch; }
  .pipe-col { flex: 0 0 260px; }
}

/* Backdrop mobile */
.sb-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 40; }
.sb-backdrop.show { display: block; }
