:root {
  --sidebar-bg: #1a1a1a;
  --panel-bg: #151515;
  --panel-bg-dark: #111;
  --card-bg: #242424;
  --green-bg-dim: #1c3224;
  --orange-bg-dim: #392613;
  --yellow-bg-dim: #2a2118;
  --red-bg-dim: #3a1c1c;

  --hover-bg: #ffffff14;
  --hover-bg-light: #ffffff0d;
  --border-light: #ffffff0b;
  --table-hover: #ffffff02;
  --border-strong: #ffffff1c;

  --text-muted-dark: #a6a6a6;
  --text-dim: #cfcfcf;
  --orange-light: #ffc16f;
  --green-light: #62d991;
  --yellow-light: #f6c657;

  --orange-dim: #ff9d2d20;
  --orange-dim-2: #ff9d2d0b;

  --topbar-bg: #1a1a1acc;
  --shift-bg-start: #191714;

  --bg: #1a1a1a;
  --surface: #121212;
  --surface2: #181818;
  --border: rgba(255, 255, 255, 0.08);
  --text: #fff;
  --muted: rgba(255, 255, 255, 0.55);
  --dim: rgb(255, 255, 255);
  --orange: #ff9d2d;
  --green: #22c55e;
  --yellow: #facc15;
  --red: #ef4444;
  --accent: var(--orange);
  color-scheme: dark;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f8f9fa;
  --surface: #ffffff;
  --surface2: #f1f3f5;
  --border: rgba(0, 0, 0, 0.1);
  --text: #1a1b1e;
  --muted: rgba(0, 0, 0, 0.6);
  --dim: rgba(50, 50, 50, 0.822);

  --orange: #e8590c;
  --green: #0ca678;
  --yellow: #f59f00;
  --red: #e03131;
  --accent: var(--orange);

  --sidebar-bg: #f1f3f5;
  --panel-bg: #ffffff;
  --panel-bg-dark: #f8f9fa;
  --card-bg: #ffffff;

  --green-bg-dim: #e6fcf5;
  --orange-bg-dim: #fff4e6;
  --yellow-bg-dim: #fff9db;
  --red-bg-dim: #ffe3e3;

  --hover-bg: rgba(0, 0, 0, 0.05);
  --hover-bg-light: rgba(0, 0, 0, 0.03);
  --border-light: rgba(0, 0, 0, 0.05);
  --table-hover: rgba(0, 0, 0, 0.02);
  --border-strong: rgba(0, 0, 0, 0.15);

  --text-muted-dark: #495057;
  --text-dim: #6d7378;
  --orange-light: #e8590c;
  --green-light: #0ca678;
  --yellow-light: #f59f00;

  --orange-dim: rgba(232, 89, 12, 0.15);
  --orange-dim-2: rgba(232, 89, 12, 0.05);

  --topbar-bg: rgba(248, 249, 250, 0.8);
  --shift-bg-start: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    14px Poppins,
    Arial,
    sans-serif;
  letter-spacing: -0.15px;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  width: 272px;
  height: 100vh;
  position: fixed;
  inset: 0 auto 0 0;
  padding: 25px 14px 16px;
  display: flex;
  flex-direction: column;
  z-index: 5;
  transition: 0.3s ease;
}

.brand {
  height: 48px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  text-decoration: none;
}

.brand-logo {
  height: 62px;
  max-width: 100%;
  object-fit: contain;
  background: #ffffff00;
  padding: 4px 10px;
  border-radius: 8px;
}

.mobile-brand {
  display: none;
}

@media (max-width: 760px) {
  .mobile-brand {
    display: flex;
    align-items: center;
    margin-left: 8px;
    margin-right: auto;
    text-decoration: none;
  }

  .mobile-brand .brand-logo {
    height: 32px;
    padding: 3px 8px;
  }
}

.workspace {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-radius: 12px;
  margin: 29px 4px 24px;
  padding: 10px;
}

.workspace-dot {
  height: 8px;
  width: 8px;
  border-radius: 10px;
  background: var(--green);
}

.workspace small,
.sidebar-footer small {
  display: block;
  color: var(--dim);
  font-size: 9px;
  letter-spacing: 0.8px;
}

.workspace strong {
  font-size: 10px;
  font-weight: 500;
}

.workspace button,
.sidebar-footer button {
  color: var(--muted);
  border: 0;
  background: transparent;
  margin-left: auto;
}

.nav {
  overflow: auto;
  scrollbar-width: none;
}

.nav-label {
  font-size: 9px;
  color: var(--dim);
  font-weight: 600;
  letter-spacing: 1px;
  margin: 14px 12px 9px;
}

.nav-label.lower {
  margin-top: 27px;
}

.nav-link,
.nav-parent {
  height: 42px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  text-decoration: none;
  font: 500 13px inherit;
  cursor: pointer;
  transition: 0.2s;
}

.nav-link:hover,
.nav-parent:hover {
  background: var(--surface2);
  color: var(--text);
}

.nav-link.active {
  background: linear-gradient(90deg, var(--orange-dim), var(--orange-dim-2));
  color: var(--orange-light);
  box-shadow: inset 2px 0 var(--orange);
}

.nav-link i,
.nav-parent i {
  width: 18px;
  color: var(--text-muted-dark);
  font-style: normal;
  font-size: 16px;
}

.nav-parent {
  justify-content: space-between;
}

.nav-parent span {
  display: flex;
  gap: 12px;
  align-items: center;
}

.nav-parent b {
  font-size: 13px;
  font-weight: 400;
  transition: 0.25s;
}

.nav-group.open .nav-parent b {
  transform: rotate(180deg);
}

.nav-children {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.nav-group.open .nav-children {
  max-height: 1000px;
}

.nav-children a {
  height: 34px;
  margin: 0 0 0 27px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  text-decoration: none;
  color: var(--dim);
  font-size: 12px;
  border-radius: 8px;
}

.nav-children a::before {
  content: "";
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: currentColor;
  opacity: 0.4;
  flex-shrink: 0;
}

.nav-children a:hover {
  color: var(--text);
  background: var(--surface2);
}

.nav-children a.active {
  background: linear-gradient(90deg, var(--orange-dim), var(--orange-dim-2));
  color: var(--orange-light);
  box-shadow: inset 2px 0 var(--orange);
}

.nav-children em {
  margin-left: auto;
  font-style: normal;
  background: var(--yellow-bg-dim);
  color: #eeb46d;
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 10px;
}

.sidebar-footer {
  margin-top: auto;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 10px;
}

.sidebar-footer strong {
  font-size: 10px;
  font-weight: 500;
}

.help-icon {
  width: 27px;
  height: 27px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--card-bg);
  color: var(--orange);
  font-weight: 600;
}

