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

:root {
  /* Paleta de marca Yapomarket: verde, amarillo y naranjo */
  --bg: #f6f9f2;
  --bg-accent: #f0f9e8;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e7edd9;

  --primary: #2e9c3f;
  --primary-dark: #1f7a2e;
  --primary-light: #6cc551;
  --primary-bg: #eefbe9;

  --orange: #f5821f;
  --orange-dark: #d9660f;
  --orange-bg: #fff3e8;
  --yellow: #f4c11f;
  --yellow-dark: #d99e0e;
  --yellow-bg: #fef9e6;
  --blue: #3b82f6;
  --blue-bg: #eff6ff;
  --purple: #8b5cf6;
  --purple-bg: #f5f3ff;

  --danger: #e11d48;
  --danger-bg: #fff1f2;
  --ok: #2e9c3f;
  --ok-bg: #eefbe9;
  --warn: #d9660f;
  --warn-bg: #fff3e8;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 10px rgba(46, 156, 63, 0.08), 0 1px 2px rgba(46, 156, 63, 0.08);
  --shadow-lg: 0 10px 30px rgba(46, 156, 63, 0.16);
}

/* ---------- temas ---------- */

:root[data-tema="yapomarket-oscuro"] {
  --bg: #0f1a12; --bg-accent: #14210f; --card: #182a1c; --text: #e8f3ea; --muted: #9db6a3; --border: #2a4030;
  --primary: #3fbf54; --primary-dark: #2e9c3f; --primary-light: #6cc551; --primary-bg: #1c3322;
  --orange: #f5821f; --orange-dark: #d9660f; --orange-bg: #3a2415;
  --yellow: #f4c11f; --yellow-dark: #d99e0e; --yellow-bg: #3a3115;
  --danger: #f87171; --danger-bg: #3a1a1a; --ok: #4ade80; --ok-bg: #1c3322; --warn: #fb923c; --warn-bg: #3a2415;
  --shadow: 0 2px 10px rgba(0,0,0,.35); --shadow-lg: 0 10px 30px rgba(0,0,0,.5);
}

:root[data-tema="oceano-claro"] {
  --bg: #f0f7fb; --bg-accent: #e6f2fa; --card: #ffffff; --text: #1e293b; --muted: #64748b; --border: #dce8f0;
  --primary: #2563eb; --primary-dark: #1d4ed8; --primary-light: #60a5fa; --primary-bg: #eff6ff;
  --orange: #0891b2; --orange-dark: #0e7490; --orange-bg: #ecfeff;
  --yellow: #06b6d4; --yellow-dark: #0891b2; --yellow-bg: #ecfeff;
  --danger: #e11d48; --danger-bg: #fff1f2; --ok: #16a34a; --ok-bg: #f0fdf4; --warn: #d97706; --warn-bg: #fffbeb;
}

:root[data-tema="oceano-oscuro"] {
  --bg: #0b1220; --bg-accent: #0f1729; --card: #131b2e; --text: #e2e8f0; --muted: #94a3b8; --border: #243049;
  --primary: #3b82f6; --primary-dark: #2563eb; --primary-light: #60a5fa; --primary-bg: #152238;
  --orange: #22d3ee; --orange-dark: #06b6d4; --orange-bg: #0e2430;
  --yellow: #38bdf8; --yellow-dark: #0ea5e9; --yellow-bg: #0e2430;
  --danger: #f87171; --danger-bg: #3a1a1a; --ok: #34d399; --ok-bg: #0f2a22; --warn: #fbbf24; --warn-bg: #2e2610;
  --shadow: 0 2px 10px rgba(0,0,0,.35); --shadow-lg: 0 10px 30px rgba(0,0,0,.5);
}

:root[data-tema="uva-claro"] {
  --bg: #f7f5fb; --bg-accent: #f1edfa; --card: #ffffff; --text: #2e1a47; --muted: #7c6a92; --border: #e3d9f2;
  --primary: #7c3aed; --primary-dark: #6d28d9; --primary-light: #a78bfa; --primary-bg: #f5f3ff;
  --orange: #db2777; --orange-dark: #be185d; --orange-bg: #fdf2f8;
  --yellow: #c026d3; --yellow-dark: #a21caf; --yellow-bg: #fdf4ff;
  --danger: #e11d48; --danger-bg: #fff1f2; --ok: #16a34a; --ok-bg: #f0fdf4; --warn: #d97706; --warn-bg: #fffbeb;
}

:root[data-tema="uva-oscuro"] {
  --bg: #160f24; --bg-accent: #1c1330; --card: #221934; --text: #ede9fe; --muted: #a78bd6; --border: #3a2a52;
  --primary: #a78bfa; --primary-dark: #8b5cf6; --primary-light: #c4b5fd; --primary-bg: #2a1f42;
  --orange: #f472b6; --orange-dark: #ec4899; --orange-bg: #3a1f2e;
  --yellow: #e879f9; --yellow-dark: #d946ef; --yellow-bg: #341b38;
  --danger: #f87171; --danger-bg: #3a1a1a; --ok: #4ade80; --ok-bg: #1c3322; --warn: #fbbf24; --warn-bg: #2e2610;
  --shadow: 0 2px 10px rgba(0,0,0,.35); --shadow-lg: 0 10px 30px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Nunito', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(180deg, var(--bg-accent) 0%, var(--bg) 320px);
  color: var(--text);
}

