/* Prototipando 3D — executive workspace */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── Variables ─────────────────────────────────────────────────────────────── */
:root {
  color-scheme: light;
  --bg-base:        #f3f5f4;
  --bg-surface:     #ffffff;
  --bg-card:        #ffffff;
  --bg-card-hover:  #f7faf9;
  --bg-glass:       rgba(26, 56, 66, 0.04);
  --bg-glass-hover: rgba(26, 56, 66, 0.08);
  --surface:        #ffffff;

  --border:         #dce4e3;
  --border-glow:    rgba(17, 112, 115, 0.3);
  --text-primary:   #243b45;
  --text-secondary: #52666d;
  --text-muted:     #607077;

  --accent:         #117073;
  --blue:           #117073;
  --accent-dim:     #e6f2f0;
  --green:          #26714f;
  --green-dim:      #e8f3eb;
  --red:            #b04444;
  --red-dim:        #f9ebeb;
  --orange:         #99601e;
  --orange-dim:     #fbf1e3;
  --yellow:         #946314;
  --yellow-dim:     #fbf0da;
  --purple:         #695a98;
  --purple-dim:     #f0edf7;
  --gray-dim:       #edf1f2;

  --radius-sm:      8px;
  --radius:         14px;
  --radius-lg:      18px;
  --radius-xl:      22px;
  --shadow:         0 4px 18px rgba(29, 52, 60, 0.06);
  --shadow-glow:    0 4px 14px rgba(17, 112, 115, 0.08);
  --shadow-green:   0 4px 14px rgba(38, 113, 79, 0.10);
  --shadow-red:     0 4px 14px rgba(176, 68, 68, 0.10);
  --transition:     0.18s ease;
}

/* ─── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}
button { cursor: pointer; border: none; outline: none; background: none; }
input, select, textarea { outline: none; }
a { text-decoration: none; color: inherit; }

/* ─── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ─── Layout ────────────────────────────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  grid-template-rows: 64px 1fr;
  grid-template-areas:
    "header header"
    "sidebar main";
  height: 100vh;
}

/* ─── Header ────────────────────────────────────────────────────────────────── */
.app-header {
  grid-area: header;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-brand .logo-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: var(--shadow-glow);
  flex-shrink: 0;
}
.header-brand h1 {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(90deg, var(--accent), var(--green));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.header-brand span {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 400;
  -webkit-text-fill-color: var(--text-muted);
}
.header-stats {
  display: flex;
  gap: 24px;
  align-items: center;
}
.stat-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
}
.stat-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-green { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot-blue  { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.dot-red   { background: var(--red); box-shadow: 0 0 8px var(--red); }
.dot-gray  { background: var(--text-muted); }

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition);
  font-size: 16px;
}
.btn-icon:hover { background: var(--bg-glass-hover); color: var(--text-primary); border-color: var(--border-glow); }
.polling-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.polling-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.8); }
}

/* ─── Sidebar ───────────────────────────────────────────────────────────────── */
.app-sidebar {
  grid-area: sidebar;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.sidebar-section {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-section:last-child { border-bottom: none; flex: 1; }
.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─── Upload Zone ───────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.upload-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-dim), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 24px var(--accent-dim);
}
.upload-zone:hover::before, .upload-zone.drag-over::before { opacity: 1; }
.upload-zone input { display: none; }
.upload-icon { font-size: 32px; margin-bottom: 10px; display: block; }
.upload-title { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.upload-subtitle { font-size: 12px; color: var(--text-muted); }
.upload-file-name {
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--accent-dim);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
  word-break: break-all;
  display: none;
}

/* ─── Form Elements ─────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: all var(--transition);
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  background: var(--bg-card-hover);
}
.form-input::placeholder { color: var(--text-muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ─── Filament Slots ────────────────────────────────────────────────────────── */
.filament-list { display: flex; flex-direction: column; gap: 8px; }
.filament-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.filament-color {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.2);
}
.filament-info { flex: 1; min-width: 0; }
.filament-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.filament-material { font-size: 11px; color: var(--text-muted); }
.slot-select {
  width: 60px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
}
.slot-select:focus { border-color: var(--accent); }

/* ─── Printer Selection ─────────────────────────────────────────────────────── */
.printer-select-info {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.printer-select-info.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--text-primary);
}
.selected-printer-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}
.selected-printer-ip {
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary);
}

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background var(--transition);
}
.btn:hover::after { background: rgba(255,255,255,0.08); }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #0066cc);
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-dim);
}
.btn-primary:hover { box-shadow: 0 6px 24px rgba(31,125,255,0.3); }

.btn-success {
  background: linear-gradient(135deg, var(--green), #00a855);
  color: #fff;
  box-shadow: 0 4px 16px var(--green-dim);
}
.btn-success:hover { box-shadow: var(--shadow-green); }

.btn-danger {
  background: linear-gradient(135deg, var(--red), #cc0022);
  color: #fff;
  box-shadow: 0 4px 16px var(--red-dim);
}
.btn-ghost {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--text-muted); }
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}
.btn-sm { padding: 7px 14px; font-size: 12px; width: auto; }
.btn-gap { margin-top: 10px; }
.btn-gap + .btn-gap { margin-top: 8px; }

/* ─── Spinner ───────────────────────────────────────────────────────────────── */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Main Content ──────────────────────────────────────────────────────────── */
.app-main {
  grid-area: main;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ─── Tabs ──────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  width: fit-content;
}
.tab-btn {
  padding: 8px 18px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--transition);
}
.tab-btn:hover { color: var(--text-secondary); }
.tab-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── Farm Grid ─────────────────────────────────────────────────────────────── */
.farm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  align-items: start;
}

