:root {
  --bg: #14181A;
  --panel: #1C2224;
  --panel-soft: #20272A;
  --border: rgba(236,238,236,0.09);
  --border-strong: rgba(236,238,236,0.16);
  --text: #ECEEEC;
  --text-muted: #8C9694;
  --accent: #2FD8B0;
  --accent-hover: #3EE8C0;
  --paper: #F3F1E9;
  --paper-muted: #6B6558;
  --paper-line: rgba(20,24,26,0.12);
  --danger: #E5626B;
  --font-head: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

.icon { display: inline-block; vertical-align: -0.15em; flex-shrink: 0; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  position: relative;
  display: flex;
}

.grid-texture {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 34px 34px;
  opacity: 0.5;
  pointer-events: none;
}

/* --- sidebar --- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 220px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 22px 14px;
  z-index: 2;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 8px 20px;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}
.sidebar-logo { width: 24px; height: 24px; border-radius: 3px; object-fit: cover; }
.mobile-topbar-brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-head); font-weight: 600; font-size: 14.5px; color: var(--text); }
.mobile-topbar-brand img { width: 22px; height: 22px; border-radius: 3px; object-fit: cover; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  padding: 9px 10px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background .15s ease, color .15s ease, transform .1s ease;
}
.sidebar-nav a .icon { flex-shrink: 0; }
.sidebar-nav a:hover { color: var(--text); background: rgba(255,255,255,0.03); transform: translateX(2px); }
.sidebar-nav a.active { color: var(--bg); background: var(--accent); font-weight: 600; }
.sidebar-group-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 16px 10px 6px;
}
.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 9px 10px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  transition: color .15s ease;
}
.sidebar-logout .icon { flex-shrink: 0; }
.sidebar-logout:hover { color: var(--danger); }

.main-area { margin-left: 220px; flex: 1; min-width: 0; position: relative; }

.inner {
  position: relative;
  max-width: 960px;
  padding: 40px 32px 70px;
}

.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
}
.hamburger-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  width: 38px;
  height: 38px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 29;
}

@media (max-width: 860px) {
  body { display: block; }
  .mobile-topbar { display: flex; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 240px;
    height: 100vh;
    border-right: 1px solid var(--border);
    border-bottom: none;
    padding: 18px 14px;
    overflow-x: visible;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 30;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .sidebar-brand { display: none; }
  .sidebar-nav { flex-direction: column; }
  .sidebar-nav a { white-space: normal; }
  .sidebar-group-label { display: block; }
  .main-area { margin-left: 0; }
  .inner { padding: 24px 18px 50px; }
}

h1 {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: clamp(26px, 4vw, 34px);
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.subtitle { color: var(--text-muted); font-size: 15px; margin: 0; max-width: 480px; line-height: 1.5; }

.warning-banner {
  background: rgba(229,98,107,0.12);
  border: 1px solid rgba(229,98,107,0.3);
  color: #F0A0A6;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 4px;
  margin-bottom: 20px;
}

.section-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: 0.02em;
  margin: 0;
}

.hint { color: var(--text-muted); font-size: 13px; margin: 6px 0 16px; }

@keyframes panelIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 24px;
  animation: panelIn .3s ease both;
  transition: border-color .2s ease;
}

.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }

.field-pair { display: flex; gap: 14px; margin-top: 12px; }
.field { flex: 1; min-width: 0; }
.field label {
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: block;
}

.input {
  width: 100%;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 9px 11px;
  border-radius: 3px;
  outline: none;
  transition: border-color .15s ease;
}
.input-text { font-family: var(--font-body); }
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--text-muted); opacity: .6; }

.btn-primary {
  background: var(--accent);
  color: #0B1413;
  border: none;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  padding: 11px 18px;
  border-radius: 3px;
  cursor: pointer;
  transition: background .15s ease, transform .1s ease, box-shadow .15s ease;
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 14px rgba(47,216,176,0.25); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary .icon { margin-right: 7px; flex-shrink: 0; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 9px 14px;
  border-radius: 3px;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, transform .1s ease;
}
.btn-ghost:hover { border-color: var(--border-strong); color: var(--text); }
.btn-ghost:active { transform: scale(0.97); }
.btn-ghost .icon { margin-right: 6px; flex-shrink: 0; }

.receipt-wrap { position: sticky; top: 20px; }
.receipt {
  background: var(--paper);
  border-radius: 3px;
  padding: 26px 24px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.35);
  transform: rotate(0.4deg);
  transition: transform .25s ease;
}
.receipt:hover { transform: rotate(0deg); }
.receipt-eyebrow { font-family: var(--font-mono); font-size: 11px; color: var(--paper-muted); letter-spacing: 0.04em; }
.receipt-title { font-family: var(--font-head); font-weight: 600; font-size: 19px; color: #211D18; margin-top: 4px; }
.receipt-client { font-family: var(--font-body); font-size: 13px; color: var(--paper-muted); margin-top: 2px; }

.dashes { border-top: 1px dashed var(--paper-line); margin: 10px 0; }
.dashes.solid { border-top: 1.5px solid var(--paper-muted); }

.receipt-line { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13.5px; color: #2A2621; }
.receipt-line span:last-child { font-family: var(--font-mono); }
.receipt-line.muted { color: var(--paper-muted); }

.total-row { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px; }
.total-label { font-family: var(--font-body); font-weight: 600; font-size: 14px; color: #211D18; }
.total-value { font-family: var(--font-mono); font-weight: 600; font-size: 22px; color: #0F5C46; }
.receipt-footer { text-align: center; font-family: var(--font-mono); font-size: 11px; color: var(--paper-muted); margin-top: 18px; }

@keyframes rowIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.history-list { margin-top: 12px; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.history-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .15s ease;
  animation: rowIn .25s ease both;
}
.history-row:hover { background: rgba(255,255,255,0.02); }
.history-row:last-child { border-bottom: none; }
.history-main { flex: 1; min-width: 160px; }
.history-title { font-family: var(--font-body); font-size: 14px; color: var(--text); }
.history-title .client { color: var(--text-muted); }
.history-meta { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.history-total { font-family: var(--font-mono); font-size: 15px; color: var(--accent); margin-right: 14px; }
.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 3px;
  font-family: var(--font-body);
  font-size: 13px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color .15s ease, background .15s ease, transform .1s ease;
}
.icon-btn:hover { color: var(--danger); background: rgba(229,98,107,0.1); }
.icon-btn:active { transform: scale(0.94); }
.sold-btn:hover { color: var(--accent); background: rgba(47,216,176,0.1); }
.sold-tag {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--accent);
  border: 1px solid var(--accent-dim, var(--accent));
  padding: 4px 9px;
  border-radius: 3px;
  margin-right: 6px;
}

.share-note { color: var(--text-muted); font-size: 12.5px; margin-top: 30px; line-height: 1.5; }

@media (max-width: 860px) {
  .grid-2col { grid-template-columns: 1fr; }
  .receipt-wrap { order: -1; position: static; }
}

@media (max-width: 600px) {
  .field-pair { flex-direction: column; gap: 12px; }
  .history-row { padding: 12px; }
  .history-total { margin-right: 8px; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
}

/* --- Ventas / estadísticas --- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}
.summary-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 16px 18px;
}
.summary-card.highlight { border-color: rgba(47,216,176,0.35); }
.summary-label { font-size: 12.5px; color: var(--text-muted); margin-bottom: 8px; }
.summary-value { font-family: var(--font-mono); font-size: 20px; color: var(--text); }
.summary-card.highlight .summary-value { color: var(--accent); }

select.input { appearance: none; }

/* --- utilidades para las páginas nuevas --- */
.badge {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  margin-left: 8px;
}
.badge.low { color: var(--danger); border-color: rgba(229,98,107,0.4); }
.badge.ok { color: var(--accent); border-color: rgba(47,216,176,0.4); }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1.5px dashed var(--border-strong);
  border-radius: 6px;
  padding: 36px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); color: var(--text); background: rgba(47,216,176,0.04); }
