:root {
  --ink: #1a1a1a;
  --verde: #1d6f42;
  --verde-dark: #155c35;
  --naranja: #e67e22;
  --rojo: #c0392b;
  --paper: #fefefe;
  --card: #ffffff;
  --line: #e0e0e0;
  --muted: #666;
  --bg: #f5f5f5;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Segoe UI", system-ui, sans-serif;
}
a { color: inherit; }

/* Header */
.top {
  background: var(--verde);
  color: white;
}
.top-inner, .wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.top-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 64px;
  gap: 16px;
}
.logo {
  text-decoration: none;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.5px;
}
.logo small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  opacity: 0.85;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.top nav { display: flex; gap: 16px; align-items: center; font-size: 14px; }
.top nav a { text-decoration: none; }
.btn {
  display: inline-block;
  background: white;
  color: var(--verde);
  font-weight: 600;
  text-decoration: none;
  padding: 12px 20px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.btn:hover { 
  background: #f0f0f0; 
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

/* Hero */
.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 40px;
  padding: 56px 0 48px;
}
.kicker {
  color: var(--verde);
  font-size: 12px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-weight: 600;
}
h1, h2, h3 { font-weight: 700; }
h1 { font-size: 42px; line-height: 1.15; margin: 10px 0; }
.lead { font-size: 17px; color: var(--muted); max-width: 36rem; line-height: 1.55; }

/* Ticket preview */
.ticket {
  background: var(--card);
  border: 2px solid var(--verde);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 6px 6px 0 rgba(29, 111, 66, 0.15);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.ticket:hover {
  transform: translate(-4px, -4px);
  box-shadow: 10px 10px 0 rgba(29, 111, 66, 0.2);
}
.ticket-img { height: 130px; overflow: hidden; }
.ticket-img img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.ticket:hover .ticket-img img { transform: scale(1.05); }
.ticket-body { padding: 20px; }
.ticket header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px dashed var(--line);
  padding-bottom: 10px;
  margin-bottom: 12px;
}
.ticket-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px dotted var(--line);
}
.ticket-item:last-child { border: 0; }
.ticket-item .name { font-weight: 500; }
.ticket-item .price { color: var(--verde); font-weight: 600; }
.ticket-total {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 2px solid var(--ink);
  display: flex;
  justify-content: space-between;
  font-size: 18px;
  font-weight: 700;
}