.main {
  margin-left: 268px;
  min-height: 100vh;
}

.topbar {
  height: 76px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 36px;
  justify-content: space-between;
  background: var(--topbar-bg);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 4;
}

.global-search {
  height: 38px;
  width: 310px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 8px;
  color: var(--dim);
}

.global-search span {
  font-size: 21px;
  line-height: 0;
}

.global-search input {
  background: none;
  border: 0;
  color: var(--text);
  font: 12px inherit;
  outline: 0;
  width: 100%;
}

.global-search input::placeholder {
  color: var(--dim);
}

.global-search kbd {
  color: var(--dim);
  border: 1px solid var(--border);
  font-size: 9px;
  border-radius: 4px;
  padding: 2px 4px;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.profile {
  border: 0;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.2s ease;
}

.profile:hover {
  background: rgba(0, 0, 0, 0.04);
}

html[data-theme="dark"] .profile:hover {
  background: rgba(255, 255, 255, 0.08);
}

.profile > span:last-of-type {
  text-align: left;
  display: flex;
  flex-direction: column;
}

.profile strong {
  display: block;
  font-size: 13px;
  line-height: 1.2;
}

.profile small {
  color: var(--dim);
  font-size: 11px;
}

.profile .chevron {
  color: var(--dim);
  transition: transform 0.2s ease;
}

.avatar-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid transparent;
  transition: border-color 0.2s ease;
}

.profile:hover .avatar-img {
  border-color: var(--orange);
}

.profile-container {
  position: relative;
}

.profile-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
  padding: 8px 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
}

.profile-container:hover .profile-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.profile-container:hover .chevron {
  transform: rotate(180deg);
}

.dropdown-header {
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
}

.dropdown-header strong {
  font-size: 13px;
  color: var(--text);
}

.dropdown-header small {
  font-size: 11px;
  color: var(--dim);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--text);
  font-size: 13px;
  text-decoration: none;
  transition:
    background 0.2s ease,
    color 0.2s ease;
}

.dropdown-item:hover {
  background: rgba(0, 0, 0, 0.03);
}

html[data-theme="dark"] .dropdown-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.dropdown-item svg {
  color: var(--dim);
  transition: color 0.2s ease;
}

.dropdown-item:hover svg {
  color: var(--text);
}

.logout-btn {
  color: #ef4444;
}

.logout-btn svg {
  color: #ef4444;
}

.logout-btn:hover {
  background: #fef2f2;
  color: #dc2626;
}

.logout-btn:hover svg {
  color: #dc2626;
}

html[data-theme="dark"] .logout-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
}

html[data-theme="dark"] .logout-btn:hover svg {
  color: #f87171;
}

.badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--orange);
  color: white;
  font-size: 9px;
  font-weight: 700;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--topbar-bg);
}

.icon-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.icon-button:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text);
}

html[data-theme="dark"] .icon-button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.menu-toggle {
  display: none;
}

.content {
  padding: 32px 38px 50px;
  max-width: 1600px;
  margin: auto;
}

.breadcrumb {
  display: flex;
  gap: 8px;
  color: var(--dim);
  font-size: 11px;
  margin-bottom: 16px;
}

.breadcrumb span:last-child {
  color: var(--muted);
}

.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 30px;
}

.page-heading h1 {
  font-size: 27px;
  letter-spacing: -1.25px;
  margin: 0 0 5px;
}

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

.primary-button {
  border: 0;
  color: #1c1207;
  background: linear-gradient(135deg, #ffb052, #ff8d22);
  font: 600 12px inherit;
  border-radius: 10px;
  padding: 11px 15px;
  cursor: pointer;
  box-shadow: 0 5px 16px #ff941e2c;
  transition: 0.2s;
}

.primary-button:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

.primary-button span {
  font-size: 16px;
  margin-left: 8px;
}

.secondary-button {
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--surface2);
  font: 600 12px inherit;
  border-radius: 10px;
  padding: 11px 15px;
  cursor: pointer;
  transition: 0.2s;
}

.secondary-button:hover {
  background: var(--border);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 26px;
}

.metric-card,
.panel {
  background: linear-gradient(145deg, var(--panel-bg), var(--panel-bg-dark));
  border: 1px solid var(--border);
  border-radius: 17px;
}

.metric-card {
  padding: 18px;
  min-height: 128px;
  position: relative;
  overflow: hidden;
  transition: 0.25s;
}

.metric-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
}

.metric-card:after {
  content: "";
  position: absolute;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--glow, var(--orange));
  filter: blur(55px);
  opacity: 0.1;
  right: -40px;
  top: -45px;
}

.metric-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
}

.metric-icon {
  width: 27px;
  height: 27px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--hover-bg);
  color: var(--accent, var(--orange));
  font-size: 15px;
}

.metric-value {
  font-weight: 600;
  font-size: 24px;
  letter-spacing: -1px;
  margin: 13px 0 7px;
}

.metric-note {
  color: var(--dim);
  font-size: 10px;
}

.metric-note b {
  color: var(--green);
  font-weight: 500;
  margin-right: 3px;
}

.metric-note.warn b {
  color: var(--yellow);
}

.sparkline {
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 38px;
  opacity: 0.6;
  pointer-events: none;
}

.sparkline svg {
  width: 100%;
  height: 100%;
  stroke: var(--trend, var(--orange));
  stroke-width: 2;
  fill: none;
  vector-effect: non-scaling-stroke;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 16px;
}

/* ── Module Grid (Overview mini cards) ── */
.module-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  align-items: stretch;
}

.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  cursor: pointer;
  transition:
    border-color 0.2s,
    box-shadow 0.2s,
    transform 0.15s;
}

.module-card:hover {
  border-color: var(--orange);
  box-shadow: 0 6px 24px #ff9d2d18;
  transform: translateY(-2px);
}

