:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #273549;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
}

/* ── Light mode overrides ── */
html.light-mode {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #cbd5e1;
  --shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
}
html.light-mode body { background: var(--bg) !important; color: var(--text) !important; }
html.light-mode tbody tr:hover { background: #e2e8f0; }
html.light-mode thead tr { background: #e2e8f0; }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Button reset — elimina estilos default del browser ── */
button {
  font-family: inherit;
  font-size: inherit;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  padding: 0;
  line-height: inherit;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

/* ── Layout ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.app-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}

.card--sm { max-width: 420px; width: 100%; }
.card__title { font-size: 1.25rem; font-weight: 600; margin-bottom: 1.5rem; }
.card__subtitle { color: var(--text-muted); font-size: .875rem; margin-bottom: 1.5rem; }

/* ── Form ── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .375rem; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: .625rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .625rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-dark); }
.btn--danger  { background: var(--danger); color: #fff; }
.btn--danger:hover  { background: #b91c1c; }
.btn--ghost   { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn--ghost:hover { background: var(--bg); }
.btn--full    { width: 100%; }
.btn--sm      { padding: .375rem .75rem; font-size: .875rem; }

/* ── Flash messages ── */
.flash {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
}
.flash--error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flash--success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.flash--warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead tr { background: var(--bg); }
th, td { padding: .625rem .75rem; text-align: left; border-bottom: 1px solid var(--border); }
th { font-weight: 600; color: var(--text-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
tbody tr:hover { background: var(--surface-2); }

/* ── Branding ── */
.brand { font-size: 1.5rem; font-weight: 700; color: var(--primary); letter-spacing: -.02em; }

/* ── Stat grid (cierre report) ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.stat { background: var(--bg); padding: 1rem; border-radius: var(--radius); }
.stat__label { font-size: .8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.stat__value { font-size: 1.375rem; font-weight: 700; margin-top: .25rem; }
.stat--danger .stat__value { color: var(--danger); }
.stat--success .stat__value { color: var(--success); }

/* ── Nav ── */
.nav { background: var(--surface); border-bottom: 1px solid var(--border); padding: .75rem 1.5rem; display: flex; align-items: center; gap: 1.25rem; margin-bottom: 1.5rem; }
.nav__brand { font-weight: 800; color: var(--primary); font-size: 1.5rem; letter-spacing: -.02em; line-height: 1; }
.nav__logo  { height: 48px; max-width: 160px; object-fit: contain; border-radius: 6px; }
.nav__user  { margin-left: auto; font-size: .875rem; color: var(--text-muted); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .app-wrap { padding: 1rem .75rem; }
  .card { padding: 1.25rem; }
  .nav { padding: .5rem .75rem; gap: .75rem; flex-wrap: wrap; }
  .nav__user { margin-left: auto; }
  .card__title { font-size: 1.1rem; }
}

@media (max-width: 480px) {
  .app-wrap { padding: .75rem .5rem; }
  .card { padding: 1rem; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .btn { font-size: .875rem; padding: .5rem 1rem; }
}

/* Prevent horizontal overflow globally */
img, table { max-width: 100%; }
.nav { overflow-x: auto; }

/* Utility — stack flex on small screens */
@media (max-width: 600px) {
  .flex-stack { flex-direction: column !important; }
  .flex-stack > * { width: 100%; }
}

/* ── Global Pager ─────────────────────────────────────────── */
.pager {
  display: flex; gap: .3rem; padding: .75rem 1rem;
  justify-content: center; align-items: center;
  flex-wrap: wrap;
}
.pager a {
  min-width: 2rem; height: 2rem; padding: 0 .5rem;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  font-size: .8rem; font-weight: 600;
  text-decoration: none;
  border: 1.5px solid var(--border);
  color: var(--text);
  background: var(--surface);
  transition: all .15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  cursor: pointer;
  user-select: none;
}
.pager a:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  transform: translateY(-1px);
}
.pager a:active { transform: translateY(0); }
.pager a.active {
  background: var(--primary); color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 40%, transparent);
  pointer-events: none;
}
.pager-sep  { font-size: .85rem; color: var(--text-muted); padding: 0 .15rem; }
.pager-info { font-size: .75rem; color: var(--text-muted); margin-left: .5rem; font-weight: 500; }

/* ── Aviso pago admin banner ─────────────────────────── */
.aviso-pago-admin {
    display: flex;
    align-items: center;
    gap: .6rem;
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
    border-left: 4px solid #ff9800;
    padding: .65rem 1.1rem;
    font-size: .92rem;
    position: sticky;
    top: 0;
    z-index: 9999;
}
.aviso-pago-icon {
    font-size: 1.25rem;
    animation: aviso-blink 1s step-start infinite;
}
@keyframes aviso-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

/* === Utility Layer (CSP Phase 3) === */

/* Visibility / Display */
.hidden       { display: none !important; }
.d-none       { display: none !important; }
.d-block      { display: block; }
.d-flex       { display: flex; }
.d-grid       { display: grid; }
.d-inline     { display: inline; }
.d-inline-block { display: inline-block; }
.d-inline-flex { display: inline-flex; }

/* Flex utilities */
.flex-center  { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-end     { display: flex; align-items: center; justify-content: flex-end; }
.flex-start   { display: flex; align-items: center; justify-content: flex-start; }
.flex-col     { display: flex; flex-direction: column; }
.flex-wrap    { flex-wrap: wrap; }
.flex-1       { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.align-center { align-items: center; }
.align-start  { align-items: flex-start; }
.align-end    { align-items: flex-end; }
.justify-center  { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.gap-xs { gap: .25rem; }
.gap-sm { gap: .5rem; }
.gap-md { gap: 1rem; }
.gap-lg { gap: 1.5rem; }

/* Grid helpers */
.grid-2col    { display: grid; grid-template-columns: 1fr 1fr; }
.grid-2col-sm { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; }

/* Typography */
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.text-left    { text-align: left; }
.font-mono    { font-family: monospace; }
.fw-bold      { font-weight: 700; }
.fw-600       { font-weight: 600; }
.fw-normal    { font-weight: normal; }
.fs-xs        { font-size: .75rem; }
.fs-sm        { font-size: .8rem; }
.fs-md        { font-size: .9rem; }
.fs-lg        { font-size: 1.1rem; }
.no-underline { text-decoration: none; }
.uppercase    { text-transform: uppercase; }
.white-space-nowrap { white-space: nowrap; }

/* Color / State */
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-muted   { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-white   { color: #fff; }
.is-danger    { color: var(--danger); }
.is-success   { color: var(--success); }
.is-warning   { color: var(--warning); }
.is-muted     { color: var(--text-muted); }
.is-inactive  { opacity: .5; color: var(--text-muted); }
.bg-danger    { background: var(--danger); color: #fff; }
.bg-success   { background: var(--success); color: #fff; }
.bg-warning   { background: var(--warning); color: #000; }
.bg-surface2  { background: var(--surface-2); }
.bg-danger-subtle  { background: color-mix(in srgb, var(--danger) 8%, transparent); }
.bg-success-subtle { background: color-mix(in srgb, var(--success) 8%, transparent); }

/* Spacing */
.m-0   { margin: 0; }
.mt-0  { margin-top: 0; }
.mt-xs { margin-top: .25rem; }
.mt-sm { margin-top: .4rem; }
.mb-0  { margin-bottom: 0; }
.mb-sm { margin-bottom: .5rem; }
.mb-md { margin-bottom: .75rem; }
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }
.p-0   { padding: 0; }
.p-sm  { padding: .5rem .75rem; }
.p-md  { padding: 1rem; }
.p-lg  { padding: 1.5rem; }
.px-sm { padding-left: .5rem; padding-right: .5rem; }
.px-md { padding-left: 1rem; padding-right: 1rem; }
.py-sm { padding-top: .5rem; padding-bottom: .5rem; }
.border-radius-full { border-radius: 999px; }

/* Width / Sizing */
.w-full  { width: 100%; }
.w-auto  { width: auto; }
.min-w-0 { min-width: 0; }

/* Borders / Misc */
.rounded     { border-radius: 6px; }
.rounded-sm  { border-radius: 4px; }
.cursor-pointer { cursor: pointer; }
.overflow-hidden { overflow: hidden; }
.relative    { position: relative; }
.pos-relative { position: relative; }
.absolute    { position: absolute; }

/* Component modifiers */
/* Nav button — repeated in 30+ files */
.btn--nav {
  font-size: .8rem;
  font-weight: 700;
  padding: .3rem .8rem;
  background: var(--primary);
  color: #fff;
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
}

/* Pill badge — repeated across Configuracion, Omnicanalidad, Ventas */
.badge-pill {
  display: inline-flex;
  align-items: center;
  font-size: .72rem;
  font-weight: 700;
  padding: .2rem .55rem;
  border-radius: 99px;
}

/* Moneda toggle buttons (pos.php, pos_fruteria.php, pos_carrito.php) */
.btn-moneda {
  padding: .25rem .75rem;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-moneda--active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.btn-moneda--inactive {
  border: 2px solid var(--border);
  background: transparent;
  color: inherit;
}
