/* ==========================================================================
   CUSTOM DIPS — PanelX-Inspired Industrial Instrumentation Theme
   Matches the reference precision console aesthetic:
   - Silver-grey top menu bar & steel-grey icon ribbon with coral-orange active tile (#e85d38)
   - Steel-blue docked left sidebar (#3470a2 -> #285d8c) with dark navy section bars (#1c446b)
   - White digital readout box + 4 frosted instrument action tiles + coral alert bar
   - Cool silver-blue parameter sub-toolbar (#b5c3d1) with dark charcoal control buttons (#485868)
   - Crisp white oscilloscope/spectrum plot frames (#ffffff) with signal green (#22c55e)
     and vivid magenta (#e11d9f) traces, plus dark navy bottom status bar (#183757)
   ========================================================================== */

:root {
  --chrome-menu: #d9e0e8;
  --chrome-ribbon-top: #9eabb9;
  --chrome-ribbon-bot: #8a98a8;
  --chrome-subbar: #bcc8d6;
  --sidebar-top: #3774a8;
  --sidebar-bot: #295f8f;
  --sidebar-header: #1c446b;
  --statusbar-bg: #183757;
  --accent-orange: #e85d38;
  --accent-orange-hover: #d14b27;
  --btn-charcoal: #475869;
  --btn-charcoal-hover: #354454;
  --bg-workspace: #e3eaf1;
  --bg-panel: #ffffff;
  --bg-inset: #f2f6fa;
  --border-hard: #7e92a6;
  --border-mid: #aebecd;
  --border-soft: #d5dfe9;
  --text-main: #162636;
  --text-muted: #4b6075;
  --text-dim: #6f8499;
  --trace-green: #22c55e;
  --trace-green-dark: #15803d;
  --trace-charcoal: #475569;
  --spec-magenta: #e11d9f;
  --danger: #dc2626;
  --amber: #d97706;
  --font-ui: 'Segoe UI', 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;
}

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

html, body {
  height: 100%;
  font-family: var(--font-ui);
  font-size: 12.5px;
  color: var(--text-main);
  background: var(--bg-workspace);
}

/* ==================== APP SHELL LAYOUT ==================== */
.px-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* 1. Thin Classic Industrial Menu Bar */
.px-menubar {
  background: linear-gradient(180deg, #e5ebf1 0%, #cfd7e0 100%);
  border-bottom: 1px solid #96a4b3;
  height: 24px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: #1e2d3d;
  user-select: none;
}

.px-menu-items {
  display: flex;
  align-items: center;
  gap: 2px;
}

.px-menu-title {
  font-weight: 700;
  color: #1c446b;
  letter-spacing: 0.3px;
  margin-right: 10px;
}

.px-menu-wrap {
  position: relative;
}

.px-menu-btn {
  background: transparent;
  border: 1px solid transparent;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  color: #1e2d3d;
  cursor: pointer;
  border-radius: 1px;
}

.px-menu-btn:hover,
.px-menu-wrap.open .px-menu-btn {
  background: #3470a2;
  color: #ffffff;
  border-color: #1c446b;
}

.px-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background: #f8fafc;
  border: 1px solid #1c446b;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.22);
  z-index: 600;
  padding: 3px 0;
}

.px-menu-wrap.open .px-dropdown {
  display: block;
}

.px-dd-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 6px 12px;
  font-size: 11.5px;
  color: #162636;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
}

.px-dd-item:hover {
  background: #3470a2;
  color: #ffffff;
}

.px-dd-sep {
  height: 1px;
  background: #cbd5e1;
  margin: 3px 0;
}

/* 2. Steel-Grey Icon Ribbon Navigation Bar */
.px-ribbon {
  background: linear-gradient(180deg, var(--chrome-ribbon-top) 0%, var(--chrome-ribbon-bot) 100%);
  border-bottom: 1px solid #6b7c8e;
  padding: 0 8px;
  display: flex;
  align-items: stretch;
  gap: 2px;
  overflow-x: auto;
  min-height: 54px;
}

.nav-tab {
  background: transparent;
  border: none;
  border-right: 1px solid rgba(255,255,255,0.14);
  padding: 6px 14px;
  min-width: max-content;
  flex-shrink: 0;
  color: #f4f7fa;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  white-space: nowrap;
  position: relative;
  transition: background 0.12s;
}

.nav-tab .tab-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
}

.nav-tab .tab-ico svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.px-tile-btn span.ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
}