.module-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.module-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--orange);
  background: var(--orange-dim);
  padding: 3px 8px;
  border-radius: 6px;
}

.module-tag.ai-tag {
  color: #a78bfa;
  background: #a78bfa18;
}

.module-arrow {
  color: var(--dim);
  font-size: 14px;
  transition: transform 0.2s;
}

.module-card:hover .module-arrow {
  transform: translateX(4px);
}

.module-card > p {
  font-size: 12px;
  color: var(--dim);
  margin-bottom: 12px;
}

/* Stage bars (Production card) */
.module-stages {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stage-bar {
  display: flex;
  height: 8px;
  border-radius: 6px;
  overflow: hidden;
  gap: 2px;
}
.stage-done {
  background: var(--green-light);
  border-radius: 4px;
}
.stage-wip {
  background: var(--orange);
  border-radius: 4px;
}
.stage-warn {
  background: #f59e0b;
  border-radius: 4px;
}
.stage-rest {
  background: var(--border);
  border-radius: 4px;
  flex: 1;
}
.stage-labels {
  display: flex;
  justify-content: space-between;
}
.stage-labels span {
  font-size: 10px;
  color: var(--dim);
}
.stage-labels small {
  display: block;
  color: var(--dim);
  opacity: 0.7;
}

/* Stock bars */
.module-stock-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.module-stock-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.module-stock-row span {
  font-size: 11px;
  color: var(--text);
  min-width: 90px;
}
.module-stock-bar {
  flex: 1;
  height: 5px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.module-stock-bar b {
  display: block;
  height: 100%;
  background: var(--green-light);
  border-radius: 4px;
  transition: width 0.5s;
}
.module-stock-row.low .module-stock-bar b {
  background: #f59e0b;
}

/* PO / Sales rows */
.module-po-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.module-po-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.module-po-row span {
  font-size: 12px;
  color: var(--dim);
}
.module-po-row strong {
  color: var(--text);
}
.po-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 5px;
}
.po-badge.pending {
  background: var(--orange-bg-dim);
  color: var(--orange-light);
}
.po-badge.received {
  background: var(--green-bg-dim);
  color: var(--green-light);
}
.po-badge.dispatched {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
}

/* Xonier AI card */
.atom-ai-card {
  background: var(
    --ai-card-bg,
    linear-gradient(135deg, #16162a 0%, #1a1a2e 100%)
  );
  grid-column: span 1;
}
[data-theme="light"] .atom-ai-card {
  --ai-card-bg: linear-gradient(135deg, #f3f0ff 0%, #ede9fe 100%);
  border-color: rgba(167, 139, 250, 0.3) !important;
}
.ai-prompt-bubble {
  background: var(--ai-bubble-bg, rgba(255, 255, 255, 0.07));
  border: 1px solid var(--ai-bubble-border, rgba(255, 255, 255, 0.12));
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12px;
  color: var(--ai-bubble-text, rgba(255, 255, 255, 0.7));
  margin-bottom: 8px;
}
[data-theme="light"] .ai-prompt-bubble {
  --ai-bubble-bg: rgba(255, 255, 255, 0.8);
  --ai-bubble-border: rgba(167, 139, 250, 0.3);
  --ai-bubble-text: #495057;
}
.ai-answer {
  font-size: 12px;
  color: var(--ai-answer-color, rgba(255, 255, 255, 0.85));
  line-height: 1.5;
  margin-bottom: 10px;
}
[data-theme="light"] .ai-answer {
  --ai-answer-color: #212529;
}
.ai-answer strong {
  color: var(--orange-light);
}
.ai-tags {
  display: flex;
  gap: 5px;
}
.ai-tags span {
  font-size: 10px;
  font-weight: 600;
  background: var(--ai-tag-bg, rgba(255, 255, 255, 0.1));
  color: var(--ai-tag-text, rgba(255, 255, 255, 0.6));
  padding: 2px 7px;
  border-radius: 5px;
}
[data-theme="light"] .ai-tags span {
  --ai-tag-bg: rgba(167, 139, 250, 0.15);
  --ai-tag-text: #6d28d9;
}

/* Shipment tracking list (module-card) */
.module-tracking {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.module-tracking li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.module-tracking li span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 3px;
  flex-shrink: 0;
}
.track-done span {
  background: var(--green-light);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}
.track-active span {
  background: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-dim);
}
.track-pending span {
  background: var(--border);
  border: 2px solid var(--dim);
}
.module-tracking li div strong {
  font-size: 12px;
  color: var(--text);
}
.module-tracking li div small {
  font-size: 11px;
  color: var(--dim);
  display: block;
}

/* ── Shipment tab tracker cards ── */
.shipment-tracker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  align-items: stretch;
}

.shipment-track-card {
  border-radius: 14px;
}

.stc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.stc-head strong {
  font-size: 15px;
  color: var(--text);
}

.stc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.stc-meta span {
  font-size: 12px;
  color: var(--dim);
  background: var(--bg);
  padding: 3px 9px;
  border-radius: 6px;
}

.stc-progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.stc-progress {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.stc-progress b {
  display: block;
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}
.completed-fill {
  background: var(--green-light);
}
.progress-fill {
  background: var(--orange);
}
.hold-fill {
  background: #f59e0b;
}
.pending-fill {
  background: var(--border);
}
.stc-progress-wrap small {
  font-size: 11px;
  color: var(--dim);
  white-space: nowrap;
}

.panel {
  padding: 20px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 19px;
}

.panel-heading h2 {
  font-size: 14px;
  margin: 0;
  font-weight: 500;
}

.panel-heading p {
  font-size: 10px;
  color: var(--dim);
  margin: 3px 0 0;
}

.text-button {
  color: var(--orange);
  background: transparent;
  border: 0;
  font: 11px inherit;
  cursor: pointer;
}

.progress-list {
  display: flex;
  flex-direction: column;
  gap: 19px;
}

.progress-row {
  display: grid;
  grid-template-columns: 34px 1fr 55px;
  align-items: center;
  gap: 11px;
}

.progress-row .initial {
  width: 31px;
  height: 31px;
  border-radius: 9px;
  background: #211b16;
  color: var(--orange-light);
  display: grid;
  place-items: center;
  font-size: 10px;
}

.progress-row strong {
  display: block;
  font-size: 11px;
  font-weight: 500;
}

.progress-row small {
  color: var(--dim);
  font-size: 9px;
}

.progress-bar {
  height: 5px;
  background: var(--hover-bg-light);
  border-radius: 8px;
  margin-top: 8px;
  overflow: hidden;
}

.progress-bar b {
  height: 100%;
  display: block;
  border-radius: 8px;
  background: linear-gradient(90deg, #e87c18, #ffb454);
  animation: grow 0.9s ease;
}

.progress-row > span {
  font-size: 10px;
  color: var(--muted);
  text-align: right;
}

.load-row {
  margin-bottom: 15px;
}

.load-row:last-child {
  margin: 0;
}

.load-name {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  margin-bottom: 7px;
}

.load-name small {
  color: var(--dim);
}

.load-track {
  display: flex;
  height: 7px;
  background: var(--hover-bg);
  border-radius: 6px;
  overflow: hidden;
}

.load-track b {
  background: var(--orange);
  border-radius: 6px;
}

.load-track b.green {
  background: var(--green-light);
}

.load-track b.yellow {
  background: #e8b52d;
}

.wide {
  grid-column: span 1;
}

.chart-panel {
  margin-top: 16px;
}

.chart {
  height: 176px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 10px 2px 0;
  border-bottom: 1px solid var(--border);
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 42px,
    var(--border) 43px
  );
}

.bar-group {
  height: 100%;
  display: flex;
  align-items: end;
  gap: 4px;
  width: 26px;
  position: relative;
}

.bar {
  width: 10px;
  background: linear-gradient(#ffb455, #e77d19);
  border-radius: 4px 4px 0 0;
  opacity: 0.95;
}

.bar.alt {
  background: var(--border-strong);
}

.bar-group small {
  position: absolute;
  bottom: -19px;
  color: var(--dim);
  font-size: 9px;
  left: 0;
}

.activity {
  margin-top: 16px;
}

.activity-item {
  display: flex;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.activity-item:last-child {
  border: 0;
}

.activity-dot {
  height: 26px;
  width: 26px;
  border-radius: 8px;
  background: #1b261e;
  color: var(--green);
  display: grid;
  place-items: center;
  font-size: 11px;
}

.activity-item strong {
  display: block;
  font-size: 10px;
  font-weight: 500;
}

.activity-item small {
  color: var(--dim);
  font-size: 9px;
}

.section-grid {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 16px;
  margin-top: 16px;
}

.stock-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.stock-item:last-child {
  border: 0;
}

.stock-item > span {
  width: 32px;
  height: 32px;
  background: #1b1b1b;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--orange-light);
}

.stock-item strong {
  font-size: 10px;
  display: block;
  font-weight: 500;
}

.stock-item small {
  font-size: 9px;
  color: var(--dim);
}

.stock-item em {
  font-style: normal;
  margin-left: auto;
  font-size: 10px;
  color: #ffbc5c;
  background: #352817;
  padding: 4px 8px;
  border-radius: 7px;
}

.delivery {
  font-size: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 9px;
}

.delivery:last-child {
  border: 0;
}

.delivery-date {
  font-size: 9px;
  background: #1d1d1d;
  color: #bfbfbf;
  border-radius: 7px;
  padding: 5px;
}

.delivery span {
  color: var(--dim);
  margin-left: auto;
}

.summary-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

.summary-mini {
  padding: 14px;
}

.summary-mini small {
  color: var(--dim);
  font-size: 10px;
  display: block;
}

.summary-mini b {
  font-size: 19px;
  font-weight: 500;
  display: block;
  margin-top: 5px;
}

.table-panel {
  padding: 0;
  overflow: hidden;
}

.table-panel .panel-heading {
  padding: 17px 19px 0 19px;
  margin-bottom: 12px;
}

.table-toolbar {
  padding: 17px 19px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.table-toolbar .small-search {
  width: 220px;
}

.small-search {
  height: 33px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  padding: 0 9px;
  gap: 6px;
  color: var(--dim);
}

.small-search input {
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  width: 100%;
  font: 10px inherit;
}

.small-search input::placeholder {
  color: var(--dim);
}

.filter-button {
  background: var(--border);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  font: 10px inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-button {
  background: var(--border);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  font: 11px inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: 0.2s ease;
}

.toolbar-button:hover,
.filter-button:hover {
  background: var(--hover-bg);
  color: var(--text);
}

.toolbar-button svg,
.small-search svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.toolbar-button b {
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
}

.export-wrap {
  position: relative;
}

.export-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 130px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-5px);
  transition: 0.2s ease;
  z-index: 10;
}

.export-wrap.open .export-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.export-menu button {
  background: transparent;
  border: 0;
  color: var(--muted);
  text-align: left;
  padding: 8px 10px;
  font: 11px inherit;
  cursor: pointer;
  border-radius: 6px;
  transition: 0.2s;
}

.export-menu button:hover {
  background: var(--hover-bg);
  color: var(--text);
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
  text-align: left;
  min-width: 760px;
}

th {
  height: 42px;
  color: var(--dim);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.4px;
  background: var(--hover-bg);
  white-space: nowrap;
  padding: 0 12px;
}

td {
  height: 57px;
  color: var(--text-dim);
  font-size: 10px;
  border-top: 1px solid var(--border);
  white-space: nowrap;
  padding: 0 12px;
}

th:first-child,
td:first-child {
  padding-left: 20px;
}

th:last-child,
td:last-child {
  padding-right: 20px;
}

td strong {
  color: var(--text);
  font-weight: 500;
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:hover {
  background: var(--table-hover);
}

.row-quick-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
  opacity: 0.3;
  transition: opacity 0.15s ease;
}

tr:hover .row-quick-actions {
  opacity: 1;
}

.row-quick-actions button {
  background: transparent;
  border: 0;
  color: var(--dim);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: 0.15s;
  padding: 0;
}

.row-quick-actions button:hover {
  background: var(--hover-bg);
  color: var(--text);
}

.row-quick-actions button svg {
  width: 14px;
  height: 14px;
}

/* Status-forward-only: disabled edit buttons for terminal/locked records */
.row-quick-actions button:disabled,
.row-quick-actions button[disabled] {
  opacity: 0.3 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
  color: var(--muted) !important;
}


.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 9px;
}

.status svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.status.active,
.status.approved,
.status.passed,
.status.paid {
  color: #57d586;
  background: var(--green-bg-dim);
}

.status.pending,
.status.progress,
.status.partial {
  color: #e19229;
  background: antiquewhite;
}

.status.delayed,
.status.failed,
.status.low {
  color: #fa7777;
  background: #3a1d1d;
}

.status.planned,
.status.draft {
  color: #aeaeae;
  background: var(--card-bg);
}

.row-action {
  border: 0;
  background: transparent;
  color: var(--dim);
  font-size: 16px;
  cursor: pointer;
}

.pagination {
  padding: 13px 20px;
  color: var(--dim);
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pagination div {
  display: flex;
  gap: 5px;
}

.pagination button {
  color: var(--muted);
  background: var(--border);
  border: 0;
  border-radius: 5px;
  font: 10px inherit;
  min-width: 24px;
  height: 24px;
}

.pagination button.active {
  background: linear-gradient(135deg, #ffb052, #ff8d22);
  color: #211305;
}

.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-90px);
  z-index: 9999;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 40px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 360px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transition:
    transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.5s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast > span {
  background: var(--green-bg-dim);
  color: var(--green);
  border-radius: 8px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.toast.error > span {
  background: var(--red-bg-dim);
  color: var(--red);
}

.toast.warning > span {
  background: var(--yellow-bg-dim);
  color: var(--yellow);
}

.toast strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.toast small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.toast button {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--dim);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: 0.2s;
}

.toast button:hover {
  color: var(--text);
  background: var(--surface2);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 12;
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  width: min(660px, calc(100% - 32px));
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 28px 20px;
  position: relative;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  transform: translateY(15px);
  transition: 0.25s;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
}

.modal-wide {
  width: min(850px, calc(100% - 32px)) !important;
}

.modal-xl {
  width: min(1000px, calc(100% - 32px)) !important;
}

.open .modal {
  transform: none;
}

.modal-close {
  position: absolute;
  right: 16px;
  top: 14px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text);
}

.modal-icon {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.modal-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.modal h2 {
  font-size: 18px;
  margin: 12px 0 4px;
  color: var(--text);
}

.modal p {
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 14px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modal label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 10px;
}

.modal input,
.modal select {
  width: 100%;
  margin-top: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  height: 34px;
  border-radius: 7px;
  padding: 0 10px;
  color: var(--text);
  font: 13px inherit;
  outline: 0;
  box-sizing: border-box;
}

.modal input:focus,
.modal select:focus {
  border-color: var(--orange);
}

.modal .primary-button {
  width: 100%;
  margin-top: 6px;
}

.modal-submit {
  display: flex;
  justify-content: center;
  align-items: center;
}

@keyframes grow {
  from {
    width: 0;
  }
}

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

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

  .profile > span:last-of-type,
  .company-button > span:not(.company-icon) {
    display: none;
  }
}

@media (max-width: 760px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 10px 0 30px #0008;
  }

  .sidebar.show {
    transform: none;
  }

  .main {
    margin-left: 0;
  }

  .topbar {
    height: 64px;
    padding: 0 17px;
  }

  .menu-toggle {
    display: block;
  }

  .global-search {
    width: 45%;
    margin-right: auto;
    margin-left: 12px;
  }

  .top-actions {
    gap: 8px;
  }

  .company-button {
    border: 0;
    padding: 0;
  }

  .content {
    padding: 25px 17px;
  }

  .page-heading {
    align-items: start;
    gap: 12px;
  }

  .page-heading h1 {
    font-size: 23px;
  }

  .page-heading .primary-button {
    white-space: nowrap;
  }

  .metrics {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .metric-card {
    padding: 14px;
    min-height: 112px;
  }

  .metric-value {
    font-size: 20px;
  }

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

  .panel {
    padding: 16px;
  }

  .table-panel {
    padding: 0;
  }

  .table-toolbar {
    align-items: flex-start;
    gap: 8px;
  }

  .small-search {
    width: 155px !important;
  }
}

/* Consistent +3px type scale across the interface. */
body {
  font-size: 17px;
}

.brand-mark {
  font-size: 20px;
}

.brand-name {
  font-size: 22px;
}

.workspace small,
.sidebar-footer small {
  font-size: 12px;
}

.workspace strong {
  font-size: 13px;
}

.nav-label {
  font-size: 12px;
}

.nav-link,
.nav-parent {
  font-size: 15px;
}

.nav-link i,
.nav-parent i {
  font-size: 19px;
}

.nav-parent b {
  font-size: 16px;
}

.nav-children a {
  font-size: 14px;
}

.nav-children em {
  font-size: 13px;
}

.sidebar-footer,
.sidebar-footer strong {
  font-size: 13px;
}

.global-search span {
  font-size: 24px;
}

.global-search input {
  font-size: 15px;
}

.global-search kbd {
  font-size: 12px;
}

.icon-button {
  font-size: 21px;
}

.company-button,
.profile {
  font-size: 15px;
}

.company-icon,
.avatar {
  font-size: 13px;
}

.profile strong {
  font-size: 13px;
}

.profile small {
  font-size: 12px;
}

.breadcrumb {
  font-size: 14px;
}

.page-heading h1 {
  font-size: 30px;
}

.page-heading p {
  font-size: 15px;
}

.primary-button {
  font-size: 15px;
}

.primary-button span {
  font-size: 19px;
}

.metric-label {
  font-size: 14px;
}

.metric-icon {
  font-size: 18px;
}

.metric-value {
  font-size: 27px;
}

.metric-note {
  font-size: 13px;
}

.panel-heading h2 {
  font-size: 17px;
}

.panel-heading p {
  font-size: 13px;
}

.text-button {
  font-size: 14px;
}

.progress-row .initial {
  font-size: 13px;
}

.progress-row strong {
  font-size: 14px;
}

.progress-row small {
  font-size: 12px;
}

.progress-row > span {
  font-size: 13px;
}

.load-name {
  font-size: 13px;
}

.bar-group small {
  font-size: 12px;
}

.activity-dot {
  font-size: 14px;
}

.activity-item strong {
  font-size: 13px;
}

.activity-item small {
  font-size: 12px;
}

.stock-item strong {
  font-size: 13px;
}

.stock-item small {
  font-size: 12px;
}

.stock-item em {
  font-size: 13px;
}

.delivery {
  font-size: 13px;
}

.delivery-date {
  font-size: 12px;
}

.summary-mini small {
  font-size: 13px;
}

.summary-mini b {
  font-size: 22px;
}

.small-search input,
.filter-button {
  font-size: 13px;
}

th {
  font-size: 12px;
}

td {
  font-size: 13px;
}

.status {
  font-size: 12px;
}

.row-action {
  font-size: 19px;
}

.pagination,
.pagination button {
  font-size: 13px;
}

.toast strong {
  font-size: 13px;
}

.toast small {
  font-size: 12px;
}

.toast button {
  font-size: 19px;
}

.modal-close {
  font-size: 25px;
}

.modal h2 {
  font-size: 22px;
}

.modal p {
  font-size: 14px;
}

.modal label {
  font-size: 13px;
}

.modal input,
.modal select {
  font-size: 14px;
}

@media (max-width: 760px) {
  .page-heading h1 {
    font-size: 26px;
  }

  .metric-value {
    font-size: 23px;
  }
}

/* Dashboard live factory overview */
.live-factory {
  margin-top: 8px;
}

.live-factory-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin: 0 0 16px;
}

.live-eyebrow {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.live-eyebrow i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px #22c55e88;
}

.live-factory-heading p {
  margin: 4px 0 0;
  color: var(--dim);
  font-size: 13px;
}

.live-time {
  font-size: 12px;
  color: #63d991;
}

.live-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
}

.live-card {
  padding: 20px;
  transition: 0.25s;
}

.live-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
}

