:root {
  --bg: #f4efe6;
  --panel: #ffffff;
  --ink: #241a12;
  --muted: #8a7a68;
  --accent: #c65d2e;
  --accent-2: #2e6b5e;
  --border: #e2d6c4;
  --danger: #b8402f;
  --ok: #2e6b5e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}

input {
  font-family: inherit;
}

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Login --- */
.login-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  width: 100%;
  max-width: 380px;
}

.login-box h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

.login-box p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input, .field select {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 16px;
  background: var(--bg);
  color: var(--ink);
}

.btn-primary {
  width: 100%;
  padding: 16px;
  border-radius: 14px;
  background: var(--accent);
  color: white;
  font-size: 17px;
  font-weight: 700;
  margin-top: 8px;
}

.btn-primary:active { opacity: 0.85; }

.error-msg {
  color: var(--danger);
  font-size: 14px;
  margin-top: 10px;
}

/* --- POS header --- */
.pos-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.pos-header .titles h2 {
  margin: 0;
  font-size: 17px;
}

.pos-header .titles span {
  font-size: 12px;
  color: var(--muted);
}

.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--ok);
}

.status-dot.off { background: var(--danger); }

.pos-header .right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

.pill {
  background: var(--bg);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
}

.icon-btn {
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  text-decoration: underline;
}

/* --- Grid de productos --- */
.grid {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  align-content: start;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 0;
}

.card:active { transform: scale(0.98); }

.card .thumb {
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg) center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
}

.card .info {
  padding: 10px 12px 14px;
}

.card .info .name {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 2px;
}

.card .info .price {
  color: var(--accent);
  font-weight: 700;
  font-size: 15px;
}

.card .info .stock-low {
  color: var(--danger);
  font-size: 11px;
  margin-top: 2px;
}

.card.disabled {
  opacity: 0.4;
}

/* --- Sheet modal --- */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(36, 26, 18, 0.5);
  display: flex;
  align-items: flex-end;
  z-index: 50;
}

.sheet {
  background: var(--panel);
  width: 100%;
  border-radius: 24px 24px 0 0;
  padding: 24px;
  max-height: 80vh;
  overflow-y: auto;
}

.sheet h3 {
  margin: 0 0 4px;
  font-size: 19px;
}

.sheet .sub {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 18px;
}

.option-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.option-btn {
  flex: 1;
  min-width: 90px;
  padding: 18px 10px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--bg);
  font-size: 16px;
  font-weight: 700;
  text-align: center;
}

.option-btn .stock-tag {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  margin-top: 2px;
}

.option-btn.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.option-btn.medio {
  padding: 26px 10px;
  font-size: 18px;
}

.option-btn.medio.efectivo { border-color: var(--ok); }
.option-btn.medio.posnet { border-color: var(--accent); }
.option-btn.medio.qr { border-color: #6b4fa0; }

.close-sheet {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  background: var(--bg);
  color: var(--muted);
  font-weight: 600;
}

/* --- Confirmación / undo --- */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  padding: 14px 20px;
  border-radius: 14px;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 60;
}

.toast button {
  background: var(--accent);
  color: white;
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 13px;
}

/* --- Admin --- */
.admin-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
  width: 100%;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.tab-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
}

.panel h3 {
  margin-top: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}

.summary-total {
  font-size: 26px;
  font-weight: 800;
  color: var(--accent);
}

.product-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}

.product-block input {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
  width: 100%;
}

.variant-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}

.variant-row input { margin-bottom: 0; }

.btn-secondary {
  background: var(--bg);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger);
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
}
