/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Arial, sans-serif;
  font-size: 13px;
  color: #1a202c;
  background: #f0f4f8;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, textarea, select {
  font: inherit;
  border: 1px solid #cbd5e0;
  border-radius: 4px;
  padding: 6px 10px;
  background: #fff;
  color: #1a202c;
  outline: none;
  transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
textarea { resize: vertical; min-height: 80px; }

/* ── Login ────────────────────────────────────────────────────────────────── */
.login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: #1e3a5f;
}
.login-box {
  background: #fff; border-radius: 8px; padding: 36px 40px;
  width: 360px; box-shadow: 0 4px 24px rgba(0,0,0,.25);
}
.login-logo {
  display: flex; align-items: center; gap: 12px; margin-bottom: 28px;
}
.login-logo-icon { font-size: 36px; }
.login-logo-title { font-size: 20px; font-weight: 700; color: #1e3a5f; }
.login-logo-sub { font-size: 12px; color: #718096; }
.login-error { background: #fed7d7; color: #742a2a; padding: 8px 12px; border-radius: 4px; margin-bottom: 12px; font-size: 13px; }

/* ── App layout ───────────────────────────────────────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: 220px; flex-shrink: 0;
  background: #1e3a5f;
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: width .2s;
}
.sidebar.collapsed { width: 52px; }
.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .sidebar-sub,
.sidebar.collapsed .nav-item span:not(.nav-icon),
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .sidebar-user-info,
.sidebar.collapsed .sidebar-sub { display: none !important; }

.sidebar-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 14px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo-icon { font-size: 22px; flex-shrink: 0; }
.sidebar-title { font-size: 15px; font-weight: 700; color: #fff; white-space: nowrap; }
.sidebar-sub { font-size: 11px; color: rgba(255,255,255,.5); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }

.nav-section-title {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .8px;
  color: rgba(255,255,255,.35); padding: 14px 14px 4px; white-space: nowrap;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; color: rgba(255,255,255,.75);
  border-radius: 0; transition: background .15s, color .15s;
  white-space: nowrap; position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: #2c5282; color: #fff; font-weight: 500; }
.nav-icon { font-size: 16px; flex-shrink: 0; width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto; background: #e53e3e; color: #fff;
  font-size: 10px; font-weight: 700; min-width: 18px; height: 18px;
  border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 5px;
}

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 8px;
}
.sidebar-user { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.sidebar-user-info { min-width: 0; }
.sidebar-user-info > div:first-child { color: #fff; font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { color: rgba(255,255,255,.45); font-size: 11px; }

/* ── Main ─────────────────────────────────────────────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.topbar {
  height: 52px; background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; gap: 12px; flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.breadcrumb { font-size: 15px; font-weight: 600; color: #2d3748; }

.topbar-user { display: flex; align-items: center; gap: 8px; }
#topbar-user-name { font-size: 13px; font-weight: 500; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: 4px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background .15s, box-shadow .15s;
  border: 1px solid transparent;
}
.btn-primary { background: #2563eb; color: #fff; border-color: #1d4ed8; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #fff; color: #374151; border-color: #d1d5db; }
.btn-secondary:hover { background: #f9fafb; }
.btn-danger { background: #ef4444; color: #fff; border-color: #dc2626; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: none; color: #2563eb; font-size: 12px; padding: 0; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }
.btn-icon {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 4px; color: #4a5568; font-size: 16px;
  transition: background .15s;
}
.btn-icon:hover { background: #f0f4f8; }

/* ── Content area ─────────────────────────────────────────────────────────── */
.content { flex: 1; overflow-y: auto; padding: 20px; }
.content::-webkit-scrollbar { width: 6px; }
.content::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 3px; }

.page { display: none; }
.page.active { display: block; }

/* ── Page header ──────────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.page-title { font-size: 18px; font-weight: 700; color: #1a202c; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: #fff; border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  border: 1px solid #e2e8f0;
}
.card-header {
  padding: 12px 16px; border-bottom: 1px solid #e2e8f0;
  font-weight: 600; font-size: 13px; color: #2d3748;
  display: flex; align-items: center; justify-content: space-between;
}
.card-body { padding: 16px; }

/* ── KPI grid ─────────────────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 6px;
  padding: 14px 16px; box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.kpi-label { font-size: 11px; color: #718096; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.kpi-value { font-size: 26px; font-weight: 700; color: #1a202c; line-height: 1; }
.kpi-sub { font-size: 11px; color: #718096; margin-top: 4px; }
.kpi-delta-up { color: #38a169; }
.kpi-delta-down { color: #e53e3e; }

/* ── Dashboard layout ─────────────────────────────────────────────────────── */
.dashboard-grid { display: grid; grid-template-columns: 1fr 320px; gap: 16px; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: #f7fafc; text-align: left; padding: 8px 12px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  color: #718096; border-bottom: 1px solid #e2e8f0; white-space: nowrap;
}
tbody tr { border-bottom: 1px solid #f0f4f8; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f7fafc; }
tbody td { padding: 9px 12px; vertical-align: middle; }
.td-nowrap { white-space: nowrap; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-green { background: #c6f6d5; color: #22543d; }
.badge-yellow { background: #feebc8; color: #744210; }
.badge-red { background: #fed7d7; color: #742a2a; }
.badge-blue { background: #bee3f8; color: #2a4365; }
.badge-gray { background: #edf2f7; color: #4a5568; }
.badge-purple { background: #e9d8fd; color: #44337a; }

/* ── Filters row ──────────────────────────────────────────────────────────── */
.filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input { font-size: 13px; padding: 6px 10px; min-width: 120px; }
.filters .spacer { flex: 1; }

/* ── Task list ────────────────────────────────────────────────────────────── */
.task-list { display: flex; flex-direction: column; gap: 1px; }
.task-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; background: #fff;
  border-bottom: 1px solid #f0f4f8; cursor: pointer;
  transition: background .12s;
}
.task-row:hover { background: #f7fafc; }
.task-row:last-child { border-bottom: none; }
.task-priority-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.priority-urgent { background: #e53e3e; }
.priority-high { background: #ed8936; }
.priority-normal { background: #3b82f6; }
.priority-low { background: #a0aec0; }

.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 500; color: #2d3748; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-meta { font-size: 11px; color: #718096; margin-top: 2px; display: flex; gap: 10px; }
.task-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ── Kanban ───────────────────────────────────────────────────────────────── */
.kanban-board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; min-height: 500px; }
.kanban-col {
  flex-shrink: 0; width: 240px;
  background: #f7fafc; border: 1px solid #e2e8f0; border-radius: 6px;
  display: flex; flex-direction: column;
}
.kanban-col-header {
  padding: 10px 12px; font-weight: 600; font-size: 12px;
  border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; justify-content: space-between;
}
.kanban-cards { flex: 1; padding: 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.kanban-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 5px;
  padding: 10px 12px; cursor: pointer;
  transition: box-shadow .12s, border-color .12s;
}
.kanban-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.1); border-color: #cbd5e0; }
.kanban-card-title { font-weight: 500; font-size: 12px; color: #2d3748; margin-bottom: 6px; }
.kanban-card-meta { font-size: 11px; color: #718096; display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Deal card ────────────────────────────────────────────────────────────── */
.deal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.deal-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 6px;
  padding: 14px 16px; cursor: pointer;
  transition: box-shadow .12s, border-color .12s;
}
.deal-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,.1); border-color: #90cdf4; }
.deal-card-title { font-weight: 600; font-size: 14px; margin-bottom: 6px; color: #1a202c; }
.deal-card-company { font-size: 12px; color: #718096; margin-bottom: 8px; }
.deal-card-footer { display: flex; align-items: center; justify-content: space-between; }
.deal-amount { font-size: 15px; font-weight: 700; color: #2d3748; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 5px; font-size: 12px; color: #4a5568; }
.form-group input, .form-group select, .form-group textarea { width: 100%; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; padding-top: 8px; }

/* ── Modals ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 60px 20px; z-index: 1000; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 8px; width: 100%; max-width: 600px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.modal-lg { max-width: 800px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid #e2e8f0;
  font-weight: 600; font-size: 15px;
}
.modal-close {
  color: #718096; font-size: 18px; line-height: 1;
  padding: 2px 6px; border-radius: 4px;
}
.modal-close:hover { background: #f0f4f8; }
.modal-body { padding: 20px; }

/* ── Notifications ────────────────────────────────────────────────────────── */
.notif-btn-wrap { position: relative; }
.notif-btn { position: relative; }
.notif-badge {
  position: absolute; top: 0; right: 0;
  background: #e53e3e; color: #fff; font-size: 9px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.notif-dropdown {
  position: absolute; right: 0; top: 100%; margin-top: 4px;
  width: 340px; background: #fff; border: 1px solid #e2e8f0;
  border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 900;
}
.notif-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid #e2e8f0;
  font-weight: 600; font-size: 13px;
}
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item {
  display: flex; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid #f0f4f8; cursor: pointer;
  transition: background .12s;
}
.notif-item:hover { background: #f7fafc; }
.notif-item.unread { background: #ebf8ff; }
.notif-item.unread:hover { background: #bee3f8; }
.notif-icon { font-size: 18px; flex-shrink: 0; margin-top: 2px; }
.notif-content { min-width: 0; }
.notif-title { font-weight: 500; font-size: 12px; color: #2d3748; }
.notif-body { font-size: 11px; color: #718096; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-time { font-size: 10px; color: #a0aec0; margin-top: 3px; }
.notif-empty { padding: 24px; text-align: center; color: #a0aec0; font-size: 12px; }

/* ── Activity feed ────────────────────────────────────────────────────────── */
.activity-item {
  display: flex; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid #f0f4f8;
}
.activity-item:last-child { border-bottom: none; }
.activity-icon { font-size: 18px; flex-shrink: 0; width: 28px; text-align: center; }
.activity-content { min-width: 0; }
.activity-text { font-size: 13px; color: #2d3748; }
.activity-time { font-size: 11px; color: #a0aec0; margin-top: 2px; }

/* ── Task detail ──────────────────────────────────────────────────────────── */
.task-detail-grid { display: grid; grid-template-columns: 1fr 260px; gap: 20px; }
.task-detail-left {}
.task-detail-right { display: flex; flex-direction: column; gap: 12px; }
.detail-section { margin-bottom: 20px; }
.detail-section-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: #718096; margin-bottom: 8px; }
.detail-field { margin-bottom: 10px; }
.detail-label { font-size: 11px; color: #a0aec0; margin-bottom: 2px; }
.detail-value { font-size: 13px; color: #2d3748; }

/* Status selector buttons */
.status-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.status-btn {
  padding: 5px 10px; border-radius: 4px; font-size: 11px; font-weight: 600;
  border: 2px solid transparent; cursor: pointer; transition: all .12s;
}
.status-btn.active { border-color: currentColor; }
.status-open { background: #edf2f7; color: #4a5568; }
.status-in_progress { background: #bee3f8; color: #2a4365; }
.status-review { background: #feebc8; color: #744210; }
.status-done { background: #c6f6d5; color: #22543d; }
.status-cancelled { background: #fed7d7; color: #742a2a; }

/* Comments */
.comment-list { display: flex; flex-direction: column; gap: 10px; }
.comment-item { display: flex; gap: 10px; }
.comment-bubble {
  background: #f7fafc; border: 1px solid #e2e8f0; border-radius: 6px;
  padding: 8px 12px; flex: 1;
}
.comment-author { font-weight: 600; font-size: 12px; color: #2d3748; }
.comment-time { font-size: 11px; color: #a0aec0; margin-left: 8px; }
.comment-text { font-size: 13px; color: #4a5568; margin-top: 4px; white-space: pre-wrap; }
.comment-form { display: flex; gap: 8px; margin-top: 12px; }
.comment-form textarea { flex: 1; min-height: 60px; }

/* ── User avatar ──────────────────────────────────────────────────────────── */
.user-avatar-sm {
  width: 30px; height: 30px; border-radius: 50%;
  background: #2c5282; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}

/* ── Quick create menu ────────────────────────────────────────────────────── */
.quick-menu {
  position: fixed; top: 52px; right: 60px;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 800; min-width: 180px;
}
.quick-menu-item {
  display: block; width: 100%; text-align: left;
  padding: 10px 14px; font-size: 13px; color: #374151;
  transition: background .12s;
}
.quick-menu-item:hover { background: #f7fafc; }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 40px 20px; color: #a0aec0; }
.empty-state-icon { font-size: 36px; margin-bottom: 10px; }
.empty-state-text { font-size: 14px; }

/* ── Loader ───────────────────────────────────────────────────────────────── */
.loader { text-align: center; padding: 24px; color: #a0aec0; font-size: 13px; }

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid #e2e8f0; margin-bottom: 16px; }
.tab {
  padding: 8px 16px; font-size: 13px; font-weight: 500; color: #718096;
  border-bottom: 2px solid transparent; margin-bottom: -2px; cursor: pointer;
  transition: color .12s, border-color .12s;
}
.tab.active { color: #2563eb; border-bottom-color: #2563eb; }
.tab:hover:not(.active) { color: #2d3748; }

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; justify-content: center; padding: 12px 0; }
.pagination button { padding: 5px 10px; border: 1px solid #e2e8f0; border-radius: 4px; font-size: 12px; background: #fff; color: #4a5568; }
.pagination button.active, .pagination button:hover { background: #2563eb; color: #fff; border-color: #2563eb; }

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.text-muted { color: #718096; }
.text-small { font-size: 11px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-12 { margin-bottom: 12px; }
.flex { display: flex; }
.flex-center { align-items: center; }
.gap-8 { gap: 8px; }
.divider { border: none; border-top: 1px solid #e2e8f0; margin: 16px 0; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .task-detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .sidebar { position: fixed; z-index: 500; height: 100%; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.mobile-open { transform: translateX(0); }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Sidebar toggle ───────────────────────────────────────────────────────── */
.sidebar-toggle { display: flex; }