.production-card {
  grid-column: span 4;
}

.machines-card {
  grid-column: span 8;
}

.workforce-card {
  grid-column: span 4;
}

.output-card {
  grid-column: span 8;
}

.health-card {
  grid-column: span 5;
}

.alerts-card {
  grid-column: span 4;
}

.shift-card {
  grid-column: span 3;
  background: linear-gradient(
    145deg,
    var(--shift-bg-start),
    var(--panel-bg-dark)
  );
}

.live-chip {
  border-radius: 7px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 500;
}

.live-chip.orange {
  background: var(--orange-bg-dim);
  color: var(--orange-light);
}

.live-chip.green {
  background: var(--green-bg-dim);
  color: var(--green-light);
}

.production-content {
  display: flex;
  align-items: center;
  gap: 22px;
  padding-top: 3px;
}

.progress-ring,
.health-ring {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, var(--panel-bg) 59%, transparent 60%),
    conic-gradient(
      var(--orange) calc(var(--progress) * 1%),
      var(--border-light) 0
    );
  box-shadow: inset 0 0 22px #0006;
}

.progress-ring > div,
.health-ring > div {
  text-align: center;
}

.progress-ring strong,
.health-ring strong {
  display: block;
  font-size: 27px;
  letter-spacing: -1px;
}

