/* ============================================================
   Kasvuvoima CRM — design system
   ============================================================ */
:root {
  --bg:          #f5f7fa;
  --surface:     #ffffff;
  --surface-2:   #fbfcfe;
  --ink:         #0f172a;
  --ink-soft:    #334155;
  --muted:       #64748b;
  --line:        #e8edf3;
  --line-soft:   #f1f5f9;

  --brand:       #10b981;
  --brand-600:   #059669;
  --brand-700:   #047857;
  --brand-soft:  #ecfdf5;
  --grad:        linear-gradient(135deg, #10b981 0%, #0d9488 100%);
  --grad-soft:   linear-gradient(135deg, #34d399 0%, #14b8a6 100%);

  --sidebar:     #0b1424;
  --sidebar-2:   #0f1d33;

  --shadow-sm:   0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.04);
  --shadow:      0 4px 12px rgba(15,23,42,.06), 0 2px 4px rgba(15,23,42,.04);
  --shadow-lg:   0 18px 40px rgba(15,23,42,.12);
  --radius:      14px;
  --radius-sm:   10px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 0.9rem;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

h1, h2, h3, h4, h5 { letter-spacing: -0.02em; }

/* ============================================================
   App shell + sidebar
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 256px;
  flex: 0 0 256px;
  background: linear-gradient(180deg, var(--sidebar-2) 0%, var(--sidebar) 100%);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1040;
  border-right: 1px solid rgba(255,255,255,.04);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 22px 20px 18px;
}
.brand-mark {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: var(--grad);
  border-radius: 11px;
  font-weight: 800;
  font-size: 1.25rem;
  color: #fff;
  box-shadow: 0 6px 16px rgba(16,185,129,.35);
}
.brand-text {
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  line-height: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.brand-text small {
  font-size: .62rem;
  letter-spacing: .22em;
  color: var(--brand);
  font-weight: 600;
}

.sidebar-nav { padding: 8px 14px; flex: 1; overflow-y: auto; }
.nav-label {
  font-size: .67rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: #5b6b82;
  font-weight: 600;
  padding: 10px 12px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #94a3b8;
  text-decoration: none;
  font-weight: 500;
  font-size: .9rem;
  margin-bottom: 2px;
  transition: all .15s ease;
  position: relative;
}
.nav-item i { font-size: 1.05rem; width: 20px; text-align: center; }
.nav-item:hover { background: rgba(255,255,255,.05); color: #e2e8f0; }
.nav-item.active {
  background: rgba(16,185,129,.12);
  color: #fff;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -14px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 22px;
  background: var(--brand);
  border-radius: 0 3px 3px 0;
}
.nav-item.active i { color: var(--brand); }
.nav-ext { margin-left: auto; font-size: .75rem !important; opacity: .5; }

.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,.05); }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: rgba(255,255,255,.04);
  border-radius: 11px;
}
.user-avatar {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: var(--grad);
  color: #fff; font-weight: 700;
  border-radius: 9px;
  flex-shrink: 0;
}
.user-meta { line-height: 1.2; flex: 1; min-width: 0; }
.user-meta strong { color: #fff; font-size: .85rem; display: block; }
.user-meta small { color: #64748b; font-size: .72rem; }
.logout-btn {
  color: #64748b; font-size: 1.05rem;
  padding: 4px; border-radius: 7px;
  transition: all .15s;
}
.logout-btn:hover { color: #f87171; background: rgba(248,113,113,.1); }

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(8,12,20,.5);
  z-index: 1035;
  backdrop-filter: blur(2px);
}

/* ============================================================
   Main + topbar
   ============================================================ */
.main {
  flex: 1;
  margin-left: 256px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 32px;
  background: rgba(245,247,250,.8);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 1020;
  border-bottom: 1px solid var(--line);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0;
  color: var(--ink);
}
.topbar-title .subtitle {
  font-size: .82rem;
  color: var(--muted);
  margin-top: 2px;
}
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.menu-toggle {
  display: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  width: 40px; height: 40px;
  font-size: 1.2rem;
  color: var(--ink);
  cursor: pointer;
}
.content { padding: 28px 32px 48px; }

/* ============================================================
   Cards
   ============================================================ */
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--line-soft);
  padding: 16px 20px;
  font-weight: 600;
  border-radius: var(--radius) var(--radius) 0 0 !important;
}
.card-body { padding: 20px; }