/* Sections */
.section { padding: 32px 0 16px; }
.section h2 { font-size: 26px; margin-bottom: 16px; }
.modules {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.modules article {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.modules article:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}
.mod-icon {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.mod-icon img { width: 100%; height: 100%; object-fit: cover; }
.modules h3 {
  margin: 0 0 10px;
  font-size: 18px;
  color: var(--verde);
}
.modules p { color: var(--muted); line-height: 1.55; margin: 0; font-size: 14px; }

/* Table */
table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--card); border-radius: 10px; overflow: hidden; box-shadow: 0 2px 12px rgba(0,0,0,0.05); }
th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  background: #f9f9f9;
}
td, th { padding: 12px 10px; border-bottom: 1px solid var(--line); }
tbody tr { transition: background 0.2s ease; }
tbody tr:hover { background: #f5f5f5; }
.note { color: var(--muted); font-size: 14px; margin-bottom: 12px; }

/* Tags */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}
.tag.stock { background: #d4edda; color: #155724; }
.tag.bajo { background: #fff3cd; color: #856404; }
.tag.agotado { background: #f8d7da; color: #721c24; }
.tag.fiado { background: #cce5ff; color: #004085; }

footer { padding: 32px 0 48px; color: var(--muted); font-size: 14px; }

/* Panel App */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
}
.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  padding: 20px 24px 8px;
  background: var(--paper);
}
.toolbar h1 { font-size: 26px; margin: 4px 0; }
.eyebrow {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.stats {
  display: flex;
  gap: 8px;
  padding: 0 24px 12px;
  flex-wrap: wrap;
  background: var(--paper);
}
.stats button, .stats div {
  background: white;
  border: 1px solid var(--line);
  padding: 8px 12px;
  min-width: 100px;
  text-align: left;
  border-radius: 4px;
  cursor: pointer;
}
.stats strong { display: block; font-size: 20px; color: var(--verde); }
.stats .on { border-color: var(--verde); background: #e8f5e9; }

.workspace {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  min-height: 0;
  background: var(--paper);
}
.list, .detail { padding: 0 24px 32px; }
.list { overflow-y: auto; }
.list table { background: var(--card); }
.row { cursor: pointer; transition: background 0.15s; }
.row:hover { background: #f9f9f9; }
.row.on { background: #e8f5e9; }

.detail {
  background: white;
  border-left: 1px solid var(--line);
  padding: 16px 24px 32px;
  overflow-y: auto;
}
.detail h2 { font-size: 20px; margin: 0 0 4px; }
.meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
  font-size: 14px;
}
.meta span { display: block; color: var(--muted); font-size: 12px; }

label { display: block; font-size: 13px; color: var(--muted); margin-top: 10px; }
input, select, textarea {
  width: 100%;
  font: inherit;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: white;
  color: var(--ink);
}
.actions { display: flex; gap: 8px; margin-top: 14px; }
.ghost {
  background: transparent;
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
}
.btn-panel {
  background: var(--verde);
  color: white;
  border: 0;
  padding: 10px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
}
.btn-panel:hover { background: var(--verde-dark); }

.timeline { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 8px; }
.timeline h3 { font-size: 14px; margin: 0 0 8px; }
.timeline p { margin: 6px 0; font-size: 13px; }
.timeline time { display: block; color: var(--verde); font-size: 11px; font-weight: 600; }

.create {
  display: none;
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
  margin: 0 24px 12px;
}
.create.open { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.create button { align-self: end; }

.amount { text-align: right; font-variant-numeric: tabular-nums; }

.arca-section {
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  border-radius: 6px;
  padding: 12px;
  margin: 12px 0;
}
.arca-section h4 { margin: 0 0 8px; font-size: 13px; color: var(--verde); display: flex; align-items: center; gap: 6px; }
.factura-box {
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 6px;
  padding: 12px;
  margin: 12px 0;
  font-size: 13px;
}
.factura-box h4 { margin: 0 0 8px; font-size: 13px; color: #166534; }
.factura-box .cae { font-family: monospace; color: #166534; }

@media (max-width: 900px) {
  .hero, .modules, .workspace, .create.open { grid-template-columns: 1fr; }
  .top-inner, .toolbar { flex-direction: column; align-items: start; }
  h1 { font-size: 32px; }
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #333;
  color: white;
  padding: 14px 28px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.btn-ghost {
  background: transparent;
  color: white;
  border: 1px solid rgba(255,255,255,0.55);
  box-shadow: none;
}
.btn-ghost:hover { background: rgba(255,255,255,0.12); color: white; }
.btn-solid { background: var(--verde); color: white; }
.btn-solid:hover { background: var(--verde-dark); color: white; }

.hero-kiosk {
  position: relative;
  min-height: 460px;
  color: #f4fff6;
  overflow: hidden;
}
.hero-kiosk-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 42% 48%;
}
.hero-kiosk-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, rgba(12, 42, 24, 0.88) 0%, rgba(12, 42, 24, 0.45) 70%, rgba(12, 42, 24, 0.2) 100%);
}
.hero-kiosk-inner {
  position: relative;
  display: grid;
  grid-template-columns: 1.2fr 0.7fr;
  gap: 32px;
  align-items: end;
  padding: 72px 24px 48px;
}
.hero-kiosk h1 { font-size: 44px; margin: 8px 0 12px; }
.kicker.light, .lead.light { color: #d7f3e0; }
.lead.light { max-width: 36rem; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.local-card {
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  border-radius: 12px;
  padding: 22px 24px;
  border-left: 6px solid var(--verde);
}
.local-name { font-weight: 700; font-size: 20px; margin: 0 0 8px; color: var(--verde); }
.local-card p { margin: 4px 0; }
.local-hours { color: var(--muted); }
.local-tel { font-weight: 700; }

.cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.cat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  padding: 0;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}
.cat-card img { width: 100%; height: 92px; object-fit: cover; display: block; }
.cat-card span { display: block; padding: 10px 12px; font-weight: 600; }
.cat-card:hover { border-color: var(--verde); box-shadow: 0 6px 18px rgba(29, 111, 66, 0.12); }

.catalog-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 12px;
}
.catalog-header h2 { margin: 0; }
.catalog-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search-field input {
  width: 200px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters button {
  background: var(--card);
  border: 1px solid var(--line);
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
}
.filters button:hover { border-color: var(--verde); }
.filters button.active { background: var(--verde); color: white; border-color: var(--verde); }
.catalog-count { color: var(--muted); font-size: 14px; margin: 0 0 16px; }

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}
.product-card {
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  cursor: pointer;
  border: 1px solid var(--line);
}
.product-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,0.1); }
.product-card img { width: 100%; height: 150px; object-fit: cover; display: block; background: #eef6f0; }
.product-card .card-body { padding: 12px 14px 16px; }
.product-card h3 { margin: 0 0 6px; font-size: 15px; }
.product-card .cat { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--verde); font-weight: 600; margin: 0 0 4px; }
.product-card .price { font-size: 20px; font-weight: 700; color: var(--verde); margin: 0; }
.product-card .stock { font-size: 12px; margin: 6px 0 10px; color: var(--muted); }
.product-card .stock.bajo { color: #e67e22; }
.product-card .stock.agotado { color: #e74c3c; }
.tile-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tile-actions .ghost, .tile-actions .btn-panel { width: auto; }

.admin-link {
  text-align: center;
  margin: 16px 0 8px;
  padding: 24px;
  background: var(--card);
  border-radius: 12px;
}
.info-grid { grid-template-columns: repeat(3, 1fr); }

.cart-wrap { position: relative; }
.cart-btn { background: none; border: 0; color: inherit; cursor: pointer; font-size: 18px; padding: 8px 12px; position: relative; }
.cart-badge {
  position: absolute;
  top: 0;
  right: 0;
  background: #e53935;
  color: white;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cart-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  color: var(--ink);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  width: 360px;
  z-index: 100;
}
.cart-dropdown[hidden] { display: none; }
.cart-dropdown h4 { margin: 0; padding: 16px; border-bottom: 1px solid #eee; }
.cart-items { max-height: 300px; overflow-y: auto; }
.cart-item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid #f5f5f5; align-items: center; }
.cart-item img, .thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 4px; background: #eef6f0; flex-shrink: 0; }
.cart-item .info { flex: 1; min-width: 0; }
.cart-item .info .title { font-size: 13px; margin: 0; }
.cart-item .info .price { font-size: 13px; font-weight: 600; margin: 4px 0 0; }
.cart-item .remove { background: none; border: none; color: #999; cursor: pointer; font-size: 18px; }
.cart-footer { padding: 16px; border-top: 1px solid #eee; }
.cart-footer .total { display: flex; justify-content: space-between; margin-bottom: 12px; }
.cart-empty { padding: 24px 16px; text-align: center; color: var(--muted); }
.qty-ctrl { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; }
.qty-ctrl button { width: 26px; height: 26px; border: 1px solid var(--line); background: #fff; border-radius: 4px; cursor: pointer; font-size: 16px; line-height: 1; }
.qty-ctrl span { min-width: 1.2em; text-align: center; font-size: 13px; font-weight: 600; }

.ficha-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 42, 24, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 180;
  padding: 20px;
}
.ficha-overlay[hidden] { display: none; }
.ficha-modal {
  position: relative;
  background: white;
  color: var(--ink);
  border-radius: 14px;
  max-width: 720px;
  width: 100%;
  max-height: min(90vh, 760px);
  overflow: auto;
  box-shadow: 0 16px 48px rgba(0,0,0,0.2);
}
.ficha-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 18px;
  background: #f4f4f5;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  z-index: 2;
}
.ficha-modal #fichaBody { display: grid; grid-template-columns: 240px 1fr; gap: 22px; padding: 22px; }
.ficha-photo { width: 100%; height: 240px; object-fit: cover; border-radius: 10px; background: #eef6f0; }
.ficha-info .cat { margin: 0; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--verde); font-weight: 600; }
.ficha-info h2 { margin: 4px 36px 8px 0; font-size: 26px; line-height: 1.2; }
.ficha-desc { margin: 12px 0; font-size: 15px; line-height: 1.55; color: var(--muted); }
.ficha-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 16px; }
.ficha-meta dt { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.ficha-meta dd { margin: 4px 0 0; font-weight: 600; }
body.ficha-open { overflow: hidden; }

.checkout-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.checkout-overlay[hidden] { display: none; }
.checkout-modal { background: white; border-radius: 12px; padding: 24px; max-width: 420px; width: 100%; }
.checkout-modal h2 { margin: 0 0 12px; }
.checkout-total { font-weight: 700; margin-top: 8px; }
.checkout-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

.workspace[hidden], .panel-section[hidden] { display: none !important; }
.tabs { display: flex; gap: 0; padding: 0 24px; background: var(--paper); border-bottom: 1px solid var(--line); }
.tabs button {
  background: transparent;
  border: none;
  padding: 12px 20px;
  font: inherit;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}
.tabs button.on { color: var(--verde); border-bottom-color: var(--verde); }
.panel-section { padding: 16px 24px 32px; background: var(--paper); }
.venta-card, .fiado-card { background: white; border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 10px; }
.venta-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; margin-bottom: 8px; font-size: 13px; }
.venta-items { display: grid; gap: 8px; }
.venta-line { display: flex; gap: 10px; align-items: center; font-size: 13px; }
.fiado-card { cursor: pointer; }
.fiado-card.on { border-color: var(--verde); background: #e8f5e9; }
.fiado-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.fiado-card h3 { margin: 0 0 4px; font-size: 16px; }
.fiado-amounts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; font-size: 14px; }
.fiado-amounts span { display: block; color: var(--muted); font-size: 12px; }
.fiado-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.thumb.fallback, .cover-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e8f5e9;
  color: var(--verde);
  font-weight: 700;
}
.detail-cover { width: 100%; max-height: 180px; object-fit: cover; border-radius: 8px; margin-bottom: 12px; }
.detail-cover.cover-fallback { height: 120px; }
.detail-desc { font-size: 14px; line-height: 1.5; margin: 8px 0 12px; color: var(--muted); }
.tag.abierto { background: #cce5ff; color: #004085; }
.tag.parcial { background: #fff3cd; color: #856404; }
.tag.cobrado { background: #d4edda; color: #155724; }

@media (max-width: 900px) {
  .hero-kiosk-inner, .cat-grid, .info-grid, .ficha-modal #fichaBody, .fiado-edit { grid-template-columns: 1fr; }
  .hero-kiosk h1 { font-size: 32px; }
  .cart-dropdown { width: min(360px, calc(100vw - 32px)); right: -12px; }
}
