/* Masgrow ERP Hub — main dashboard */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 240px;
  --topbar-h: 58px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-sm: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --blue: #3b82f6;
  --purple: #8b5cf6;
  --teal: #14b8a6;
  --amber: #f59e0b;
  --green: #22c55e;
  --red: #ef4444;
  --blue-bg: #eff6ff;
  --purple-bg: #f5f3ff;
  --teal-bg: #f0fdfa;
  --amber-bg: #fffbeb;
  --green-bg: #f0fdf4;
  --red-bg: #fef2f2;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08);
}

html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 13.5px;
  line-height: 1.5;
  display: flex;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
button { font-family: var(--font); cursor: pointer; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: #0f172a;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  border-right: 1px solid rgba(255,255,255,.06);
  z-index: 200;
}
.sidebar-logo {
  height: var(--topbar-h);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.logo-mark {
  width: 34px; height: 34px;
  background: var(--blue);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.logo-mark i { width: 18px; height: 18px; }
.brand { font-size: 15px; font-weight: 700; color: #f8fafc; }
.brand span { color: var(--blue); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0 12px; scrollbar-width: none; }
.sidebar-nav::-webkit-scrollbar { display: none; }
.nav-group { padding: 0 12px; margin-bottom: 4px; }
.nav-section {
  display: block;
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1px;
  color: #475569; padding: 14px 8px 5px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: #94a3b8; font-size: 13px; font-weight: 450;
  transition: background .13s, color .13s; margin-bottom: 1px;
}
.nav-item i { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.nav-item.active { background: rgba(59,130,246,.18); color: #93c5fd; font-weight: 500; }
.badge {
  margin-left: auto; background: var(--red); color: #fff;
  border-radius: 20px; padding: 1px 7px; font-size: 10px; font-weight: 700;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; gap: 10px;
}
.avatar-wrap { position: relative; }
.avatar-status {
  position: absolute; bottom: 0; right: 0;
  width: 8px; height: 8px; background: var(--green);
  border-radius: 50%; border: 2px solid #0f172a;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 11px;
}
.avatar.sm { width: 28px; height: 28px; font-size: 10px; }
.user-info { flex: 1; min-width: 0; }
.user-info .name { color: #e2e8f0; font-weight: 600; font-size: 12.5px; }
.user-info .role { color: #475569; font-size: 10.5px; }
.icon-ghost {
  background: none; border: none; color: #475569;
  padding: 4px; border-radius: var(--radius-sm);
  display: flex; align-items: center;
}
.icon-ghost i { width: 15px; height: 15px; }
.icon-ghost:hover { background: rgba(255,255,255,.08); color: #94a3b8; }

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  z-index: 150;
}
.sidebar-backdrop.show { display: block; }

.menu-toggle {
  display: none;
  flex-direction: column; justify-content: center; gap: 5px;
  width: 36px; height: 36px;
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px;
}
.menu-toggle span {
  display: block; height: 2px; background: var(--text-secondary);
  border-radius: 2px;
}

/* Main */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-left h1 { font-size: 15px; font-weight: 700; }
.topbar-left p { font-size: 11px; color: var(--text-muted); }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.search-wrap { position: relative; display: flex; align-items: center; }
.search-icon {
  position: absolute; left: 10px;
  width: 14px; height: 14px; color: var(--text-muted); pointer-events: none;
}
.search-box {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 36px 6px 32px;
  font-size: 12.5px; font-family: var(--font);
  width: 220px; outline: none;
}
.search-box:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,130,246,.1); }
.search-kbd {
  position: absolute; right: 8px; font-size: 10px;
  color: var(--text-muted); background: var(--border-sm);
  border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px;
}

.icon-btn {
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); position: relative;
}
.icon-btn i { width: 16px; height: 16px; }
.notif-dot {
  position: absolute; top: 7px; right: 8px;
  width: 6px; height: 6px; background: var(--red);
  border-radius: 50%; border: 1.5px solid var(--surface);
}
.divider-v { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }
.user-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--border); border-radius: 20px;
  font-size: 12.5px; font-weight: 500;
}

.content {
  flex: 1; overflow-y: auto;
  padding: 22px 24px 32px;
  scrollbar-width: thin;
}

.page-heading {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}
.page-heading h2 { font-size: 18px; font-weight: 700; }
.page-heading p { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.heading-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn-ghost, .btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-sm);
  font-size: 12.5px; font-weight: 500;
}
.btn-ghost {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg); color: var(--text-primary); }
.btn-primary {
  border: none; background: var(--blue); color: #fff; font-weight: 600;
  box-shadow: 0 1px 3px rgba(59,130,246,.4);
}
.btn-primary:hover { background: #2563eb; }

.section-title {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted); margin-bottom: 12px;
}

