/* =========================================================
   Supply Chain BI Dashboard CSS
   Dashboard shell, cards, charts, lists and responsive rules.
   Kept separate from BI Showcase page-level styling.
   ========================================================= */

.bi-dashboard-shell {
  --dashboard-bg: #f8fafc;
  --dashboard-panel: #ffffff;
  --dashboard-panel-soft: #f6faf7;
  --dashboard-text: #0f172a;
  --dashboard-muted: #64748b;
  --dashboard-muted-2: #94a3b8;
  --dashboard-line: #e5eaf0;
  --dashboard-green: #15803d;
  --dashboard-green-2: #16a34a;
  --dashboard-green-3: #22c55e;
  --dashboard-green-soft: #ecfdf3;
  --dashboard-red: #ef4444;
  --dashboard-yellow: #eab308;
  --dashboard-blue: #0ea5e9;

  display: grid;
  grid-template-columns: 245px minmax(0, 1fr);
  min-height: 850px;
  overflow: hidden;
  border: 1px solid rgba(191, 219, 254, 0.14);
  border-radius: 34px;
  background: var(--dashboard-bg);
  color: var(--dashboard-text);
  box-shadow:
    0 32px 90px rgba(0, 0, 0, 0.42),
    0 0 0 1px rgba(255, 255, 255, 0.04);
}

/* Make dashboard text independent from global dark theme */
.bi-dashboard-shell h2,
.bi-dashboard-shell h3,
.bi-dashboard-shell p,
.bi-dashboard-shell strong,
.bi-dashboard-shell small,
.bi-dashboard-shell span,
.bi-dashboard-shell em,
.bi-dashboard-shell a,
.bi-dashboard-shell button {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.bi-dashboard-shell h2,
.bi-dashboard-shell h3 {
  color: var(--dashboard-text);
  letter-spacing: -0.04em;
}

.bi-dashboard-shell p {
  color: var(--dashboard-muted);
}

.bi-dashboard-shell button {
  cursor: pointer;
}

/* Sidebar */
.dashboard-sidebar {
  display: flex;
  flex-direction: column;
  padding: 1.45rem 1.1rem;
  background:
    radial-gradient(circle at 30% 15%, rgba(22, 163, 74, 0.16), transparent 13rem),
    #020707;
  color: #ffffff;
}

.dashboard-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 2rem;
}

.dashboard-brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(34, 197, 94, 0.22), rgba(21, 128, 61, 0.92));
  color: #d9ffe5;
  font-size: 0.95rem;
  font-weight: 950;
  box-shadow: 0 0 28px rgba(34, 197, 94, 0.2);
}

.dashboard-brand strong {
  display: block;
  color: #ffffff;
  font-size: 1.05rem;
  line-height: 1.15;
}

.dashboard-brand small {
  display: block;
  margin-top: 0.15rem;
  color: #8f9ca3;
  font-size: 0.75rem;
}

.dashboard-menu {
  display: grid;
  gap: 0.45rem;
}

.dashboard-menu a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 46px;
  padding: 0.72rem 0.8rem;
  border-radius: 13px;
  color: #cad5dc;
  font-size: 0.9rem;
  font-weight: 750;
  text-decoration: none;
  transition:
    background 160ms ease,
    color 160ms ease;
}

.dashboard-menu a:hover,
.dashboard-menu a.active {
  background:
    linear-gradient(135deg, rgba(34, 197, 94, 0.9), rgba(21, 128, 61, 0.92));
  color: #ffffff;
}

.menu-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  flex: 0 0 24px;
  color: currentColor;
  font-size: 1rem;
}

/* Main dashboard */
.dashboard-main {
  padding: 2rem;
  background:
    radial-gradient(circle at 95% -5%, rgba(34, 197, 94, 0.055), transparent 18rem),
    var(--dashboard-bg);
}

.dashboard-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 1.55rem;
}

.dashboard-topbar h2 {
  margin-bottom: 0.35rem;
  font-size: clamp(1.6rem, 2.6vw, 2rem);
}

.dashboard-topbar p {
  margin: 0;
  color: var(--dashboard-muted);
  font-size: 0.95rem;
}

.dashboard-toolbar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.dashboard-control,
.dashboard-export,
.panel-select {
  min-height: 44px;
  border: 1px solid var(--dashboard-line);
  border-radius: 12px;
  background: #ffffff;
  color: var(--dashboard-text);
  padding: 0.72rem 1rem;
  font-size: 0.85rem;
  font-weight: 850;
}

.dashboard-control {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.dashboard-export {
  border-color: #cfe8d6;
  color: var(--dashboard-green);
  background: #ffffff;
}

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.kpi-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 130px;
  padding: 1.05rem;
  border: 1px solid var(--dashboard-line);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.035);
}

.kpi-icon {
  width: 45px;
  height: 45px;
  display: grid;
  place-items: center;
  flex: 0 0 45px;
  border-radius: 999px;
  background: var(--dashboard-green-soft);
  color: var(--dashboard-green);
  font-size: 1.45rem;
  font-weight: 900;
}

