:root {
  --bg: #f1f5f9;
  --bg-accent: #e8f0f8;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #00629b;
  --primary-strong: #004e7a;
  --primary-soft: #e8f4fc;
  --success: #16a34a;
  --warning: #ea580c;
  --danger: #dc2626;
  --border: #e2e8f0;
  --header-border: rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 1px 3px rgba(15, 23, 42, 0.06), 0 12px 32px rgba(15, 23, 42, 0.06);
  --shadow-focus: 0 0 0 2px rgba(0, 98, 155, 0.2);
  --radius-panel: 16px;
  --radius-control: 10px;
  --page-pad-x: clamp(0.75rem, 4vw, 2.75rem);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "cv02", "cv03", "cv04";
  background: var(--bg);
  background-image: radial-gradient(1200px 480px at 12% -10%, var(--bg-accent), transparent),
    radial-gradient(900px 400px at 100% 0%, #dbeafe, transparent 55%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.78);
  border-bottom: 1px solid var(--header-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.header-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0.6rem var(--page-pad-x);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.philips-logo {
  display: block;
  width: 40px;
  height: auto;
  flex-shrink: 0;
}

.header-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.header-eyebrow {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.2;
}

.header-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--text);
}

.header-desc {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
  line-height: 1.35;
}

.header-aside {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  flex-shrink: 0;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  max-width: 280px;
  padding: 0.38rem 0.7rem;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--primary-strong);
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-chip--muted {
  color: var(--muted);
  font-weight: 500;
  background: #f8fafc;
}

.app-header--with-actions .header-shell {
  align-items: flex-start;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  flex-shrink: 0;
}

.layout {
  display: grid;
  grid-template-columns: minmax(272px, 320px) 1fr;
  gap: 1.1rem;
  padding: 1.15rem var(--page-pad-x) 2rem;
  align-items: start;
}

.stream-panel,
.dashboard-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  padding: 1.15rem;
  box-shadow: var(--shadow-soft);
}

.stream-panel {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 5.5rem);
  min-height: 0;
}