/* ============================================================
   Stat cards
   ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.stat-icon {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 12px;
  font-size: 1.3rem;
  color: #fff;
  margin-bottom: 16px;
}
.stat-icon.g-emerald { background: linear-gradient(135deg,#10b981,#0d9488); box-shadow:0 8px 18px rgba(16,185,129,.3); }
.stat-icon.g-blue    { background: linear-gradient(135deg,#3b82f6,#2563eb); box-shadow:0 8px 18px rgba(59,130,246,.3); }
.stat-icon.g-violet  { background: linear-gradient(135deg,#8b5cf6,#6d28d9); box-shadow:0 8px 18px rgba(139,92,246,.3); }
.stat-icon.g-amber   { background: linear-gradient(135deg,#f59e0b,#d97706); box-shadow:0 8px 18px rgba(245,158,11,.3); }
.stat-value { font-size: 2rem; font-weight: 800; line-height: 1; color: var(--ink); }
.stat-label { font-size: .82rem; color: var(--muted); margin-top: 6px; font-weight: 500; }
.stat-trend { font-size: .75rem; font-weight: 600; margin-top: 10px; display: inline-flex; align-items: center; gap: 4px; }
.stat-trend.up { color: var(--brand-600); }
.stat-card .stat-bg {
  position: absolute; right: -20px; top: -20px;
  font-size: 7rem; opacity: .04; color: var(--ink);
  transform: rotate(-12deg); pointer-events: none;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn { font-weight: 600; border-radius: 10px; padding: .5rem .95rem; font-size: .85rem; transition: all .15s; }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; border-radius: 8px; }
.btn-lg { padding: .8rem 1.6rem; font-size: 1rem; border-radius: 12px; }

.btn-primary, .btn-dark {
  background: var(--grad);
  border: none;
  color: #fff;
  box-shadow: 0 4px 12px rgba(16,185,129,.28);
}
.btn-primary:hover, .btn-dark:hover {
  background: linear-gradient(135deg,#0ea371 0%,#0b8276 100%);
  color: #fff;
  box-shadow: 0 6px 18px rgba(16,185,129,.4);
  transform: translateY(-1px);
}
.btn-outline-secondary {
  border-color: var(--line);
  color: var(--ink-soft);
  background: var(--surface);
}
.btn-outline-secondary:hover { background: var(--line-soft); color: var(--ink); border-color: #cbd5e1; }
.btn-outline-success { border-color: #a7f3d0; color: var(--brand-600); }
.btn-outline-success:hover { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-outline-danger { border-color: #fecaca; color: #dc2626; }
.btn-outline-danger:hover { background: #ef4444; border-color: #ef4444; color: #fff; }
.btn-link { text-decoration: none; }

/* ============================================================
   Badges / stage pills
   ============================================================ */
