/* Dashboard Penjualan — grid, tren, pipeline, top pelanggan.
   Base list/table/stat dari quotations.css; chart bar dari reports.css. */

.sales-intro {
  align-items: flex-start;
}

.asof-badge {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--muted);
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  margin: 10px 0 0;
  padding: 4px 8px;
}

.intro-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.ghost-button {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  gap: 6px;
  justify-content: center;
  min-height: 36px;
  padding: 8px 14px;
  text-decoration: none;
}

.ghost-button:hover {
  border-color: var(--purple);
  color: var(--purple);
}

.dashboard-status {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  margin: 0 0 14px;
}

.dashboard-status[hidden] {
  display: none;
}

.dashboard-error {
  align-items: center;
  background: #fce8e8;
  border: 1px solid #eebaba;
  border-radius: 4px;
  color: #7d1b1b;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-bottom: 18px;
  padding: 14px 16px;
}

.dashboard-error[hidden] {
  display: none;
}

.dashboard-error strong {
  display: block;
  font-size: 13px;
}

.dashboard-error span {
  display: block;
  font-size: 12.5px;
  margin-top: 2px;
}

.dashboard-main-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 0.9fr);
  margin-bottom: 18px;
}

.dashboard-lower-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  margin-bottom: 18px;
}

.dashboard-card {
  min-width: 0;
}

.dashboard-card-heading {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.dashboard-card-heading h2 {
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  margin: 0;
}

.dashboard-card-heading p {
  color: var(--muted);
  font-size: 12px;
  margin: 4px 0 0;
}

.text-link {
  color: var(--purple);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.text-link:hover {
  text-decoration: underline;
}

.period-select {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-family: var(--font-mono);
  font-size: 11px;
  gap: 7px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.period-select select {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  min-height: 32px;
  padding: 4px 8px;
}

/* Tren pendapatan: bar CSS dari reports.css */
.trend-chart {
  display: grid;
  gap: 8px;
  grid-template-columns: 42px minmax(0, 1fr);
  margin-top: 16px;
}

.trend-scale {
  color: #b4b2aa;
  display: flex;
  flex-direction: column;
  font-family: var(--font-mono);
  font-size: 10px;
  height: 220px;
  justify-content: space-between;
  padding-bottom: 26px;
  text-align: right;
  white-space: nowrap;
}

.trend-plot {
  height: 220px;
  min-width: 0;
  position: relative;
}

.trend-plot .production-grid {
  left: 8px;
}

.trend-plot .production-bars {
  left: 8px;
  right: 4px;
}

.trend-plot .production-bar-group {
  max-width: 72px;
  min-width: 26px;
}

.trend-plot .production-bar {
  width: 46%;
}

.trend-plot .production-bar-group > strong {
  font-size: 10.5px;
}

.dashboard-card-footer {
  border-top: 1px solid #f2f0e5;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 12.5px;
  gap: 10px 24px;
  margin-top: 14px;
  padding-top: 12px;
}

.dashboard-card-footer strong {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 11.5px;
  margin-left: 3px;
}

/* Pipeline quotation */
.pipeline-list {
  margin-top: 8px;
}

.pipeline-row {
  border-bottom: 1px dashed var(--line);
  display: grid;
  gap: 4px 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 10px 0;
}

.pipeline-row:last-child {
  border-bottom: 0;
}

.pipeline-label {
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
}

.pipeline-count {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}

.pipeline-track {
  background: var(--surface-subtle);
  border-radius: 2px;
  grid-column: 1 / -1;
  height: 6px;
  overflow: hidden;
}

.pipeline-track i {
  background: var(--purple);
  display: block;
  height: 100%;
}

.pipeline-value {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  grid-column: 1 / -1;
}

/* Sales order terbaru */
.recent-order-table {
  margin-top: 12px;
  min-width: 0 !important;
  width: 100%;
}

.table-card .recent-order-table th,
.table-card .recent-order-table td {
  padding-left: 8px !important;
  padding-right: 8px !important;
}

.table-card .recent-order-table th {
  font-size: 10px !important;
  letter-spacing: 0.03em;
}

.table-card .recent-order-table td {
  font-size: 11.5px !important;
}

.table-card .recent-order-table .status {
  font-size: 10px !important;
  padding: 2px 5px !important;
  white-space: nowrap;
}

.recent-order-table .order-id {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}

/* Status pill (paritas label halaman Sales Order) */
.status.waiting { background: #fdf1e1; border: 1px solid #edd0a7; color: #8c4a08; }
.status.process { background: #e8effa; border: 1px solid #bfd2f2; color: #1e4785; }
.status.shipped { background: #e3f3eb; border: 1px solid #b5dec9; color: #13613e; }
.status.delivered { background: #e3f3eb; border: 1px solid #b5dec9; color: #13613e; }
.status.cancelled { background: #fce8e8; border: 1px solid #eebaba; color: #a12020; }

/* Top pelanggan */
.top-customer-list {
  margin-top: 10px;
}

.top-customer-row {
  border-bottom: 1px dashed var(--line);
  display: grid;
  gap: 2px 10px;
  grid-template-columns: 22px 30px minmax(0, 1fr) auto;
  padding: 10px 0;
}

.top-customer-row:last-child {
  border-bottom: 0;
}

.top-customer-rank {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 30px;
}

.top-customer-avatar {
  align-items: center;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-2);
  display: inline-flex;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  height: 30px;
  justify-content: center;
  width: 30px;
}

.top-customer-name {
  align-self: center;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-customer-revenue {
  align-self: center;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.top-customer-share {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-family: var(--font-mono);
  font-size: 10.5px;
  gap: 8px;
  grid-column: 3 / -1;
}

.top-customer-share i {
  background: var(--surface-subtle);
  border-radius: 2px;
  display: block;
  flex: 1;
  height: 5px;
  overflow: hidden;
}

.top-customer-share i b {
  background: var(--ink-2);
  display: block;
  height: 100%;
}

.dashboard-card .empty-state {
  font-size: 12.5px;
  margin-top: 12px;
}

.sales-dashboard-error .ghost-button {
  flex-shrink: 0;
}

@media (max-width: 1200px) {
  .dashboard-lower-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

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

  .stat-card:nth-child(2) {
    border-right: 0;
  }

  .stat-card:nth-child(-n+2) {
    border-bottom: 1px solid var(--line);
  }

  .trend-plot .production-bars {
    gap: 8px;
  }
}

@media (max-width: 980px) {
  .dashboard-main-grid,
  .dashboard-lower-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .sales-intro {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  .intro-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 600px) {
  .trend-chart {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .dashboard-error {
    align-items: flex-start;
    flex-direction: column;
  }
}

.primary-button:focus-visible,
.ghost-button:focus-visible,
.text-link:focus-visible,
.period-select select:focus-visible,
#dashboard-retry:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