/* ─── Printer Card ──────────────────────────────────────────────────────────── */
.printer-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  user-select: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 168px;
}
.printer-card.dragging { opacity: 0.4; }
/* .card-dynamic é o wrapper substituído a cada polling — precisa do mesmo
   flex+gap do card pra manter o espaçamento entre header/progresso/ações. */
.card-dynamic {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.printer-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--card-accent, var(--border)), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}
.printer-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--card-accent, var(--border));
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.printer-card:hover::before { opacity: 1; }

/* Status variants */
.printer-card.ready    { --card-accent: var(--green); }
.printer-card.printing { --card-accent: var(--accent); }
.printer-card.pause    { --card-accent: var(--orange); }
.printer-card.failed   { --card-accent: var(--red);   }
.printer-card.offline  { --card-accent: var(--text-muted); opacity: 0.7; }
.printer-card.unconfigured { --card-accent: var(--text-muted); opacity: 0.5; }

.printer-card.selected {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-dim), var(--shadow-glow);
  transform: translateY(-2px);
}
.printer-card.selected::before { opacity: 1; --card-accent: var(--accent); }

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.card-number {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}
.card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.card-ip {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
}
.card-header-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.card-header-actions .btn-camera,
.card-header-actions .btn-aux-fan {
  width: 28px;
  height: 28px;
  font-size: 13px;
}
.btn-aux-fan { opacity: 0.4; filter: grayscale(1); }
.btn-aux-fan.active {
  opacity: 1;
  filter: none;
  box-shadow: 0 0 10px rgba(255, 210, 60, 0.6);
}

/* Status Badge */
.status-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.badge-ready        { background: var(--green-dim);   color: var(--green); }
.badge-printing     { background: var(--accent-dim);  color: var(--accent); }
.badge-ejecting,
.badge-waiting      { background: var(--orange-dim);  color: var(--orange); }
.badge-completed    { background: var(--purple-dim);  color: var(--purple); }
.badge-failed,
.badge-error        { background: var(--red-dim);     color: var(--red); }
.badge-offline      { background: var(--gray-dim);    color: var(--text-muted); }
.badge-unconfigured { background: var(--gray-dim);    color: var(--text-muted); }
.badge-sending      { background: var(--orange-dim);  color: var(--orange); }

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.badge-printing .badge-dot,
.badge-sending .badge-dot {
  animation: pulse-dot 1.2s infinite;
}

/* IFS slots row */
.card-ifs {
  display: flex;
  align-items: center;
  gap: 6px;
}
.card-ifs-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.ifs-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Progress */
.card-progress {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.card-progress-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.card-temp {
  font-size: 11px;
  color: var(--text-secondary);
}
.card-eta {
  font-size: 11px;
  color: var(--text-muted);
}
.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.progress-label { font-size: 11px; color: var(--text-muted); }
.progress-value { font-size: 12px; font-weight: 700; color: var(--text-primary); font-family: 'JetBrains Mono', monospace; }
.progress-bar {
  height: 4px;
  background: var(--bg-surface);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--green));
  transition: width 0.8s ease;
  box-shadow: 0 0 8px var(--accent);
  min-width: 0;
}
.printer-card.failed .progress-fill { background: var(--red); }
.card-layers {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

/* Card cycle info */
.card-cycle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.cycle-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 2px 7px;
  border-radius: 99px;
}

/* Ações rápidas de job direto no card (pausar/retomar/cancelar) */
.card-job-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.card-job-actions .btn { width: auto; flex: 1; }

/* Erro ativo reportado pela impressora */
.card-error {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--red-dim);
  border: 1px solid var(--red);
  color: var(--red);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}
.card-error-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.btn-clear-error {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-clear-error:hover { opacity: 0.85; }

/* Câmera — usada só dentro do modal de detalhes agora */
.card-camera-img {
  width: 100%;
  display: block;
  border-radius: var(--radius-sm);
  background: #000;
  max-height: 220px;
  object-fit: cover;
}

/* ─── Jobs Panel ────────────────────────────────────────────────────────────── */
.jobs-list { display: flex; flex-direction: column; gap: 10px; }
.job-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: all var(--transition);
}
.job-card:hover { border-color: rgba(255,255,255,0.15); }
.job-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 12px;
}
.job-printer { font-size: 15px; font-weight: 700; }
.job-meta { font-size: 12px; color: var(--text-muted); }
.job-snapshot-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  flex-shrink: 0;
  cursor: pointer;
  transition: border-color var(--transition);
}
.job-snapshot-thumb:hover { border-color: var(--accent); }
.job-progress { margin-bottom: 8px; }
.job-log {
  max-height: 140px;
  overflow-y: auto;
  background: var(--bg-base);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary);
  line-height: 1.7;
  display: none;
}
.job-log.visible { display: block; }
.job-log-entry { color: var(--text-muted); }
.job-log-entry.success { color: var(--green); }
.job-log-entry.error   { color: var(--red); }

/* ─── Toast ─────────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: slide-in 0.3s ease;
  max-width: 340px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.success { border-color: var(--green); }
.toast.error   { border-color: var(--red); }
.toast.info    { border-color: var(--accent); }

/* ─── PWA install banner ────────────────────────────────────────────────────── */
.pwa-install-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius);
  box-shadow: var(--shadow-glow), 0 12px 32px rgba(0,0,0,0.5);
  padding: 14px 16px;
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.pwa-install-text { flex: 1; min-width: 180px; font-size: 13px; color: var(--text-secondary); line-height: 1.4; }
@keyframes slide-in {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slide-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(24px); }
}

