/* ==========================================================================
   i-Spin IoT Monitoring Dashboard - Production Theme & Stylesheet
   Pixel-Accurate reproduction of Reference IoT Spinning Mill Dashboard
   UI density tuned to ~110% content scale (native sizes, not browser zoom)
   ========================================================================== */

:root {
  --dash-bg: #070b14;
  --dash-shell-bg: #080d18;
  --dash-sidebar-bg: #0b111e;
  --dash-card-bg: #0e1526;
  --dash-card-bg-gradient: linear-gradient(180deg, #10182c 0%, #0c1322 100%);
  --dash-subcard-bg: #090f1d;
  --dash-border: rgba(255, 255, 255, 0.08);
  --dash-border-subtle: rgba(255, 255, 255, 0.05);

  --dash-primary-blue: #1e88e5;
  --dash-blue-accent: #3b82f6;
  --dash-cyan: #38bdf8;
  --dash-green: #22c55e;
  --dash-purple: #a855f7;
  --dash-purple-ai: #9333ea;
  --dash-orange: #f97316;
  --dash-yellow-orange: #fbbf24;
  --dash-yellow: #eab308;
  --dash-red: #ef4444;

  --dash-text-main: #ffffff;
  --dash-text-heading: #f1f5f9;
  --dash-text-muted: #7e8b9e;
  --dash-text-dim: #5c687a;
  --dash-grid: rgba(255, 255, 255, 0.06);

  --dash-font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --dash-font-serif: "Playfair Display", Georgia, "Times New Roman", serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overflow-x: hidden;
  background-color: var(--dash-bg);
  color: var(--dash-text-main);
  font-family: var(--dash-font-sans);
  /* Base UI sized for ~110% readability without browser zoom */
  font-size: 13.2px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scoped Wrapper */
.dashboard-page {
  display: flex;
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: 100dvh;
  overflow: hidden;
  background-color: var(--dash-bg);
}

.dashboard-page [hidden] {
  display: none !important;
}

/* Color Helpers */
.text-blue { color: #3b82f6 !important; }
.text-blue-cyan { color: #38bdf8 !important; }
.text-green { color: #22c55e !important; }
.text-purple { color: #a855f7 !important; }
.text-orange { color: #f97316 !important; }
.text-yellow-orange { color: #fbbf24 !important; }
.text-red { color: #ef4444 !important; }
.font-medium { font-weight: 500; }

/* ==========================================================================
   SIDEBAR
   ========================================================================== */
.dash-sidebar {
  width: 176px;
  min-width: 176px;
  max-width: 176px;
  height: 100vh;
  background-color: var(--dash-sidebar-bg);
  border-right: 1px solid var(--dash-border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 9px 6.5px 9px 6.5px;
  z-index: 100;
  user-select: none;
}

.brand-wrap {
  padding: 2px 9px 6.5px 9px;
}

.brand {
  text-decoration: none;
  display: flex;
  align-items: center;
}

.brand-logo {
  font-family: var(--dash-font-serif);
  font-style: italic;
  font-weight: 700;
  font-size: 24px;
  letter-spacing: 0.5px;
  color: #ffffff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

.dash-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  overflow-y: auto;
  margin-top: 2px;
}

.dash-nav::-webkit-scrollbar {
  width: 3.5px;
}
.dash-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3.5px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 7.5px;
  height: 31px;
  padding: 0 9px;
  border-radius: 5.5px;
  color: #8b97ab;
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
  position: relative;
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.04);
  color: #d1d9e6;
}

.nav-link.is-active {
  background-color: var(--dash-primary-blue);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(30, 136, 229, 0.35);
}

.nav-icon {
  width: 15.5px;
  height: 15.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 15.5px;
  height: 15.5px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-link.is-active .nav-icon svg {
  stroke: #ffffff;
}

.nav-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-badge {
  background-color: var(--dash-red);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 4.5px;
  border-radius: 9px;
  line-height: 1.1;
}

.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 5.5px;
  padding-top: 3.5px;
  margin-top: -24px;
  border-top: 1px solid var(--dash-border);
}

.plant-meta {
  background: var(--dash-subcard-bg);
  border: 1px solid var(--dash-border-subtle);
  border-radius: 5.5px;
  padding: 6.5px 7.5px;
  font-size: 11px;
}

.meta-label {
  color: var(--dash-text-muted);
  font-size: 9.5px;
  line-height: 1.35;
  margin-top: 3.5px;
}

.meta-label:first-child {
  margin-top: 0;
}

.meta-value {
  color: #ffffff;
  font-weight: 600;
  font-size: 11px;
  line-height: 1.35;
  margin-bottom: 4.5px;
}
.meta-value:last-child {
  margin-bottom: 0;
}

.user-meta-block {
  position: relative;
}

.user-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 5.5px;
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 3.5px 4.5px;
  border-radius: 5.5px;
  text-align: left;
  transition: background 0.15s ease;
}

.user-btn:hover {
  background: rgba(255, 255, 255, 0.04);
}

.avatar-wrap {
  position: relative;
  width: 26.5px;
  height: 26.5px;
  border-radius: 50%;
  background: #1e293b;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.avatar-svg {
  width: 15.5px;
  height: 15.5px;
  stroke: #94a3b8;
  stroke-width: 1.8;
  fill: none;
}

.online-indicator {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 5.5px;
  height: 5.5px;
  border-radius: 50%;
  background-color: var(--dash-green);
  border: 1px solid var(--dash-sidebar-bg);
}

.user-info {
  flex: 1;
  overflow: hidden;
}

.u-name {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
}

.u-role {
  display: block;
  font-size: 9.5px;
  color: var(--dash-text-muted);
}

.chevron-svg {
  width: 11px;
  height: 11px;
  stroke: #7e8b9e;
  stroke-width: 2;
  fill: none;
}

.user-menu {
  position: absolute;
  bottom: 100%;
  left: 0;
  width: 100%;
  background: #131b2e;
  border: 1px solid var(--dash-border);
  border-radius: 5.5px;
  padding: 3.5px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 4.5px;
  z-index: 200;
}

.user-menu button {
  background: transparent;
  border: none;
  color: #cbd5e1;
  font-size: 11px;
  padding: 4.5px 6.5px;
  border-radius: 4.5px;
  text-align: left;
  cursor: pointer;
}
.user-menu button:hover {
  background: var(--dash-primary-blue);
  color: #ffffff;
}

/* ==========================================================================
   MAIN CONTENT SHELL
   ========================================================================== */
.dash-shell {
  flex: 1;
  min-width: 0;
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--dash-bg);
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.dash-header {
  height: 48.5px;
  min-height: 48.5px;
  max-height: 48.5px;
  display: flex;
  align-items: center;
  padding: 0 11px;
  background-color: var(--dash-bg);
  border-bottom: 1px solid var(--dash-border);
  gap: 9px;
  flex-shrink: 0;
  min-width: 0;
}

.header-titles {
  flex-shrink: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.header-center-group {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  min-width: 0;
}

.header-timestamps {
  display: flex;
  align-items: center;
  gap: 5.5px;
}

.header-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6.5px;
}

.menu-toggle {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  flex-direction: column;
  gap: 3.5px;
  padding: 4.5px;
}
.menu-toggle span {
  display: block;
  width: 17.5px;
  height: 2px;
  background: #ffffff;
  border-radius: 2px;
}

.header-titles h1 {
  font-size: 15.5px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.15;
}

.header-titles p {
  font-size: 10.5px;
  color: var(--dash-text-muted);
  line-height: 1.15;
}

.clock-icon-wrap {
  width: 15.5px;
  height: 15.5px;
  stroke: #7e8b9e;
  stroke-width: 1.8;
  fill: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.clock-icon-wrap svg {
  width: 15.5px;
  height: 15.5px;
}

.time-lines {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.time-row {
  display: flex;
  align-items: center;
  gap: 5.5px;
  font-size: 10px;
}

.t-lbl {
  color: var(--dash-text-muted);
}

.t-val {
  color: #ffffff;
  font-weight: 600;
}

.live-badge-wrap {
  display: flex;
  align-items: center;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 4.5px;
  padding: 2px 6.5px;
  background-color: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 11px;
  color: var(--dash-green);
  font-size: 10.5px;
  font-weight: 600;
}

.pulse-dot {
  width: 4.5px;
  height: 4.5px;
  border-radius: 50%;
  background-color: var(--dash-green);
  box-shadow: 0 0 5px var(--dash-green);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.header-efficiency-block {
  display: flex;
  align-items: center;
  gap: 6.5px;
  background: rgba(37, 99, 235, 0.14);
  border: 1px solid rgba(59, 130, 246, 0.55);
  border-radius: 4.5px;
  padding: 3.5px 9px;
  flex-shrink: 0;
}

.eff-title {
  font-size: 9.5px;
  line-height: 1.15;
  color: var(--dash-text-muted);
  text-align: right;
}

.eff-big-val {
  font-size: 16.5px;
  font-weight: 700;
  color: var(--dash-green);
  white-space: nowrap;
}

.filter-dropdown-wrap {
  position: relative;
}

.btn-filter {
  display: flex;
  align-items: center;
  gap: 4.5px;
  background: #0d1424;
  border: 1px solid rgba(59, 130, 246, 0.45);
  border-radius: 4.5px;
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 4.5px 9px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-filter:hover {
  border-color: #3b82f6;
  background: #121c32;
}

.filter-icon {
  width: 11px;
  height: 11px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
}

.filter-panel {
  position: absolute;
  top: calc(100% + 6.5px);
  right: 0;
  width: 242px;
  background: #111827;
  border: 1px solid var(--dash-border);
  border-radius: 5.5px;
  padding: 11px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 6.5px;
}

.filter-title {
  font-size: 11.5px;
  font-weight: 700;
  color: #ffffff;
  border-bottom: 1px solid var(--dash-border);
  padding-bottom: 3.5px;
}

.filter-panel label {
  display: flex;
  flex-direction: column;
  font-size: 10.5px;
  color: var(--dash-text-muted);
  gap: 2px;
}

.filter-panel input,
.filter-panel select {
  background: #090d16;
  border: 1px solid var(--dash-border);
  border-radius: 4.5px;
  color: #ffffff;
  padding: 3.5px 5.5px;
  font-size: 10.5px;
}

.filter-btns {
  display: flex;
  justify-content: flex-end;
  gap: 5.5px;
  margin-top: 3.5px;
}

.filter-btns button {
  padding: 3.5px 6.5px;
  font-size: 10.5px;
  border-radius: 4.5px;
  cursor: pointer;
  border: none;
}

#filter-reset {
  background: transparent;
  color: #94a3b8;
}

.btn-apply {
  background: var(--dash-primary-blue);
  color: #ffffff;
  font-weight: 600;
}

.btn-refresh {
  width: 26.5px;
  height: 26.5px;
  border-radius: 4.5px;
  background: #0d1424;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #eab308;
  transition: all 0.15s ease;
}

.btn-refresh:hover {
  background: #141f38;
  border-color: #eab308;
}

.btn-refresh svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
}

.btn-refresh.is-spinning svg {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.header-logo-box {
  height: 28.5px;
  display: flex;
  align-items: center;
}

.header-nestling-logo,
.header-customer-logo {
  height: 28.5px;
  width: auto;
  border-radius: 3.5px;
  display: block;
}

/* ==========================================================================
   MAIN DASHBOARD GRID (4 PANELS)
   ========================================================================== */
.dash-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 4.5px 9px 3.5px 9px;
  gap: 4.5px;
  min-width: 0;
  min-height: 0;
}

.dash-grid {
  flex: 1;
  display: grid;
  /* 80-col grid: top row 50/50; bottom row ~31.25/68.75 (Utilisation @125% / NEST AI) */
  grid-template-columns: repeat(80, 1fr);
  /* Top row doubled so Production & Production Efficiency graphs are taller */
  grid-template-rows: minmax(0, 1.44fr) minmax(0, 1.42fr);
  gap: 6.5px;
  min-height: 0;
  align-items: stretch;
}

.panel-production {
  grid-column: 1 / 41;
  grid-row: 1;
  height: 100%;
  max-height: 100%;
}

.panel-efficiency {
  grid-column: 41 / 81;
  grid-row: 1;
  height: 100%;
  max-height: 100%;
}

.panel-utilisation {
  /* Was 20 cols (1/21); 125% => 25 cols */
  grid-column: 1 / 26;
  grid-row: 2;
}

.panel-nest-ai {
  grid-column: 26 / 81;
  grid-row: 2;
}

/* Panel Styles */
.dash-panel {
  background: var(--dash-card-bg);
  background-image: var(--dash-card-bg-gradient);
  border: 1px solid var(--dash-border);
  border-radius: 6.5px;
  padding: 6.5px 9px 6.5px 9px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.panel-header {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 4.5px;
  line-height: 1.2;
  flex-shrink: 0;
}

/* Chart Container inside Cards */
.chart-container {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-top: 2px;
}

.panel-production .chart-container,
.panel-efficiency .chart-container {
  flex: 1 1 0;
  min-height: 0;
  max-height: none;
  overflow: hidden;
}

.panel-production .canvas-wrap,
.panel-efficiency .canvas-wrap {
  flex: 1 1 0;
  min-height: 0;
  /* Keep room for X-axis labels drawn inside the canvas */
  padding-bottom: 2px;
}

.chart-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1px;
}

.panel-production .chart-container .chart-header-row,
.panel-efficiency .chart-container .chart-header-row {
  margin-bottom: 9px;
  padding-bottom: 2px;
  flex-shrink: 0;
}

.panel-production .chart-container .canvas-wrap,
.panel-efficiency .chart-container .canvas-wrap {
  margin-top: 4.5px;
}

.chart-title {
  font-size: 10.5px;
  font-weight: 600;
  color: #d1d9e6;
  line-height: 1.2;
}

.canvas-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
  width: 100%;
}

.canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.dash-chart-tooltip {
  position: fixed;
  background: rgba(9, 13, 22, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4.5px;
  padding: 3.5px 5.5px;
  font-size: 9.5px;
  color: #ffffff;
  pointer-events: none;
  z-index: 10000;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}
.dash-chart-tooltip strong {
  display: block;
  font-size: 9px;
  color: var(--dash-text-muted);
}

/* ==========================================================================
   PANEL 1: PRODUCTION
   ========================================================================== */
.prod-kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5.5px;
  margin-bottom: 2px;
  flex-shrink: 0;
}

.prod-kpi-card {
  background: var(--dash-subcard-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5.5px;
  padding: 7.5px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48.5px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.kpi-left {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.kpi-label {
  font-size: 9.5px;
  color: var(--dash-text-muted);
  line-height: 1.35;
}

.kpi-value {
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.3;
  margin-top: 1px;
}

.kpi-value-split {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  margin-top: 1px;
}

.val-actual {
  color: #ffffff;
}
.val-slash {
  color: #ffffff;
  margin: 0 1px;
}
.val-target {
  color: var(--dash-blue-accent);
}

.kpi-sub-unit {
  font-size: 9px;
  color: var(--dash-text-muted);
  line-height: 1.3;
  margin-top: 1px;
}

.kpi-spark {
  width: 48.5px;
  height: 20px;
  flex-shrink: 0;
}

.kpi-spark canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ==========================================================================
   PANEL 2: PRODUCTION EFFICIENCY
   ========================================================================== */
.eff-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(2, auto);
  gap: 3.5px 4.5px;
  margin-bottom: 2px;
  flex-shrink: 0;
}

.eff-item {
  display: flex;
  align-items: center;
  gap: 5.5px;
  min-width: 0;
  background: var(--dash-subcard-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5.5px;
  padding: 5.5px 6.5px;
  min-height: 42px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.eff-circle {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.eff-svg {
  width: 12px;
  height: 12px;
}

.eff-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  gap: 2px;
}

.eff-lbl {
  font-size: 8px;
  color: var(--dash-text-muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.eff-val {
  font-size: 10.5px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.3;
}

/* ==========================================================================
   PANEL 3: UTILISATION
   ========================================================================== */
.util-kpi-row {
  display: grid;
  grid-template-columns: 0.9fr 1.3fr;
  gap: 5.5px;
  margin-bottom: 2px;
  flex-shrink: 0;
}

.util-kpi-card {
  background: var(--dash-subcard-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5.5px;
  padding: 7.5px 7.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48.5px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.util-chart-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--dash-subcard-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5.5px;
  padding: 4.5px 6.5px;
  margin-top: 2px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.util-chart-card .chart-header-row {
  margin-bottom: 2px;
}

.util-chart-card .canvas-wrap {
  flex: 1;
  min-height: 145px;
}

.util-kpi-card.stops-card {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.04);
}

.util-card-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3.5px;
}

.util-big-num {
  font-size: 17.5px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.3;
  margin-top: 1px;
}

.util-icon-box {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.util-icon-box svg {
  width: 22px;
  height: 22px;
}

.major-stop-card {
  justify-content: flex-start;
  gap: 6.5px;
}

.gear-icon-box {
  width: 24px;
  height: 24px;
  background: rgba(34, 197, 94, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gear-icon-box svg {
  width: 15.5px;
  height: 15.5px;
}

.stop-title {
  font-size: 11.5px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.3;
  margin-top: 1px;
}

.stop-duration {
  font-size: 9.5px;
  color: var(--dash-text-muted);
  line-height: 1.3;
  margin-top: 1px;
}

.stop-dur-val {
  color: #ffffff;
  font-weight: 600;
}

/* ==========================================================================
   PANEL 4: NEST AI
   ========================================================================== */
.nest-ai-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 6.5px;
  min-height: 0;
}

.ai-charts-col {
  display: flex;
  flex-direction: column;
  gap: 3.5px;
  min-height: 0;
}

.ai-chart-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--dash-subcard-bg);
  border: 1px solid var(--dash-border-subtle);
  border-radius: 4.5px;
  padding: 3.5px 5.5px;
}

.ai-chart-box .chart-title {
  font-size: 9.5px;
  font-weight: 600;
  color: #d1d9e6;
  margin-bottom: 1px;
}

.canvas-wrap.compact {
  flex: 1;
  min-height: 0;
}

/* AI Chat Window */
.ai-chat-box {
  background: var(--dash-subcard-bg);
  border: 1px solid var(--dash-border-subtle);
  border-radius: 4.5px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 5.5px;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 4.5px;
  margin-bottom: 3.5px;
  padding-bottom: 3.5px;
  border-bottom: 1px solid var(--dash-border-subtle);
}

.chat-ai-icon {
  width: 13px;
  height: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-ai-icon svg {
  width: 13px;
  height: 13px;
}

.chat-header-title {
  font-size: 10.5px;
  font-weight: 700;
  color: #ffffff;
}

.chat-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4.5px;
  overflow-y: auto;
  padding: 1px;
  min-height: 0;
}

.chat-messages::-webkit-scrollbar {
  width: 2px;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.chat-bubble {
  max-width: 94%;
  padding: 4.5px 6.5px;
  font-size: 9.5px;
  line-height: 1.25;
}

.chat-bubble.is-user {
  align-self: flex-end;
  background: #2563eb;
  color: #ffffff;
  border-radius: 6.5px 6.5px 2px 6.5px;
}

.chat-bubble.is-ai {
  align-self: flex-start;
  background: #141d2e;
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6.5px 6.5px 6.5px 2px;
}

.bubble-meta {
  font-size: 8px;
  color: rgba(255, 255, 255, 0.6);
  text-align: right;
  margin-top: 2px;
}
.bubble-meta .checks {
  color: #60a5fa;
  font-weight: 700;
}

.chat-input-row {
  display: flex;
  align-items: center;
  gap: 3.5px;
  margin-top: 3.5px;
  background: #070b14;
  border: 1px solid var(--dash-border);
  border-radius: 4.5px;
  padding: 5px 6px;
  min-height: 28px;
}

.chat-input-row input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-size: 9.5px;
  padding: 2px 4px;
  line-height: 1.4;
}
.chat-input-row input::placeholder {
  color: var(--dash-text-dim);
}

.chat-send-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  width: 13px;
  height: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.chat-send-btn svg {
  width: 12px;
  height: 12px;
}

/* ==========================================================================
   ALERT FLASH TICKER
   ========================================================================== */
.dash-flash-ticker {
  height: 24px;
  min-height: 24px;
  max-height: 24px;
  background: #38080a;
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 4.5px;
  display: flex;
  align-items: center;
  overflow: hidden;
  padding: 0 4.5px;
  gap: 6.5px;
  flex-shrink: 0;
}

/* Alert / Flash Label */
.flash-badge {
  display: flex;
  align-items: center;
  gap: 3.5px;
  background: transparent;
  color: #ef4444;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 1px 3.5px;
  flex-shrink: 0;
}

.flash-bolt {
  width: 10px;
  height: 10px;
  stroke: #ef4444;
  stroke-width: 1.8;
  fill: none;
}

.flash-marquee {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
}

.flash-track {
  display: inline-flex;
  align-items: center;
  animation: flashTicker 32s linear infinite;
}

.flash-track:hover {
  animation-play-state: paused;
}

@keyframes flashTicker {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.flash-msg {
  font-size: 10.5px;
  font-weight: 600;
  color: #fca5a5;
  margin-right: 11px;
}

.flash-sep {
  display: inline-block;
  color: rgba(239, 68, 68, 0.45);
  font-size: 10px;
  font-weight: 700;
  margin: 0 9px;
}

/* ==========================================================================
   BOTTOM STATUS FOOTER
   ========================================================================== */
.dash-footer {
  height: 24px;
  min-height: 24px;
  max-height: 24px;
  background-color: var(--dash-bg);
  border-top: 1px solid var(--dash-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 11px;
  font-size: 10.5px;
  color: var(--dash-text-muted);
  flex-shrink: 0;
}

.foot-col {
  display: flex;
  align-items: center;
  gap: 4.5px;
}

.foot-icon {
  width: 13px;
  height: 13px;
  stroke-width: 2;
  fill: none;
}

.foot-label {
  color: var(--dash-text-muted);
}

.foot-val {
  color: #ffffff;
  font-weight: 700;
}

.status-dot {
  width: 5.5px;
  height: 5.5px;
  border-radius: 50%;
}
.dot-green { background-color: var(--dash-green); }
.dot-red { background-color: var(--dash-red); }

.foot-refresh-block {
  display: flex;
  align-items: center;
  gap: 4.5px;
}

.refresh-cycle-icon {
  width: 12px;
  height: 12px;
}

/* ==========================================================================
   MODULE PLACEHOLDER (For sub-views)
   ========================================================================== */
.module-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--dash-card-bg);
  border: 1px solid var(--dash-border);
  border-radius: 6.5px;
  padding: 33px;
  text-align: center;
}
.module-placeholder h2 {
  font-size: 20px;
  color: #ffffff;
  margin-bottom: 6.5px;
}
.module-placeholder p {
  color: var(--dash-text-muted);
  max-width: 484px;
}

/* ==========================================================================
   RESPONSIVE DESIGN BREAKPOINTS
   ========================================================================== */

/* Large laptop / compact desktop */
@media (max-width: 1440px) {
  .dash-sidebar {
    width: 168px;
    min-width: 168px;
    max-width: 168px;
  }
  .nav-link {
    height: 29px;
    font-size: 11.5px;
  }
  .header-titles h1 {
    font-size: 14.5px;
  }
  .header-titles p {
    font-size: 10px;
  }
}

/* Laptop (1366x768 / 1280x720) */
@media (max-width: 1366px) {
  .dash-sidebar {
    width: 158px;
    min-width: 158px;
    max-width: 158px;
  }
  .nav-link {
    height: 27px;
    font-size: 11px;
  }
  .dash-header {
    height: 44px;
    min-height: 44px;
    max-height: 44px;
    gap: 6px;
    padding: 0 8px;
  }
  .eff-big-val {
    font-size: 14.5px;
  }
  .header-center-group {
    gap: 8px;
  }
  .dash-main {
    padding: 4px 6px 3px 6px;
  }
  /* Slightly rebalance bottom row on narrower desktops */
  .panel-utilisation {
    grid-column: 1 / 28;
  }
  .panel-nest-ai {
    grid-column: 28 / 81;
  }
}

/* Medium screens — keep 2x2 but tighten */
@media (max-width: 1200px) {
  .header-timestamps .t-lbl {
    display: none;
  }
  .header-subtitle,
  .header-titles p {
    display: none;
  }
  .eff-title {
    display: none;
  }
  .prod-kpi-card {
    min-height: 40px;
    padding: 5px 6px;
  }
  .eff-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .panel-utilisation {
    grid-column: 1 / 32;
  }
  .panel-nest-ai {
    grid-column: 32 / 81;
  }
  .nest-ai-layout {
    grid-template-columns: 1.1fr 1fr;
    gap: 5px;
  }
}

/* Tablet landscape / small laptop — stack panels */
@media (max-width: 1100px) {
  html, body {
    overflow: hidden;
  }

  .dashboard-page {
    height: 100dvh;
  }

  .dash-shell {
    overflow: hidden;
  }

  .dash-main {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .dash-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto;
    overflow: visible;
    gap: 8px;
    align-content: start;
    flex: 0 0 auto;
    height: auto;
  }

  .dash-flash-ticker {
    position: relative;
    flex: 0 0 auto;
  }

  .panel-production,
  .panel-efficiency,
  .panel-utilisation,
  .panel-nest-ai {
    grid-column: auto;
    grid-row: auto;
    height: auto;
    max-height: none;
  }

  .panel-production {
    grid-column: 1;
  }
  .panel-efficiency {
    grid-column: 2;
  }
  .panel-utilisation {
    grid-column: 1;
  }
  .panel-nest-ai {
    grid-column: 2;
  }

  .panel-production,
  .panel-efficiency {
    min-height: 360px;
  }
  .panel-utilisation,
  .panel-nest-ai {
    min-height: 320px;
  }

  .panel-production .canvas-wrap,
  .panel-efficiency .canvas-wrap {
    min-height: 200px;
  }

  .util-chart-card .canvas-wrap {
    min-height: 180px;
  }

  .canvas-wrap.compact {
    min-height: 120px;
  }

  .header-center-group {
    gap: 6px;
  }
  .header-efficiency-block {
    padding: 3px 6px;
  }
  .live-badge {
    padding: 2px 5px;
  }
  .filter-panel {
    width: min(240px, calc(100vw - 24px));
    right: 0;
  }
}

/* Tablet portrait */
@media (max-width: 900px) {
  .menu-toggle {
    display: flex;
  }

  .dash-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(220px, 82vw);
    min-width: 0;
    max-width: 220px;
    height: 100dvh;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    z-index: 1000;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.45);
  }

  .dash-sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999;
  }

  /* Let the whole page scroll; do not pin flash over panels */
  .dash-main {
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .dash-grid {
    grid-template-columns: 1fr;
    flex: 0 0 auto;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .panel-production,
  .panel-efficiency,
  .panel-utilisation,
  .panel-nest-ai {
    grid-column: 1;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .dash-flash-ticker {
    position: relative;
    flex: 0 0 auto;
    margin-top: 2px;
  }

  .header-timestamps,
  .header-efficiency-block {
    display: none;
  }

  .header-actions {
    gap: 5px;
  }

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

  .nest-ai-layout {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    flex: 0 0 auto;
    height: auto;
    min-height: 0;
    gap: 10px;
  }

  .ai-charts-col {
    flex: 0 0 auto;
    min-height: 0;
    gap: 10px;
  }

  .ai-chart-box {
    flex: 0 0 auto;
    min-height: 210px;
    height: 210px;
  }

  .canvas-wrap.compact {
    flex: 1 1 auto;
    min-height: 170px;
    height: 170px;
  }

  .ai-chat-box {
    flex: 0 0 auto;
    min-height: 240px;
    height: auto;
  }

  .panel-production,
  .panel-efficiency {
    min-height: 0;
  }

  .panel-utilisation,
  .panel-nest-ai {
    min-height: 0;
  }

  /* Explicit chart heights so canvases do not collapse */
  .panel-production .chart-container,
  .panel-efficiency .chart-container {
    flex: 0 0 auto;
    min-height: 250px;
    overflow: visible;
  }

  .panel-production .canvas-wrap,
  .panel-efficiency .canvas-wrap {
    flex: 0 0 auto;
    min-height: 230px;
    height: 230px;
  }

  .util-chart-card {
    flex: 0 0 auto;
    min-height: 250px;
  }

  .util-chart-card .canvas-wrap {
    flex: 0 0 auto;
    min-height: 220px;
    height: 220px;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .dash-header {
    height: auto;
    min-height: 48px;
    max-height: none;
    flex-wrap: wrap;
    padding: 6px 8px;
    gap: 6px;
  }

  .header-titles {
    flex: 1;
    min-width: 0;
  }

  .header-titles h1 {
    font-size: 14px;
  }

  .header-center-group {
    order: 3;
    flex: 1 1 100%;
    justify-content: flex-start;
    gap: 8px;
  }

  .header-customer-logo,
  .btn-filter span {
    display: none;
  }

  .btn-filter {
    padding: 5px 7px;
  }

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

  .eff-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    flex: 0 0 auto;
  }

  .util-kpi-row {
    grid-template-columns: 1fr;
    flex: 0 0 auto;
  }

  .panel-production,
  .panel-efficiency,
  .panel-utilisation,
  .panel-nest-ai {
    min-height: 0;
    height: auto;
    overflow: visible;
  }

  /* 1) Hourly production + 3) efficiency loss charts */
  .panel-production .chart-container,
  .panel-efficiency .chart-container {
    flex: 0 0 auto;
    min-height: 280px;
    margin-top: 8px;
    overflow: visible;
  }

  .panel-production .canvas-wrap,
  .panel-efficiency .canvas-wrap {
    flex: 0 0 auto;
    min-height: 260px;
    height: 260px;
  }

  /* 4) Utilisation x-axis room */
  .util-chart-card {
    flex: 0 0 auto;
    min-height: 280px;
    padding-bottom: 8px;
  }

  .util-chart-card .canvas-wrap {
    flex: 0 0 auto;
    min-height: 240px;
    height: 240px;
  }

  /* 5) Nest AI: un-collapse charts + chat into a vertical stack */
  .panel-nest-ai {
    min-height: 0;
  }

  .nest-ai-layout {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: auto;
    min-height: 0;
    flex: 0 0 auto;
  }

  .ai-charts-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 0 0 auto;
    min-height: 0;
  }

  .ai-chart-box {
    flex: 0 0 auto;
    min-height: 230px;
    height: 230px;
  }

  .canvas-wrap.compact {
    flex: 1 1 auto;
    min-height: 190px;
    height: 190px;
  }

  .ai-chat-box {
    flex: 0 0 auto;
    min-height: 280px;
    max-height: none;
  }

  .chat-messages {
    min-height: 140px;
    flex: 1 1 auto;
  }

  /* 2) Flash scrolls with content — not stuck over efficiency */
  .dash-flash-ticker {
    position: relative;
    flex: 0 0 auto;
    height: auto;
    min-height: 28px;
    max-height: none;
    padding: 4px 6px;
    margin-top: 4px;
    z-index: 1;
  }

  .dash-footer {
    flex-wrap: wrap;
    height: auto;
    min-height: 0;
    max-height: none;
    padding: 6px 8px;
    gap: 8px 12px;
    justify-content: flex-start;
  }

  .foot-col,
  .foot-refresh-block {
    flex: 0 1 auto;
  }

  .chat-input-row {
    min-height: 34px;
    padding: 6px 8px;
  }

  .chat-input-row input {
    font-size: 12px;
  }
}

/* Small phones */
@media (max-width: 480px) {
  .dash-main {
    padding: 4px;
    gap: 4px;
  }

  .dash-panel {
    padding: 6px;
    border-radius: 6px;
  }

  .header-nestling-logo {
    height: 22px;
  }

  .live-badge {
    font-size: 9px;
  }

  .eff-grid {
    grid-template-columns: 1fr 1fr;
    gap: 4px;
  }

  .panel-production .chart-container,
  .panel-efficiency .chart-container {
    min-height: 250px;
  }

  .panel-production .canvas-wrap,
  .panel-efficiency .canvas-wrap {
    min-height: 230px;
    height: 230px;
  }

  .util-chart-card {
    min-height: 250px;
  }

  .util-chart-card .canvas-wrap {
    min-height: 210px;
    height: 210px;
  }

  .ai-chart-box {
    min-height: 210px;
    height: 210px;
  }

  .canvas-wrap.compact {
    min-height: 170px;
    height: 170px;
  }

  .ai-chat-box {
    min-height: 240px;
  }

  .flash-msg {
    font-size: 9px;
  }

  .dash-footer {
    font-size: 9px;
    gap: 6px 10px;
  }
}

/* Short viewports (laptops with low height / landscape phones) */
@media (max-height: 760px) {
  .dash-main {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .dash-grid {
    grid-template-rows: auto;
    align-content: start;
  }

  .panel-production,
  .panel-efficiency,
  .panel-utilisation,
  .panel-nest-ai {
    height: auto;
    max-height: none;
    min-height: 280px;
  }

  .panel-production .canvas-wrap,
  .panel-efficiency .canvas-wrap {
    min-height: 160px;
  }
}

@media (max-height: 760px) and (min-width: 1101px) {
  .dash-grid {
    grid-template-columns: repeat(80, 1fr);
    grid-template-rows: minmax(280px, 1fr) minmax(260px, 1fr);
  }

  .panel-production {
    grid-column: 1 / 41;
    grid-row: 1;
  }
  .panel-efficiency {
    grid-column: 41 / 81;
    grid-row: 1;
  }
  .panel-utilisation {
    grid-column: 1 / 28;
    grid-row: 2;
  }
  .panel-nest-ai {
    grid-column: 28 / 81;
    grid-row: 2;
  }
}