.px-tile-btn span.ico svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-tab:hover {
  background: rgba(255, 255, 255, 0.14);
}

.nav-tab.active {
  background: linear-gradient(180deg, #f16a45 0%, var(--accent-orange) 100%);
  color: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35);
}

.nav-badge {
  position: absolute;
  top: 4px;
  right: 6px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 2px;
  background: #dc2626;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.6);
}
.nav-badge.ok { background: #16a34a; }

/* 3. Body Split: Left Steel-Blue Docked Sidebar + Right Workspace */
.px-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

.px-sidebar {
  width: 224px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar-top) 0%, var(--sidebar-bot) 100%);
  border-right: 1px solid #1a3d61;
  color: #f0f6fc;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.px-side-section {
  border-bottom: 1px solid rgba(15, 39, 64, 0.45);
}

.px-side-hdr {
  background: var(--sidebar-header);
  color: #d9e8f7;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  letter-spacing: 0.3px;
}

.px-side-body {
  padding: 8px;
}

/* White Digital Readout Screen (like PanelX "250 g") */
.px-readout-screen {
  background: #ffffff;
  border: 1px solid #1b4266;
  border-radius: 1px;
  padding: 8px 10px 6px;
  color: #102438;
  margin-bottom: 8px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.12);
}

.px-readout-top {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #5b738a;
  font-family: var(--font-mono);
  text-transform: uppercase;
}

.px-readout-big {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  text-align: right;
  color: #0f2133;
  line-height: 1.15;
  margin-top: 2px;
}

.px-readout-big small {
  font-size: 11px;
  font-weight: 600;
  color: #4f6780;
  margin-left: 3px;
}

/* 4 Frosted Square Action Tiles (like Start / Tare / x10 / Zero) */
.px-tile-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.px-tile-btn {
  background: linear-gradient(180deg, #ebf4fc 0%, #cfe2f3 100%);
  border: 1px solid #1e4b75;
  border-radius: 2px;
  padding: 6px 2px;
  color: #163a5c;
  font-size: 9.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: filter 0.12s;
}

.px-tile-btn span.ico { font-size: 13px; line-height: 1; }
.px-tile-btn:hover { filter: brightness(1.06); }

/* Sidebar Role Controls & Orange Status Strip */
.px-side-field {
  margin-bottom: 7px;
}

.px-side-field label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  color: #bdd8f0;
  font-family: var(--font-mono);
  margin-bottom: 3px;
}

.px-side-field select {
  width: 100%;
  background: #ffffff;
  color: #13293d;
  border: 1px solid #1a4066;
  padding: 4px 6px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 1px;
}

.px-orange-strip {
  background: linear-gradient(180deg, #f06c48 0%, var(--accent-orange) 100%);
  border: 1px solid #b53f1f;
  color: #ffffff;
  font-weight: 700;
  font-size: 11px;
  padding: 6px 8px;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  margin-top: 6px;
}

.px-orange-strip:hover { background: var(--accent-orange-hover); }

.px-side-brand {
  padding: 12px 10px 10px;
  border-top: 1px solid rgba(255,255,255,0.12);
}

.px-side-brand-name {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.4px;
  color: #ffffff;
}

.px-side-brand-name sup {
  font-size: 9px;
  font-weight: 600;
  color: #c2ddf5;
}

.px-side-brand-sub {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: #b7d3ec;
  margin-top: 2px;
}

/* 4. Right Workspace Column */
.px-workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-workspace);
}