.badge { font-weight: 600; padding: .4em .7em; border-radius: 7px; font-size: .72rem; letter-spacing: .01em; }
.stage-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: .32em .7em; border-radius: 20px;
  font-size: .72rem; font-weight: 600; text-transform: capitalize;
}
.stage-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.stage-lead       { background: #f1f5f9; color: #64748b; }
.stage-contacted  { background: #eff6ff; color: #2563eb; }
.stage-proposal   { background: #f5f3ff; color: #7c3aed; }
.stage-won        { background: #ecfdf5; color: #059669; }
.stage-lost       { background: #fef2f2; color: #dc2626; }

.tag-chip {
  display: inline-block;
  background: var(--brand-soft);
  color: var(--brand-700);
  border: 1px solid #d1fae5;
  padding: .2em .6em;
  border-radius: 6px;
  font-size: .73rem;
  font-weight: 500;
  margin: 0 3px 3px 0;
}

/* ============================================================
   Tables
   ============================================================ */
.table { margin: 0; }
.table thead th {
  font-weight: 600; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted);
  border-bottom: 1px solid var(--line); padding: 12px 20px;
  background: var(--surface-2);
}
.table tbody td { padding: 14px 20px; vertical-align: middle; border-color: var(--line-soft); }
.table tbody tr { transition: background .12s; }
.table-hover tbody tr:hover { background: var(--surface-2); }
.table a { color: var(--ink); }
.table a:hover { color: var(--brand-600); }
.card > .table:last-child tbody tr:last-child td,
.card .table-flush tbody tr:last-child td { border-bottom: 0; }

/* ============================================================
   Forms
   ============================================================ */
.form-label { font-weight: 600; font-size: .82rem; color: var(--ink-soft); margin-bottom: .4rem; }
.form-control, .form-select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .6rem .8rem;
  font-size: .88rem;
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(16,185,129,.15);
}
.form-control::placeholder { color: #9aa6b6; }

/* ============================================================
   List groups
   ============================================================ */
.list-group-item {
  padding: 14px 20px;
  border-color: var(--line-soft);
  font-size: .88rem;
}
.list-group-item:first-child { border-top: 0; }

/* ============================================================
   Section heading helper
   ============================================================ */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.muted { color: var(--muted); }
.empty-state {
  text-align: center; padding: 48px 20px; color: var(--muted);
}
.empty-state i { font-size: 2.4rem; opacity: .3; display: block; margin-bottom: 12px; }

/* ============================================================
   Kanban board
   ============================================================ */
.kanban {
  display: grid;
  grid-template-columns: repeat(5, minmax(204px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
}
.kanban-col {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  min-height: 180px;
}
.kanban-col-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.kanban-col-head .col-name { font-weight: 700; font-size: .82rem; text-transform: capitalize; display: flex; align-items: center; gap: 7px; }
.kanban-col-head .col-dot { width: 8px; height: 8px; border-radius: 50%; }
.kanban-col-head .col-count { font-size: .72rem; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 1px 9px; font-weight: 600; }
.kanban-col-total { padding: 4px 16px 10px; font-size: .75rem; color: var(--muted); font-weight: 600; }
.kanban-cards { padding: 6px 12px 14px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.deal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 13px 14px;
  text-decoration: none;
  display: block;
  box-shadow: var(--shadow-sm);
  transition: all .15s;
  border-left: 3px solid transparent;
}
.deal-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-left-color: var(--brand); }
.deal-card .deal-name { font-weight: 600; color: var(--ink); font-size: .88rem; margin-bottom: 5px; }
.deal-card .deal-value { font-weight: 800; color: var(--brand-700); font-size: 1rem; }
.deal-card .deal-contact { font-size: .76rem; color: var(--muted); margin-top: 6px; display: flex; align-items: center; gap: 5px; }
.col-dot.d-lead { background:#94a3b8; } .col-dot.d-contacted { background:#3b82f6; }
.col-dot.d-proposal { background:#8b5cf6; } .col-dot.d-won { background:#10b981; }
.col-dot.d-lost { background:#ef4444; }

/* ============================================================
   Auth + landing share these
   ============================================================ */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  background: var(--bg);
}
.auth-brand {
  background: linear-gradient(150deg, #0b1424 0%, #0f1d33 55%, #064e3b 140%);
  color: #fff;
  padding: 56px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.auth-brand::after {
  content: ''; position: absolute; width: 460px; height: 460px;
  background: radial-gradient(circle, rgba(16,185,129,.25), transparent 70%);
  bottom: -160px; right: -120px; border-radius: 50%;
}
.auth-brand .brand-mark { width: 48px; height: 48px; font-size: 1.5rem; border-radius: 13px; }
.auth-tag { font-size: 2rem; font-weight: 800; line-height: 1.18; margin: 0; max-width: 440px; }
.auth-tag span { background: var(--grad-soft); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.auth-points { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 14px; position: relative; z-index: 2; }
.auth-points li { display: flex; gap: 11px; align-items: center; color: #cbd5e1; font-size: .92rem; }
.auth-points i { color: var(--brand); font-size: 1.1rem; }
.auth-form-side { display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth-card { width: 100%; max-width: 360px; }
.auth-card h2 { font-weight: 800; font-size: 1.5rem; margin-bottom: 4px; }

@media (max-width: 900px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 992px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: grid; place-items: center; }
  .sidebar-backdrop.show { display: block; }
  .content { padding: 20px 18px 40px; }
  .topbar { padding: 16px 18px; }
}