.sidebar-nav {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-section {
  flex-shrink: 0;
}

.sidebar-section--list {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-heading {
  margin: 0 0 0.4rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.sidebar-hint {
  margin: 0.35rem 0 0;
  font-size: 0.68rem;
  line-height: 1.35;
  color: var(--muted);
}

.sidebar-filter {
  width: 100%;
  margin: 0 0 0.45rem;
  padding: 0.38rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.78rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

.sidebar-filter::placeholder {
  color: #94a3b8;
}

.sidebar-filter:focus {
  outline: none;
  border-color: rgba(0, 98, 155, 0.45);
  box-shadow: var(--shadow-focus);
}

.sidebar-nav__featured {
  font-weight: 650;
  border: 1px solid rgba(0, 98, 155, 0.35);
  background: linear-gradient(180deg, #f0f8fc 0%, #e2f1fa 100%);
}

.sidebar-nav__featured.active {
  border-color: rgba(0, 98, 155, 0.55);
  background: var(--primary-soft);
}

.sidebar-list {
  flex: 1;
  min-height: 0;
  max-height: min(200px, 28vh);
  overflow-y: auto;
  padding-right: 0.2rem;
  scrollbar-gutter: stable;
}

.sidebar-list__li.sidebar-list__item--hidden {
  display: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.stream-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.panel-footer {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid #e0e8f4;
}

.panel-footer-link {
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
}

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

.stream-btn {
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-control);
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
  font-size: 0.86rem;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.stream-btn:hover {
  transform: translateY(-1px);
  border-color: #cbd5e1;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.07);
}

.factory-multi-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.factory-global-stream {
  scroll-margin-top: 5.5rem;
  padding-top: 0.35rem;
}

.factory-global-stream:not(:first-child) {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.factory-global-stream-title {
  margin: 0 0 0.5rem;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--primary-strong);
}

.stream-btn.active {
  border-color: rgba(0, 98, 155, 0.35);
  background: var(--primary-soft);
  color: var(--primary-strong);
  box-shadow: 0 0 0 1px rgba(0, 98, 155, 0.12);
}

.empty-state {
  color: var(--muted);
  padding: 1.1rem 0.6rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: #fafcff;
}

.hidden {
  display: none;
}

.kpi-container {
  display: grid;
  gap: 0.8rem;
}

details.kpi-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  overflow: hidden;
  background: #ffffff;
  transition: box-shadow 0.28s ease, border-color 0.28s ease;
}

details.kpi-group:hover {
  border-color: #bcd4e9;
}

details.kpi-group[open] {
  box-shadow: var(--shadow-soft);
  border-color: #9fc1de;
}

details.kpi-group > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.78rem 0.9rem;
  font-weight: 700;
  background: linear-gradient(180deg, #f8fbff 0%, #f0f7fd 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  transition: background 0.24s ease;
}

details.kpi-group > summary.kpi-summary.green {
  background: linear-gradient(180deg, #f4fcf6 0%, #ddf5e5 100%);
}

details.kpi-group > summary.kpi-summary.yellow {
  background: linear-gradient(180deg, #fff9ef 0%, #ffe8c4 100%);
}

details.kpi-group > summary.kpi-summary.red {
  background: linear-gradient(180deg, #fff6f7 0%, #ffd9de 100%);
}

details.kpi-group > summary::-webkit-details-marker {
  display: none;
}

.kpi-title {
  font-size: 0.96rem;
}

.kpi-summary-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.kpi-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.76rem;
  line-height: 1;
  padding: 0.3rem 0.52rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 700;
  color: #2f4869;
  background: #edf4fb;
}

.kpi-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a6b2c8;
}

.kpi-status-pill.green {
  background: #ebf9ef;
  color: #207a3f;
  border-color: #c8ecd3;
}

.kpi-status-pill.green .kpi-status-dot {
  background: var(--success);
}

.kpi-status-pill.yellow {
  background: #fff5e8;
  color: #aa6310;
  border-color: #f7ddbb;
}

.kpi-status-pill.yellow .kpi-status-dot {
  background: var(--warning);
}

.kpi-status-pill.red {
  background: #ffecef;
  color: #a8222a;
  border-color: #f5c6cc;
}

.kpi-status-pill.red .kpi-status-dot {
  background: var(--danger);
}

.kpi-summary-action {
  color: #4e6787;
  font-size: 0.78rem;
  padding: 0.3rem 0.5rem;
  border-radius: 8px;
  border: 1px solid #cfe0f1;
  background: #f3f8fd;
}

details.kpi-group[open] .kpi-summary-action {
  color: #17456f;
  border-color: #9cc1df;
  background: #e4f1fb;
}

details.kpi-group[open] > summary.kpi-summary.green .kpi-summary-action {
  color: #176b35;
  border-color: #9ed1af;
  background: #e5f6ea;
}

details.kpi-group[open] > summary.kpi-summary.yellow .kpi-summary-action {
  color: #8f5712;
  border-color: #edc98d;
  background: #fff0d7;
}

details.kpi-group[open] > summary.kpi-summary.red .kpi-summary-action {
  color: #8d2630;
  border-color: #e5a5ad;
  background: #ffe6e9;
}

.kpi-content {
  padding: 0.8rem 0.95rem 0.95rem;
  transform-origin: top center;
}

details.kpi-group[open] .kpi-content {
  animation: kpi-reveal 0.46s cubic-bezier(0.22, 0.61, 0.36, 1);
}

@keyframes kpi-reveal {
  from {
    opacity: 0;
    transform: translateY(-8px) scaleY(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scaleY(1);
  }
}

.kpi-list {
  margin: 0;
  padding-left: 1.05rem;
  color: var(--text);
  line-height: 1.5;
}

.kpi-list li {
  margin-bottom: 0.35rem;
}

.kpi-section-title {
  margin: 0 0 0.55rem;
  font-size: 0.84rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #55627b;
  font-weight: 700;
}

.kpi-section-intro {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  line-height: 1.5;
  color: #4b5d7b;
}

.udf-block {
  margin-bottom: 1.1rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid #d8e5f3;
  border-radius: 10px;
  background: #fbfdff;
}

.udf-block--total {
  background: #f4f8fd;
  border-color: #c5d9ef;
}

.udf-block-title {
  margin: 0 0 0.5rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: #1a3a5c;
}

.udf-metric-table {
  font-size: 0.78rem;
}

.udf-metric-table th[scope="row"] {
  font-weight: 600;
  text-align: left;
  white-space: normal;
  max-width: 14rem;
}

.udf-row--gap th,
.udf-row--gap-cum th {
  font-weight: 700;
}

.uspcsp-table-wrap {
  max-width: 100%;
}

.uspcsp-pivot-table {
  min-width: 760px;
  font-size: 0.78rem;
}

.uspcsp-pivot-table th,
.uspcsp-pivot-table td {
  padding: 0.34rem 0.48rem;
}

.uspcsp-pivot-table thead th {
  color: #17446f;
}

.uspcsp-slice-cell,
.uspcsp-detail-slice,
.uspcsp-metric-cell {
  text-align: left !important;
}

.uspcsp-slice-cell {
  min-width: 7.5rem;
  color: #14395d;
  font-weight: 600;
}

.uspcsp-metric-cell {
  min-width: 8.5rem;
  color: #243b53;
}

.uspcsp-toggle {
  border: 0;
  background: transparent;
  color: #0f4c81;
  padding: 0;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.uspcsp-toggle:hover {
  color: var(--primary-strong);
  text-decoration: underline;
}

.uspcsp-summary-row .value-good,
.uspcsp-detail-row .value-good {
  background: #c9efcf;
  color: #064d21;
}

.uspcsp-summary-row .value-bad,
.uspcsp-detail-row .value-bad {
  background: #ffc6cb;
  color: #9d121d;
}

.uspcsp-detail-row th,
.uspcsp-detail-row td {
  background: #fbfdff;
}

.uspcsp-detail-row.uspcsp-row--gap-cum th {
  font-weight: 700;
}

.uspcsp-detail-slice {
  color: #14395d;
  font-weight: 700;
}

.fillrate-chart {
  margin-bottom: 0.95rem;
  padding: 0.65rem;
  border: 1px solid #d8e5f3;
  border-radius: 10px;
  background: #f9fcff;
}

.fillrate-chart-subtitle {
  margin: -0.15rem 0 0.55rem;
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.35;
}

.fillrate-chart-bars-row {
  position: relative;
  min-height: 200px;
  margin-bottom: 0.35rem;
}

.fillrate-target-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 2px dashed #ea580c;
  z-index: 4;
  pointer-events: none;
  opacity: 0.92;
}

.fillrate-bars--in-plot {
  position: absolute;
  inset: 0;
  display: grid;
  align-items: end;
  gap: 0.35rem;
  padding: 0 0.15rem 0;
  z-index: 1;
}

.fillrate-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  min-height: 0;
  gap: 0.2rem;
}

.fillrate-bar-column {
  flex: 1;
  width: 100%;
  min-height: 120px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.fillrate-bar-value {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fillrate-bar-value--muted {
  color: var(--muted);
  font-weight: 500;
}

.fillrate-bar {
  width: 78%;
  max-width: 36px;
  min-width: 10px;
  border-radius: 6px 6px 3px 3px;
  border: 1px solid transparent;
  flex-shrink: 0;
}

.fillrate-bar.ok {
  background: linear-gradient(180deg, #bceec9 0%, #56c271 100%);
  border-color: #9ad8ad;
}

.fillrate-bar.risk {
  background: linear-gradient(180deg, #ffc9cf 0%, #f15f6d 100%);
  border-color: #e8929b;
}

.fillrate-bar--na {
  background: #e2e8f0;
  border-color: #cbd5e1;
  min-height: 4px;
}

.fillrate-bar-label {
  font-size: 0.65rem;
  color: #5e6b83;
  text-align: center;
  line-height: 1.15;
}

.fillrate-chart-legend {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.68rem;
  color: var(--muted);
  flex-wrap: wrap;
}

.fillrate-legend-line {
  display: inline-block;
  width: 1.35rem;
  border-top: 2px dashed #ea580c;
  vertical-align: middle;
  opacity: 0.92;
}

.fillrate-breakdown-toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
  padding: 0.45rem 0.55rem;
  border-radius: 10px;
  background: #f1f5f9;
  border: 1px solid var(--border);
}

.fillrate-breakdown-toolbar-head,
.fillrate-breakdown-order,
.fillrate-breakdown-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
}

.fillrate-breakdown-toolbar-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-right: 0.15rem;
}

.fillrate-breakdown-toolbar-help {
  font-size: 0.72rem;
  color: #51657f;
}

.fillrate-breakdown-order-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  min-width: 4.8rem;
}

.fillrate-breakdown-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.fillrate-breakdown-chip {
  border: 1px dashed rgba(0, 98, 155, 0.45);
  background: #fff;
  color: var(--primary-strong);
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: inherit;
  cursor: grab;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.fillrate-breakdown-chip[draggable="false"] {
  cursor: default;
}

.fillrate-breakdown-chip--empty {
  cursor: default;
  color: #64748b;
  background: #f8fafc;
  border-style: solid;
  font-weight: 600;
}

.fillrate-breakdown-chip:hover {
  border-color: rgba(0, 98, 155, 0.65);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.fillrate-breakdown-chip.dragging {
  opacity: 0.55;
  cursor: grabbing;
}

.fillrate-breakdown-chip.drag-over {
  background: #e0f2fe;
  border-color: #0284c7;
  transform: translateY(-1px);
}

.fillrate-breakdown-btn {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #475569;
  border-radius: 8px;
  padding: 0.28rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.fillrate-breakdown-btn:hover {
  border-color: #94a3b8;
  color: var(--text);
}

.fillrate-breakdown-btn.active {
  background: var(--primary-soft);
  border-color: rgba(0, 98, 155, 0.4);
  color: var(--primary-strong);
}

.kpi-table-wrap {
  margin-top: 0.9rem;
  overflow-x: auto;
}

.kpi-matrix-table,
.kpi-action-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  background: #fff;
  border: 1px solid #d8e5f3;
  border-radius: 10px;
  overflow: hidden;
}

.kpi-matrix-table th,
.kpi-matrix-table td,
.kpi-action-table th,
.kpi-action-table td {
  border-bottom: 1px solid #edf1f9;
  padding: 0.42rem 0.52rem;
  text-align: center;
  white-space: nowrap;
}

.kpi-matrix-table thead th,
.kpi-action-table thead th {
  background: #eef5fc;
  color: #39587a;
  font-weight: 700;
  position: sticky;
  top: 0;
}

.kpi-matrix-table th[scope="row"],
.kpi-action-table td:first-child,
.kpi-action-table th:first-child {
  text-align: left;
}

.kpi-matrix-table .is-total-row th,
.kpi-matrix-table .is-total-row td {
  font-weight: 700;
  background: #f3f8fd;
}

.value-good {
  color: #176f37;
  font-weight: 700;
}

.value-warn {
  color: #a35c08;
  font-weight: 700;
}

.value-bad {
  color: #a8222a;
  font-weight: 700;
}

.value-green {
  color: #176f37;
  font-weight: 700;
  background: #eaf8ee;
}

.value-yellow {
  color: #a35c08;
  font-weight: 700;
  background: #fff4df;
}

.value-red {
  color: #a8222a;
  font-weight: 700;
  background: #fdeced;
}

.factory-kpi-intro {
  margin: 0 0 0.55rem;
  color: #51627b;
  font-size: 0.85rem;
}

.factory-block {
  border: 1px solid #d8e5f3;
  border-radius: 12px;
  padding: 0.65rem 0.8rem 0.75rem;
  background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
}

.factory-block + .factory-block {
  margin-top: 0.85rem;
}

.factory-block-header {
  display: inline-flex;
  align-items: center;
  margin-bottom: 0.12rem;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  background: #e9f4fc;
  color: #1b517f;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.factory-kpi-table-wrap {
  margin-top: 0.2rem;
}

.factory-kpi-table thead th {
  padding-top: 0.34rem;
  padding-bottom: 0.34rem;
}

.factory-kpi-table td {
  min-width: 72px;
  padding-top: 0.36rem;
  padding-bottom: 0.36rem;
}

.kpi-controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.kpi-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.mode-label {
  font-size: 0.78rem;
  color: #5b6981;
  font-weight: 600;
}

.mode-toggle-btn {
  border: 1px solid #b9d2e8;
  background: #edf5fc;
  color: #205384;
  border-radius: 999px;
  padding: 0.28rem 0.62rem;
  font-size: 0.77rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.mode-toggle-btn:hover {
  transform: translateY(-1px);
  border-color: #91b8d7;
  box-shadow: 0 8px 18px rgba(0, 98, 155, 0.14);
}

.mode-toggle-btn.active {
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
}

.primary-btn,
.ghost-btn {
  border-radius: 8px;
  padding: 0.44rem 0.72rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.primary-btn {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
}

.primary-btn:hover {
  transform: translateY(-1px);
  background: var(--primary-strong);
  border-color: var(--primary-strong);
  box-shadow: 0 6px 20px rgba(0, 98, 155, 0.28);
}

.ghost-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--primary-strong);
}

.ghost-btn:hover {
  transform: translateY(-1px);
  border-color: #cbd5e1;
  background: #f8fafc;
}

.header-actions .primary-btn,
.header-actions .ghost-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(7, 25, 51, 0.46);
  display: grid;
  place-items: center;
  z-index: 40;
  padding: 1rem;
}

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

.upload-page-panel {
  max-width: 980px;
}

.modal-card {
  width: min(920px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #cddff0;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(7, 25, 51, 0.26);
  padding: 1rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.4rem;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.step-indicator {
  margin-bottom: 0.65rem;
}

#stepBadge {
  display: inline-block;
  border: 1px solid #bfd4e8;
  background: #edf5fc;
  color: #1f4f7e;
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 700;
}

.upload-step h3 {
  margin: 0.2rem 0 0.45rem;
}

.upload-type-selector {
  margin-bottom: 1rem;
  padding: 0.85rem;
  border: 1px solid #d8e5f3;
  border-radius: 12px;
  background: linear-gradient(180deg, #fbfdff 0%, #f4f9fe 100%);
}

.upload-type-selector h3 {
  margin: 0 0 0.5rem;
}

.upload-type-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.upload-format-guide {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid #c9daf0;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.upload-format-guide h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  color: #1a3a5c;
}

.upload-format-guide-intro {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
  color: #4b5d7b;
  line-height: 1.45;
}

.upload-format-guide-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.upload-format-guide .download-template-btn {
  flex-shrink: 0;
}

.upload-format-bullets {
  margin: 0 0 0.65rem 1rem;
  padding: 0;
  font-size: 0.8rem;
  color: #3d4f6e;
  line-height: 1.5;
}

.upload-format-columns {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  margin-bottom: 0.65rem;
}

.upload-format-columns th,
.upload-format-columns td {
  border: 1px solid #d3e3f5;
  padding: 0.4rem 0.5rem;
  text-align: left;
  vertical-align: top;
}

.upload-format-columns th {
  background: #edf4fc;
  font-weight: 700;
  color: #1f4f7e;
  white-space: nowrap;
}

.upload-format-columns td:first-child {
  font-weight: 600;
  color: #243a57;
  white-space: nowrap;
}

.upload-format-example-caption {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #2f4668;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.upload-format-example-wrap {
  overflow-x: auto;
  margin-bottom: 0.15rem;
  -webkit-overflow-scrolling: touch;
}

.upload-format-example-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 0.76rem;
}

.upload-format-example-table th,
.upload-format-example-table td {
  border: 1px solid #d3e3f5;
  padding: 0.35rem 0.45rem;
  text-align: left;
  word-break: break-word;
}

.upload-format-example-table th {
  background: #f6f9fc;
  font-weight: 700;
  color: #1f4f7e;
}

.upload-step p {
  margin: 0.2rem 0 0.6rem;
  color: #4b5d7b;
}

.upload-step label {
  display: block;
  margin-top: 0.55rem;
  margin-bottom: 0.2rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: #2f4668;
}

.upload-step input[type="text"],
.upload-step input[type="file"] {
  width: 100%;
  border: 1px solid #c9dbee;
  border-radius: 10px;
  padding: 0.48rem 0.55rem;
  background: #fff;
}

.step-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.validation-summary {
  margin-top: 0.65rem;
  font-size: 0.82rem;
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
  border: 1px solid #d3dfef;
  background: #f5f9ff;
  color: #32567f;
}

.validation-summary.success {
  border-color: #bfe5cb;
  background: #effaf3;
  color: #1f703a;
}

.validation-summary.error {
  border-color: #f0c7cc;
  background: #fff1f3;
  color: #9f232b;
}

.preview-container {
  margin-top: 0.7rem;
}

.upload-result {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #2e5278;
}

.upload-result.success {
  color: #1e6f3a;
}

.upload-result.error {
  color: #a1222a;
}

.action-log-section {
  padding-inline: 2px;
  max-width: 100%;
}

.action-log-table th,
.action-log-table td {
  vertical-align: top;
  font-size: 0.74rem;
  padding: 0.28rem 0.34rem;
  text-align: left;
  white-space: normal;
  word-break: break-word;
}

.action-log-table {
  table-layout: fixed;
  width: 100%;
  min-width: min(100%, 880px);
}

.supply-risk-section {
  padding-inline: 2px;
}

.supply-risk-table {
  table-layout: fixed;
  width: 100%;
  min-width: 0;
}

.supply-risk-table th,
.supply-risk-table td {
  vertical-align: top;
  font-size: 0.72rem;
  padding: 0;
  text-align: left;
  white-space: normal;
  word-break: break-word;
  border: 1px solid #c8d7ea;
}

.supply-risk-table thead th {
  background: #071b73;
  color: #fff;
  padding: 0.32rem 0.38rem;
  line-height: 1.15;
  vertical-align: middle;
}

.supply-risk-table .kpi-input {
  font-size: 0.7rem;
  min-height: 5.9rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #0f172a;
  box-shadow: none;
}

.supply-risk-table textarea.kpi-input {
  min-height: 5.9rem;
  padding: 0.38rem 0.42rem;
}

.supply-risk-table select.kpi-input {
  height: 5.9rem;
  padding: 0.32rem 0.42rem;
}

.supply-risk-table .action-market-checkboxes {
  min-height: 5.9rem;
  padding: 0.35rem 0.42rem;
  gap: 0.16rem 0.45rem;
}

.supply-risk-table .supply-risk-select:disabled {
  opacity: 1;
}

.supply-risk-table .icon-btn {
  width: auto;
  min-width: 2.4rem;
  padding-inline: 0.35rem;
}

.supply-risk-table th:nth-child(1),
.supply-risk-table td:nth-child(1) {
  width: 4.9rem;
}

.supply-risk-table th:nth-child(2),
.supply-risk-table td:nth-child(2) {
  width: 5.3rem;
}

.supply-risk-table th:nth-child(3),
.supply-risk-table td:nth-child(3) {
  width: 5.4rem;
}

.supply-risk-table th:nth-child(4),
.supply-risk-table td:nth-child(4) {
  width: 3.9rem;
}

.supply-risk-table th:nth-child(5),
.supply-risk-table td:nth-child(5) {
  width: 6.7rem;
}

.supply-risk-table th:nth-child(6),
.supply-risk-table td:nth-child(6) {
  width: 5.7rem;
}

.supply-risk-table th:nth-child(7),
.supply-risk-table td:nth-child(7) {
  width: 27%;
}

.supply-risk-table th:nth-child(8),
.supply-risk-table td:nth-child(8) {
  width: 4.9rem;
}

.supply-risk-table th:nth-child(9),
.supply-risk-table td:nth-child(9) {
  width: 25%;
}

.supply-risk-table th:nth-child(10),
.supply-risk-table td:nth-child(10) {
  width: 4.5rem;
}

.supply-risk-table th:nth-child(11),
.supply-risk-table td:nth-child(11) {
  width: 4.8rem;
}

.supply-risk-table th:nth-child(12),
.supply-risk-table td:nth-child(12) {
  width: 4.3rem;
}

.supply-risk-table th:nth-child(13),
.supply-risk-table td:nth-child(13) {
  width: 4.2rem;
}

.supply-risk-table--with-vs th:nth-child(1),
.supply-risk-table--with-vs td:nth-child(1) {
  width: 7.2rem;
}

.supply-risk-table--with-vs th:nth-child(2),
.supply-risk-table--with-vs td:nth-child(2) {
  width: 5.3rem;
}

.supply-risk-table--with-vs th:nth-child(3),
.supply-risk-table--with-vs td:nth-child(3) {
  width: 5.2rem;
}

.supply-risk-table--with-vs th:nth-child(4),
.supply-risk-table--with-vs td:nth-child(4) {
  width: 5.6rem;
}

.supply-risk-table--with-vs th:nth-child(5),
.supply-risk-table--with-vs td:nth-child(5) {
  width: 4.3rem;
}

.supply-risk-table--with-vs th:nth-child(6),
.supply-risk-table--with-vs td:nth-child(6) {
  width: 7rem;
}

.supply-risk-table--with-vs th:nth-child(7),
.supply-risk-table--with-vs td:nth-child(7) {
  width: 6.5rem;
}

.supply-risk-table--with-vs th:nth-child(8),
.supply-risk-table--with-vs td:nth-child(8) {
  width: 25%;
}

.supply-risk-table--with-vs th:nth-child(9),
.supply-risk-table--with-vs td:nth-child(9) {
  width: 5.6rem;
}

.supply-risk-table--with-vs th:nth-child(10),
.supply-risk-table--with-vs td:nth-child(10) {
  width: 23%;
}

.supply-risk-table--with-vs th:nth-child(11),
.supply-risk-table--with-vs td:nth-child(11) {
  width: 5.1rem;
}

.supply-risk-table--with-vs th:nth-child(12),
.supply-risk-table--with-vs td:nth-child(12) {
  width: 5rem;
}

.supply-risk-table--with-vs th:nth-child(13),
.supply-risk-table--with-vs td:nth-child(13) {
  width: 4.8rem;
}

.supply-risk-select {
  font-weight: 700;
}

.supply-risk-table .supply-risk-level--low,
.supply-risk-table .supply-risk-level--low:disabled {
  background: #92d050;
  color: #102a0c;
}

.supply-risk-table .supply-risk-level--mid,
.supply-risk-table .supply-risk-level--mid:disabled {
  background: #ffc000;
  color: #362600;
}

.supply-risk-table .supply-risk-level--high,
.supply-risk-table .supply-risk-level--high:disabled {
  background: #ff0000;
  color: #fff;
}

.supply-risk-table .supply-risk-vslw--new,
.supply-risk-table .supply-risk-vslw--new:disabled {
  background: #f8b4bf;
  color: #6d1018;
}

.supply-risk-table .supply-risk-vslw--dropped,
.supply-risk-table .supply-risk-vslw--dropped:disabled {
  background: #f8b4bf;
  color: #6d1018;
}

.supply-risk-table .supply-risk-vslw--flat,
.supply-risk-table .supply-risk-vslw--flat:disabled {
  background: #e5e7eb;
  color: #374151;
}

.supply-risk-table .supply-risk-vslw--improved,
.supply-risk-table .supply-risk-vslw--improved:disabled {
  background: #c6efce;
  color: #0f4d1e;
}

.supply-risk-table .supply-risk-select option {
  background: #fff;
  color: #0f172a;
}

/* Stream: No. | Concern | Cause | Countermeasure | Deadline | Owner | Markets | Action */
.action-log-table--stream th:nth-child(1),
.action-log-table--stream td:nth-child(1) {
  width: 2.5rem;
  max-width: 3rem;
  white-space: nowrap;
}

.action-log-table--stream th:nth-child(2),
.action-log-table--stream td:nth-child(2),
.action-log-table--stream th:nth-child(3),
.action-log-table--stream td:nth-child(3),
.action-log-table--stream th:nth-child(4),
.action-log-table--stream td:nth-child(4) {
  width: 22%;
  min-width: 7.5rem;
}

.action-log-table--stream th:nth-child(5),
.action-log-table--stream td:nth-child(5) {
  width: 6.25rem;
  max-width: 7rem;
  white-space: nowrap;
}

.action-log-table--stream th:nth-child(6),
.action-log-table--stream td:nth-child(6) {
  width: 4.5rem;
  max-width: 5.25rem;
  white-space: nowrap;
}

.action-log-table--stream th:nth-child(7),
.action-log-table--stream td:nth-child(7) {
  width: 11rem;
  min-width: 10rem;
}

.action-log-table--stream th:nth-child(8),
.action-log-table--stream td:nth-child(8) {
  width: 5.75rem;
  max-width: 6.5rem;
  text-align: right;
  white-space: nowrap;
}

/* Market: Value stream | No. | Concern | Cause | Countermeasure | Deadline | Owner */
.action-log-table--market th:nth-child(1),
.action-log-table--market td:nth-child(1) {
  width: 9rem;
  min-width: 6rem;
  font-weight: 600;
}

.action-log-table--market th:nth-child(2),
.action-log-table--market td:nth-child(2) {
  width: 2.5rem;
  max-width: 3rem;
  white-space: nowrap;
}

.action-log-table--market th:nth-child(3),
.action-log-table--market td:nth-child(3),
.action-log-table--market th:nth-child(4),
.action-log-table--market td:nth-child(4),
.action-log-table--market th:nth-child(5),
.action-log-table--market td:nth-child(5) {
  width: 18%;
  min-width: 6.5rem;
}

.action-log-table--market th:nth-child(6),
.action-log-table--market td:nth-child(6) {
  width: 6.25rem;
  max-width: 7rem;
  white-space: nowrap;
}

.action-log-table--market th:nth-child(7),
.action-log-table--market td:nth-child(7) {
  width: 4.5rem;
  max-width: 5.25rem;
  white-space: nowrap;
}

.action-market-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.55rem;
  align-items: flex-start;
  justify-content: flex-start;
}

.action-market-cb-label {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.68rem;
  color: #3d4f66;
  cursor: pointer;
  white-space: nowrap;
}

.action-market-badge {
  display: inline-block;
  font-size: 0.66rem;
  padding: 0.12rem 0.32rem;
  border-radius: 999px;
  background: #eef5fc;
  border: 1px solid #c9dbee;
  margin: 0.08rem 0.12rem 0 0;
}

.action-log-vs-cell {
  font-weight: 600;
  color: #1b517f;
}

.kpi-input {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  border: 1px solid #c9dbee;
  border-radius: 8px;
  padding: 0.24rem 0.36rem;
  font-size: 0.73rem;
  font-family: inherit;
  background: #fff;
}

.kpi-input--textarea {
  display: block;
  min-height: 2.6rem;
  max-height: 14rem;
  line-height: 1.45;
  resize: vertical;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  field-sizing: content;
}

.kpi-input--date {
  max-width: 100%;
  padding: 0.2rem 0.28rem;
  font-size: 0.7rem;
}

.kpi-input--owner {
  max-width: 100%;
  padding: 0.22rem 0.3rem;
  text-align: left;
}

.kpi-input:disabled {
  background: #f7f9fc;
  color: #5f6d83;
  border-color: #dbe5f1;
}

tr.is-editing .kpi-input {
  background: #fff;
}

.kpi-row-actions {
  text-align: right;
  vertical-align: middle;
}

.kpi-row-actions-wrap {
  display: inline-flex;
  gap: 0.28rem;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: nowrap;
  padding-inline-start: 0.15rem;
}

.icon-btn {
  width: 24px;
  height: 24px;
  border: 1px solid #d2deed;
  background: #f7faff;
  color: #2a507d;
  border-radius: 6px;
  padding: 0;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}

.icon-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.icon-btn.danger {
  border-color: #e6cad0;
  background: #fff4f6;
  color: #9f2b33;
}

.closed-badge {
  font-size: 0.66rem;
  color: #6f7d92;
  border: 1px solid #d8e1ef;
  background: #f6f9fd;
  border-radius: 999px;
  padding: 0.14rem 0.34rem;
}

.add-row-btn {
  margin-top: 0.5rem;
  padding: 0.24rem 0.48rem;
  font-size: 0.72rem;
}

.action-table-controls {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-end;
}

.action-row-closed td {
  opacity: 0.72;
}

.status {
  font-weight: 700;
}

.status.green {
  color: var(--success);
}

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

.status.red {
  color: var(--danger);
}

.context-grid {
  margin-top: 1.1rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

.context-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem;
  background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
  box-shadow: 0 6px 18px rgba(14, 26, 45, 0.06);
}

.context-card h3 {
  margin: 0 0 0.5rem;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #4a5872;
}

.context-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
}

.context-editor {
  width: 100%;
  margin-top: 0.45rem;
  border: 1px solid #c9dbee;
  border-radius: 8px;
  padding: 0.42rem 0.5rem;
  font-size: 0.8rem;
  resize: vertical;
}

.context-card ul {
  margin: 0;
  padding-left: 1rem;
  line-height: 1.45;
}

@media (max-width: 980px) {
  .header-shell {
    flex-direction: column;
    align-items: stretch;
  }

  .header-aside,
  .header-actions {
    justify-content: flex-start;
  }

  .status-chip {
    max-width: none;
    white-space: normal;
  }

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

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

}