/* Module launcher */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.module-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s, border-color .15s;
  --mc: var(--blue);
}
.module-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--mc) 35%, var(--border));
}
.module-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: color-mix(in srgb, var(--mc) 12%, #fff);
  color: var(--mc);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.module-icon i { width: 22px; height: 22px; }
.module-body { flex: 1; min-width: 0; }
.module-title {
  font-size: 14px; font-weight: 700; color: var(--text-primary);
  display: flex; align-items: center; gap: 8px;
}
.module-badge {
  font-size: 10px; font-weight: 700;
  background: var(--red); color: #fff;
  padding: 1px 7px; border-radius: 20px;
}
.module-desc { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.module-stat { font-size: 11px; font-weight: 600; color: var(--mc, var(--blue)); margin-top: 6px; }
.module-arrow { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.module-card:hover .module-arrow { color: var(--mc); }

/* KPI */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px; margin-bottom: 18px;
}
.kpi-card {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); padding: 18px 20px;
  box-shadow: var(--shadow);
}
.kpi-top { display: flex; justify-content: space-between; margin-bottom: 12px; }
.kpi-label { font-size: 11.5px; color: var(--text-secondary); }
.kpi-icon-wrap {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.kpi-icon-wrap i { width: 16px; height: 16px; }
.kpi-icon-wrap.blue { background: var(--blue-bg); color: var(--blue); }
.kpi-icon-wrap.purple { background: var(--purple-bg); color: var(--purple); }
.kpi-icon-wrap.teal { background: var(--teal-bg); color: var(--teal); }
.kpi-icon-wrap.amber { background: var(--amber-bg); color: var(--amber); }
.kpi-value { font-size: 24px; font-weight: 800; letter-spacing: -.5px; margin-bottom: 10px; }
.kpi-footer { display: flex; align-items: center; gap: 6px; }
.kpi-badge {
  font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 20px;
}
.kpi-badge.up { background: var(--green-bg); color: #16a34a; }
.kpi-badge.down { background: var(--red-bg); color: #dc2626; }
.kpi-badge.warn { background: var(--amber-bg); color: #b45309; }
.kpi-comp { font-size: 11px; color: var(--text-muted); }

/* Cards & charts */
.card {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); padding: 20px; box-shadow: var(--shadow);
}
.card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 16px; gap: 12px;
}
.card-title { font-size: 13.5px; font-weight: 700; }
.card-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.pill-group { display: flex; gap: 4px; }
.pill {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 4px 11px;
  font-size: 11.5px; font-family: var(--font); color: var(--text-secondary);
}
.pill.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.link-btn {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 500; color: var(--blue);
}
.link-btn i { width: 13px; height: 13px; }

.charts-row {
  display: grid; grid-template-columns: 2fr 1fr;
  gap: 14px; margin-bottom: 18px;
}
.chart-area { display: flex; gap: 10px; height: 130px; }
.y-axis {
  display: flex; flex-direction: column; justify-content: space-between;
  text-align: right; padding-bottom: 18px;
}
.y-axis span { font-size: 10px; color: var(--text-muted); }
.bar-chart-wrap { flex: 1; position: relative; }
.x-grid {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: space-between;
  pointer-events: none; padding-bottom: 18px;
}
.grid-line { border-top: 1px dashed #f1f5f9; width: 100%; }
.bar-chart {
  position: relative; display: flex; align-items: flex-end; gap: 5px;
  height: 112px; z-index: 1;
}
.bar-wrap {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end; height: 100%;
}
.bar {
  width: 100%; border-radius: 4px 4px 0 0; min-height: 3px;
  transition: opacity .15s;
}
.bar-label { font-size: 9.5px; color: var(--text-muted); margin-top: 4px; }
.chart-legend { margin-top: 12px; font-size: 11px; color: var(--text-muted); }
.legend-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; margin-right: 5px;
}

.donut-wrap { display: flex; flex-direction: column; align-items: center; }
.donut-legend { width: 100%; display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.dl-item { display: flex; align-items: center; font-size: 12px; }
.dl-left { display: flex; align-items: center; gap: 7px; flex: 1; }
.dl-dot { width: 8px; height: 8px; border-radius: 50%; }
.dl-name { color: var(--text-secondary); }
.dl-val { font-weight: 700; min-width: 22px; text-align: right; }
.dl-pct { font-size: 11px; color: var(--text-muted); min-width: 36px; text-align: right; }

.bottom-row {
  display: grid; grid-template-columns: 1.5fr 1fr 1fr;
  gap: 14px;
}

.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px;
  font-weight: 600; color: var(--text-muted);
  padding: 0 10px 10px; text-align: left;
  border-bottom: 1px solid var(--border-sm);
}
.data-table tbody tr { border-bottom: 1px solid var(--border-sm); }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody td { padding: 10px; font-size: 12.5px; }
.fw-600 { font-weight: 600; }
.text-muted { color: var(--text-muted) !important; font-size: 12px; }

.contact-cell { display: flex; align-items: center; gap: 9px; }
.mini-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 10px;
}
.contact-name { font-weight: 500; font-size: 12.5px; }
.contact-co { font-size: 11px; color: var(--text-muted); }

.status-pill {
  display: inline-block; border-radius: 20px;
  padding: 3px 9px; font-size: 10.5px; font-weight: 600;
}
.status-pill.won { background: var(--green-bg); color: #15803d; }
.status-pill.active-deal { background: var(--blue-bg); color: #1d4ed8; }
.status-pill.nego { background: var(--amber-bg); color: #b45309; }
.status-pill.lost { background: var(--red-bg); color: #b91c1c; }

.activity-list { display: flex; flex-direction: column; }
.act-item {
  display: flex; gap: 10px; padding: 9px 0;
  border-bottom: 1px solid var(--border-sm);
}
.act-item:last-child { border: none; }
.act-icon-wrap {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.act-icon-wrap i { width: 13px; height: 13px; }
.act-icon-wrap.green { background: var(--green-bg); color: #16a34a; }
.act-icon-wrap.blue { background: var(--blue-bg); color: var(--blue); }
.act-icon-wrap.amber { background: var(--amber-bg); color: var(--amber); }
.act-icon-wrap.purple { background: var(--purple-bg); color: var(--purple); }
.act-icon-wrap.red { background: var(--red-bg); color: var(--red); }
.act-text { font-size: 12px; color: var(--text-secondary); line-height: 1.45; }
.act-text strong { color: var(--text-primary); }
.act-time { font-size: 10.5px; color: var(--text-muted); margin-top: 2px; }

.pipeline-stages { display: flex; flex-direction: column; gap: 10px; }
.stage-row { display: flex; flex-direction: column; gap: 4px; }
.stage-info { display: flex; justify-content: space-between; font-size: 12px; }
.stage-left { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.stage-val { font-weight: 600; font-size: 11.5px; }
.stage-count {
  font-size: 10px; color: var(--text-muted);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 20px; padding: 0 6px;
}
.stage-bar-bg { background: #f1f5f9; border-radius: 4px; height: 5px; }
.stage-bar-fill { height: 5px; border-radius: 4px; }

.upcoming-header {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .7px;
  margin-top: 18px; padding-top: 14px;
  border-top: 1px solid var(--border-sm); margin-bottom: 10px;
}
.course-list { display: flex; flex-direction: column; gap: 7px; }
.course-item { display: flex; justify-content: space-between; font-size: 12px; }
.course-left { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); }
.course-dot { width: 7px; height: 7px; border-radius: 50%; }
.course-dot.blue { background: var(--blue); }
.course-dot.amber { background: var(--amber); }
.course-date { font-size: 11.5px; font-weight: 600; color: var(--blue); }
.course-date.amber { color: var(--amber); }

.empty-note {
  text-align: center; color: var(--text-muted);
  padding: 24px 12px; font-size: 12.5px;
}

/* Login */
body.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; overflow: auto;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
}
.login-wrap { width: 100%; max-width: 400px; padding: 24px; }
.login-box {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 36px 32px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-mark {
  width: 52px; height: 52px; margin: 0 auto 14px;
  border-radius: 14px; font-size: 22px; font-weight: 800;
}
.login-logo h1 { font-size: 22px; font-weight: 800; color: var(--text-primary); }
.login-logo p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.login-error {
  background: var(--red-bg); color: #b91c1c;
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 16px;
}
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 6px;
}
.form-input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: var(--font); outline: none;
}
.form-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,130,246,.1); }
.w-full { width: 100%; }

/* Responsive */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .bottom-row { grid-template-columns: 1fr 1fr; }
  .bottom-row .card:first-child { grid-column: 1 / -1; }
}
@media (max-width: 960px) {
  .charts-row { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: flex; }
  .bottom-row, .kpi-grid { grid-template-columns: 1fr; }
  .search-box { width: 140px; }
  .search-kbd, .user-chip span, .divider-v { display: none; }
  .page-heading { flex-direction: column; align-items: flex-start; }
}