.progress-ring small,
.health-ring small {
  color: var(--dim);
  font-size: 12px;
}

.production-copy {
  flex: 1;
  display: grid;
  gap: 11px;
}

.production-copy small,
.output-stats small,
.shift-details small {
  display: block;
  color: var(--dim);
  font-size: 12px;
}

.production-copy b {
  display: block;
  margin-top: 2px;
  font-size: 18px;
  font-weight: 500;
}

.production-copy em {
  font-style: normal;
  color: var(--dim);
  font-size: 12px;
  font-weight: 400;
}

.production-copy p {
  margin: 0;
  color: var(--dim);
  font-size: 12px;
}

.production-copy p span {
  color: #63d991;
  font-weight: 500;
}

.machine-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.machine-card {
  background: var(--hover-bg);
  border: 1px solid var(--hover-bg);
  border-radius: 11px;
  padding: 12px;
  min-width: 0;
}

.machine-card:hover {
  background: var(--border);
}

.machine-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.machine-icon {
  width: 27px;
  height: 27px;
  border-radius: 8px;
  background: var(--hover-bg);
  color: var(--orange-light);
  display: grid;
  place-items: center;
  font-size: 15px;
}

.machine-state {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--dim);
  font-size: 11px;
}

.machine-state i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.machine-state.running {
  color: #57d586;
}

