/* Estilos base */
:root {
  --bg: #0f172a;
  --panel: #111827;
  --muted: #64748b;
  --text: #e5e7eb;
  --accent: #22c55e;
  --accent-weak: #86efac33;
  --danger: #ef4444;
  --stroke: #94a3b8;
  --stroke-strong: #fbbf24;
  --panel-alt: #0c2330;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, 'Helvetica Neue', Arial, 'Noto Sans', 'Apple Color Emoji', 'Segoe UI Emoji';
  background: radial-gradient(1200px 800px at 12% -12%, #1b2433, #0a101b 55%, #05080d);
  color: var(--text);
}

.app-header {
  padding: 28px 16px 20px;
  display: grid;
  justify-items: center;
  gap: 18px;
  position: relative;
  background:
    linear-gradient(160deg, rgba(8, 13, 23, 0.95), rgba(6, 10, 18, 0.82)),
    linear-gradient(120deg, rgba(245, 158, 11, 0.18), rgba(234, 88, 12, 0.05));
  border-bottom: 1px solid rgba(248, 191, 73, 0.18);
  box-shadow: 0 24px 40px rgba(5, 8, 14, 0.45);
}
.app-header::before {
  content: '';
  position: absolute;
  inset: -120px -220px auto;
  height: 280px;
  background: radial-gradient(circle at 50% 15%, rgba(245, 158, 11, 0.35), transparent 70%);
  filter: blur(40px);
  pointer-events: none;
  z-index: 0;
}
.header-main { text-align: center; position: relative; z-index: 1; }
.app-header h1 {
  margin: 0;
  font-size: 2.4rem;
  letter-spacing: .04em;
  color: #fbbf24;
  text-shadow: 0 8px 18px rgba(217, 119, 6, 0.45);
}
.user-session {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(10, 16, 25, 0.9);
  border: 1px solid rgba(251, 191, 36, 0.28);
  border-radius: 999px;
  padding: 8px 12px 8px 8px;
  min-height: 52px;
  box-shadow: 0 10px 26px rgba(5, 8, 14, 0.45);
}
.app-header .user-session { align-self: auto; }
.user-session .ghost-btn { margin-left: 4px; }
.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fbbf24, #d97706);
  color: #0b1320;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-size: .95rem;
  box-shadow: 0 8px 20px rgba(217, 119, 6, 0.45);
}
.user-meta { display: flex; flex-direction: column; gap: 2px; max-width: 180px; }
.user-greeting { font-weight: 600; font-size: .95rem; color: #fbbf24; }
.user-email { font-size: .78rem; color: rgba(226, 232, 240, 0.7); }
.ghost-btn {
  background: rgba(8, 13, 23, 0.4);
  border-color: rgba(248, 191, 73, 0.35);
  color: #fef3c7;
  font-weight: 600;
}
.ghost-btn:hover { background: rgba(252, 211, 77, 0.18); }
.ghost-btn:focus { outline: none; box-shadow: 0 0 0 3px rgba(251,191,36,.35); }
.subtitle { margin: 0; color: var(--muted); }

.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px 16px 48px;
}

