@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
  --accent: #B08D57;
  --accent-hover: #9A7A48;
  --accent-light: #F0E4D3;
  --rose: #EFAFAF;
  --rose-light: #FBEAEA;
  --bg: #F7EDE6;
  --surface: #FFFBF8;
  --border: #EBDDD0;
  --text: #2A2320;
  --text-muted: #8A7F76;
  --green: #4C9A6A;
  --green-light: #E4F3EA;
  --red: #C4665C;
  --red-light: #FBEAE8;
  --amber: #C99A3D;
  --amber-light: #FBF1DE;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 10px rgba(120, 90, 60, 0.08);
  --bottom-nav-h: 62px;
  --topbar-h: 64px;
  --sidebar-w: 220px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Poppins', system-ui, sans-serif;
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

img { max-width: 100%; display: block; }

/* ---------- Layout general ---------- */

.app-shell {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-brand {
  text-align: center;
  margin-bottom: 18px;
}
.brand-logo {
  width: 100%;
  border-radius: 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
}
.nav-item .ic {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--accent-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.nav-item.active { background: var(--accent-light); color: var(--accent-hover); }
.nav-item:hover { background: var(--rose-light); }

.nav-logout {
  margin-top: auto;
  color: var(--text-muted);
}

.main-area {
  flex: 1;
  min-width: 0;
  padding-bottom: 40px;
}

.topbar {
  display: none; /* solo mobile */
}

.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 24px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 22px; margin: 0; }
.page-header .muted { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* ---------- Botones ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 999px; padding: 11px 20px;
  font-weight: 600; font-size: 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-rose { background: var(--rose); color: #6b2b2b; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent-hover); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-danger { background: var(--red-light); color: var(--red); border-color: transparent; }
.btn-full { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.stat-card .label {
  font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-muted); font-weight: 600;
}
.stat-card .value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat-card .foot { font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.stat-card .foot a { color: var(--accent-hover); font-weight: 600; }

.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}
.quick-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
}
.quick-item .ic {
  width: 42px; height: 42px; margin: 0 auto 8px;
  border-radius: 50%;
  background: var(--rose-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px;
}

/* ---------- Formularios ---------- */

.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 5px;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; font-size: 14px; color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Tablas / listas ---------- */

.list { display: flex; flex-direction: column; gap: 10px; }
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 10px 16px; margin-bottom: 16px;
}
.search-bar input { border: none; background: transparent; flex: 1; font-size: 14px; }
.search-bar input:focus { outline: none; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  padding: 7px 16px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-muted);
}
.chip.active { background: var(--rose); color: #6b2b2b; border-color: transparent; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
}
.badge-green { background: var(--green-light); color: var(--green); }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-amber { background: var(--amber-light); color: var(--amber); }
.badge-muted { background: var(--accent-light); color: var(--accent-hover); }

/* ---------- Producto card ---------- */

.prod-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.prod-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
}
.prod-card .foto {
  width: 100%; aspect-ratio: 4/3; object-fit: cover;
  background: var(--accent-light);
}
.prod-card .foto-placeholder {
  width: 100%; aspect-ratio: 4/3;
  background: var(--accent-light);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); font-size: 30px;
}
.prod-card .body { padding: 12px 14px 14px; flex: 1; display: flex; flex-direction: column; }
.prod-card .nombre { font-weight: 600; font-size: 14.5px; margin-bottom: 2px; }
.prod-card .precio { color: var(--accent-hover); font-weight: 700; font-size: 17px; margin: 4px 0; }
.prod-card .variantes { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.prod-card .tag {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--border); color: var(--text-muted);
}
.prod-card .stock-line { font-size: 12px; font-weight: 600; margin-top: auto; padding-top: 8px; }
.prod-card .actions { display: flex; gap: 6px; margin-top: 10px; }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed; inset: 0; background: rgba(30, 20, 15, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 100;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface); border-radius: var(--radius);
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
}
.modal-header {
  padding: 18px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h2 { font-size: 17px; margin: 0; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--text-muted); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 16px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ---------- Login ---------- */

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--surface); border-radius: 20px; box-shadow: var(--shadow);
  padding: 40px 32px; width: 100%; max-width: 360px; text-align: center;
}
.login-logo { width: 220px; max-width: 100%; margin: 0 auto 26px; border-radius: 18px; }
.login-error { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 16px; }

/* ---------- Utilidades ---------- */

.muted { color: var(--text-muted); }
.text-right { text-align: right; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state .ic { font-size: 34px; margin-bottom: 10px; }
.toast {
  position: fixed; bottom: calc(var(--bottom-nav-h) + 16px); left: 50%; transform: translateX(-50%);
  background: #2A2320; color: #fff; padding: 11px 20px; border-radius: 999px;
  font-size: 13px; z-index: 200; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.show { opacity: 1; }

/* ---------- Bottom nav (mobile) ---------- */

.bottom-nav {
  display: none;
}

@media (max-width: 860px) {
  .sidebar { display: none; }

  .topbar {
    display: flex; align-items: center; justify-content: center; position: relative;
    height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border);
    position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  }
  .brand-logo-topbar { height: 40px; width: auto; border-radius: 8px; }
  .topbar-menu, .topbar-back {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    width: 36px; height: 36px; border-radius: 50%; background: var(--bg);
    display: flex; align-items: center; justify-content: center; font-size: 16px;
    border: none;
  }

  .main-area { padding-top: var(--topbar-h); padding-bottom: calc(var(--bottom-nav-h) + 12px); }
  .page { padding: 18px 14px; }

  .bottom-nav {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0; height: var(--bottom-nav-h);
    background: var(--surface); border-top: 1px solid var(--border);
    z-index: 50;
  }
  .bottom-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; font-size: 10.5px; font-weight: 600; color: var(--text-muted);
  }
  .bottom-nav a .ic { font-size: 19px; }
  .bottom-nav a.active { color: var(--accent-hover); }

  .field-row { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 420px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card .value { font-size: 21px; }
}