.kpi-label {
  display: block;
  margin-bottom: 0.45rem;
  color: #334155;
  font-size: 0.78rem;
  font-weight: 850;
}

.kpi-card strong {
  display: block;
  color: var(--dashboard-text);
  font-size: clamp(1.35rem, 2vw, 1.8rem);
  line-height: 1;
  letter-spacing: -0.04em;
}

.kpi-card small {
  display: inline-flex;
  margin-top: 0.75rem;
  font-size: 0.78rem;
  font-weight: 850;
}

.kpi-card small.positive {
  color: var(--dashboard-green-2);
}

.kpi-card small.negative {
  color: var(--dashboard-green);
}

.kpi-card em {
  display: block;
  margin-top: 0.15rem;
  color: var(--dashboard-muted);
  font-size: 0.72rem;
  font-style: normal;
}

/* Panels */
.dashboard-grid-top {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.85fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.dashboard-grid-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr) minmax(320px, 0.86fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.dashboard-panel {
  padding: 1.25rem;
  border: 1px solid var(--dashboard-line);
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.035);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel-header h3 {
  margin-bottom: 0.25rem;
  font-size: 1.05rem;
}

.panel-header p {
  margin: 0;
  font-size: 0.82rem;
}

.compact-header {
  align-items: center;
}

.compact-header h3 {
  margin: 0;
}

.compact-header a {
  color: var(--dashboard-green);
  font-size: 0.8rem;
  font-weight: 850;
  text-decoration: none;
}

/* Line chart */
.chart-panel {
  min-height: 310px;
}

.line-chart {
  width: 100%;
  height: auto;
  display: block;
}

.chart-grid-line {
  stroke: #edf2f7;
  stroke-width: 1;
}

.chart-label,
.chart-date {
  fill: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.chart-area {
  fill: url(#lineArea);
}

.chart-line {
  fill: none;
  stroke: var(--dashboard-green-2);
  stroke-width: 3;
  stroke-linecap: round;
}

.chart-points circle {
  fill: var(--dashboard-green-2);
  stroke: #ffffff;
  stroke-width: 2;
}

.chart-callout rect {
  fill: var(--dashboard-green);
}

.chart-callout text {
  fill: #ffffff;
  font-size: 13px;
  font-weight: 900;
}

/* Donut */
.donut-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  align-items: center;
  gap: 1.2rem;
  min-height: 250px;
}

.donut-chart {
  position: relative;
  width: 190px;
  height: 190px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background:
    conic-gradient(
      #006b16 0 var(--raw, 39.8%),
      #22a81f var(--raw, 39.8%) var(--wip, 65.8%),
      #b9ef9a var(--wip, 65.8%) 100%
    );
}

.donut-chart::after {
  content: "";
  position: absolute;
  width: 96px;
  height: 96px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px #eef2f7;
}

.donut-chart span {
  position: relative;
  z-index: 1;
  display: grid;
  text-align: center;
}

.donut-chart strong {
  color: var(--dashboard-text);
  font-size: 1.4rem;
  line-height: 1;
}

.donut-chart small {
  margin-top: 0.25rem;
  color: var(--dashboard-muted);
  font-size: 0.75rem;
  font-weight: 850;
}

.donut-legend {
  display: grid;
  gap: 1rem;
}

.donut-legend div {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.65rem;
  align-items: center;
}

.legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
}

.legend-dot.dark {
  background: #006b16;
}

.legend-dot.mid {
  background: #22a81f;
}

.legend-dot.light {
  background: #8bdc5d;
}

.donut-legend strong {
  color: var(--dashboard-text);
  font-size: 0.86rem;
}

.donut-legend small {
  grid-column: 2;
  color: var(--dashboard-muted);
  font-size: 0.78rem;
}

/* Risk list */
.risk-list,
.shipment-list {
  display: grid;
  gap: 0.7rem;
}

.risk-item,
.shipment-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.75rem;
  min-height: 58px;
  padding: 0.6rem;
  border-radius: 14px;
  background: #ffffff;
}

.risk-icon,
.shipment-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  font-weight: 900;
}

.risk-item.high .risk-icon {
  color: var(--dashboard-red);
  background: #fff1f2;
}

.risk-item.medium .risk-icon {
  color: var(--dashboard-yellow);
  background: #fffbeb;
}

.risk-item.low .risk-icon {
  color: var(--dashboard-blue);
  background: #eff6ff;
}

.risk-item strong,
.shipment-item strong {
  display: block;
  color: var(--dashboard-text);
  font-size: 0.83rem;
}

.risk-item small,
.shipment-item small {
  display: block;
  color: var(--dashboard-muted);
  font-size: 0.72rem;
}

.risk-item em {
  justify-self: end;
  padding: 0.25rem 0.45rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 900;
}

.risk-item.high em {
  background: #fff1f2;
  color: var(--dashboard-red);
}

.risk-item.medium em {
  background: #fffbeb;
  color: #b7791f;
}

.risk-item.low em {
  background: #eff6ff;
  color: var(--dashboard-blue);
}

.risk-item time {
  color: var(--dashboard-muted);
  font-size: 0.72rem;
}