.main-grid {
  display: grid;
  grid-template-columns: 2.6fr .6fr;
  gap: 12px;
  align-items: start;
}
.stack { display: grid; gap: 12px; }

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.project { display: grid; gap: 6px; }
.project label { font-size: .82rem; color: rgba(226, 232, 240, 0.7); letter-spacing: .04em; text-transform: uppercase; }
.project input { height: 42px; padding: 0 14px; border-radius: 10px; border: 1px solid rgba(148, 163, 184, 0.35); background: #0f172a; color: var(--text); min-width: 320px; box-shadow: 0 10px 20px rgba(5, 10, 18, 0.25); }
.project input:focus { outline: none; border-color: rgba(251, 191, 36, 0.4); box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.18); }
.hint-inline { color: var(--muted); font-size: .85rem; margin-left: 8px; opacity: .9; }
.btn {
  appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.95), rgba(10, 16, 27, 0.92));
  color: var(--text);
  height: 42px;
  padding: 0 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .05s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease;
  display: inline-flex;
  align-items: center;
  line-height: 1;
  font-weight: 600;
}
.btn:hover {
  background: linear-gradient(180deg, rgba(24, 34, 52, 0.95), rgba(15, 23, 42, 0.95));
  border-color: rgba(251, 191, 36, 0.35);
  box-shadow: 0 10px 20px rgba(5, 10, 18, 0.35);
}
.btn:active { transform: translateY(1px); }
.btn.btn-pending {
  border-style: dashed;
}
.btn.btn-busy {
  cursor: wait;
  opacity: 0.7;
}
.btn.btn-soft {
  background: rgba(30, 41, 59, 0.55);
  border-color: rgba(148, 163, 184, 0.2);
  color: rgba(226, 232, 240, 0.85);
}
.btn.btn-soft:hover {
  background: rgba(51, 65, 85, 0.7);
  border-color: rgba(251, 191, 36, 0.25);
}
.disabled-btn {
  opacity: 0.55;
  pointer-events: none;
  cursor: not-allowed;
}
.btn.primary {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: #d97706;
  color: #0b1320;
  box-shadow: 0 14px 30px rgba(217, 119, 6, 0.45);
}
.btn.primary:hover { filter: brightness(1.05); box-shadow: 0 16px 34px rgba(217, 119, 6, 0.55); }
.btn.btn-attention {
  background: linear-gradient(180deg, #facc15, #eab308);
  border-color: #f59e0b;
  color: #1f2937;
  font-weight: 600;
  box-shadow: 0 0 0 1px #fde68a55;
}
.btn.btn-attention:hover {
  background: linear-gradient(180deg, #fde047, #facc15);
  border-color: #fbbf24;
}
.limit-note { margin-left: auto; color: var(--muted); font-size: .9rem; }
.export-group { margin-left: 8px; display: flex; gap: 6px; flex-wrap: wrap; flex: 1 1 auto; min-width: 0; }
.export-group .btn { transform: translateY(10px); }
.export-group #installBtn { background: #101933; border-color: #2b3b59; }
.export-group #themeToggle { margin-left: auto; order: 99; }

.rows { display: grid; gap: 10px; }

.rows-header { display: grid; gap: 8px; margin: 6px 0 8px; }
.rows-intro { margin: 0; color: rgba(226, 232, 240, 0.65); }
.rows-controls { display: flex; align-items: center; gap: 8px; }
.sheet {
  margin-bottom: 12px;
  background: linear-gradient(160deg, rgba(8, 13, 23, 0.92), rgba(7, 11, 19, 0.96));
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 18px 35px rgba(5, 10, 18, 0.45);
}
.sheet-title { margin: 0 0 10px; font-size: 1.05rem; color: #fbbf24; letter-spacing: .03em; }
.sheet-grid { display: grid; gap: 10px; }
.plates-controls { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.plates-controls .plate-material { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; color: rgba(226, 232, 240, 0.7); letter-spacing: .04em; }
.plates-controls .plate-edge-catalog { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; color: rgba(226, 232, 240, 0.7); letter-spacing: .04em; }
.plates-controls .plate-material select {
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: linear-gradient(180deg, rgba(24, 34, 52, 0.95), rgba(16, 24, 38, 0.92));
  color: #fef3c7;
}
.plates-controls .plate-edge-catalog select {
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: linear-gradient(180deg, rgba(24, 34, 52, 0.95), rgba(16, 24, 38, 0.92));
  color: #fef3c7;
  min-width: 200px;
}
.plates-controls .plate-material select option {
  background: #0f172a;
  color: #fef3c7;
}
.plates-controls .plate-edge-catalog select option {
  background: #0f172a;
  color: #fef3c7;
}
.plates-controls .plate-material select:focus { outline: none; border-color: rgba(251, 191, 36, 0.45); box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.18); }
.plates-controls .plate-edge-catalog select:focus { outline: none; border-color: rgba(59, 130, 246, 0.45); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18); }
.plates-controls .limit-note { margin-left: 0; }
.plates { display: grid; gap: 8px; }
.plate-row {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr .8fr .9fr;
  grid-template-rows: auto auto;
  gap: 10px;
  align-items: start;
  background: linear-gradient(160deg, rgba(8, 13, 23, 0.9), rgba(7, 11, 19, 0.94));
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 12px 26px rgba(5, 10, 18, 0.35);
}
.plate-row .field { display: flex; flex-direction: column; gap: 6px; }
.plate-row label { font-size: .78rem; color: rgba(226, 232, 240, 0.7); letter-spacing: .04em; }
.plate-row input { height: 40px; padding: 0 12px; border-radius: 9px; border: 1px solid rgba(148, 163, 184, 0.35); background: #0f172a; color: var(--text); }
.plate-row input:focus { outline: none; border-color: rgba(251, 191, 36, 0.4); box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.18); }

/* Controles de refilado por placa */
.trim-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.trim-controls .trim-label {
  font-size: .8rem;
  color: var(--muted);
  flex-basis: 100%;
  margin-top: 0;
}
.trim-controls .trim-mm {
  width: 70px;
  height: 32px;
  padding: 0 8px;
  margin-top: 0;
}
.trim-controls .side {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .8rem;
  color: var(--muted);
  margin-left: 0;
}
.trim-controls .side:first-of-type { margin-left: 0; }
.trim-controls .side input { width: 16px; height: 16px; }
.plate-row .trim-wrap {
  grid-column: 1 / span 3;
  grid-row: 2;
  display: grid;
  gap: 6px;
  margin-top: 0;
}
.trim-badge { background: #f59e0b33; border: 1px solid #f59e0b66; color: #fbbf24; padding: 2px 6px; border-radius: 6px; font-size: .75rem; }
.plate-actions {
  display: grid;
  gap: 8px;
  align-content: start;
  justify-items: stretch;
  grid-column: 4;
  grid-row: 1;
}
.plate-actions .btn.remove {
  justify-self: start;
  margin-top: 10px;
  padding: 0 14px;
  min-width: 110px;
  width: auto;
  background: linear-gradient(180deg, #ef4444, #dc2626);
  border-color: #b91c1c;
  color: #ffffff;
}
.plate-actions .btn.remove:hover {
  filter: brightness(1.05);
}
.plate-actions .btn.remove:disabled {
  opacity: 0.6;
  filter: none;
}
.kerf-slot {
  grid-column: 4;
  grid-row: 2;
  display: grid;
  align-content: start;
}
.kerf-slot .kerf-field { display: grid; gap: 4px; margin-top: 0; }
.kerf-slot .kerf-field label { font-size: .8rem; color: var(--muted); }
.kerf-slot .kerf-field input {
  height: 40px;
  width: 80px;
  max-width: 80px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid #233046;
  background: #0e1629;
  color: var(--text);
  text-align: right;
}
.kerf-slot .kerf-field input:focus { outline: none; border-color: #36507c; box-shadow: 0 0 0 3px #93c5fd22; }

.row {
  display: grid;
  grid-template-columns: auto 90px 270px 270px auto 1.7fr;
  gap: 10px;
  align-items: center;
  background: linear-gradient(180deg, #0b1222, #0b1222), radial-gradient(600px 120px at 10% -60%, #2a333f55, transparent 60%);
  border: 1px solid #1f2937;
  border-radius: 12px;
  padding: 12px;
}
.row .idx { min-width: 28px; text-align: center; color: var(--muted); font-weight: 600; }

.row .field { display: flex; flex-direction: column; gap: 6px; }
.row .field--qty input { max-width: 70px; }
.row .field--width .row-input-primary,
.row .field--height .row-input-primary {
  max-width: 90px;
  flex: 0 0 90px;
  width: 90px;
}
.row .dim-inputs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.row .dim-inputs input { height: 40px; }
.row .dim-inputs .row-input-secondary { width: 38px; padding: 0 6px; text-align: center; }
.row label { font-size: .8rem; color: var(--muted); }
.row input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid #233046;
  background: #0e1629;
  color: var(--text);
}
.row input:focus { outline: none; border-color: #36507c; box-shadow: 0 0 0 3px #93c5fd22; }
.row select {
  height: 40px;
  border-radius: 8px;
  border: 1px solid #233046;
  background: #0e1629;
  color: var(--text);
  padding: 0 12px;
}
.row select:focus { outline: none; border-color: #36507c; box-shadow: 0 0 0 3px #93c5fd22; }
.row .dim-inputs .edge-select {
  min-width: 90px;
  flex: 0 1 100px;
  width: 102px;
  padding: 0 8px;
}
.row .dim-inputs .edge-select option {
  background-color: #101933;
  color: var(--text);
}
.row .units { color: var(--muted); font-size: .85rem; height: 40px; display: inline-flex; align-items: center; padding: 0 4px; }

.row .actions { display: flex; gap: 8px; align-items: center; align-self: center; margin-top: 0; transform: translateY(7px); }
.row .remove { color: var(--danger); border-color: #b91c1c; background: #1c0b10; }
.row .remove:hover { filter: brightness(1.1); }
.color-dot { width: 14px; height: 14px; border-radius: 50%; border: 1px solid #1f2937; box-shadow: 0 0 0 2px #00000022 inset; }
.rot-label { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: .8rem; }
.rot-label input { accent-color: #60a5fa; width: 16px; height: 16px; }
.rot-label.rot-disabled { opacity: .55; pointer-events: none; }

.preview {
  width: 100%;
  height: 110px;
  background: #0a0f1c;
  border: 1px dashed #223048;
  border-radius: 8px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}
.preview .hint {
  position: absolute;
  top: 6px; left: 8px;
  font-size: .75rem; color: var(--muted);
}
.preview .overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 15, 28, 0.6);
  color: var(--muted);
  font-size: .85rem;
  text-align: center;
  padding: 6px 8px;
  pointer-events: all;
}

/* SVG rectangle + edges */
.svg-wrap { width: 100%; height: 100%; display: grid; place-items: center; }
svg { width: 100%; height: 100%; }

.edge { stroke: var(--stroke); stroke-width: 4; stroke-linecap: round; fill: none; cursor: pointer; transition: stroke .15s ease, filter .15s ease; }
.edge:hover { filter: drop-shadow(0 0 4px #60a5fa77); }
.edge.selected { stroke: var(--stroke-strong); }
.edge-hit { stroke: transparent; stroke-width: 18; fill: none; pointer-events: stroke; cursor: pointer; }

.rect-outline { stroke: #cbd5e144; stroke-width: 2; fill: #64748b0d; }
.rect-outline { pointer-events: none; }
.rect-shadow { filter: drop-shadow(0 0px 6px rgba(0,0,0,.35)); }

.dims-label {
  font-size: 10px;
  fill: #9ca3af;
}
.dims-label { pointer-events: none; }
.dims-badge { pointer-events: none; }

@media (max-width: 920px) {
  .main-grid { grid-template-columns: 1fr; }
  .row { grid-template-columns: auto 1fr; }
  .row .actions { grid-column: 1 / -1; }
  .row .preview { grid-column: 1 / -1; height: 140px; }
}
.summary {
  position: sticky;
  top: 10px;
  align-self: start;
  background: linear-gradient(160deg, rgba(8, 13, 23, 0.9), rgba(7, 11, 19, 0.96));
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 20px 40px rgba(5, 10, 18, 0.45);
}
.summary-title { margin: 0 0 12px; font-size: 1.1rem; color: #fbbf24; letter-spacing: .03em; }
.summary-subtitle { margin: 22px 0 6px; font-size: .95rem; color: rgba(226, 232, 240, 0.7); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.summary-total {
  margin: 20px 0 8px;
  font-weight: 500;
  color: #94a3b8;
  display: grid;
  gap: 6px;
  background: #0e1629;
  border: 1px solid #1e293b;
  padding: 10px 12px;
  border-radius: 8px;
  box-shadow: none;
}
.summary-plates-value {
  margin: 20px 0 8px;
  font-weight: 500;
  color: #94a3b8;
  display: grid;
  gap: 6px;
  background: #0e1629;
  border: 1px solid #1e293b;
  padding: 10px 12px;
  border-radius: 8px;
}
.summary-grand-total {
  margin: 20px 0 8px;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fbbf24;
  display: grid;
  gap: 6px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(217, 119, 6, 0.12));
  border: 2px solid rgba(245, 158, 11, 0.4);
  padding: 14px 16px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2), inset 0 1px 0 rgba(251, 191, 36, 0.25);
}
.summary-grand-total .grand-total-label {
  font-size: 0.85rem;
  color: #fbbf24;
  opacity: 0.9;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.summary-grand-total .grand-total-amount {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fcd34d;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
.summary-stat { margin: 2px 0 6px; color: rgba(226, 232, 240, 0.75); }
.summary-list { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 6px; }
.summary-list li { color: rgba(226, 232, 240, 0.7); font-size: .9rem; display: flex; align-items: center; gap: 8px; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid #1f2937; }

.panel-title {
  margin: 22px 0 4px;
  font-size: .98rem;
  font-weight: 600;
  color: #fbbf24;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.panel-description {
  margin: 0 0 12px;
  font-size: .82rem;
  color: rgba(226, 232, 240, 0.7);
}

.social-connect {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  display: grid;
  gap: 12px;
}
.social-summary {
  grid-column: 2;
  align-self: start;
}
.social-summary .social-connect {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
.social-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}
.social-links a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #111f36;
  border: 1px solid #1d2f4f;
  color: #e2e8f0;
  text-decoration: none;
  transition: transform .08s ease, border-color .2s ease, background .2s ease;
}
.social-links a:hover {
  transform: translateY(-1px);
  background: #142744;
  border-color: #2e4368;
}
.social-label {
  font-weight: 600;
  letter-spacing: .01em;
}
.social-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #0f172a;
  position: relative;
  overflow: hidden;
}
.social-icon::after {
  content: attr(data-icon);
  color: inherit;
}
.social-icon--instagram {
  background: linear-gradient(135deg, #f56040, #bc2a8d 55%, #833ab4);
  color: #fff5f5;
}
.social-icon--facebook {
  background: #1877f2;
  color: #ffffff;
}
.social-icon--whatsapp {
  background: linear-gradient(135deg, #25d366, #128c7e);
  color: #f0fff4;
}
.social-icon--youtube {
  background: linear-gradient(135deg, #ff4d4f, #c40000);
  color: #ffffff;
}
body.theme-light .panel-title { color: #0f172a; }
body.theme-light .social-links a {
  background: #f8fafc;
  border-color: #cbd5f5;
  color: #0f172a;
}
body.theme-light .social-links a:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

/* Vista general de la placa (abajo) */
.sheet-overview {
  margin-top: 16px;
  background: linear-gradient(180deg, var(--panel-alt), #071821);
  border: 1px solid #123040;
  border-radius: 12px;
  padding: 12px;
}
.sheet-canvas {
  /* Altura flexible: crece según la cantidad de placas */
  height: auto;
  min-height: 120px;
  border: 1px dashed #234a60;
  border-radius: 8px;
  background: #081720;
  position: relative;
  overflow: visible;
  display: block;
  padding: 10px;
}
.sheet-multi { display: grid; gap: 14px; width: 100%; }
.plate-title { color: var(--muted); font-size: .9rem; margin: 0 0 4px 4px; }
.plate-title { cursor: pointer; display: flex; align-items: center; gap: 6px; user-select: none; }
.plate-title .caret { font-size: .95rem; opacity: .9; }
.plate-collapsed svg { display: none !important; }
.sheet-canvas .hint {
  position: absolute;
  color: var(--muted);
  font-size: .9rem;
}
.sheet-canvas svg { width: 100%; height: auto; display: block; }
.sheet-outline { fill: #0e3344; stroke: #3ba1c6; stroke-width: 2; }
.body.theme-light .sheet-outline { fill: #e6f3f9; stroke: #60a5fa; }
.sheet-outline { filter: drop-shadow(0 0 10px rgba(23, 162, 184, .2)); }
.sheet-dims { fill: #cbd5e1; font-size: 16px; }
.piece-rot { fill: #e5e7eb; font-size: 13px; opacity: .9; }
.piece-label { fill: #e5e7eb; text-anchor: middle; dominant-baseline: middle; opacity: .95; }

.stock-body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
}

.stock-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  display: grid;
  gap: 20px;
}

.stock-header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.stock-panel {
  background: linear-gradient(180deg, #0b1222, #0b1222);
  border: 1px solid #1f2937;
  border-radius: 12px;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.admin-panel {
  position: relative;
  border: none;
  padding: 24px;
  background:
    radial-gradient(120% 140% at 10% -20%, rgba(34, 211, 238, 0.4), rgba(59, 130, 246, 0.15)),
    linear-gradient(180deg, #0b1222, #111933);
  box-shadow: 0 25px 60px rgba(15, 23, 42, 0.45);
  border-radius: 16px;
  overflow: hidden;
}

.admin-panel::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 2px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.8), rgba(236, 72, 153, 0.6));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  pointer-events: none;
}

.admin-panel h2 {
  font-size: 1.35rem;
  color: #e0f2fe;
}

.admin-panel-description {
  margin: 0;
  color: #bae6fd;
  font-size: .9rem;
  line-height: 1.55;
}

.admin-form {
  display: grid;
  gap: 16px;
  background: rgba(8, 13, 25, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 14px;
  padding: 16px 18px 18px;
  backdrop-filter: blur(6px);
}

.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 18px;
}

.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: .85rem;
  color: #cbd5f5;
}

.admin-form input {
  height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(13, 20, 38, 0.75);
  color: var(--text);
  font-size: 0.95rem;
}

.admin-form input:focus {
  outline: none;
  border-color: rgba(96, 165, 250, 0.75);
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.25);
}

.admin-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(8, 13, 25, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 14px;
  overflow: hidden;
}

.admin-table th {
  text-align: left;
  font-size: .85rem;
  color: #cbd5f5;
  font-weight: 600;
  padding: 14px 18px;
  background: rgba(37, 99, 235, 0.25);
}

.admin-table td {
  padding: 12px 18px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  color: #e2e8f0;
  font-size: .9rem;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table .btn {
  font-size: .8rem;
  padding: 6px 12px;
  height: auto;
}

.admin-empty {
  text-align: center;
  padding: 20px 0;
  color: rgba(226, 232, 240, 0.8);
  font-size: .9rem;
}

.stock-panel h2 { margin: 0; font-size: 1rem; color: var(--muted); }

.stock-form {
  display: grid;
  gap: 12px;
}

.stock-form label {
  display: grid;
  gap: 6px;
  font-size: .9rem;
  color: var(--muted);
}

.stock-form input {
  height: 38px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid #233046;
  background: #0e1629;
  color: var(--text);
}

.stock-form input:focus {
  outline: none;
  border-color: #36507c;
  box-shadow: 0 0 0 3px #93c5fd22;
}

.stock-form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stock-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

.stock-table th,
.stock-table td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid #1f2937;
}

.stock-table th { color: var(--muted); font-weight: 600; }

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: #60a5fa;
  cursor: pointer;
  font-size: inherit;
  text-decoration: underline;
}
.link-button:hover { color: #93c5fd; }

.stock-empty { text-align: center; color: var(--muted); padding: 18px 0; }

.stock-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.stock-actions-panel {
  margin-top: 20px;
  padding: 18px;
  border: 1px dashed rgba(148, 163, 184, 0.3);
  border-radius: 12px;
  background: rgba(8, 13, 25, 0.45);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.stock-actions-buttons {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-small { padding: 4px 10px; font-size: .75rem; }

.btn.danger { background: #3f0b16; border-color: #b91c1c; color: #fca5a5; }
.btn.danger:hover { filter: brightness(1.1); }
.btn.btn-secondary { background: #1c253b; border-color: #1d2a46; color: var(--muted); }
.btn.btn-secondary:hover { filter: brightness(1.1); }
.plate-row .btn.remove { transform: translateY(10px); }
body.theme-light {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-alt: #eef2f7;
  --muted: #475569;
  --text: #0f172a;
  --accent: #22c55e;
  --accent-weak: #bbf7d033;
  --stroke: #94a3b8;
  --stroke-strong: #2563eb;
  background: #f5f7fb;
  color: var(--text);
}
body.theme-light .row { background: #ffffff; border-color: #e5e7eb; box-shadow: 0 1px 2px rgba(15,23,42,.05), 0 6px 18px rgba(15,23,42,.08); }
body.theme-light .sheet,
body.theme-light .summary { background: #ffffff; border-color: #e2e8f0; box-shadow: 0 1px 2px rgba(15,23,42,.05), 0 6px 18px rgba(15,23,42,.08); }
body.theme-light .preview { background: #f8fafc; border-color: #d1d5db; }
body.theme-light .sheet-overview { background: #f8fafc; border-color: #cbd5e1; }
body.theme-light .sheet-canvas { background: #eef2f7; border-color: #cbd5e1; }
body.theme-light .btn { background: #f3f4f6; border-color: #e5e7eb; color: #0f172a; box-shadow: 0 1px 2px rgba(15,23,42,.06); }
body.theme-light .btn.primary { background: linear-gradient(180deg, #4ade80, #22c55e); border-color: #22c55e; color: #0d1b0f; }
body.theme-light .btn.danger { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }
body.theme-light .btn.btn-soft { background: #e2e8f0; border-color: #cbd5e1; color: #334155; }
body.theme-light .btn.btn-attention { background: linear-gradient(180deg, #fde047, #facc15); border-color: #fbbf24; color: #78350f; }
body.theme-light .project input,
body.theme-light .row input,
body.theme-light .sheet input,
body.theme-light .plate-row input,
body.theme-light select,
body.theme-light .plates-controls .plate-material select,
body.theme-light .plates-controls .plate-edge-catalog select,
body.theme-light .row select,
body.theme-light .sheet select,
body.theme-light .plate-row select {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(15,23,42,.04) inset;
}
body.theme-light .plates-controls .plate-material select,
body.theme-light .plates-controls .plate-edge-catalog select,
body.theme-light .kerf-slot .kerf-field input {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}
body.theme-light .legend-dot { border-color: #94a3b8; }
body.theme-light .piece-label { fill: #334155; }
body.theme-light .piece-rot { fill: #475569; }
body.theme-light .dims-label { fill: #475569; }
body.theme-light .plate-row { background: #ffffff; border-color: #e2e8f0; box-shadow: 0 1px 2px rgba(15,23,42,.05), 0 4px 14px rgba(15,23,42,.07); }
body.theme-light .sheet-outline { fill: #e6f3f9; stroke: #60a5fa; }
body.theme-light .row .dim-inputs .edge-select option { background-color: #ffffff; color: #0f172a; }
body.theme-light .plates-controls .plate-material select option,
body.theme-light .plates-controls .plate-edge-catalog select option { background-color: #ffffff; color: #0f172a; }
body.theme-light .user-session {
  background: linear-gradient(180deg, #f8fafc, #e2e8f0);
  border-color: #cbd5e1;
  color: #0f172a;
}
body.theme-light .user-avatar {
  background: linear-gradient(180deg, #dbeafe, #bfdbfe);
  color: #0f172a;
}
body.theme-light .user-email { color: #475569; }
body.theme-light .ghost-btn {
  border-color: #cbd5e1;
  color: #0f172a;
}
body.theme-light .ghost-btn:hover { background: rgba(148, 163, 184, 0.2); }

/* Tema claro (white) */

/* Login */
body.login-page {
  background: radial-gradient(circle at 10% -10%, #1f2937 0%, #0f172a 55%, #05070d 100%);
  color: #e5e7eb;
  min-height: 100vh;
}

.login-wrapper {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 72px 16px;
  overflow: hidden;
}

.login-wrapper::before,
.login-wrapper::after {
  content: '';
  position: absolute;
  width: 1100px;
  height: 250px;
  border-radius: 40px;
  z-index: 0;
  transform-origin: center;
  opacity: 0.9;
}

.login-wrapper::before {
  background: linear-gradient(120deg, rgba(120, 63, 4, 0.92), rgba(79, 40, 7, 0.95));
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-18deg);
  box-shadow: 0 34px 70px rgba(41, 16, 2, 0.55);
}

.login-wrapper::after {
  background:
    linear-gradient(120deg, rgba(30, 41, 59, 0.85), rgba(15, 23, 42, 0.95)),
    repeating-linear-gradient(135deg, rgba(148, 163, 184, 0.12) 0 8px, rgba(148, 163, 184, 0.02) 8px 26px);
  top: 65%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(18deg);
  box-shadow: 0 40px 90px rgba(6, 10, 18, 0.55);
}

.login-stage {
  position: relative;
  z-index: 1;
  width: min(500px, 100%);
}

.login-card {
  position: relative;
  background: linear-gradient(160deg, #0d1520, #161f2c 60%, #111a27 100%);
  border-radius: 28px;
  padding: 152px 36px 40px;
  box-shadow: 0 40px 85px rgba(5, 8, 14, 0.6);
  border: 1px solid rgba(100, 116, 139, 0.2);
}

.login-card__hero {
  position: absolute;
  inset: 0;
  height: 46%;
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  background: linear-gradient(135deg, #f59e0b, #d97706 65%, #b45309 100%);
  display: grid;
  place-items: center;
  color: #1f2937;
  font-size: 1.35rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  font-weight: 700;
  text-shadow: 0 6px 20px rgba(15, 23, 42, 0.35);
}

.login-card__hero h2 {
  margin: 0;
}

.login-card__avatar {
  position: absolute;
  top: 33%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.avatar-circle {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #0b1320 0 38%, transparent 39%),
    conic-gradient(from 0deg,
      #fde68a 0 18deg,
      #0b1320 18deg 36deg,
      #fbbf24 36deg 54deg,
      #0b1320 54deg 72deg,
      #fde68a 72deg 90deg,
      #0b1320 90deg 108deg,
      #fbbf24 108deg 126deg,
      #0b1320 126deg 144deg,
      #fde68a 144deg 162deg,
      #0b1320 162deg 180deg,
      #fbbf24 180deg 198deg,
      #0b1320 198deg 216deg,
      #fde68a 216deg 234deg,
      #0b1320 234deg 252deg,
      #fbbf24 252deg 270deg,
      #0b1320 270deg 288deg,
      #fde68a 288deg 306deg,
      #0b1320 306deg 324deg,
      #fbbf24 324deg 342deg,
      #0b1320 342deg 360deg);
  border: 6px solid #05070d;
  display: grid;
  place-items: center;
  box-shadow: 0 18px 36px rgba(5, 8, 14, 0.55);
}

.avatar-icon {
  font-size: 1.8rem;
  color: #fef3c7;
}

.login-card__panel {
  background: linear-gradient(160deg, rgba(10, 16, 25, 0.96), rgba(8, 13, 21, 0.98));
  border-radius: 18px;
  padding: 78px 36px 40px;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.12);
}

.login-header {
  text-align: center;
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
}

.login-header h1 {
  margin: 0;
  font-size: 1.6rem;
  color: #fbbf24;
  letter-spacing: .06em;
}

.login-header p {
  margin: 0;
  color: rgba(226, 232, 240, 0.72);
}

.login-actions {
  display: grid;
  gap: 24px;
}

.login-actions .btn {
  width: 100%;
  justify-content: center;
}

.login-actions .btn.login-btn {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: #d97706;
  color: #0b1320;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  box-shadow: 0 18px 38px rgba(217, 119, 6, 0.45);
}

.login-actions .btn.login-btn:hover {
  filter: brightness(1.05);
  box-shadow: 0 22px 44px rgba(217, 119, 6, 0.55);
}

.input-field select {
  cursor: pointer;
  font-weight: 600;
  background: linear-gradient(180deg, rgba(42, 55, 74, 0.95), rgba(26, 36, 52, 0.94));
  color: #fde68a;
  text-shadow: 0 0 6px rgba(217, 119, 6, 0.35);
}

.input-field select option {
  color: #fde68a;
  background-color: #111827;
}

.login-footer,
.login-policy {
  margin-top: 18px;
  text-align: center;
  font-size: .82rem;
  color: rgba(226, 232, 240, 0.55);
}

.login-footer a,
.login-policy a {
  color: #fbbf24;
  font-weight: 600;
}

/* Login legacy (Google OAuth) */
body.login-page.login-page-legacy {
  background: linear-gradient(180deg, #111b2a 0%, #050911 100%);
  color: #e2e8f0;
}

.login-wrapper--legacy {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
}

.login-wrapper--legacy::before,
.login-wrapper--legacy::after {
  display: none;
}

.login-legacy-card {
  width: min(420px, 100%);
  display: grid;
  gap: 24px;
  padding: 42px 32px 36px;
  background: linear-gradient(160deg, rgba(8, 13, 23, 0.92), rgba(6, 10, 18, 0.94));
  border-radius: 22px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow: 0 26px 60px rgba(5, 10, 18, 0.55);
}

.login-wrapper--legacy .login-header {
  text-align: center;
  display: grid;
  gap: 10px;
}

.login-wrapper--legacy .login-header h1 {
  margin: 0;
  font-size: 2rem;
  color: #fbbf24;
  letter-spacing: .04em;
}

.login-wrapper--legacy .login-header p {
  margin: 0;
  color: rgba(226, 232, 240, 0.75);
}

.login-wrapper--legacy .login-actions {
  display: grid;
  gap: 18px;
}

.login-wrapper--legacy .login-actions .btn.login-btn {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: #d97706;
  color: #0b1320;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  box-shadow: 0 12px 28px rgba(217, 119, 6, 0.45);
}

.login-wrapper--legacy .login-note {
  margin: 0;
  text-align: center;
  color: rgba(226, 232, 240, 0.65);
  font-size: .85rem;
}

.login-wrapper--legacy .login-footer,
.login-wrapper--legacy .login-policy {
  text-align: center;
  font-size: .82rem;
  color: rgba(226, 232, 240, 0.6);
}

.login-wrapper--legacy .login-policy a {
  color: #fbbf24;
  font-weight: 600;
}

body.dialog-open {
  overflow: hidden;
}

.app-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 23, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 9999;
  backdrop-filter: blur(4px);
}

.app-dialog {
  background: linear-gradient(180deg, #0b1222, #111827);
  border: 1px solid #1f2937;
  border-radius: 14px;
  width: min(420px, 100%);
  padding: 24px 24px 20px;
  box-shadow: 0 20px 60px rgba(12, 18, 32, 0.65);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.app-dialog-header h2 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--text);
}

.app-dialog-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--muted);
  line-height: 1.55;
}

.app-dialog-body p {
  margin: 0;
}

.app-dialog-actions {
  display: flex;
  justify-content: flex-end;
}

.app-dialog-actions .btn {
  min-width: 96px;
}

.app-dialog-success {
  border-color: rgba(34, 197, 94, 0.45);
  box-shadow: 0 20px 60px rgba(22, 163, 74, 0.25);
}

.app-dialog-success .app-dialog-header h2 {
  color: #bbf7d0;
}

.app-dialog-warning {
  border-color: rgba(251, 191, 36, 0.45);
  box-shadow: 0 20px 60px rgba(251, 191, 36, 0.2);
}

.app-dialog-warning .app-dialog-header h2 {
  color: #fcd34d;
}

.app-dialog-error {
  border-color: rgba(239, 68, 68, 0.45);
  box-shadow: 0 20px 60px rgba(239, 68, 68, 0.2);
}

.app-dialog-error .app-dialog-header h2 {
  color: #fecaca;
}

.app-dialog .btn {
  font-weight: 600;
}

/* Estilos para números de corte en las piezas */
.piece-cut-number {
  font-family: system-ui, -apple-system, sans-serif;
  user-select: none;
  pointer-events: none;
}

/* Mejorar la legibilidad de los números de corte en SVG */
text.piece-cut-number {
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}