/* ─── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5), var(--shadow-glow);
  animation: modal-in 0.25s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-glass-hover); }

/* ─── Filter Bar ────────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-btn {
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: all var(--transition);
}
.filter-btn:hover { color: var(--text-primary); border-color: rgba(255,255,255,0.2); }
.filter-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── Empty State ───────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; display: block; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p  { font-size: 13px; }

/* ─── Step indicator ────────────────────────────────────────────────────────── */
.steps {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
}
.step {
  flex: 1;
  text-align: center;
  padding: 10px 4px 8px;
  border-bottom: 2px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: all var(--transition);
  position: relative;
}
.step.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.step.done {
  color: var(--green);
  border-bottom-color: var(--green);
}
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1.5px solid currentColor;
  font-size: 10px;
  margin-bottom: 4px;
}

/* ─── Estoque ───────────────────────────────────────────────────────────────── */
.stock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  align-items: start;
}
.stock-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stock-card.low { border-color: var(--red); }
.stock-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.stock-color {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.15);
}
.stock-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stock-material {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}
.stock-low-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--red);
  background: var(--red-dim);
  padding: 3px 7px;
  border-radius: 99px;
  flex-shrink: 0;
}
.stock-bar {
  height: 6px;
  background: var(--bg-surface);
  border-radius: 99px;
  overflow: hidden;
}
.stock-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.4s ease;
}
.stock-weight {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
}

