:root {
  --bg: #f3efe6;
  --bg-2: #ebe4d6;
  --ink: #1c1914;
  --muted: #6b6458;
  --line: #d9d0c0;
  --brand: #0f3d2e;
  --brand-2: #1a5c45;
  --accent: #c45c26;
  --card: #fffcf7;
  --danger: #a33b2d;
  --ok: #1f6b4a;
  --warn: #9a6b16;
  --shadow: 0 10px 30px rgba(28, 25, 20, 0.08);
  --radius: 14px;
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --display: "Segoe UI Semibold", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, #fff8ea 0%, transparent 40%),
    linear-gradient(160deg, var(--bg), var(--bg-2));
  min-height: 100vh;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--accent); }

.app-shell {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #0d3327, #123f31 55%, #0b2a21);
  color: #f4efe6;
  padding: 1.4rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-head {
  flex: 0 0 auto;
}
.sidebar-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
.sidebar-close {
  display: none;
  border: 0;
  background: rgba(255,255,255,0.12);
  color: #fff;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 10px;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}
.sidebar-backdrop {
  display: none;
}
.mobile-bar {
  display: none;
}

.brand {
  font-family: var(--display);
  font-size: 1.25rem;
  letter-spacing: 0.02em;
  margin: 0 0 0.2rem;
}
.brand small {
  display: block;
  opacity: 0.7;
  font-size: 0.75rem;
  font-weight: 400;
  margin-top: 0.25rem;
}

.nav {
  margin-top: 1.5rem;
  display: grid;
  gap: 0.25rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0.25rem;
  padding-bottom: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.35) transparent;
}
.nav::-webkit-scrollbar {
  width: 6px;
}
.nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.3);
  border-radius: 999px;
}
.nav::-webkit-scrollbar-track {
  background: transparent;
}
.nav a {
  color: #e8e0d2;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  display: block;
  font-size: 0.95rem;
}
.nav a:hover, .nav a.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
}
.nav .section {
  margin: 1rem 0.85rem 0.35rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.55;
}
.badge-plan {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(196, 92, 38, 0.25);
  border: 1px solid rgba(255,255,255,0.15);
  font-size: 0.75rem;
}

.main { padding: 1.5rem; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.topbar h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.55rem;
}
.muted { color: var(--muted); }

.grid {
  display: grid;
  gap: 1rem;
}
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.stat, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat { padding: 1.1rem 1.2rem; }
.stat .label { color: var(--muted); font-size: 0.85rem; }
.stat .value { font-size: 1.55rem; font-weight: 700; margin-top: 0.3rem; }
.panel { padding: 1.2rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  border-radius: 10px;
  padding: 0.65rem 1rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
}
.btn:hover { background: var(--brand-2); color: #fff; }
.btn-accent { background: var(--accent); }
.btn-accent:hover { filter: brightness(1.05); color: #fff; }
.btn-outline {
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--line);
}
.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.85rem; }

.table-wrap { overflow: auto; }
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  text-align: left;
  padding: 0.75rem 0.6rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.35rem; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  background: #fff;
  font: inherit;
  color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }

.alert {
  padding: 0.85rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}
.alert-success { background: #e8f6ef; color: var(--ok); border-color: #bfe3cf; }
.alert-danger { background: #fbeceb; color: var(--danger); border-color: #f0c7c1; }
.alert-warning { background: #fff6e5; color: var(--warn); border-color: #f0d9a0; }

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    linear-gradient(135deg, rgba(15,61,46,0.92), rgba(196,92,38,0.55)),
    url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 80 80"><circle cx="2" cy="2" r="1.5" fill="%23ffffff22"/></svg>');
}
.auth-card {
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 18px;
  padding: 1.8rem;
  box-shadow: var(--shadow);
}
.auth-card h1 { margin: 0 0 0.3rem; font-size: 1.6rem; }
.auth-card p { margin-top: 0; color: var(--muted); }
.auth-card .btn { width: 100%; margin-top: 0.5rem; }
.stack { display: grid; gap: 0.85rem; }

.plan-card {
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
.plan-card.featured {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(196,92,38,0.15);
}
.plan-card h3 { margin: 0 0 0.4rem; }
.plan-price { font-size: 1.8rem; font-weight: 700; margin: 0.6rem 0; }
.plan-card ul { padding-left: 1.1rem; color: var(--muted); }
.tag {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: #efe8db;
  color: var(--muted);
}
.tag-ok { background: #e5f4ec; color: var(--ok); }
.tag-warn { background: #fff1d6; color: var(--warn); }

.pdv-layout {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: 1rem;
}
.cart-item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
}
.search-results {
  margin-top: 0.5rem;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.search-results button {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 0.7rem 0.8rem;
  cursor: pointer;
}
.search-results button:hover { background: #f7f2e8; }

.recibo {
  max-width: 380px;
  margin: 1.5rem auto;
  background: #fff;
  padding: 1.25rem;
  border: 1px dashed #bbb;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.85rem;
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }

  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: -0.25rem 0 1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 40;
    background: color-mix(in srgb, var(--bg) 88%, #fff);
    backdrop-filter: blur(8px);
  }
  .mobile-bar-brand {
    flex: 1;
    min-width: 0;
  }
  .mobile-bar-brand strong {
    display: block;
    font-size: 0.98rem;
    line-height: 1.2;
  }
  .mobile-bar-brand small {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .menu-toggle {
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--card);
    display: inline-grid;
    align-content: center;
    gap: 4px;
    padding: 0.55rem;
    cursor: pointer;
    flex: 0 0 auto;
  }
  .menu-toggle span {
    display: block;
    height: 2px;
    background: var(--brand);
    border-radius: 2px;
  }
  .topbar-pdv { display: none; }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(20, 17, 14, 0.45);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(300px, 86vw);
    height: 100vh;
    max-height: 100vh;
    z-index: 100;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    box-shadow: 12px 0 40px rgba(0,0,0,0.25);
  }
  .sidebar-close { display: inline-grid; place-items: center; }
  .nav {
    max-height: none;
    overflow-y: auto;
  }

  body.menu-open { overflow: hidden; }
  body.menu-open .sidebar { transform: translateX(0); }
  body.menu-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .main { padding: 1rem; }
  .topbar { align-items: flex-start; }
  .topbar h1 { font-size: 1.3rem; }
  .grid-4, .grid-3, .grid-2, .pdv-layout, .form-grid { grid-template-columns: 1fr; }
}