/* Shipments */
.shipment-item {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.shipment-icon {
  color: #ffffff;
  background: linear-gradient(135deg, #16a34a, #166534);
}

.status {
  padding: 0.25rem 0.45rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 900;
}

.status.transit {
  background: #fef9c3;
  color: #a16207;
}

.status.delivered {
  background: #ecfdf3;
  color: var(--dashboard-green);
}

.status.pending {
  background: #f1f5f9;
  color: #475569;
}

.panel-link {
  display: inline-flex;
  margin-top: 0.95rem;
  color: var(--dashboard-green);
  font-size: 0.83rem;
  font-weight: 900;
  text-decoration: none;
}

/* AI insights */
.insight-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.9rem;
  padding: 1rem;
  border: 1px solid #edf2f7;
  border-radius: 16px;
  background: #fbfdfb;
}

.insight-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--dashboard-green-soft);
  color: var(--dashboard-green);
  font-size: 1.35rem;
  font-weight: 900;
}

.insight-card strong {
  color: var(--dashboard-text);
  font-size: 0.9rem;
  line-height: 1.45;
}

.insight-card a {
  grid-column: 2;
  width: fit-content;
  margin-top: 0.65rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid #cfe8d6;
  border-radius: 10px;
  color: var(--dashboard-green);
  background: #ffffff;
  font-size: 0.78rem;
  font-weight: 900;
  text-decoration: none;
}

.insight-list {
  display: grid;
  gap: 0.75rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.insight-list li {
  position: relative;
  padding-left: 1.55rem;
  color: #334155;
  font-size: 0.84rem;
}

.insight-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0.05rem;
  width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  border: 1px solid #86efac;
  border-radius: 999px;
  color: var(--dashboard-green);
  font-size: 0.72rem;
  font-weight: 900;
}

/* Efficiency strip */
.efficiency-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 230px;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.25rem;
  border: 1px solid var(--dashboard-line);
  border-radius: 20px;
  background: #ffffff;
}

.efficiency-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.efficiency-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: 0 0 48px;
  border-radius: 999px;
  background: linear-gradient(135deg, #16a34a, #166534);
  color: #ffffff;
  font-size: 1.3rem;
  font-weight: 900;
}

.efficiency-left strong {
  display: block;
  color: var(--dashboard-text);
  font-size: 0.95rem;
}

.efficiency-left small {
  display: block;
  margin-top: 0.2rem;
  color: var(--dashboard-muted);
  font-size: 0.82rem;
}

.efficiency-score span {
  display: block;
  color: var(--dashboard-muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.efficiency-score strong {
  display: block;
  color: var(--dashboard-green);
  font-size: 2rem;
  line-height: 1;
}

.mini-sparkline {
  width: 100%;
  height: 70px;
}

.mini-sparkline path {
  fill: none;
  stroke: var(--dashboard-green-2);
  stroke-width: 3;
  stroke-linecap: round;
}

.mini-sparkline circle {
  fill: var(--dashboard-green-2);
}

/* Mount and non-JavaScript fallback */
.supply-chain-dashboard-mount {
  min-height: 850px;
}

.dashboard-noscript {
  padding: 1.5rem;
  border: 1px solid rgba(191, 219, 254, 0.14);
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.012)),
    rgba(13, 16, 34, 0.58);
}

.dashboard-noscript h2 {
  margin-bottom: 0.6rem;
}

.dashboard-noscript p {
  margin: 0;
}

/* Responsiveness */
@media (max-width: 1180px) {
  .bi-dashboard-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .dashboard-main {
    padding: 1.4rem;
  }

  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-grid-top,
  .dashboard-grid-bottom {
    grid-template-columns: 1fr;
  }

  .donut-layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }
}

@media (max-width: 980px) {
  .bi-dashboard-shell {
    grid-template-columns: 1fr;
  }

  .dashboard-sidebar {
    display: none;
  }

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

  .dashboard-toolbar {
    width: 100%;
    flex-wrap: wrap;
  }

  .efficiency-strip {
    grid-template-columns: 1fr;
  }

  .mini-sparkline {
    max-width: 260px;
  }
}

@media (max-width: 720px) {
  .bi-dashboard-shell {
    border-radius: 24px;
  }

  .dashboard-main {
    padding: 1rem;
  }

  .dashboard-toolbar,
  .dashboard-control,
  .dashboard-export {
    width: 100%;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .kpi-card {
    min-height: auto;
  }

  .donut-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .donut-legend {
    width: 100%;
  }

  .risk-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .risk-item em,
  .risk-item time {
    grid-column: 2;
    justify-self: start;
  }

  .shipment-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .shipment-item .status {
    grid-column: 2;
    width: fit-content;
  }
}

@media (max-width: 520px) {
  .dashboard-main {
    padding: 0.75rem;
  }

  .dashboard-panel,
  .kpi-card,
  .efficiency-strip,
  .dashboard-noscript {
    border-radius: 18px;
  }

  .line-chart {
    min-width: 560px;
  }

  .chart-panel {
    overflow-x: auto;
  }
}