.machine-state.idle {
  color: var(--yellow-light);
}

.machine-state.maintenance {
  color: #fa7777;
}

.machine-card strong {
  display: block;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.machine-card small {
  display: block;
  color: var(--dim);
  font-size: 11px;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.machine-util {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  color: var(--dim);
  font-size: 11px;
}

.machine-util b {
  color: var(--muted);
  font-weight: 500;
}

.machine-track {
  height: 4px;
  margin-top: 5px;
  background: var(--hover-bg);
  border-radius: 8px;
  overflow: hidden;
}

.machine-track i {
  display: block;
  height: 100%;
  background: var(--orange);
  border-radius: inherit;
}

.machine-track i.running {
  background: var(--green-light);
}

.machine-track i.idle {
  background: #e8b52d;
}

.machine-track i.maintenance {
  background: var(--red);
}

.workforce-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 13px;
}

.workforce-grid > div {
  background: var(--hover-bg);
  border-radius: 10px;
  padding: 11px;
}

.workforce-icon {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 8px;
  background: var(--green-bg-dim);
  color: var(--green-light);
  font-size: 14px;
}

.workforce-icon.muted {
  background: #252525;
  color: var(--muted);
}

.workforce-icon.orange {
  background: var(--orange-bg-dim);
  color: var(--orange-light);
}

.workforce-icon.green {
  background: var(--green-bg-dim);
  color: var(--green-light);
}

.workforce-grid small {
  display: block;
  color: var(--dim);
  font-size: 11px;
  margin-top: 8px;
}

.workforce-grid b {
  font-size: 17px;
  font-weight: 500;
}

.output-bar {
  height: 12px;
  background: var(--hover-bg);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  margin: 11px 0 17px;
}

.output-bar span {
  height: 100%;
}

.output-completed {
  background: linear-gradient(90deg, #e87c18, #ffb454);
}

.output-rejected {
  background: var(--red);
}

.output-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.output-stats b {
  display: block;
  margin-top: 3px;
  font-size: 17px;
  font-weight: 500;
}

.green-text {
  color: var(--green-light);
}

.warning-text {
  color: var(--yellow-light);
}

.health-main {
  display: flex;
  align-items: center;
  gap: 23px;
}

.health-ring {
  --progress: 97;
  width: 116px;
  height: 116px;
  background:
    radial-gradient(circle at center, var(--panel-bg) 59%, transparent 60%),
    conic-gradient(
      var(--green-light) calc(var(--progress) * 1%),
      var(--border-light) 0
    );
}

.health-ring strong {
  font-size: 24px;
}

.health-metrics {
  flex: 1;
  display: grid;
  gap: 12px;
}

.health-metrics div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 10px;
  font-size: 11px;
}

.health-metrics span {
  color: var(--dim);
}

.health-metrics b {
  font-weight: 500;
  color: var(--muted);
}

.health-metrics i {
  grid-column: span 2;
  height: 4px;
  background: var(--border-light);
  border-radius: 5px;
  overflow: hidden;
}

.health-metrics em {
  display: block;
  height: 100%;
  background: var(--green-light);
  border-radius: inherit;
}

.alert-count {
  height: 24px;
  min-width: 24px;
  padding: 0 7px;
  border-radius: 7px;
  background: var(--orange-bg-dim);
  color: var(--orange-light);
  display: grid;
  place-items: center;
  font-size: 12px;
}

.alert-list {
  display: grid;
  gap: 7px;
}

.alert-item {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--hover-bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 9px;
}

.alert-item > span {
  width: 21px;
  height: 21px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--orange-bg-dim);
  color: var(--yellow-light);
  font-size: 13px;
  font-weight: 600;
}

