/* ── Dashboard Layout ── */
.dashboard-grid {
  padding: 20px;
  display: grid;
  gap: 8px;
  grid-template-columns: 3fr 2fr;
  grid-template-areas: "main side";
}

.dashboard-main { grid-area: main; display: flex; flex-direction: column; gap: 8px; }
.dashboard-side { grid-area: side; display: flex; flex-direction: column; gap: 8px; }

.kpi-pair { display: flex; gap: 8px; }
.kpi-pair .tile { flex: 1; min-width: 0; }

/* ── Tile Shell ── */
.tile {
  background: #fff;
  border: 0.854px solid #ddd;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 0 4.272px rgba(0, 0, 0, 0.05);
}

.tile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.tile-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 24px;
  color: #212121;
  margin: 0;
}

.tile-header-link {
  font-size: 14px;
  font-weight: 600;
  color: #0073e3;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.tile-header-link:hover { text-decoration: underline; color: #0067cc; }

.kpi-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.tile-header-label {
  font-size: 14px;
  font-weight: 400;
  color: #606060;
  white-space: nowrap;
  flex-shrink: 0;
}

.kpi-footer-link {
  font-size: 14px;
  font-weight: 600;
  color: #0073e3;
  text-decoration: none;
  white-space: nowrap;
}
.kpi-footer-link:hover { text-decoration: underline; color: #0067cc; }

.tile-link-icon {
  width: 24px;
  height: 24px;
  color: #0073e3;
  flex-shrink: 0;
}

/* ── Graph Tile ── */
.graph-total {
  margin-bottom: 16px;
}

.graph-total strong {
  font-size: 40px;
  font-weight: 400;
  color: #606060;
  margin-right: 8px;
  line-height: 1;
  vertical-align: middle;
}

.graph-total span {
  font-size: 14px;
  color: #606060;
  vertical-align: middle;
}

.graph-bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 168px;
}

.graph-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
}

.graph-bar-wrap {
  flex: 1;
  display: flex;
  align-items: flex-end;
  width: 100%;
}

.graph-bar {
  width: 100%;
  background: #1e90ff;
  border-radius: 12px 12px 4px 4px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 8px;
  min-height: 24px;
}


.graph-bar span {
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
}

.graph-bar-label {
  font-size: 14px;
  color: #212121;
  text-align: center;
  white-space: nowrap;
}

/* ── KPI Tile ── */
.kpi-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.kpi-value {
  font-size: 40px;
  font-weight: 400;
  color: #606060;
  line-height: 1.1;
  margin: 4px 0 8px;
}