h1, h2, h3 { font-weight: 800; letter-spacing: -0.01em; }

header.topbar {
  background: linear-gradient(100deg, var(--primary) 0%, var(--yellow) 55%, var(--orange) 100%);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
  overflow: visible;
}

/* Logo tipo "escudo": mas grande que la franja, sobresale un poco arriba y abajo. */
.header-logo {
  flex-shrink: 0;
  height: 58px;
  width: 58px;
  object-fit: contain;
  background: #fff;
  border-radius: 14px;
  padding: 5px;
  margin: -6px 0;
  box-shadow: 0 4px 14px rgba(0,0,0,.28);
}

.hamburger {
  display: none;
  background: rgba(255,255,255,.18);
  color: #fff;
  border: none;
  box-shadow: none;
  font-size: 20px;
  padding: 6px 12px;
  border-radius: 8px;
}

#menu-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 9998;
}

header.topbar .brand {
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(0,0,0,.15);
  opacity: .95;
}

header.topbar h1 {
  font-size: 19px;
  margin: 2px 0 0;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  text-shadow: 0 1px 2px rgba(0,0,0,.1);
}

header.topbar h1::before {
  content: "🏪";
  font-size: 22px;
}

header.topbar .sub {
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  opacity: .95;
}

main {
  max-width: 1150px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 20% 20%, #d7f2c2 0%, transparent 45%),
              radial-gradient(circle at 85% 15%, #fdecc8 0%, transparent 40%),
              radial-gradient(circle at 75% 85%, #fbdcc0 0%, transparent 45%),
              var(--bg);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin-top: 0;
  font-size: 17px;
  color: var(--primary-dark);
}

.login-card {
  width: 100%;
  max-width: 400px;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-card .logo {
  width: 230px;
  max-width: 80%;
  height: auto;
  margin: 0 auto 6px;
  display: block;
}

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

.login-card label { text-align: left; }

label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 5px;
  margin-top: 14px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
  transition: border-color .15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-light);
}

textarea { resize: vertical; min-height: 60px; }

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

button {
  cursor: pointer;
  border: none;
  border-radius: 999px;
  padding: 11px 20px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 800;
  background: linear-gradient(120deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(46, 156, 63, 0.3);
  transition: transform .1s ease, box-shadow .1s ease;
}

button:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(46, 156, 63, 0.38); }
button:active { transform: translateY(0); }

.login-card button[type="submit"] { width: 100%; padding: 12px; font-size: 15px; }

button.secondary {
  background: var(--card);
  color: var(--primary-dark);
  border: 2px solid var(--border);
  box-shadow: none;
}
button.secondary:hover { border-color: var(--primary-light); box-shadow: none; }

button.danger { background: linear-gradient(120deg, var(--danger) 0%, #f43f5e 100%); box-shadow: 0 2px 8px rgba(225,29,72,.28); }

button.small { padding: 6px 12px; font-size: 12px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0 16px;
}

@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.error {
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
  margin-top: 10px;
  min-height: 16px;
}

.ok-msg {
  color: var(--ok);
  font-size: 13px;
  font-weight: 700;
  margin-top: 10px;
}

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

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
  background: var(--primary-bg);
}

tbody tr:hover { background: var(--bg-accent); }

.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.table-wrap table { border: none; }
.table-wrap th:first-child, .table-wrap td:first-child { padding-left: 14px; }

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

.tabs button {
  background: var(--card);
  color: var(--primary-dark);
  border: 2px solid var(--border);
  box-shadow: none;
  font-weight: 700;
}
.tabs button:hover { transform: none; border-color: var(--primary-light); }

.tabs button.active {
  background: linear-gradient(120deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(46, 156, 63, 0.3);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadein .2s ease; }

/* Menu movil: va DESPUES de la regla base ".tabs" a proposito, para que
   siempre gane por orden en el codigo (misma especificidad que la regla
   de arriba). Si se pone antes, la regla base la pisa y el menu queda
   siempre visible sin importar el JavaScript. */
@media (max-width: 760px) {
  .hamburger {
    display: block;
    position: fixed;
    top: 14px;
    right: 16px;
    z-index: 10000;
  }
  header.topbar { padding-right: 60px; }
  header.topbar > div { flex: 1; text-align: center; min-width: 0; }
  header.topbar h1 { justify-content: center; }
  .header-logo { height: 70px; width: 70px; margin: -14px 0; }
  .tabs {
    display: none;
    flex-direction: column;
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 78%;
    max-width: 320px;
    background: var(--card);
    z-index: 9999;
    padding: 70px 16px 16px;
    box-shadow: -8px 0 24px rgba(0,0,0,.2);
    overflow-y: auto;
  }
  .tabs.abierto { display: flex; }
  #menu-overlay.abierto { display: block; }
  .tabs button { width: 100%; text-align: left; }
}

@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 5px solid var(--primary);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.stat:nth-child(6n+2) { border-left-color: var(--orange); }
.stat:nth-child(6n+3) { border-left-color: var(--yellow-dark); }
.stat:nth-child(6n+4) { border-left-color: var(--orange-dark); }
.stat:nth-child(6n+5) { border-left-color: var(--primary-dark); }
.stat:nth-child(6n+6) { border-left-color: var(--ok); }

.stat .label { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
.stat .value { font-size: 24px; font-weight: 900; margin-top: 6px; color: var(--text); }
.stat .value.neg { color: var(--danger); }
.stat .value.pos { color: var(--ok); }

.preview-box {
  background: var(--primary-bg);
  border: 2px dashed var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-top: 16px;
  font-size: 14px;
}

.preview-box .row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
}

.preview-box .row strong { color: var(--primary-dark); font-size: 15px; }

.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.tag.pos { background: var(--ok-bg); color: var(--ok); }
.tag.neg { background: var(--danger-bg); color: var(--danger); }
.tag.neutral { background: var(--border); color: var(--muted); }

.muted { color: var(--muted); }

.actions-row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.inline-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.inline-form > div { flex: 1; min-width: 140px; }

.chart-wrap { position: relative; height: 260px; }
@media (max-width: 640px) { .chart-row { grid-template-columns: 1fr; } .chart-wrap { height: 220px; } }

.subtabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }

.subtab-btn {
  background: var(--card);
  color: var(--primary-dark);
  border: 2px solid var(--border);
  box-shadow: none;
  font-weight: 700;
}
.subtab-btn:hover { transform: none; border-color: var(--primary-light); }
.subtab-btn.active {
  background: linear-gradient(120deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(46, 156, 63, 0.3);
}

.subtab-panel { display: none; }
.subtab-panel.active { display: block; animation: fadein .2s ease; }

.temas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.tema-opcion {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  cursor: pointer;
  background: var(--card);
  text-align: left;
}

.tema-opcion.activo { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }

.tema-swatch {
  height: 44px;
  border-radius: 8px;
  margin-bottom: 8px;
  display: flex;
  overflow: hidden;
}

.tema-swatch span { flex: 1; }

.tema-nombre { font-size: 12px; font-weight: 700; color: var(--text); }

/* ---------- reporte imprimible (hoja carta) ---------- */

#reporte-imprimir { display: none; }

.rep-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid #16532a;
  padding-bottom: 10px;
  margin-bottom: 16px;
}
.rep-brand { font-size: 20px; font-weight: 900; color: #16532a; }
.rep-brand span { font-weight: 700; color: #444; font-size: 13px; display: block; margin-top: 2px; }
.rep-periodo { text-align: right; font-size: 13px; color: #444; }
.rep-periodo strong { display: block; font-size: 16px; color: #16532a; }

.rep-summary {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}
.rep-summary td { padding: 7px 4px; border-bottom: 1px solid #ddd; font-size: 13px; }
.rep-summary td:first-child { color: #333; }
.rep-summary td:last-child { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.rep-summary tr.rep-total td { border-top: 2px solid #16532a; border-bottom: none; padding-top: 10px; font-size: 15px; }
.rep-summary tr.rep-total td:last-child { color: #16532a; }

.rep-section-title {
  font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  color: #16532a; margin: 18px 0 8px; border-bottom: 1px solid #ccc; padding-bottom: 4px;
}

.rep-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.rep-table th, .rep-table td { border: 1px solid #ccc; padding: 6px 8px; text-align: left; font-variant-numeric: tabular-nums; }
.rep-table th { background: #eefbe9; color: #16532a; font-weight: 800; }

.rep-footer { margin-top: 24px; font-size: 11px; color: #888; text-align: center; border-top: 1px solid #ddd; padding-top: 8px; }
.rep-charts { display: flex; justify-content: center; align-items: flex-start; gap: 18px; flex-wrap: wrap; margin-bottom: 18px; }
.rep-charts img { display: block; }

/* ---------- alertas en vivo (toast) ---------- */

#toast-container {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 320px;
}

.toast {
  background: var(--card);
  border-left: 5px solid var(--primary);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  font-size: 13px;
  animation: toast-in .25s ease;
}

.toast strong { display: block; color: var(--primary-dark); font-size: 14px; margin-bottom: 2px; }

@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

@media print {
  @page { size: letter; margin: 16mm 14mm; }

  body * { visibility: hidden; }
  #reporte-imprimir, #reporte-imprimir * { visibility: visible; }
  #reporte-imprimir {
    display: block;
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    color: #111;
    background: #fff;
  }
}
