:root {
  --bg: #f4f7f5;
  --panel: #ffffff;
  --text: #18231f;
  --muted: #6f7b76;
  --line: #dfe6e2;
  --accent: #1f7a4d;
  --accent-2: #0f5d39;
  --danger: #b63131;
  --hot: #d45600;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.layout { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { background: #12201a; color: #fff; padding: 24px; display: flex; flex-direction: column; gap: 24px; }
.brand { font-weight: 800; font-size: 22px; line-height: 1.2; }
.nav { display: flex; flex-direction: column; gap: 10px; }
.nav a { color: #d8efe3; padding: 10px 12px; border-radius: 12px; }
.nav a:hover { background: rgba(255,255,255,0.08); text-decoration: none; }
.content { padding: 28px; }
.page-header h1 { margin: 0 0 8px; font-size: 32px; }
.page-header p { margin: 0 0 22px; color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 18px; box-shadow: 0 8px 18px rgba(15, 35, 28, 0.05); }
.cards-grid { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 18px; }
.cards-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat-card .stat { font-size: 34px; font-weight: 800; margin-top: 6px; }
.muted { color: var(--muted); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.btn { background: var(--accent); color: white; border: 0; border-radius: 12px; padding: 11px 16px; cursor: pointer; font-weight: 700; }
.btn:hover { background: var(--accent-2); }
.btn-secondary { background: #e9f1ed; color: var(--text); }
.btn-secondary:hover { background: #dce8e2; }
.w-full { width: 100%; }
.filters, .filter-bar { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 12px; margin-bottom: 16px; }
input, select, textarea { width: 100%; margin-top: 6px; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; font: inherit; background: white; }
label { display: block; font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.badge { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; padding: 6px 10px; background: #eef4f1; font-weight: 700; }
.badge-hot { background: #fff0e4; color: var(--hot); }
.details { display: grid; grid-template-columns: 180px 1fr; gap: 10px 14px; margin: 0; }
.details dt { color: var(--muted); font-weight: 600; }
.details dd { margin: 0; }
.preformatted, .code-box { white-space: pre-wrap; word-break: break-word; background: #fbfcfb; border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.comment { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: #fbfcfb; }
.comment-meta { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.auth-body { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #eef5f0, #dae8e0); }
.auth-card { width: 100%; max-width: 430px; background: white; padding: 26px; border-radius: 20px; border: 1px solid var(--line); box-shadow: 0 14px 36px rgba(15, 35, 28, 0.08); }
.alert.error { background: #ffeded; color: var(--danger); border: 1px solid #f0b4b4; padding: 12px; border-radius: 12px; margin-bottom: 16px; }
.checkbox { display: flex; gap: 10px; align-items: center; }
.checkbox input { width: auto; margin-top: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

@media (max-width: 1100px) {
  .cards-grid, .cards-grid.two, .filters, .filter-bar { grid-template-columns: 1fr; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { gap: 16px; }
}

.header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.stats-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.lead-filter-bar { grid-template-columns: minmax(220px, 2fr) minmax(150px, 1fr) minmax(150px, 1fr) minmax(110px, .7fr) auto auto auto auto; align-items: end; }
.checkbox.compact { font-weight: 600; white-space: nowrap; margin-top: 4px; }
.btn-mini { padding: 7px 9px; border-radius: 10px; font-size: 12px; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #912424; }
.quick-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.actions-cell { min-width: 230px; }
.lead-title-cell { min-width: 260px; }
.table-card { overflow-x: auto; }
.leads-table { min-width: 1100px; }
.status-pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 6px 10px; font-weight: 800; font-size: 12px; background: #eef4f1; color: var(--text); white-space: nowrap; }
.status-new { background: #eef4f1; color: #1f4d36; }
.status-in_progress { background: #e5f0ff; color: #124b8f; }
.status-duplicate { background: #fff1dd; color: #985c00; }
.status-irrelevant { background: #f3f3f3; color: #666; }
.status-processed { background: #e3f7ea; color: #19723a; }
.status-archived { background: #ececec; color: #555; }
.quick-panel { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.quick-panel-title { font-weight: 900; font-size: 18px; }
.detail-actions .btn { min-width: 130px; }

@media (max-width: 1300px) {
  .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lead-filter-bar { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 700px) {
  .header-row, .quick-panel { flex-direction: column; align-items: stretch; }
  .stats-grid { grid-template-columns: 1fr; }
  .lead-filter-bar { grid-template-columns: 1fr; }
  .quick-actions { flex-direction: column; align-items: stretch; }
  .quick-actions form, .quick-actions .btn { width: 100%; }
}

/* Sales funnel module */
.header-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.small { font-size: 12px; }
.wide-stats { grid-template-columns: repeat(8, minmax(0, 1fr)); }
.danger-soft { background: #fff5f5; border-color: #f1c7c7; }
.btn-success { background: #168a49; color: #fff; }
.btn-success:hover { background: #0f6c39; }
.status-contacted { background: #e6f7ff; color: #03637d; }
.status-waiting_reply { background: #fff8db; color: #8b6a00; }
.status-quote_requested { background: #f3e8ff; color: #6e3ca3; }
.status-quote_sent { background: #e8fff2; color: #157447; }
.status-deal { background: #dcfce7; color: #166534; }
.status-refused { background: #ffe4e6; color: #9f1239; }
.funnel-summary { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.funnel-summary div { display: flex; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fbfcfb; }
.funnel-summary span { color: var(--muted); }
.funnel-summary b { font-size: 18px; }
.funnel-board { display: grid; grid-template-columns: repeat(8, minmax(260px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 16px; margin-bottom: 18px; }
.funnel-column { min-width: 260px; background: #eef4f1; border: 1px solid var(--line); border-radius: 18px; padding: 12px; }
.funnel-column-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 900; margin-bottom: 10px; }
.funnel-column-head b { background: white; border: 1px solid var(--line); border-radius: 999px; padding: 4px 9px; }
.funnel-cards { display: flex; flex-direction: column; gap: 10px; }
.funnel-card { padding: 12px; box-shadow: none; }
.funnel-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.funnel-title { display: block; font-weight: 800; line-height: 1.25; margin-bottom: 8px; color: var(--text); }
.funnel-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.funnel-meta span { background: #eef4f1; border-radius: 999px; padding: 4px 8px; color: var(--muted); font-size: 12px; }
.funnel-actions { margin-top: 8px; }
.funnel-empty { border: 1px dashed #cfd8d3; border-radius: 14px; padding: 14px; color: var(--muted); text-align: center; }
.status-border-new { border-left: 4px solid #1f7a4d; }
.status-border-in_progress { border-left: 4px solid #124b8f; }
.status-border-contacted { border-left: 4px solid #03637d; }
.status-border-waiting_reply { border-left: 4px solid #8b6a00; }
.status-border-quote_requested { border-left: 4px solid #6e3ca3; }
.status-border-quote_sent { border-left: 4px solid #157447; }
.status-border-deal { border-left: 4px solid #166534; }
.status-border-refused { border-left: 4px solid #9f1239; }

@media (max-width: 1500px) {
  .wide-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 800px) {
  .wide-stats { grid-template-columns: 1fr; }
  .header-actions { justify-content: stretch; }
  .header-actions .btn { width: 100%; text-align: center; }
}