.kpi-trend {
  font-size: 13px;
  font-weight: 600;
}
.kpi-trend.positive { color: #218500; }
.kpi-trend.negative { color: #b90000; }

.kpi-sub {
  font-size: 13px;
  color: #606060;
}

/* ── Bar Tile (percentage + progress) ── */
.bar-tile-body {
  display: flex;
  align-items: stretch;
  gap: 20px;
}

.bar-tile-pct {
  font-size: 40px;
  font-weight: 400;
  color: #606060;
  line-height: 1;
  flex-shrink: 0;
  align-self: center;
}

.progress-bar-wrap {
  flex: 1;
  min-height: 20px;
  background: #01295f;
  border-radius: 8px;
  position: relative;
}

.progress-bar-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  background: #1e90ff;
  border-radius: 8px;
  box-shadow: 0 0 0 2px #fff;
}

/* ── AI Insight Tile ── */
.ai-tile {
  background: linear-gradient(180deg, #fff 0%, #f9f3fc 100%);
}

.ai-tile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.ai-tile-title {
  font-size: 18px;
  font-weight: 700;
  color: #212121;
  margin: 0;
}

.ai-badge-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ai-badge {
  font-size: 12px;
  font-weight: 400;
  color: #7a29a3;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-disclaimer {
  font-size: 12px;
  font-weight: 600;
  color: #0073e3;
  text-decoration: none;
}
.ai-disclaimer:hover { text-decoration: underline; color: #0067cc; }

.ai-body {
  font-size: 14px;
  line-height: 20px;
  color: #212121;
  margin: 0 0 16px;
}

/* ── Button: Primary (blue pill) ── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  background: #0073e3;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 0 20px;
  height: 32px;
  font-family: 'Manrope', sans-serif;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s;
}
.btn-primary:hover {
  background: #0067cc;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* ── Leads Tile ── */
.leads-table { display: flex; flex-direction: column; }

.leads-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}
.leads-row:last-child { border-bottom: none; }

.lead-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.lead-aside {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}

.lead-name {
  font-size: 14px;
  font-weight: 600;
  color: #0073e3;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lead-name:hover { text-decoration: underline; color: #0067cc; }

.lead-date {
  font-size: 14px;
  color: #606060;
  flex-shrink: 0;
  white-space: nowrap;
}

.lead-car-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.lead-car-thumb {
  width: 36px;
  height: 24px;
  border-radius: 4px;
  flex-shrink: 0;
  object-fit: cover;
  display: block;
}

.lead-car-name {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: #0073e3;
  text-decoration: none;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lead-car-name:hover { text-decoration: underline; color: #0067cc; }

.lead-tag {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 4px;
  white-space: nowrap;
}
.lead-tag.new       { background: #f2f8fc; color: #0270af; }
.lead-tag.contacted { background: #fff3e0; color: #a35b00; }
.lead-tag.won       { background: #ecffe5; color: #218500; }
.lead-tag.lost      { background: #ffebee; color: #b90000; }

/* ── Lead Avatar ── */
.lead-avatar {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
}

.lead-avatar--photo {
  display: block;
  object-fit: cover;
}

.lead-avatar-bg,
.lead-avatar-icon {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.lead-avatar-initials {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #000;
  line-height: 1;
}

/* ── Upsell Tile ── */
.upsell-tile {
  background: linear-gradient(180deg, #fff 0%, #f2faff 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 20px;
}

.upsell-body { flex: 1; min-width: 0; }

.upsell-title {
  font-size: 16px;
  font-weight: 600;
  color: #24ad90;
  margin: 0 0 8px;
}

.upsell-desc {
  font-size: 14px;
  color: #404040;
  margin: 0 0 12px;
  line-height: 20px;
}

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

.btn-ghost {
  background: none;
  border: none;
  font-family: 'Manrope', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #0073e3;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
}
.btn-ghost:hover { text-decoration: underline; color: #0067cc; }

.upsell-illustration-placeholder {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Marketing Tile ── */
.marketing-tile {
  background: #004180;
  color: #fff;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 16px;
}

.marketing-tile-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.marketing-tile-image {
  width: 90px;
  height: 90px;
  flex-shrink: 0;
  object-fit: cover;
}

.marketing-tile-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.marketing-tile-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.marketing-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin: 0;
}

.marketing-tag {
  display: inline-block;
  background: #e5fdff;
  color: #007078;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 4px;
  flex-shrink: 0;
}

.marketing-body {
  font-size: 14px;
  color: #c9dfff;
  line-height: 20px;
  margin: 0;
}

.marketing-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ── Responsive ── */

/* xl ≤1680: equal 1:1 split (narrow leads layout is the default) */
@media (max-width: 1680px) {
  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* xl+ >1680: wide leads — flatten into single row */
@media (min-width: 1681px) {
  .leads-row { align-items: center; gap: 12px; }
  .lead-main { flex-direction: row; align-items: center; gap: 0; }
  .lead-top  { display: contents; }
  .lead-name { width: 104px; flex-shrink: 0; }
  .lead-date { width: 102px; flex-shrink: 0; margin-right: 12px; }
  .lead-car-wrap { flex: 1; }
  .lead-aside { flex-direction: row; align-items: center; gap: 12px; }
}

/* lg ≤1198: single column, side tiles below main */
@media (max-width: 1198px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
    grid-template-areas: "main" "side";
  }
  .dashboard-side {
    display: flex;
    flex-direction: column;
  }
}

/* md ≤990: KPI tiles stack to 1 per row */
@media (max-width: 990px) {
  .kpi-tiles { grid-template-columns: 1fr; }
}

/* sm ≤766: 16px padding */
@media (max-width: 766px) {
  .dashboard-grid { padding: 16px; }
}

/* Stock matrix */
.stock-matrix {
  width: 100%;
  border-collapse: separate;
  border-spacing: 2px;
  margin-top: 4px;
}
.stock-matrix thead th {
  font-size: 12px;
  font-weight: 600;
  color: #606060;
  text-align: center;
  padding: 2px 4px 6px;
}
.stock-matrix thead th:first-child { text-align: left; }
.stock-matrix-row-label {
  font-size: 12px;
  font-weight: 600;
  color: #606060;
  padding: 0 4px 0 0;
  white-space: nowrap;
  width: 24px;
}
.stock-matrix-cell--grey,
.stock-matrix-cell--light,
.stock-matrix-cell--blue,
.stock-matrix-cell--dark {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  border-radius: 4px;
  height: 24px;
  min-width: 32px;
  cursor: pointer;
}
.stock-matrix-cell--grey {
  background: #ddd;
  color: #212121;
}
.stock-matrix-cell--light {
  background: #80c0ff;
  color: #000;
}
.stock-matrix-cell--blue {
  background: #1e90ff;
  color: #fff;
}
.stock-matrix-cell--dark {
  background: #004180;
  color: #fff;
}
.stock-matrix-cell--grey:not([data-zero]):hover {
  background: #cccccc;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.stock-matrix-cell--light:hover {
  background: #4da6ff;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.stock-matrix-cell--blue:hover {
  background: #0073e3;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.stock-matrix-cell--dark:hover {
  background: #01295f;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.stock-matrix-cell--grey[data-zero] {
  cursor: default;
}
.stock-matrix tbody tr:first-child td:nth-child(2) { border-radius: 8px 4px 4px 4px; }
.stock-matrix tbody tr:first-child td:last-child   { border-radius: 4px 8px 4px 4px; }
.stock-matrix tbody tr:last-child  td:nth-child(2) { border-radius: 4px 4px 4px 8px; }
.stock-matrix tbody tr:last-child  td:last-child   { border-radius: 4px 4px 8px 4px; }

/* xs ≤575: kpi-pairs stack, compact tile padding */
@media (max-width: 575px) {
  .dashboard-grid { padding: 12px; gap: 12px; }
  .tile { padding: 14px; }
  .graph-bars { height: 130px; }
  .kpi-pair { flex-direction: column; }
  .kpi-pair .tile { flex: none; min-width: 0; }
  .upsell-tile { flex-direction: column; align-items: flex-start; }
  .upsell-illustration-placeholder { display: none; }
  .page-header { border-radius: 0; }
}