/* ─── Calculadora de Custos ─────────────────────────────────────────────────── */
.costs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.cost-panel {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.cost-panel-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.cost-section { margin-bottom: 20px; }
.cost-section:last-child { margin-bottom: 0; }
.cost-section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}
.cost-result-list { display: flex; flex-direction: column; gap: 10px; }
.cost-result-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.cost-result-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.cost-result-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
}
.cost-result-value.highlight { color: var(--orange); }
.cost-final-price {
  margin-top: 16px;
  background: linear-gradient(135deg, var(--accent), #0066cc);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.cost-final-label { font-size: 13px; color: rgba(255,255,255,0.85); margin-bottom: 6px; }
.cost-final-value { font-size: 36px; font-weight: 800; color: #fff; font-family: 'JetBrains Mono', monospace; }

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 64px auto 1fr;
    grid-template-areas:
      "header"
      "sidebar"
      "main";
    height: auto;
  }
  .app-sidebar { max-height: none; }
  .header-stats { display: none; }
  .costs-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  html { -webkit-text-size-adjust: 100%; }
  .app-header { padding: 0 12px; gap: 8px; }
  .header-brand span { display: none; } /* "Farm de Impressão 3D" — some no header apertado */
  .header-brand h1 { font-size: 15px; }
  .header-brand .logo-icon { width: 32px; height: 32px; }
  .header-actions { gap: 6px; }
  .btn-icon { width: 32px; height: 32px; font-size: 14px; }
  .polling-badge #polling-label { display: none; } /* mantém só o ponto pulsando */

  .app-main { padding: 14px; gap: 16px; }
  .sidebar-section { padding: 14px; }

  /* Barra de tabs vira scroll horizontal em vez de estourar a largura da tela */
  .tabs { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; }
  .tab-btn { flex-shrink: 0; }

  .form-row { grid-template-columns: 1fr; }
  .modal { padding: 20px; }
  .steps { font-size: 10px; }
}

/* Administração de usuários */
.admin-toolbar { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; margin-bottom:18px; }
.admin-toolbar h3 { font-size:17px; }
.admin-toolbar-actions { display:flex; justify-content:flex-end; gap:8px; flex-wrap:wrap; }
.admin-toolbar-actions .btn, .admin-user-actions .btn { width:auto; }
.admin-filters { display:grid; grid-template-columns:minmax(180px,1fr) minmax(140px,200px); gap:14px; margin-bottom:18px; }
.admin-help { color:var(--text-secondary); font-size:12px; line-height:1.5; margin-top:6px; }
.admin-error { color:var(--red); font-size:13px; margin-bottom:12px; }
.admin-table th, .admin-table td { padding:12px 10px; border-bottom:1px solid var(--border); text-align:left; }
.admin-table th { color:var(--text-secondary); font-weight:600; }
.admin-user-actions { min-width:220px; }
.admin-user-actions .btn { display:inline-flex; padding:6px 8px; margin:2px; font-size:12px; }
.admin-user-actions .btn-admin-delete { color:var(--red); }
#modal-admin-user .modal { max-height:90vh; overflow-y:auto; }
#modal-admin-user :focus-visible, #tab-admin :focus-visible { outline:2px solid var(--accent); outline-offset:3px; }
#modal-admin-user [hidden] { display:none; }
@media (max-width:600px) { .admin-filters { grid-template-columns:1fr; } }

[hidden] { display:none !important; }
.plan-status { margin:0 0 16px; padding:10px 12px; border:1px solid var(--border); border-radius:8px; }
.admin-plans-section { margin-top:32px; padding-top:24px; border-top:1px solid var(--border); }
.plan-card { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:12px; background:var(--bg-card); padding:16px; border-radius:10px; margin-top:12px; }
.plan-limits { display:grid; grid-template-columns:1fr 1fr; gap:0 16px; margin-top:18px; }
.plan-permissions { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin:16px 0 24px; }
.plan-permission { font-size:13px; color:var(--text-secondary); display:flex; align-items:center; gap:8px; }
.plan-permission input { accent-color:var(--accent); width:16px; height:16px; }
#modal-plan :focus-visible { outline:2px solid var(--accent); outline-offset:3px; }
@media (max-width:600px) { .plan-limits,.plan-permissions { grid-template-columns:1fr; } }
.card-header-actions { display:grid; grid-template-columns:repeat(2,auto); gap:6px; align-items:center; }
.card-header-actions .status-badge { grid-column:1 / -1; justify-self:end; }
.card-header-actions .btn-printer-config { width:28px; height:28px; font-size:16px; }

/* Connections, printer storage and touch layouts */
#printer-connection {margin-bottom:18px;padding-bottom:16px;border-bottom:1px solid var(--border)}
#printer-connection [hidden] {display:none!important}
#printer-connection summary {cursor:pointer;padding:12px 0;font-weight:600}
#cloud-account-fields input,#cloud-account-fields select {margin-bottom:10px}
.connection-diagnostic {font-size:12px;line-height:1.5;color:var(--text-muted);margin:10px 0;overflow-wrap:anywhere}
.card-header-actions {display:flex;max-width:150px;flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:6px}
.card-header-actions .status-badge {order:-1;flex-basis:100%;justify-content:center}
.card-header>div:first-child {min-width:0}.card-name,.card-ip {overflow-wrap:anywhere}
.files-modal {max-width:780px}.files-toolbar {display:flex;gap:8px;margin-bottom:16px}.files-toolbar .btn {width:auto;flex:1}
.file-row {display:flex;gap:12px;align-items:center;justify-content:space-between;padding:16px 0;border-bottom:1px solid var(--border)}
.file-row>div {min-width:0;flex:1}.file-row strong {display:block;overflow-wrap:anywhere}.file-row small {display:block;color:var(--text-muted);margin-top:6px}.file-row .btn {width:auto;flex-shrink:0}
.files-empty {padding:32px 12px;text-align:center;color:var(--text-muted)}
.mobile-only,.mobile-bottom-nav {display:none}.app-main {min-width:0}.modal-is-open {overflow:hidden}
#network-banner {position:fixed;top:0;left:0;right:0;z-index:3000;padding:12px;text-align:center;background:#9b3e0b;color:white;font-size:13px}
#network-banner[hidden] {display:none}
button,a,input,select,textarea {-webkit-tap-highlight-color:transparent}
:focus-visible {outline:2px solid var(--accent);outline-offset:3px}
@media(max-width:900px){
 .app-layout {height:auto;min-height:100dvh;grid-template-columns:minmax(0,1fr);grid-template-rows:auto 1fr;grid-template-areas:'header' 'main';padding-bottom:calc(76px + env(safe-area-inset-bottom))}
 .app-header {min-height:64px;padding-top:env(safe-area-inset-top);flex-wrap:wrap;gap:8px}
 .app-main {overflow:visible;min-height:0;padding:16px}
 .app-sidebar {display:none;position:fixed;inset:0;z-index:800;background:var(--bg-surface);padding:env(safe-area-inset-top) 0 calc(16px + env(safe-area-inset-bottom));overflow:auto;overscroll-behavior:contain}
 .mobile-print-open .app-sidebar {display:flex}.mobile-print-open {overflow:hidden}
 .mobile-only {display:block;flex-shrink:0;min-height:48px}
 .mobile-bottom-nav {display:flex;position:fixed;z-index:700;left:0;right:0;bottom:0;background:var(--bg-surface);border-top:1px solid var(--border);padding:6px 12px calc(6px + env(safe-area-inset-bottom));gap:8px}
 .mobile-bottom-nav button {flex:1;min-height:52px;border:0;background:transparent;color:var(--text-primary);font-size:22px;border-radius:12px}
 .mobile-bottom-nav span {display:block;font-size:11px;font-weight:600;margin-top:3px}
 .btn-icon,.modal-close {min-width:44px;min-height:44px}.card-header-actions .btn-icon {width:44px;height:44px}
 .btn,.tab-btn,summary {min-height:44px}.form-input,input,select,textarea {font-size:16px}
 .tabs {position:sticky;top:0;z-index:90;background:var(--bg-surface);overflow-x:auto;overscroll-behavior-x:contain}
 .farm-grid {grid-template-columns:repeat(auto-fit,minmax(min(100%,300px),1fr));gap:14px}
 .modal-overlay {padding:12px;padding-top:calc(12px + env(safe-area-inset-top));padding-bottom:calc(12px + env(safe-area-inset-bottom));align-items:center;overscroll-behavior:contain}
 .modal {max-height:calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));padding:20px;overscroll-behavior:contain}
 .modal-header {gap:12px}.modal-title {font-size:17px;min-width:0;overflow-wrap:anywhere}.modal-close {flex-shrink:0}
 .form-row {grid-template-columns:1fr}.admin-table {min-width:560px}
 .header-actions {margin-left:auto}.polling-badge {display:none}
 .header-brand .logo-icon {width:30px;height:30px}.header-brand h1 {font-size:14px}
 .file-row {flex-wrap:wrap}.file-row>div {flex-basis:65%}
}
@media(max-width:380px){.app-header {padding:8px}.header-brand {gap:6px}.header-actions {gap:0}.header-actions .btn-icon {min-width:40px;width:40px}.app-main {padding:10px}.printer-card {padding:14px}.modal {padding:16px}.files-toolbar {flex-wrap:wrap}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after {animation-duration:0.01ms!important;transition-duration:0.01ms!important;scroll-behavior:auto!important}}
.card-header {gap:10px}.card-header>div:first-child {flex:1}
.card-header-actions {display:grid;grid-template-columns:repeat(3,28px);max-width:none;flex-shrink:0}
.card-header-actions .status-badge {grid-column:1/-1;justify-self:stretch}
@media(max-width:900px){.card-header-actions {grid-template-columns:repeat(3,44px)}}