/* Sub-Toolbar / Parameter Strip (like PanelX Start/Stop + Mode/Time window bar) */
.px-subbar {
  background: linear-gradient(180deg, #c6d2df 0%, #b1c0d0 100%);
  border-bottom: 1px solid var(--border-hard);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.px-subbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.px-ctrl-btn {
  background: linear-gradient(180deg, #56687a 0%, var(--btn-charcoal) 100%);
  border: 1px solid #2f3c4a;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.px-ctrl-btn:hover { background: var(--btn-charcoal-hover); }

.px-ctrl-btn.orange {
  background: linear-gradient(180deg, #f06c48 0%, var(--accent-orange) 100%);
  border-color: #b53f1f;
}
.px-ctrl-btn.orange:hover { background: var(--accent-orange-hover); }

.px-param-chip {
  background: #ffffff;
  border: 1px solid var(--border-hard);
  padding: 3px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-main);
  border-radius: 1px;
}

/* Main Content Area */
.inst-main {
  padding: 10px 12px 24px;
  flex: 1;
}

.view-section { display: none; }
.view-section.active { display: block; }

/* Instrument Panels (crisp white framed boxes) */
.inst-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-hard);
  border-radius: 1px;
  margin-bottom: 10px;
}

.inst-panel-header {
  background: linear-gradient(180deg, #eef3f8 0%, #dde6f0 100%);
  border-bottom: 1px solid var(--border-mid);
  padding: 5px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.inst-panel-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #1c446b;
  display: flex;
  align-items: center;
  gap: 6px;
}

.inst-panel-body {
  padding: 10px;
}

/* Digital Readout Grid (KPIs) */
.readout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.readout-box {
  background: #ffffff;
  border: 1px solid var(--border-hard);
  border-top: 3px solid #3470a2;
  padding: 8px 10px;
}

.readout-box.green { border-top-color: var(--trace-green); }
.readout-box.magenta { border-top-color: var(--spec-magenta); }
.readout-box.orange { border-top-color: var(--accent-orange); }
.readout-box.danger { border-top-color: var(--danger); }

.readout-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.readout-val {
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 700;
  color: var(--text-main);
}

.readout-sub {
  font-size: 10.5px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Dashboard Dual-Column Grid */
.grid-2 {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 10px;
}

.px-mobile-drawer-btn {
  display: none;
  background: #1c446b;
  color: #fff;
  border: 1px solid #0f2942;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 2px;
  cursor: pointer;
  margin-right: 6px;
}

@media (max-width: 1080px) {
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .px-mobile-drawer-btn { display: inline-flex; align-items: center; }
  .px-menubar {
    position: sticky;
    top: 0;
    z-index: 460;
    height: 36px;
    padding: 4px 8px;
    flex-wrap: nowrap;
    gap: 6px;
  }
  .px-menubar .mono { display: none; }
  .px-menu-wrap { display: none; }
  .px-menu-title { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .px-ribbon {
    position: sticky;
    top: 36px;
    z-index: 455;
    min-height: 54px;
    padding: 0;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .px-ribbon::-webkit-scrollbar { display: none; }
  .nav-tab {
    flex-shrink: 0;
    min-width: max-content;
    padding: 7px 14px;
    font-size: 11px;
  }

  .px-body { position: relative; }
  .px-sidebar {
    position: fixed;
    top: 90px;
    left: 0;
    bottom: 24px;
    width: 265px;
    z-index: 450;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: 6px 0 24px rgba(0, 0, 0, 0.35);
    overflow-y: auto;
  }
  .px-sidebar.mobile-open { transform: translateX(0); }

  /* Compact single-row mobile action bar (hide static Tax/Client text chips) */
  .px-subbar { padding: 6px 8px; gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .px-subbar::-webkit-scrollbar { display: none; }
  .px-subbar-left { flex-wrap: nowrap; gap: 6px; }
  .px-subbar .px-param-chip:not(#storage-pill) { display: none; }
  #storage-pill { font-size: 10px; padding: 4px 7px; white-space: nowrap; }
  .px-ctrl-btn { padding: 6px 10px; font-size: 11px; white-space: nowrap; }

  .inst-main { padding: 8px 8px 30px; }
  .readout-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .readout-box:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .readout-val { font-size: 16px; }

  .pipeline-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .stage-tile { min-width: 0; padding: 6px 7px; }
  .stage-step-name { font-size: 9.5px; word-break: break-word; }

  .kanban-board { scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
  .kanban-col { min-width: 84vw; max-width: 84vw; scroll-snap-align: start; }
  .modal-backdrop { padding: 6px; }
  .modal-box { max-height: 96vh; }
  .field input, .field select, .field textarea { font-size: 15px; padding: 7px 8px; }
  .btn, .px-ctrl-btn { min-height: 34px; }
  .px-statusbar { font-size: 9.5px; padding: 0 8px; }
  #statusbar-right { display: none; }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 2px;
  border: 1px solid var(--border-hard);
  background: linear-gradient(180deg, #f8fafc 0%, #e4ecf4 100%);
  color: #1a324a;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: #d8e4f0; }

.btn-primary {
  background: linear-gradient(180deg, #f06c48 0%, var(--accent-orange) 100%);
  border-color: #b53f1f;
  color: #fff;
}
.btn-primary:hover { background: var(--accent-orange-hover); }

.btn-slate {
  background: linear-gradient(180deg, #4b6178 0%, #374a5e 100%);
  border-color: #243342;
  color: #fff;
}
.btn-slate:hover { background: #2c3d4f; }

.btn-green {
  background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
  border-color: #15803d;
  color: #fff;
}
.btn-green:hover { background: #15803d; }

.btn-danger {
  background: #dc2626;
  border-color: #991b1b;
  color: #fff;
}
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 3px 7px; font-size: 11px; }

/* Tags */
.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 1px;
  border: 1px solid var(--border-mid);
  background: var(--bg-inset);
  color: #1c446b;
  text-transform: uppercase;
}
.tag.green { background: #ecfdf5; border-color: #86efac; color: #166534; }
.tag.magenta { background: #fdf2f8; border-color: #f9a8d4; color: #9d174d; }
.tag.amber { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
.tag.danger { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
.tag.blue { background: #eff6ff; border-color: #93c5fd; color: #1e40af; }

/* Alerts */
.alert-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--amber);
  background: #fff;
  margin-bottom: 5px;
}
.alert-item.critical { border-left-color: var(--danger); background: #fff7f7; }
.alert-item.warning { border-left-color: var(--accent-orange); background: #fffaf5; }
.alert-item.info { border-left-color: #3470a2; background: #f5faff; }
.alert-title { font-weight: 700; font-size: 11.5px; }
.alert-msg { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.inst-table { width: 100%; border-collapse: collapse; font-size: 12px; }
table.inst-table th {
  background: linear-gradient(180deg, #e7eef6 0%, #d5e0ec 100%);
  color: #1c446b;
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  text-align: left;
  padding: 6px 8px;
  border: 1px solid var(--border-mid);
  white-space: nowrap;
}
table.inst-table td {
  padding: 6px 8px;
  border: 1px solid var(--border-soft);
  vertical-align: middle;
}
table.inst-table tbody tr:nth-child(even) { background: #f8fafd; }
table.inst-table tbody tr:hover { background: #ebf3fb; }
.mono { font-family: var(--font-mono); }
.text-right { text-align: right; }

/* Kanban Board */
.kanban-board { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.kanban-col {
  min-width: 240px; max-width: 240px;
  background: #dce5ef;
  border: 1px solid var(--border-hard);
  flex-shrink: 0;
}
.kanban-col-header {
  background: var(--sidebar-header);
  color: #fff;
  padding: 6px 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
}
.kanban-col-header .cnt { background: rgba(255,255,255,0.2); padding: 0 5px; }
.kanban-col-body { padding: 6px; min-height: 110px; display: flex; flex-direction: column; gap: 6px; }
.job-card {
  background: #fff;
  border: 1px solid var(--border-hard);
  border-left: 3px solid var(--trace-green);
  padding: 7px 8px;
  cursor: pointer;
}
.job-card:hover { border-color: #1c446b; box-shadow: 0 2px 6px rgba(24,55,87,0.16); }
.job-card.stalled { border-left-color: var(--danger); }
.job-card.dip { border-left-color: var(--spec-magenta); }

.plate-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 10.5px;
  background: #183757;
  color: #fef08a;
  padding: 1px 6px;
  letter-spacing: 0.5px;
}
.job-meta { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* Forms & Modals */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 9px; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-family: var(--font-mono); font-size: 10px; font-weight: 700; text-transform: uppercase; color: #1c446b; }
.field input, .field select, .field textarea {
  padding: 5px 7px; border: 1px solid var(--border-hard); border-radius: 1px;
  font-family: var(--font-ui); font-size: 12px; background: #fff; color: var(--text-main);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent-orange);
}

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(18, 38, 58, 0.62); z-index: 500;
  display: none; align-items: center; justify-content: center; padding: 14px;
}
.modal-backdrop.open { display: flex; }
.modal-box {
  background: #f2f6fa; border: 1px solid #183757; width: 100%; max-width: 960px; max-height: 92vh;
  display: flex; flex-direction: column; box-shadow: 0 18px 40px rgba(0,0,0,0.35);
}
.modal-header {
  background: linear-gradient(180deg, #2b6091 0%, #1c446b 100%);
  color: #fff; padding: 8px 12px; display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-family: var(--font-mono); font-size: 12.5px; text-transform: uppercase; }
.modal-close { background: rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.4); color: #fff; width: 24px; height: 24px; cursor: pointer; }
.modal-body { padding: 12px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 8px 12px; background: #dce5ef; border-top: 1px solid var(--border-hard); display: flex; justify-content: flex-end; gap: 8px; }

/* Damage Diagram & Photos */
.damage-canvas-wrap { position: relative; background: #fff; border: 1px solid var(--border-hard); padding: 8px; text-align: center; cursor: crosshair; }
.damage-marker {
  position: absolute; width: 18px; height: 18px; margin-left: -9px; margin-top: -9px; border-radius: 50%;
  background: var(--accent-orange); border: 2px solid #fff; color: #fff; font-size: 10px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 8px; }
.photo-card { background: #fff; border: 1px solid var(--border-hard); overflow: hidden; }
.photo-card img { width: 100%; height: 100px; object-fit: cover; cursor: pointer; background: #0f172a; }
.photo-card-meta { padding: 5px; font-size: 10.5px; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.88); z-index: 900; display: none; align-items: center; justify-content: center; flex-direction: column; padding: 20px; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 92vw; max-height: 80vh; border: 2px solid #94a3b8; }
.lightbox-caption { color: #f1f5f9; font-family: var(--font-mono); margin-top: 8px; font-size: 12px; }

/* Interactive 9-Bay Pipeline Grid & Cycle-Time Meters */
.pipeline-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

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

.stage-tile {
  background: #f8fafd;
  border: 1px solid var(--border-mid);
  border-top: 3px solid #94a3b8;
  padding: 7px 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 76px;
}

.stage-tile.active {
  background: #ffffff;
  border-color: var(--border-hard);
  border-top-color: var(--trace-green);
}

.stage-tile.stalled {
  background: #fffaf5;
  border-top-color: var(--accent-orange);
}

.stage-tile-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.stage-step-name {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  color: #1c446b;
  text-transform: uppercase;
  line-height: 1.2;
}

.stage-cnt-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  padding: 1px 6px;
  background: #e2e8f0;
  color: #475569;
  border-radius: 2px;
}

.stage-tile.active .stage-cnt-pill {
  background: var(--trace-green);
  color: #ffffff;
}

.stage-tile.stalled .stage-cnt-pill {
  background: var(--accent-orange);
  color: #ffffff;
}

.stage-plates {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.stage-plate-btn {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  background: #183757;
  color: #fef08a;
  border: 1px solid #0e243b;
  padding: 2px 6px;
  cursor: pointer;
  border-radius: 1px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.stage-plate-btn:hover { background: #295f8f; }
.stage-plate-btn.stalled { background: #b91c1c; color: #fff; border-color: #7f1d1d; }

.cycle-meters {
  background: #f8fafd;
  border: 1px solid var(--border-mid);
  padding: 8px 10px;
}

.cycle-meters-hdr {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #1c446b;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}

.cycle-meter-row {
  display: grid;
  grid-template-columns: 140px 1fr 48px;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  font-size: 11px;
}

.cycle-meter-track {
  height: 9px;
  background: #dfe7f0;
  border: 1px solid #b5c4d4;
  overflow: hidden;
}

.cycle-meter-fill {
  height: 100%;
  background: linear-gradient(90deg, #3470a2 0%, var(--spec-magenta) 100%);
}

.subtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border-hard); margin-bottom: 10px; flex-wrap: wrap; }
.subtab {
  padding: 5px 10px; font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  background: #d5e0ec; border: 1px solid var(--border-hard); border-bottom: none; cursor: pointer; color: #1c446b;
}
.subtab.active { background: #fff; border-top: 2px solid var(--accent-orange); }
.subtab-pane { display: none; }
.subtab-pane.active { display: block; }

/* Bottom Dark Navy Industrial Status Bar */
.px-statusbar {
  background: var(--statusbar-bg);
  color: #cfe0f2;
  border-top: 1px solid #0e243b;
  height: 24px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.telemetry-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: #22c55e; margin-right: 5px;
}
.telemetry-dot.warn { background: #f59e0b; }
.telemetry-dot.crit { background: #ef4444; }

#toast-container { position: fixed; bottom: 30px; right: 14px; z-index: 1000; display: flex; flex-direction: column; gap: 6px; }
.toast { background: #1c446b; color: #fff; border-left: 4px solid var(--trace-green); padding: 8px 13px; font-size: 12px; box-shadow: 0 6px 16px rgba(0,0,0,0.25); }
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--accent-orange); }
