@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600&family=Manrope:wght@500;600;700&display=swap");

:root {
  --bg: #10203a;
  --panel: #132746;
  --panel2: #153054;
  --text: #e7eefc;
  --muted: #9bb0d6;
  --accent: #4ea1ff;
  --border: #ffffff;
  --topbar-h: 68px;
  --footer-h: 58px;
  --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-title: "Manrope", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 400;
}

button,
input,
select,
textarea {
  font: inherit;
}

h1,
h2,
h3,
h4,
h5,
h6,
.brand-text strong,
.panel-title,
.summary-title,
.modal-title {
  font-family: var(--font-title);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.topbar {
  display:flex; align-items:center; justify-content:space-between;
  position: relative;
  min-height: var(--topbar-h);
  padding: 8px 14px;
  border-bottom: 1px solid #87c3ff;
  background: linear-gradient(160deg, #245ca6, #184280);
  box-shadow: 0 8px 24px #041127;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  width: 220px;
  height: 46px;
  border-radius: 10px;
  border: 1px solid #abdcff;
  background: url("assets/prolink-banner.png") center center / contain no-repeat;
  background-color: #d5efff;
  box-shadow:
    inset 0 0 0 1px #ffffff,
    0 8px 18px #020a18;
  filter: saturate(1.16) contrast(1.08) brightness(1.1);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-text strong {
  font-size: 18px;
  line-height: 1;
  letter-spacing: 0.01em;
  font-weight: 600;
}

.brand-text span {
  font-size: 12px;
  color: #b8d9ff;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.actions { display:flex; gap: 8px; align-items:center; }
.topbar-controls {
  display: flex;
  align-items: center;
  margin-left: auto;
}

.topbar-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(8, 20, 37, 0.28);
  cursor: pointer;
}

.topbar-menu-toggle span {
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: #e7eefc;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.topbar-menu-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.topbar-menu-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.topbar-menu-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.dashboard-actions {
  gap: 14px;
}

.dashboard-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(8, 20, 37, 0.34);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.system-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  color: #d7e9ff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.system-link:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.system-link.is-active {
  color: #0e2240;
  background: linear-gradient(180deg, #e5f4ff, #b9deff);
  box-shadow: 0 8px 20px rgba(4, 17, 39, 0.22);
}

.dashboard-command-bar {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(6, 18, 32, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.refresh-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dashboard-refresh-controls {
  padding-right: 8px;
  border-right: 1px solid rgba(255, 255, 255, 0.14);
}

.refresh-controls label {
  color: #c5daf8;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.refresh-controls input {
  width: 72px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #2a3d5f;
  color: var(--text);
}
.refresh-countdown {
  min-width: 40px;
  font-size: 12px;
  color: #d7e9ff;
  text-align: right;
}

.btn {
  background: #213757;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 10px; border-radius: 10px;
  cursor: pointer;
  font-weight: 500;
}
.btn:hover { background: #2b4265; }
.btn.primary { background: #4ea1ff; border-color: #4ea1ff; }
.btn-ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.14);
  color: #d7e9ff;
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.07);
}

.conn-status{
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  user-select:none;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
}
.conn-status.ok{ color: #39d98a; }
.conn-status.warn{ color: #ffcc66; }
.conn-status.bad{ color: #ff6b6b; }

.layout {
  display:grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - var(--topbar-h) - var(--footer-h));
  margin-top: 0;
}

.layout.panel-collapsed {
  grid-template-columns: 56px 1fr;
}

.left {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--panel);
  padding: 12px;
  overflow: hidden;
  transition: padding 0.2s ease;
}

.left-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.panel-title { font-weight: 700; margin-bottom: 10px; color: var(--muted); }
.left-header .panel-title { margin-bottom: 0; }

.left-panel-content {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.left-toggle-btn {
  padding: 6px 8px;
  font-size: 12px;
  white-space: nowrap;
}

.layout.panel-collapsed .left {
  padding: 12px 6px;
  align-items: center;
}

.layout.panel-collapsed .panel-title,
.layout.panel-collapsed .left-panel-content {
  display: none;
}

.layout.panel-collapsed .left-header {
  width: 100%;
  justify-content: center;
}

.layout.panel-collapsed .left-toggle-btn {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  min-height: 120px;
}

.machines-search-wrap {
  margin-bottom: 10px;
}

.machines-search {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #203757;
  color: var(--text);
}

.machines-search::placeholder {
  color: #9eb3d8;
}

.machines-list {
  display:flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.machines-empty {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.color-legend {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #2b456d;
}

.legend-title {
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 8px;
}

.legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid #ffffff;
  display: inline-block;
}

.machine-item {
  border: 1px solid var(--border);
  background: #203757;
  border-radius: 14px;
  padding: 10px 12px;
  cursor: grab;
  user-select: none;
}
.machine-item:active { cursor: grabbing; }
.machine-item .id { color: var(--muted); font-size: 12px; }
.machine-item .name { font-weight: 700; margin-top: 2px; }

.ops-indicators {
  display: inline-flex;
  align-items: center;
}

.notification-badge{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  margin-left: 8px;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid #ffffff;
  background: #4ea1ff;
  color: #eaf3ff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.production-pie {
  --production: 0%;
  width: 24px;
  height: 24px;
  margin-left: 6px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.85);
  background: conic-gradient(#39d98a 0 var(--production), #1a2940 var(--production) 100%);
  box-shadow: inset 0 0 0 4px #203757;
}

.right { background: var(--panel2); padding: 12px; overflow: hidden; }

.canvas-header {
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom: 10px;
  color: var(--muted);
  gap: 10px;
}

.canvas-zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.zoom-level {
  min-width: 48px;
  text-align: right;
  color: #d7e9ff;
  font-size: 12px;
}

.canvas-header-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.plant-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.plant-tab {
  background: #213757;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
}

.plant-tab.active {
  background: #4ea1ff;
  border-color: #4ea1ff;
  color: #f0f6ff;
}

.canvas-viewport {
  position: relative;
  width: 100%;
  height: calc(100% - 60px);
  border: 1px dashed #10203a;
  border-radius: 16px;
  overflow: auto;
  background: #f2f4f8;
}

.canvas-stage {
  position: relative;
  min-width: 100%;
  min-height: 100%;
}

.canvas {
  position: absolute;
  top: 0;
  left: 0;
  background: radial-gradient(#10203a 1px, #f2f4f8 1px);
  background-size: 20px 20px;
  transform-origin: top left;
}

.canvas-card {
  position: absolute;
  width: 170px;
  min-height: 130px;
  border-radius: 14px;
  border: 1px solid #10203a;
  background: #ffffff;
  color: #10203a;
  padding: 10px;
  cursor: move;
  user-select: none;
}

.machine-item.status-s,
.canvas-card.status-s {
  background: #ff9933;
  border-color: #ff9933;
}

.machine-item.status-f,
.machine-item.status-r,
.canvas-card.status-f {
  background: #39d98a;
  border-color: #39d98a;
}

.machine-item.status-p,
.canvas-card.status-p {
  background: #4edfff;
  border-color: #8de3e4;
}

.machine-item.status-m,
.canvas-card.status-m {
  background: #ff6b6b;
  border-color: #ff6b6b;
}

.legend-swatch.status-s { background: #ff9933; border-color: #a65816; }
.legend-swatch.status-f { background: #39d98a; border-color: #1a784c; }
.legend-swatch.status-r { background: #39d98a; border-color: #1a784c; }
.legend-swatch.status-p { background: #4edfff; border-color: #148096; }
.legend-swatch.status-m { background: #ff6b6b; border-color: #9e2c2c; }
.legend-swatch.status-o { background: #ffffff; border-color: #5f6f88; }
.canvas-card .name {
  font-weight: 800;
  line-height: 1.08;
  margin-bottom: 6px;
  padding-right: 36px;
}
.canvas-card .meta-row {
  color: #31425f;
  font-size: 12px;
  margin-bottom: 4px;
}
.canvas-card .machine-icon-row {
  min-height: 24px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
}
.canvas-card .op-row {
  min-height: 64px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
}
.canvas-card .qtdop-row {
  min-height: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.canvas-card .qtdop-row .notification-badge {
  margin-left: 0;
}
.canvas-card .qtdop-row .production-pie {
  box-shadow: inset 0 0 0 4px #f5f8ff;
  border-color: #4f5f75;
}
.canvas-card .view-ops-btn {
  border: 1px solid #10203a;
  background: #f5f8ff;
  color: #10203a;
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1.2;
  flex-shrink: 0;
}
.canvas-card .view-ops-btn:hover {
  background: #e5efff;
}
.canvas-card .codop-highlight {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #10203a;
  color: #ffffff;
  font-weight: 800;
  font-size: 15px;
  line-height: 1.02;
  letter-spacing: 0;
  max-width: calc(100% - 2px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}
.canvas-card .codop-highlight.codop-empty {
  background: transparent;
  color: #31425f;
  border: 1px dashed #31425f;
  min-width: 0;
  justify-content: center;
  font-size: 16px;
  letter-spacing: 0.12em;
}

.canvas-card.status-s {
  background: #ff9933;
  border-color: #a65816;
}

.canvas-card.status-f {
  background: #39d98a;
  border-color: #1a784c;
}

.canvas-card.status-r {
  background: #39d98a;
  border-color: #1a784c;
}

.canvas-card.status-p {
  background: #4edfff;
  border-color: #148096;
}

.canvas-card.status-m {
  background: #ff6b6b;
  border-color: #9e2c2c;
}

.footer-hint{
  margin-top: 10px;
  color: #8ea0be;
  font-size: 12px;
}

.app-footer {
  min-height: var(--footer-h);
  padding: 8px 14px;
  border-top: 1px solid #87c3ff;
  background: linear-gradient(180deg, #12305a, #0f2748);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-footer-brand {
  font-size: 12px;
  color: #cfe3ff;
  font-weight: 700;
  white-space: nowrap;
}

.app-footer-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.footer-control-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #e8f2ff;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.08);
  transition: background 0.18s ease, border-color 0.18s ease;
}

.footer-control-link:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.28);
}

.app-footer-legend {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.app-footer-legend .legend-title {
  margin-bottom: 0;
  font-size: 12px;
  color: #cfe3ff;
}

.app-footer-legend .legend-items {
  gap: 6px 12px;
}

.app-footer-legend .legend-item {
  font-size: 12px;
  color: #d9e9ff;
}


.canvas-card .remove-btn{
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 10px;
  border: 1px solid #ffffff;
  background: #243145;
  color: #ffffff;
  cursor: pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  line-height: 1;
  user-select: none;
}
.canvas-card .remove-btn:hover{
  background: #3f4e64;
}

.canvas-card .working-gif {
  position: relative;
  width: 36px;
  height: 24px;
  border-radius: 8px;
  border: 1px solid rgba(16, 32, 58, 0.55);
  background: rgba(16, 32, 58, 0.12);
  overflow: hidden;
}

.canvas-card .machine-idle-gif {
  position: relative;
  width: 40px;
  height: 24px;
  border-radius: 8px;
  border: 1px solid #4f5f75;
  background: rgba(16, 32, 58, 0.12);
}

.canvas-card .idle-piece {
  position: absolute;
  left: 6px;
  bottom: 4px;
  width: 16px;
  height: 11px;
  border-radius: 2px;
  background: #10203a;
}

.canvas-card .idle-piece::before {
  content: "";
  position: absolute;
  left: 2px;
  top: -3px;
  width: 6px;
  height: 3px;
  border-radius: 1px 1px 0 0;
  background: #10203a;
}

.canvas-card .idle-z {
  position: absolute;
  color: #10203a;
  font-size: 10px;
  font-weight: 800;
  opacity: 0;
  animation: idle-sleep 1.8s ease-out infinite;
}

.canvas-card .idle-z.z1 { right: 12px; top: 11px; animation-delay: 0s; }
.canvas-card .idle-z.z2 { right: 8px; top: 7px; animation-delay: 0.4s; }
.canvas-card .idle-z.z3 { right: 4px; top: 3px; animation-delay: 0.8s; }

.canvas-card .machine-play-icon,
.canvas-card .machine-wrench-icon,
.canvas-card .machine-setup-gif {
  width: 36px;
  height: 24px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(16, 32, 58, 0.55);
  background: rgba(16, 32, 58, 0.12);
  color: #10203a;
}

.canvas-card .machine-play-icon {
  font-size: 13px;
  padding-left: 2px;
}

.canvas-card .machine-wrench-icon {
  font-size: 14px;
}

.canvas-card .machine-setup-gif {
  position: relative;
}

.canvas-card .machine-setup-gear {
  position: relative;
  width: 12px;
  height: 12px;
  border: 2px solid #10203a;
  border-radius: 50%;
  animation: setup-gear-spin 1s linear infinite;
}

.canvas-card .machine-setup-gear::before,
.canvas-card .machine-setup-gear::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 14px;
  background: #10203a;
  transform-origin: center;
}

.canvas-card .machine-setup-gear::before {
  transform: translate(-50%, -50%) rotate(0deg);
}

.canvas-card .machine-setup-gear::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.canvas-card .machine-stop-icon {
  width: 36px;
  height: 24px;
  border-radius: 8px;
  border: 1px solid #8c2222;
  background: #d64040;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
}

.canvas-card .working-gif-body {
  position: absolute;
  left: 4px;
  top: 8px;
  width: 20px;
  height: 10px;
  border-radius: 2px;
  background: #10203a;
}

.canvas-card .working-gif-body::before {
  content: "";
  position: absolute;
  left: 2px;
  top: -4px;
  width: 6px;
  height: 4px;
  border-radius: 1px 1px 0 0;
  background: #10203a;
}

.canvas-card .working-gif-gear {
  position: absolute;
  right: 5px;
  top: 7px;
  width: 10px;
  height: 10px;
  border: 2px solid #10203a;
  border-radius: 50%;
  animation: working-gear-spin 1s linear infinite;
}

.canvas-card .working-gif-gear::before,
.canvas-card .working-gif-gear::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 14px;
  background: #10203a;
  transform-origin: center;
}

.canvas-card .working-gif-gear::before {
  transform: translate(-50%, -50%) rotate(0deg);
}

.canvas-card .working-gif-gear::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.canvas-card .working-gif-spark {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #4ea1ff;
  opacity: 0;
  animation: working-spark 1.1s ease-out infinite;
}

body.modal-open {
  overflow: hidden;
}

.ops-modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 33, 0.58);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.ops-modal[aria-hidden="false"] {
  display: flex;
}

.ops-modal-card {
  width: min(980px, 100%);
  max-height: min(86vh, 720px);
  background: #ffffff;
  border: 1px solid #c8d6ea;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ops-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid #d9e4f5;
}

.ops-modal-header h2 {
  margin: 0;
  font-size: 16px;
  color: #10203a;
}

.ops-modal-body {
  padding: 12px 14px 14px;
  overflow: auto;
}

.ops-summary,
.ops-loading,
.ops-empty,
.ops-error {
  font-size: 14px;
  color: #253753;
  margin-bottom: 10px;
}

.ops-error {
  color: #9e2c2c;
}

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

.ops-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.ops-table th,
.ops-table td {
  text-align: left;
  border-bottom: 1px solid #e2e9f4;
  padding: 8px 10px;
  font-size: 13px;
  color: #10203a;
}

.ops-table th {
  position: sticky;
  top: 0;
  background: #eef4ff;
  z-index: 1;
  font-weight: 700;
}

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

@keyframes working-spark {
  0% { transform: translate(0, 0) scale(0.6); opacity: 0; }
  20% { opacity: 0.9; }
  100% { transform: translate(10px, 8px) scale(1.2); opacity: 0; }
}

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

@keyframes idle-sleep {
  0% { transform: translate(0, 0) scale(0.8); opacity: 0; }
  20% { opacity: 0.85; }
  100% { transform: translate(-3px, -12px) scale(1.1); opacity: 0; }
}

@media (max-width: 980px) {
  :root { --topbar-h: 62px; --footer-h: 96px; }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 6px 8px;
    gap: 8px;
    align-items: center;
  }

  .brand-logo {
    width: 148px;
    height: 36px;
  }

  .brand-text strong {
    font-size: 14px;
  }

  .brand-text span {
    font-size: 10px;
    letter-spacing: 0.06em;
  }

  .actions {
    gap: 6px;
  }

  .topbar-menu-toggle {
    display: inline-flex;
    margin-left: auto;
    flex-shrink: 0;
  }

  .topbar-controls {
    position: absolute;
    top: calc(100% + 10px);
    left: 8px;
    right: 8px;
    z-index: 25;
    display: none;
    margin-left: 0;
    padding: 12px;
    border-radius: 18px;
    border: 1px solid rgba(135, 195, 255, 0.22);
    background: linear-gradient(180deg, rgba(20, 39, 70, 0.98), rgba(15, 33, 58, 0.98));
    box-shadow: 0 18px 34px rgba(4, 17, 39, 0.28);
  }

  .topbar-controls.is-open {
    display: block;
  }

  .dashboard-actions,
  .dashboard-command-bar {
    width: 100%;
    flex-wrap: wrap;
  }

  .dashboard-nav {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
  }

  .dashboard-command-bar {
    justify-content: flex-start;
  }

  .dashboard-refresh-controls {
    border-right: none;
    padding-right: 0;
  }

  .indicators-actions {
    justify-content: flex-start;
  }

  .refresh-controls input {
    width: 62px;
    padding: 5px 6px;
  }

  .btn {
    padding: 7px 8px;
    font-size: 12px;
  }

  .layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - var(--topbar-h) - var(--footer-h));
    margin-top: 4px;
  }

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

  .left {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 240px;
  }

  .layout.panel-collapsed .left {
    max-height: 72px;
  }

  .layout.panel-collapsed .left-toggle-btn {
    writing-mode: horizontal-tb;
    min-height: 0;
  }

  .right {
    min-height: 480px;
  }

  .app-footer {
    padding: 8px;
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }
}

/* ===== Página de Indicadores ===== */
.indicators-topbar {
  position: sticky;
  top: 0;
  z-index: 2;
}

.indicators-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.indicators-layout {
  min-height: calc(100vh - var(--topbar-h));
  padding: 16px;
  background: linear-gradient(180deg, #112642 0%, #0f213a 100%);
}

.indicators-summary {
  padding: 14px;
  border: 1px solid #87c3ff;
  border-radius: 14px;
  background: #132746;
  box-shadow: 0 10px 24px #071326;
}

.summary-title-wrap {
  margin-bottom: 14px;
}

.summary-title {
  margin: 0;
  font-size: 22px;
}

.summary-period {
  margin: 6px 0 0;
  color: #c8dcff;
  font-size: 14px;
}

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

.summary-card {
  border: 1px solid #87c3ff;
  border-radius: 12px;
  background: #153054;
  padding: 12px;
}

.summary-card-label {
  display: block;
  color: #b5cdf3;
  font-size: 12px;
  margin-bottom: 8px;
}

.summary-card-value {
  font-size: 24px;
  line-height: 1.05;
}

.processing-section {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #87c3ff;
  border-radius: 14px;
  background: #132746;
}

.processing-title {
  font-size: 20px;
}

.processing-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
}

.processing-card {
  border: 1px solid #87c3ff;
  border-radius: 12px;
  background: #153054;
  padding: 12px;
  text-align: left;
  cursor: pointer;
  color: #e7eefc;
}

.processing-card:hover {
  filter: brightness(1.07);
}

.processing-card-label {
  display: block;
  color: #d8e7ff;
  font-size: 13px;
  margin-bottom: 8px;
}

.processing-card-value {
  font-size: 24px;
  line-height: 1.05;
}

.processing-ok {
  border-color: #39d98a;
}

.processing-pending {
  border-color: #ffcc66;
}

.processing-error {
  border-color: #ff6b6b;
}

.default-questions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.default-question-btn {
  text-align: left;
  font-size: 13px;
  line-height: 1.3;
  min-height: 54px;
}

.chat-messages {
  margin-top: 12px;
  border: 1px solid #d3dbe8;
  border-radius: 12px;
  background: #ffffff;
  padding: 10px;
  max-height: 320px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-message {
  border: 1px solid #d6dfec;
  border-radius: 10px;
  padding: 8px;
  max-width: 100%;
}

.chat-message.user {
  background: #eaf3ff;
  border-color: #b8cdea;
}

.chat-message.assistant {
  background: #f7f9fc;
  border-color: #d6dce7;
}

.chat-message-role {
  font-size: 11px;
  color: #4b5f79;
  margin-bottom: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chat-message-body {
  color: #1f2a3a;
  white-space: pre-wrap;
  line-height: 1.35;
}

.chat-consent-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.chat-form {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.chat-label {
  font-size: 13px;
  color: #334155;
}

.chat-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 82px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  color: #111827;
  padding: 10px;
  font: inherit;
}

.machine-question-modal {
  max-width: 480px;
}

.machine-question-form {
  display: grid;
  gap: 10px;
}

.machine-question-form input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  color: #111827;
  padding: 10px;
  font: inherit;
}

.r2b2-launcher {
  position: fixed;
  right: 16px;
  bottom: 18px;
  z-index: 45;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #8ec7ff;
  border-radius: 999px;
  background: #1b4a80;
  color: #e8f2ff;
  padding: 10px 14px;
  box-shadow: 0 12px 28px rgba(3, 12, 24, 0.45);
  cursor: pointer;
  overflow: visible;
}

.r2b2-launcher:hover {
  filter: brightness(1.06);
}

.r2b2-icon-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  animation: r2b2Pulse 2.8s ease-in-out infinite;
}

.r2b2-robot {
  width: 30px;
  height: 30px;
  overflow: visible;
}

.r2b2-robot-head,
.r2b2-robot-neck,
.r2b2-robot-base {
  fill: #eaf4ff;
  stroke: #8ec7ff;
  stroke-width: 2;
}

.r2b2-robot-eye {
  fill: #1f5f9f;
}

.r2b2-robot-mouth {
  fill: #4e9ce9;
}

.r2b2-robot-antenna {
  stroke: #8ec7ff;
  stroke-width: 2;
  stroke-linecap: round;
}

.r2b2-robot-antenna-tip {
  fill: #7ed6ff;
}

.r2b2-robot-arm {
  transform-origin: 49px 30px;
  animation: r2b2RobotWave 1.3s ease-in-out infinite;
}

.r2b2-robot-arm-stroke {
  fill: #eaf4ff;
  stroke: #8ec7ff;
  stroke-width: 2;
}

.r2b2-robot-hand {
  fill: #c8e6ff;
  stroke: #8ec7ff;
  stroke-width: 2;
}

.r2b2-text {
  font-size: 13px;
  font-weight: 700;
}

.r2b2-greeting {
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  color: #dff0ff;
  background: #123863;
  border: 1px solid #8ec7ff;
  border-radius: 999px;
  padding: 6px 10px;
  box-shadow: 0 10px 20px rgba(3, 12, 24, 0.35);
  pointer-events: none;
  animation: r2b2Greeting 8s ease-in-out infinite;
}

.r2b2-greeting::after {
  content: "";
  position: absolute;
  right: -6px;
  top: 50%;
  width: 10px;
  height: 10px;
  background: #123863;
  border-top: 1px solid #8ec7ff;
  border-right: 1px solid #8ec7ff;
  transform: translateY(-50%) rotate(45deg);
}

@keyframes r2b2RobotWave {
  0% { transform: rotate(0deg); }
  15% { transform: rotate(-18deg); }
  30% { transform: rotate(16deg); }
  45% { transform: rotate(-14deg); }
  60% { transform: rotate(12deg); }
  75% { transform: rotate(-8deg); }
  100% { transform: rotate(0deg); }
}

@keyframes r2b2Pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

@keyframes r2b2Greeting {
  0%, 15% { opacity: 0; transform: translateY(-50%) translateX(12px); }
  20%, 55% { opacity: 1; transform: translateY(-50%) translateX(0); }
  65%, 100% { opacity: 0; transform: translateY(-50%) translateX(10px); }
}

.r2b2-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 50;
  width: min(460px, 100vw);
  height: 100vh;
  background: #f2f5fa;
  border-left: 1px solid #cbd5e1;
  box-shadow: -14px 0 30px rgba(15, 23, 42, 0.16);
  padding: 12px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 10px;
  transform: translateX(100%);
  opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease;
  color: #111827;
  font-family: "IBM Plex Sans", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

.r2b2-panel.is-open {
  transform: translateX(0);
  opacity: 1;
}

.r2b2-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid #d3dbe8;
  padding-bottom: 10px;
}

.r2b2-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.r2b2-title {
  font-size: 20px;
  line-height: 1.1;
}

.r2b2-subtitle {
  font-size: 12px;
  color: #475569;
}

.charts-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 14px;
}

.chart-card {
  border: 1px solid #87c3ff;
  border-radius: 14px;
  background: #132746;
  padding: 12px;
  min-height: 420px;
}

.chart-card-wide {
  grid-column: 1 / -1;
  min-height: 320px;
}

.chart-header h2 {
  margin: 0;
  font-size: 18px;
}

.chart-header p {
  margin: 6px 0 0;
  color: #b5cdf3;
  font-size: 13px;
}

.bar-chart {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  align-items: center;
  gap: 8px;
}

.bar-label {
  font-weight: 700;
  color: #d9e9ff;
  white-space: normal;
  line-height: 1.2;
}

.bar-wrap {
  width: 100%;
  height: 16px;
  border-radius: 999px;
  background: #0f1f33;
  border: 1px solid #37517a;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  min-width: 2px;
}

.bar-fill-top {
  background: linear-gradient(90deg, #39d98a 0%, #1eb574 100%);
}

.bar-fill-bottom {
  background: linear-gradient(90deg, #ff9933 0%, #f0742a 100%);
}

.bar-fill-stop {
  background: linear-gradient(90deg, #ff6b6b 0%, #cc3d3d 100%);
}

.bar-fill-product {
  background: linear-gradient(90deg, #6fc3ff 0%, #2f8fda 100%);
}

.bar-value {
  min-width: 86px;
  text-align: right;
  font-size: 12px;
  color: #d9e9ff;
}

.bar-row-reason {
  grid-template-columns: minmax(220px, 2fr) 1fr auto;
}

.bar-label-reason {
  white-space: normal;
  line-height: 1.2;
}

.bar-row-product {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 6px;
}

.bar-label-product {
  font-weight: 700;
  color: #d9e9ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-metric-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}

.chart-empty {
  border: 1px dashed #87c3ff;
  border-radius: 10px;
  color: #b5cdf3;
  text-align: center;
  padding: 18px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 12, 24, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 30;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: min(760px, 100%);
  max-height: 80vh;
  border: 1px solid #87c3ff;
  border-radius: 14px;
  background: #132746;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid #2b486d;
}

.modal-title {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  padding: 12px;
  overflow: auto;
}

.modal-subtitle {
  color: #b5cdf3;
  margin-bottom: 8px;
}

.modal-op-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.modal-op-item {
  border: 1px solid #87c3ff;
  border-radius: 10px;
  background: #153054;
  padding: 8px 10px;
  font-weight: 700;
}

@media (max-width: 980px) {
  .indicators-layout {
    padding: 10px;
  }

  .summary-cards {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .processing-cards {
    grid-template-columns: 1fr;
  }

  .default-questions {
    grid-template-columns: 1fr;
  }

  .r2b2-launcher {
    right: 10px;
    bottom: 12px;
    padding: 9px 12px;
  }

  .r2b2-greeting {
    display: none;
  }

  .r2b2-panel {
    width: 100vw;
    border-left: none;
  }

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

  .bar-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .bar-value {
    grid-column: 1 / -1;
    text-align: left;
  }

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

.settings-layout {
  max-width: 980px;
  margin: 20px auto 32px;
  padding: 0 16px;
  display: grid;
  gap: 16px;
}

.settings-layout-admin {
  max-width: 1320px;
}

.auth-layout {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  align-items: start;
}

.settings-card {
  background: #fff;
  border: 1px solid #dbe4f0;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(5, 20, 40, 0.06);
}

.settings-card h1,
.settings-card h2,
.settings-card h3 {
  margin: 0 0 12px;
  color: #0f172a;
}

.settings-card p {
  margin: 0 0 12px;
  color: #334155;
}

.settings-section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.selected-customer-summary {
  min-width: 280px;
  padding: 14px 16px;
  border-radius: 12px;
  background: linear-gradient(180deg, #eff6ff, #dbeafe);
  border: 1px solid #bfdbfe;
}

.selected-customer-label {
  display: block;
  margin-bottom: 6px;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.selected-customer-summary strong {
  display: block;
  margin-bottom: 6px;
  color: #0f172a;
}

.selected-customer-summary span:last-child {
  color: #334155;
  font-size: 13px;
}

.settings-form label,
.checkbox-row,
.auth-link-row,
.auth-inline-link {
  color: #0f172a;
}

.settings-form label {
  font-weight: 600;
}

.settings-form {
  display: grid;
  gap: 10px;
}

.settings-form input,
.settings-form select {
  width: 100%;
  min-height: 38px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  color: #0f172a;
  background: #ffffff;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.checkbox-row input {
  width: auto;
  min-height: auto;
}

.auth-link-row {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.auth-inline-link {
  color: #2563eb;
  text-decoration: underline;
}

.auth-layout-single {
  max-width: 640px;
}

.settings-message {
  margin-top: 10px;
  min-height: 20px;
  color: #0f766e;
  font-weight: 600;
}

.settings-message.is-error {
  color: #b91c1c;
}

.password-rules {
  margin-top: -4px;
  color: #516173;
  font-size: 13px;
  line-height: 1.45;
}

.customer-admin-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.customer-admin-column {
  display: grid;
  gap: 12px;
}

.customer-list-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.customer-list {
  display: grid;
  gap: 10px;
}

.customer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid #dbe4f0;
  border-radius: 10px;
  padding: 12px 14px;
  background: #f8fbff;
}

.customer-item.is-selected {
  border-color: #60a5fa;
  background: linear-gradient(180deg, #eef6ff, #dbeafe);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.12);
}

.customer-item-info {
  min-width: 0;
}

.customer-item strong,
.customer-item span {
  display: block;
}

.customer-item span {
  color: #516173;
}

.customer-item-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.customer-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.customer-badge.is-ready {
  background: #dcfce7;
  color: #166534;
}

.customer-badge.is-pending {
  background: #fef3c7;
  color: #92400e;
}

@media (max-width: 980px) {
  .app-footer-actions {
    width: 100%;
    justify-content: space-between;
  }

  .settings-section-header,
  .customer-list-header,
  .customer-admin-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .selected-customer-summary {
    min-width: 0;
  }

  .customer-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .customer-item-actions {
    width: 100%;
    justify-content: space-between;
  }
}
