* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --vinotinto: #6b0f1a;
  --vinotinto-dark: #4a0911;
  --vinotinto-light: #8e1624;
  --gold: #b8860b;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1c1e21;
  --muted: #65676b;
  --border: #dfe3e8;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.topbar {
  background: linear-gradient(135deg, var(--vinotinto-dark), var(--vinotinto));
  color: #fff;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  box-shadow: 0 2px 10px rgba(74, 9, 17, 0.25);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  background: #fff;
  color: var(--vinotinto);
  font-weight: 800;
  font-size: 16px;
  padding: 8px 11px;
  border-radius: 8px;
  letter-spacing: 0.5px;
}

.topbar h1 {
  font-size: 17px;
  font-weight: 700;
}

.subtitle {
  font-size: 12px;
  opacity: 0.85;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
}

.status-demo {
  background: rgba(255, 215, 0, 0.2);
  color: #ffe57f;
  border: 1px solid rgba(255, 229, 127, 0.4);
}

.status-live {
  background: rgba(46, 204, 113, 0.2);
  color: #a3f7bf;
  border: 1px solid rgba(163, 247, 191, 0.45);
}

.btn {
  border: none;
  border-radius: 7px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s ease;
}

.btn-primary {
  background: #ffffff;
  color: var(--vinotinto);
}

.modal .btn-primary {
  background: var(--vinotinto);
  color: #fff;
}

.btn-primary:hover {
  opacity: 0.92;
}

.btn-outline {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.modal .btn-outline {
  background: #f0f2f5;
  color: var(--text);
  border: 1px solid var(--border);
}

.container {
  max-width: 1440px;
  margin: 20px auto;
  padding: 0 20px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface);
  border-radius: 10px;
  padding: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-alert {
  border-left: 4px solid var(--vinotinto);
}

.kpi-gold {
  border-left: 4px solid var(--gold);
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
}

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
}

.kpi-sub {
  font-size: 12px;
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
}

.tab {
  background: none;
  border: none;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
}

.tab.active {
  color: var(--vinotinto);
  border-bottom-color: var(--vinotinto);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.toolbar input,
.toolbar select {
  padding: 8px 12px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  min-width: 200px;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(235px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.kanban-col {
  background: #ebedf0;
  border-radius: 10px;
  padding: 10px;
  min-height: 460px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kanban-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--vinotinto-dark);
  padding: 4px 6px;
}

.col-count {
  background: var(--vinotinto);
  color: #fff;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
}

.lead-card {
  background: var(--surface);
  border-radius: 8px;
  padding: 11px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  cursor: grab;
  transition: transform 0.1s ease;
}

.lead-card:active {
  cursor: grabbing;
}

.lead-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
}

.lead-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.lead-tags {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  background: #f3e6e8;
  color: var(--vinotinto);
  padding: 2px 7px;
  border-radius: 5px;
  font-weight: 600;
}

.tag-price {
  background: #eef7ee;
  color: #1e7e34;
  padding: 2px 7px;
  border-radius: 5px;
  font-weight: 700;
}

.wa-link {
  text-decoration: none;
  font-weight: 700;
  color: #128c7e;
}

.table-card {
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: #fafafa;
  font-weight: 700;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.badge-route {
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
}

.route-ESCALAR_LEGAL {
  background: #fdecea;
  color: #b71c1c;
}

.route-ESCALAR_BROKER {
  background: #fff4e5;
  color: #b25e09;
}

.route-RUTA_OPERATIVA {
  background: #e8f4fd;
  color: #0d47a1;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--surface);
  border-radius: 12px;
  max-width: 540px;
  width: 100%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.modal-header {
  background: var(--vinotinto);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.close-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.modal-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-body label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
}

.modal-body input,
.modal-body select,
.modal-body textarea {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
}

.case-box {
  background: #f8f9fa;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
  white-space: pre-wrap;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}