.alert-item div {
  min-width: 0;
}

.alert-item strong {
  display: block;
  font-size: 11px;
  font-weight: 500;
}

.alert-item small {
  display: block;
  color: var(--dim);
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alert-item > i {
  font-style: normal;
  margin-left: auto;
  color: var(--dim);
  font-size: 16px;
}

.shift-top {
  display: flex;
  justify-content: space-between;
  align-items: start;
}

.shift-top h2 {
  margin: 9px 0 3px;
  font-size: 18px;
  font-weight: 500;
}

.shift-top p {
  margin: 0;
  color: var(--dim);
  font-size: 11px;
}

.shift-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--orange-bg-dim);
  color: var(--orange-light);
  font-size: 18px;
}

.shift-details {
  display: grid;
  gap: 11px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.shift-details div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.shift-details b {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.shift-details div:last-child b {
  color: var(--orange-light);
}

@media (max-width: 1200px) {
  .production-card,
  .workforce-card {
    grid-column: span 5;
  }

  .machines-card,
  .output-card {
    grid-column: span 7;
  }

  .health-card {
    grid-column: span 6;
  }

  .alerts-card,
  .shift-card {
    grid-column: span 3;
  }

  .machine-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .production-card,
  .machines-card,
  .workforce-card,
  .output-card,
  .health-card,
  .alerts-card,
  .shift-card {
    grid-column: span 12;
  }

  .machine-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .shift-details {
    grid-template-columns: repeat(3, 1fr);
  }

  .shift-details div {
    display: block;
  }

  .shift-details b {
    display: block;
    margin-top: 3px;
  }
}

@media (max-width: 600px) {
  .live-factory-heading {
    align-items: start;
    gap: 9px;
    flex-direction: column;
  }

  .live-grid {
    gap: 12px;
  }

  .live-card {
    padding: 16px;
  }

  .production-content {
    gap: 15px;
  }

  .progress-ring {
    width: 114px;
    height: 114px;
  }

  .machine-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .output-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .health-main {
    gap: 15px;
  }

  .alert-item small {
    white-space: normal;
  }

  .shift-details {
    grid-template-columns: 1fr;
  }

  .shift-details div {
    display: flex;
  }

  .live-time {
    font-size: 11px;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.metrics > article {
  opacity: 0;
  animation: fadeInUp 0.45s ease forwards;
}

.metrics > article:nth-child(1) {
  animation-delay: 0.05s;
}
.metrics > article:nth-child(2) {
  animation-delay: 0.1s;
}
.metrics > article:nth-child(3) {
  animation-delay: 0.15s;
}
.metrics > article:nth-child(4) {
  animation-delay: 0.2s;
}
.metrics > article:nth-child(5) {
  animation-delay: 0.25s;
}
.metrics > article:nth-child(6) {
  animation-delay: 0.3s;
}
.metrics > article:nth-child(7) {
  animation-delay: 0.35s;
}
.metrics > article:nth-child(8) {
  animation-delay: 0.4s;
}

.live-factory {
  opacity: 0;
  animation: fadeInUp 0.5s ease 0.45s forwards;
}

.dashboard-grid > section,
.section-grid > section {
  opacity: 0;
  animation: fadeInUp 0.5s ease 0.5s forwards;
}

.table-panel {
  opacity: 0;
  animation: fadeInUp 0.5s ease 0.15s forwards;
}

.summary-row > .panel {
  opacity: 0;
  animation: fadeInUp 0.45s ease forwards;
}
.summary-row > .panel:nth-child(1) {
  animation-delay: 0.05s;
}
.summary-row > .panel:nth-child(2) {
  animation-delay: 0.1s;
}
.summary-row > .panel:nth-child(3) {
  animation-delay: 0.15s;
}

/* ── Source-bound dashboard overview ─────────────────────────────────────── */
.overview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: -8px 0 20px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(100deg, var(--orange-bg-dim-2), var(--panel-bg));
}

.overview-toolbar > div:first-child {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.overview-toolbar strong {
  font-size: 12px;
  font-weight: 600;
}

.overview-toolbar small {
  color: var(--dim);
  font-size: 11px;
  padding-left: 5px;
}

.overview-live-dot,
.overview-eyebrow i {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px var(--green-bg-dim);
}

.overview-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.overview-toolbar-actions .secondary-button {
  padding: 8px 11px;
  font-size: 11px;
}

.overview-toolbar-actions button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.overview-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 34px;
}

.overview-metric {
  --metric-accent: var(--orange);
  position: relative;
  min-height: 190px;
  overflow: hidden;
  padding: 17px 18px 15px;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: linear-gradient(145deg, var(--panel-bg), var(--panel-bg-dark));
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.overview-metric:hover,
.overview-flow-card:hover,
.overview-source-panel:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: 0 10px 28px #0000000d;
}

.overview-metric::after {
  content: "";
  position: absolute;
  width: 120px;
  height: 120px;
  right: -52px;
  top: -48px;
  border-radius: 50%;
  background: var(--metric-accent);
  filter: blur(44px);
  opacity: 0.12;
  pointer-events: none;
}

.overview-metric.green { --metric-accent: var(--green); }
.overview-metric.yellow { --metric-accent: var(--yellow); }

.overview-metric-top,
.overview-metric-source,
.overview-flow-head,
.overview-section-heading,
.overview-insight-panel,
.overview-insight-example div {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.overview-metric-top {
  color: var(--muted);
  font-size: 12px;
}

.overview-metric-mark {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 9px;
  color: var(--metric-accent);
  background: var(--hover-bg);
  font-size: 15px;
}

.overview-metric-value {
  display: block;
  margin-top: 17px;
  color: var(--text);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -1.5px;
}

.overview-metric-state {
  margin: 4px 0 15px;
  color: var(--dim);
  font-size: 11px;
}

.overview-metric-source {
  justify-content: flex-start;
  gap: 7px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  color: var(--dim);
  font-size: 10px;
}

.overview-metric-source b {
  color: var(--muted);
  font-weight: 500;
}

.overview-metric-link {
  margin-top: 10px;
  padding: 0;
  border: 0;
  color: var(--metric-accent);
  background: none;
  font: 500 10px inherit;
  cursor: pointer;
}

.overview-metric-link span { padding-left: 3px; }

.overview-metric-contract {
  position: absolute;
  right: 17px;
  bottom: 17px;
  max-width: 45%;
  overflow: hidden;
  color: var(--dim);
  font-size: 8px;
  opacity: 0.6;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-section { margin: 0 0 30px; }

.overview-section-heading {
  align-items: end;
  gap: 18px;
  margin-bottom: 14px;
}

.overview-section-heading.compact { align-items: start; }

.overview-section-heading h2,
.overview-flow-card h2,
.overview-insight-copy h2 {
  margin: 8px 0 3px;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.4px;
}

.overview-section-heading p,
.overview-flow-card > p,
.overview-insight-copy p {
  margin: 0;
  color: var(--dim);
  font-size: 11px;
  line-height: 1.55;
}

.overview-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.9px;
  text-transform: uppercase;
}

.overview-eyebrow i { display: inline-block; }
.overview-eyebrow.purple i { background: #9b87f5; box-shadow: 0 0 0 4px #9b87f51c; }

.overview-contract-badge {
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--dim);
  font-size: 10px;
  white-space: nowrap;
}

.overview-flow-grid,
.overview-source-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.overview-flow-card,
.overview-source-panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.overview-flow-card {
  min-height: 250px;
  padding: 16px;
  cursor: pointer;
}

.overview-flow-head { margin-bottom: 18px; }

.overview-flow-tag {
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--metric-accent, var(--orange));
  background: var(--orange-bg-dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

.flow-supply .overview-flow-tag { color: var(--yellow-light); background: var(--yellow-bg-dim); }
.flow-execution .overview-flow-tag { color: var(--green-light); background: var(--green-bg-dim); }
.flow-fulfilment .overview-flow-tag { color: #9b87f5; background: #9b87f51c; }

.overview-flow-arrow {
  color: var(--dim);
  font-size: 16px;
}

.overview-empty {
  display: grid;
  align-content: center;
  justify-items: start;
  min-height: 118px;
  margin-top: 18px;
  padding: 13px;
  border: 1px dashed var(--border-strong);
  border-radius: 11px;
  background: var(--hover-bg-light);
}

.overview-empty-icon {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  margin-bottom: 9px;
  border-radius: 8px;
  color: var(--metric-accent, var(--orange));
  background: var(--hover-bg);
  font-size: 18px;
}

.overview-empty strong {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.overview-empty small {
  margin-top: 4px;
  color: var(--dim);
  font-size: 9px;
  line-height: 1.4;
}

.overview-source-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 16px;
}

.overview-source-panel { padding: 18px; }
.overview-source-panel .text-button { margin-top: 4px; white-space: nowrap; }
.overview-list-placeholder .overview-empty { min-height: 132px; margin-top: 12px; }

.overview-live-content {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--hover-bg-light);
}

.overview-live-summary,
.overview-live-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.overview-live-summary {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.overview-live-summary strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.overview-live-summary span,
.overview-live-row span {
  color: var(--dim);
  font-size: 10px;
}

.overview-live-row {
  padding: 9px 0 0;
}

.overview-live-row b {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-insight-panel {
  align-items: stretch;
  gap: 18px;
  margin-bottom: 18px;
  padding: 22px;
  overflow: hidden;
  border: 1px solid #9b87f540;
  border-radius: 17px;
  background: linear-gradient(115deg, #9b87f51a, var(--panel-bg));
}

.overview-insight-copy { flex: 1; min-width: 0; }
.overview-insight-copy h2 { font-size: 19px; }
.overview-insight-copy p { max-width: 650px; }
.overview-insight-copy .secondary-button { margin-top: 16px; }

.overview-insight-example {
  display: grid;
  align-content: center;
  width: min(35%, 340px);
  min-width: 260px;
  padding: 18px;
  border: 1px solid #9b87f533;
  border-radius: 12px;
  background: #9b87f50d;
}

.overview-insight-example > span {
  color: #9b87f5;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
}

.overview-insight-example div {
  align-items: start;
  gap: 9px;
  margin: 14px 0 10px;
  color: var(--muted);
  font-size: 11px;
}

.overview-insight-example em {
  color: var(--dim);
  font-size: 9px;
  font-style: normal;
  text-align: right;
}

.overview-insight-example small {
  color: var(--dim);
  font-size: 9px;
  line-height: 1.45;
}

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

@media (max-width: 700px) {
  .overview-toolbar,
  .overview-insight-panel { align-items: stretch; flex-direction: column; }
  .overview-toolbar-actions { justify-content: space-between; }
  .overview-toolbar small { display: block; }
  .overview-metrics,
  .overview-flow-grid,
  .overview-source-grid { grid-template-columns: 1fr; }
  .overview-section-heading { align-items: start; flex-direction: column; }
  .overview-contract-badge { align-self: start; }
  .overview-insight-example { width: 100%; min-width: 0; }
}