/* Executive workspace: quiet surfaces, clear hierarchy and restrained status colors. */
body { line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font-family: inherit; }
button { color: inherit; }
::selection { background: #cce9e3; color: #243b45; }
::-webkit-scrollbar-thumb { background: #c6d1d0; }
::-webkit-scrollbar-thumb:hover { background: #a8bab7; }
.app-layout { grid-template-columns: 324px minmax(0, 1fr); grid-template-rows: 76px 1fr; }
.app-header { background: #19343f; border-color: #274853; padding: 0 28px; color: #f4f8f8; box-shadow: 0 2px 10px rgba(20, 44, 54, .08); }
.header-brand { gap: 12px; }
.header-brand h1 { color: #f4f8f8; background: none; -webkit-text-fill-color: currentColor; font-size: 18px; letter-spacing: -.35px; }
.header-brand span { color: #c0cecf; -webkit-text-fill-color: currentColor; font-size: 12px; }
.header-brand .logo-icon { border-radius: 12px; box-shadow: none; border: 1px solid rgba(255,255,255,.15); }
.header-stats { gap: 10px; }
.app-header .stat-pill { background: rgba(255,255,255,.045); border-color: rgba(255,255,255,.13); color: #e6efed; padding: 7px 10px; font-size: 12px; }
.app-header .dot-green { background: #8cc8ad; }
.app-header .dot-blue { background: #90bcca; }
.app-header .dot-red { background: #e6a5a0; }
.app-header .dot-gray { background: #a7b8bd; }
.dot-green, .dot-blue, .dot-red { box-shadow: none; }
.app-header .btn-icon { background: transparent; border-color: rgba(255,255,255,.14); color: #dfe9e9; border-radius: 9px; }
.app-header .btn-icon:hover { background: rgba(255,255,255,.10); border-color: rgba(255,255,255,.3); color: #ffffff; }
.app-header .polling-badge { color: #c0cecf; font-size: 11px; }
.app-header .polling-dot { background: #8cc8ad; }
.app-header :focus-visible { outline-color: #b4dfd7; }
.app-sidebar { background: #fbfcfb; }
.sidebar-section { padding: 22px; }
.section-label { color: #52666d; font-size: 11px; letter-spacing: .055em; }
.app-main { padding: 28px; gap: 22px; }
.tabs { background: #e8eeec; border-color: #d8e2df; border-radius: 11px; padding: 5px; gap: 3px; }
.tab-btn { color: #53696e; padding: 10px 16px; border-radius: 7px; letter-spacing: -.1px; }
.tab-btn:hover { color: var(--accent); background: rgba(255,255,255,.55); }
.tab-btn.active { background: white; color: #11676a; box-shadow: 0 1px 4px rgba(29,52,60,.08); }
.upload-zone { background: #ffffff; border: 1.5px dashed #c3d4d0; padding: 26px 16px; }
.upload-zone:hover, .upload-zone.drag-over { box-shadow: none; background: #f2faf7; }
.upload-zone::before { background: none; }
.upload-title { font-size: 13px; }
.upload-subtitle { line-height: 1.6; }
.form-label { text-transform: none; letter-spacing: 0; font-size: 12px; color: #4b6168; }
.form-input { background: #ffffff; border-color: #cfdcda; min-height: 42px; border-radius: 8px; }
.form-input:focus { background: white; box-shadow: 0 0 0 3px rgba(17,112,115,.12); }
.form-input::placeholder { color: #66767c; }
.filament-row, .printer-select-info { background: #ffffff; }
.filament-color, .stock-color { border-color: #cad5d3; }
.btn { border-radius: 8px; letter-spacing: -.1px; }
.btn-primary { background: #117073; box-shadow: 0 2px 5px rgba(17,112,115,.10); }
.btn-primary:hover { background: #0d6063; box-shadow: 0 3px 8px rgba(17,112,115,.14); }
.btn-success { background: #26714f; box-shadow: none; }
.btn-success:hover { background: #205f43; box-shadow: none; }
.btn-danger { background: #b04444; box-shadow: none; }
.btn-danger:hover { background: #993a3a; }
.btn-ghost { background: white; border-color: #d2dfdc; color: #486168; }
.btn-ghost:hover { background: #f3f8f6; border-color: #a4c1ba; color: #24454b; }
.btn:disabled { opacity: .52; }
.btn-aux-fan { opacity: .8; }
.btn-aux-fan.active { background: #fbf1df; border-color: #dac9a8; color: #886422; box-shadow: none; }
.printer-card { border-width: 1px; padding: 20px; box-shadow: 0 2px 6px rgba(29,52,60,.035); }
.printer-card::before { background: var(--card-accent); height: 3px; opacity: .7; }
.printer-card:hover { transform: translateY(-1px); border-color: #bed2cc; box-shadow: var(--shadow); background: white; }
.printer-card.selected { box-shadow: 0 0 0 2px #c4e0da, var(--shadow); transform: none; }
.printer-card.offline, .printer-card.unconfigured { opacity: 1; }
.card-name { font-size: 15px; letter-spacing: -.25px; }
.card-ip, .card-number { color: #667a80; }
.card-header { border-color: #e6eeeb; }
.card-header-actions .status-badge { border-radius: 6px; }
.status-badge { padding: 5px 9px; font-size: 10px; font-weight: 600; letter-spacing: .025em; }
.card-progress { border-color: #e6eeeb; }
.card-progress-info { gap: 7px; }
.progress-bar, .stock-bar { background: #e9efed; height: 5px; }
.progress-fill { background: #328b89; box-shadow: none; }
.card-temp, .card-eta { font-size: 12px; }
.card-cycle { border-color: #e6eeeb; }
.stock-card, .cost-panel, .job-card, .plan-card { border-width: 1px; box-shadow: 0 2px 6px rgba(29,52,60,.035); }
.job-card:hover { border-color: #bfd1cc; }
.cost-result-card { background: #f7faf8; }
.cost-result-value { font-size: 22px; letter-spacing: -.5px; }
.cost-final-price { background: #1d666c !important; text-align: left; }
.cost-final-value { font-size: 32px; letter-spacing: -1px; }
.cost-final-price + .cost-final-price { background: #4a5967 !important; }
.cost-section-label { text-transform: none; letter-spacing: 0; font-size: 13px; }
.modal-overlay { background: rgba(23,44,51,.42); backdrop-filter: blur(5px); }
.modal { background: #ffffff; border-color: #e1e9e5; box-shadow: 0 24px 70px rgba(23,44,51,.18); }
.modal-title { letter-spacing: -.4px; }
.modal-header { border-bottom: 1px solid #e6eeeb; padding-bottom: 16px; margin-bottom: 20px; }
.modal-close { background: #f3f6f4; color: #597078; }
.modal-close:hover { background: #e9f1ed; }
.toast { box-shadow: 0 8px 26px rgba(23,44,51,.12); }
.pwa-install-banner { box-shadow: 0 8px 32px rgba(23,44,51,.12); }
.filter-btn { padding: 7px 14px; border-color: #d5e1dc; }
.filter-btn:hover { border-color: #a9c7be; }
.filter-btn.active { border-color: #b6d5cb; background: #e7f3ed; color: #155f60; }
.step { letter-spacing: .025em; }
.step-num { width: 24px; height: 24px; margin-bottom: 6px; background: white; }
.empty-state { background: #ffffff; border: 1px dashed #ccdcd5; border-radius: 14px; padding: 48px 22px; }
.empty-state h3 { color: #415e66; font-size: 17px; }
.empty-state p { margin: 6px auto 0; max-width: 440px; line-height: 1.7; }
#tab-admin, #tab-stock { background: white; padding: 22px; border: 1px solid #dce4e3; border-radius: 14px; }
.admin-table { border-collapse: collapse; }
.admin-table th { background: #f2f6f3; color: #53686c; font-size: 11px; font-weight: 600; }
.admin-table td { line-height: 1.6; }
.admin-table tbody tr:hover { background: #f8faf8; }
.admin-toolbar h3, .admin-plans-section h3 { font-size: 18px; letter-spacing: -.3px; }
.plan-card { border: 1px solid #dce4e3; background: #fbfdfb; }
.admin-help, .connection-diagnostic { line-height: 1.65; }

/* Instalação do agente já vinculado à conta. */
.agent-install-card { padding:20px; margin-bottom:20px; background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius); }
.agent-install-card h3 { margin:0 0 10px; color:var(--text-primary); font-size:16px; }
.agent-install-fields { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1.3fr); gap:16px; margin-top:16px; }
.agent-install-fields .form-group { min-width:0; }
.agent-install-fields .form-input { width:100%; min-width:0; }
.agent-install-private { margin:16px 0 0; color:var(--text-secondary); font-size:12px; line-height:1.65; }
.agent-install-next { margin-top:18px; padding:16px; border:1px solid var(--border); border-radius:var(--radius-sm); background:var(--bg-base); font-size:13px; line-height:1.7; }
.agent-install-next ol { padding-left:20px; margin:8px 0; }
.agent-install-next li + li { margin-top:6px; }
.agent-install-error { color:var(--red); }
.agent-manual-setup { margin-bottom:24px; border:1px solid var(--border); border-radius:var(--radius-sm); background:var(--bg-card); }
.agent-manual-setup > summary { padding:14px 16px; color:var(--text-secondary); cursor:pointer; font-size:13px; line-height:1.6; }
.agent-manual-content { padding:4px 16px 16px; }
@media (max-width:600px) {
  .agent-install-fields { grid-template-columns:minmax(0,1fr); gap:0; }
  .agent-install-card { padding:16px; }
  #agent-install-download { width:100%; white-space:normal; }
}
#network-banner { background: #926029; }
dialog.billing-card { margin: auto; background: white; color: #243b45; box-shadow: 0 24px 70px rgba(23,44,51,.18); border-radius: 18px; }
dialog.billing-card::backdrop { background: rgba(23,44,51,.42); backdrop-filter: blur(4px); }
.billing-card .billing-message.error { color: #b04444; }
.billing-grid .billing-card { background: #fbfdfb; }
.billing-scroll th { background: #f2f6f3; }
.billing-scroll td { border-bottom: 1px solid #e5ede8; }
@media (min-width: 1450px) { .app-main { padding: 32px; }.farm-grid { grid-template-columns: repeat(auto-fill,minmax(280px,1fr));gap:20px; } }
@media (min-width: 901px) and (max-width: 1150px) { .app-layout { grid-template-columns: 292px minmax(0,1fr); }.header-stats { gap: 6px; }.app-header .stat-pill { padding: 6px 8px; }.app-header .polling-badge { display: none; }.app-main { padding: 22px; }.sidebar-section { padding: 18px; } }
@media (max-width: 900px) {
 .app-layout { grid-template-columns: minmax(0,1fr); grid-template-rows: auto 1fr; }
 .app-header { padding: 12px 16px; min-height: 70px; }
 .app-main { padding: 18px; gap: 18px; }
 .app-sidebar { background: #fbfcfb; }
 .mobile-bottom-nav { background: #ffffff; box-shadow: 0 -4px 18px rgba(29,52,60,.045); }
 .mobile-bottom-nav button { color: #44626a; border-radius: 10px; }
 .mobile-bottom-nav #mobile-print { background: #e7f3ed; color: #11676a; }
 .mobile-bottom-nav span { font-weight: 600; }
 .tabs { background: #e8eeec; top: 0; border-radius: 10px; width: 100%; }
 .tab-btn { padding: 10px 15px; min-height: 46px; }
 .printer-card { padding: 18px; }
 .card-name { font-size: 15px; }
 #tab-admin, #tab-stock { padding: 18px; }
 .cost-final-value { font-size: 30px; }
}
@media (max-width: 600px) {
 .app-header { padding: 10px 12px; }
 .header-brand span { display: block; font-size: 10px; }
 .header-brand h1 { font-size: 13px; letter-spacing: -.25px; }
 .header-brand .logo-icon { width: 32px; height: 32px; border-radius: 9px; }
 .app-main { padding: 14px; }
 .sidebar-section { padding: 20px; }
 .modal { padding: 20px; }
 .card-header-actions { grid-template-columns: repeat(3,40px); gap: 5px; }
 .card-header-actions .btn-icon { min-width:40px; width:40px; }
 #tab-admin, #tab-stock { padding: 15px; }
 .admin-table th, .admin-table td { padding: 11px 8px; }
 .cost-panel { padding: 18px; }
}
@media (max-width: 380px) {
 .app-header { padding: 10px; gap: 6px; }
 .header-brand .logo-icon { width: 28px; height: 28px; }
 .header-brand { gap: 7px; }
 .header-brand h1 { font-size: 12px; }
 .header-brand span { display: none; }
 .header-actions { gap: 2px; }
 .app-header .btn-icon { width: 36px; min-width: 36px; height: 44px; font-size: 14px; }
 .app-main { padding: 12px; }
 .card-header { gap: 7px; }
 .card-header-actions { grid-template-columns: repeat(3,36px); gap: 4px; }
 .card-header-actions .btn-icon { min-width:36px; width:36px; height:44px; }
 .printer-card { padding: 15px; }
 .modal { padding: 16px; }
 .tab-btn { padding: 10px 14px; }
}
.spinner { border-color: rgba(17,112,115,.2); border-top-color: #117073; }
.btn-primary .spinner,.btn-success .spinner,.btn-danger .spinner { border-color:rgba(255,255,255,.3);border-top-color:white; }
@media(max-width:900px){.card-header-actions{grid-template-columns:repeat(3,44px)}.card-header-actions .btn-icon{width:44px;min-width:44px;height:44px}}
/* Connection setup uses the same calm visual hierarchy as the workspace. */
.connection-steps { display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:7px;padding:0;margin:0 0 22px;list-style:none;counter-reset:connection; }
.connection-steps li { counter-increment:connection;display:flex;align-items:center;gap:7px;min-width:0;padding:10px 7px;border-radius:8px;background:#eef5f1;font-size:11px;font-weight:600;color:#3e6566;line-height:1.5; }
.connection-steps li::before { content:counter(connection);display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:20px;height:20px;border:1px solid #b5d0c6;border-radius:50%;background:white;font-size:10px;color:#117073; }
.connection-step { min-width:0;border:1px solid #dce6e0;border-radius:12px;padding:16px;margin:0 0 16px;background:#fbfdfb; }
.connection-step legend { padding:0 7px;font-size:13px;font-weight:600;color:#355961; }
.connection-status { padding:12px 14px;border:1px solid #d0dfd9;border-radius:10px;background:#f2f7f4;font-size:12px;line-height:1.7;color:#44636a;overflow-wrap:anywhere;white-space:pre-wrap; }
.connection-status[data-tone=success] { background:#eaf5ee;border-color:#bcd9c8;color:#276b4f; }
.connection-status[data-tone=warning] { background:#fbf3e8;border-color:#e4d4b9;color:#89591e; }
.connection-status[data-tone=error] { background:#faeeee;border-color:#e5c6c6;color:#a34242; }
.connection-actions { display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin-top:14px; }
.connection-actions .btn { width:auto;min-height:42px; }
.connection-summary { padding:14px 16px;border:1px solid #dce6e0;border-radius:10px;background:white;font-size:12px;line-height:1.8;color:#4c6970; }
.connection-summary ul { margin:7px 0 0;padding-left:18px; }
@media(max-width:600px){.connection-steps{grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;margin-bottom:18px}.connection-steps li{font-size:11px;padding:9px}.connection-step{padding:14px}.connection-actions .btn{flex:1 1 130px;min-height:44px}}
#analysis-printer-help { font-size:11px;line-height:1.65;color:var(--text-muted);margin-top:7px; }
#modal-preview > .modal { max-width:1120px !important; }
#modal-preview-3d { background:#fbfdfb !important; }
#modal-preview .modal-header { position:sticky;top:-28px;z-index:5;background:#ffffff;padding-top:10px; }
@media(max-width:900px){#modal-preview .modal-header{top:-20px}#modal-preview>.modal{padding:20px}}
@media(max-width:380px){#modal-preview .modal-header{top:-16px}#modal-preview>.modal{padding:16px}}
.stock-editor-modal{max-width:780px}.color-catalog-picker{margin-top:10px;min-width:0;grid-column:1/-1}.color-catalog-picker summary{color:var(--accent);font-size:12px;cursor:pointer;font-weight:600;padding:7px 0}.color-catalog-filters{display:grid;grid-template-columns:minmax(0,1.4fr) minmax(0,1fr);gap:8px;margin:8px 0 12px}.color-catalog-samples{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,150px),1fr));gap:7px;max-height:290px;overflow:auto}.color-catalog-sample{display:grid;grid-template-columns:25px minmax(0,1fr);gap:4px 7px;text-align:left;border:1px solid var(--border);padding:10px 8px;border-radius:8px;background:white;min-height:52px;font-size:11px;line-height:1.5;align-items:center}.color-catalog-sample:hover,.color-catalog-sample:focus-visible{background:#eef7f1;border-color:#83b6a5}.color-catalog-dot{grid-row:1/3;width:24px;height:24px;border:1px solid #b9c9c3;border-radius:50%}.color-catalog-sample small{grid-column:2;font-family:monospace;color:var(--text-muted);font-size:10px}.color-catalog-count,.color-catalog-help{font-size:11px;line-height:1.7;color:var(--text-muted);margin-top:9px}.color-catalog-help{padding:9px 10px;border:1px solid #e1e9e3;background:#f3f8f4;border-radius:8px}.stock-search-toolbar{display:grid;grid-template-columns:minmax(0,2fr) minmax(0,1fr);gap:12px;margin:14px 0 18px}.stock-search-toolbar>label{display:grid;gap:6px;font-size:12px;color:var(--text-secondary);min-width:0}.stock-search-toolbar .stock-low-filter{display:flex;align-items:center;gap:7px}.stock-low-filter input{accent-color:var(--accent);width:17px;height:17px}.stock-search-toolbar p{align-self:center;margin:0;text-align:right}.stock-profile-tag{display:inline-flex;align-items:center;border-radius:6px;padding:3px 7px;background:#edf5ef;color:#41645d;font-size:10px;font-weight:500;margin-top:6px}.stock-spool-info{font-size:11px;line-height:1.7;color:var(--text-secondary);overflow-wrap:anywhere}.filament-picker-row{display:grid;grid-template-columns:24px minmax(0,1fr) 36px;gap:7px;align-items:center}.filament-picker-row>.color-catalog-picker{grid-column:1/-1}.slot-color-metadata{display:grid;grid-template-columns:1fr 1fr;gap:7px}.slot-color-metadata input{font-size:12px;min-width:0;padding:8px}.slot-color-metadata label{font-size:10px;color:var(--text-secondary);min-width:0}.slot-color-metadata .form-input{margin-top:4px}.slot-profile-label{font-size:10px;color:var(--text-muted);line-height:1.6;margin:6px 0}.stock-spool-fields{padding:16px 0 4px;border-top:1px solid #e3ece5;margin-top:16px}#modal-printer-slots{min-width:0}.slot-editor-card{min-width:0;border:1px solid #dce6e0;border-radius:10px;padding:12px;background:#fbfdfb}.slot-editor-heading{font-weight:600;font-size:12px;margin-bottom:8px}.slot-editor-card .form-input{font-size:12px}#modal-stock-weight:invalid{border-color:var(--red)}
@media(max-width:650px){.color-catalog-filters{grid-template-columns:1fr}.stock-search-toolbar{grid-template-columns:1fr}.stock-search-toolbar p{text-align:left}.color-catalog-samples{grid-template-columns:repeat(2,minmax(0,1fr))}.color-catalog-sample{font-size:11px}.slot-color-metadata{grid-template-columns:1fr}.slot-editor-card .form-input{font-size:16px}#modal-printer-slots{grid-template-columns:1fr!important}.stock-editor-modal{padding:20px}}
.filament-brand-picker{display:grid;gap:6px;min-width:0}.filament-brand-picker select{min-width:0;width:100%}.filament-brand-create{width:auto;justify-self:start;white-space:normal;text-align:left;line-height:1.5}.filament-brand-status{margin:0;font-size:11px;line-height:1.6;color:var(--text-muted)}.filament-brand-retry{justify-self:start;border:0;background:none;padding:2px 0;color:var(--accent);text-decoration:underline;cursor:pointer}.filament-brand-modal{z-index:1400}.filament-brand-modal>.modal{width:min(100%,480px)}.filament-brand-error{font-size:12px;line-height:1.6;color:var(--red);padding:10px 12px;border:1px solid #f1d3d0;border-radius:8px;background:#fff6f5}.filament-brand-modal .modal-footer{display:flex;gap:10px;margin-top:20px}.filament-brand-modal .admin-help{margin-bottom:18px}
@media(max-width:650px){.filament-brand-modal>.modal{padding:20px}.filament-brand-modal .form-input{font-size:16px}.filament-brand-create{min-height:40px}.filament-brand-modal .modal-footer{flex-direction:column}.filament-brand-modal .modal-footer>.btn{width:100%}}

.stock-movement-meta { display:block; margin-top:4px; color:var(--text-muted); white-space:normal; }

/* Fixed file destination across the three-step print workflow. */
.workflow-target { display:flex; flex-direction:column; gap:6px; margin:0 0 12px; padding:14px; border:1px solid var(--border); border-radius:var(--radius); background:var(--bg-card); overflow-wrap:anywhere; font-size:12px; line-height:1.6; }
.workflow-target strong { color:var(--text-primary); font-size:14px; }
.workflow-target-label { color:var(--text-muted); font-size:11px; }
.workflow-status { font-size:11px; line-height:1.65; margin-bottom:14px; color:var(--text-secondary); overflow-wrap:anywhere; }
.workflow-status.blocked { color:#8e482d; background:#fff5ed; border:1px solid #ead5c5; border-radius:8px; padding:10px; }
.aux-fan-status { display:flex; align-items:center; gap:5px; }
.aux-fan-status svg { width:15px; height:15px; flex-shrink:0; }
.btn-aux-fan.active { background:#edf7f3; border-color:#b4d7c5; color:#1e7158; }
.steps .step { min-width:0; flex:1 1 0; text-align:center; line-height:1.45; }
@media(max-width:600px) { .steps .step { font-size:11px; } .workflow-target { padding:12px; } }

.slot-color-metadata .slot-brand-field{grid-column:1/-1}