.dropzone .icon { width: 26px; height: 26px; margin-bottom: 10px; color: var(--accent); }

.stl-thumb {
  width: 72px; height: 72px;
  border-radius: 4px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  object-fit: contain;
  margin-right: 14px;
  flex-shrink: 0;
}
.stl-thumb-placeholder {
  width: 72px; height: 72px;
  border-radius: 4px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 24px;
  margin-right: 14px;
  flex-shrink: 0;
}

/* --- vista en cuadrícula de la Librería STL --- */
.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 14px;
}
.view-toggle button {
  background: var(--panel);
  color: var(--text-muted);
  border: none;
  padding: 8px 14px;
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .15s ease, color .15s ease;
}
.view-toggle button + button { border-left: 1px solid var(--border); }
.view-toggle button.active { background: var(--accent); color: #0B1413; font-weight: 600; }
.view-toggle button:hover:not(.active) { color: var(--text); background: var(--panel-soft); }

.stl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  margin-top: 12px;
}
.stl-tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  animation: rowIn .25s ease both;
  transition: border-color .15s ease, transform .15s ease;
}
.stl-tile:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.stl-tile-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 4px;
  background: var(--panel-soft);
  object-fit: contain;
  margin-bottom: 10px;
}
.stl-tile-placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 4px;
  background: var(--panel-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 30px;
  margin-bottom: 10px;
}
.stl-tile-name {
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stl-tile-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.stl-tile-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}
.stl-tile-actions .icon-btn { padding: 5px 8px; font-size: 12px; }

.config-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.config-row:last-child { border-bottom: none; }
.config-row .label { color: var(--text-muted); }
.config-row .value { font-family: var(--font-mono); color: var(--text); }

.logo-preview {
  width: 64px; height: 64px;
  border-radius: 4px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  object-fit: contain;
}

.wear-list { margin: 10px 0 0; padding-left: 18px; color: var(--text-muted); font-size: 13.5px; line-height: 1.7; }
.wear-list li strong { color: var(--text); }

.qty-inline { display: flex; align-items: center; gap: 8px; }
.qty-inline .input { width: 70px; text-align: center; }

.photo-upload-btn {
  position: relative;
  cursor: pointer;
  display: inline-block;
  border-radius: 4px;
}
.photo-upload-btn:hover::after {
  content: "+";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.45);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 22px;
  border-radius: 4px;
}

/* --- login / setup --- */
.auth-wrap {
  position: relative;
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 32px 30px;
  width: 100%;
  max-width: 360px;
  animation: panelIn .35s ease both;
}
.auth-title { font-family: var(--font-head); font-weight: 700; font-size: 24px; margin: 0 0 4px; }
.auth-error {
  background: rgba(229,98,107,0.12);
  border: 1px solid rgba(229,98,107,0.3);
  color: #F0A0A6;
  font-size: 13px;
  padding: 9px 12px;
  border-radius: 4px;
  margin-bottom: 16px;
}

