/* =====================================================================
   POS design system.
   Every colour is a CSS variable so a tenant's `brand` jsonb can restyle
   the whole app at runtime by overriding :root — that is the white-label
   mechanism. Do not hardcode colours anywhere else.
   ===================================================================== */
:root {
  --brand:        #4f46e5;
  --brand-ink:    #ffffff;
  --accent:       #0ea5e9;
  --ok:           #16a34a;
  --warn:         #f59e0b;
  --danger:       #dc2626;

  --bg:           #f1f5f9;
  --surface:      #ffffff;
  --surface-2:    #f8fafc;
  --border:       #e2e8f0;
  --ink:          #0f172a;
  --ink-2:        #475569;
  --ink-3:        #94a3b8;

  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 1px 2px rgba(15,23,42,.06), 0 4px 12px rgba(15,23,42,.05);
  --shadow-lg:    0 10px 40px rgba(15,23,42,.16);
  --font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --tap:          48px;              /* minimum touch target */
}

[data-theme="dark"] {
  --bg:        #0b1120;
  --surface:   #131c31;
  --surface-2: #1b2540;
  --border:    #26314f;
  --ink:       #e8edf7;
  --ink-2:     #a3b0c9;
  --ink-3:     #6c7a99;
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.3);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .6rem .75rem;
  width: 100%;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
label { display: block; font-size: .8rem; font-weight: 600; color: var(--ink-2); margin-bottom: .3rem; }

/* ---------------------------------------------------------- buttons */
.btn {
  /* los <a class="btn"> heredan el subrayado del navegador: quitarlo aquí
     evita tener que repetir text-decoration en cada enlace-botón */
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: var(--tap); padding: 0 1.1rem;
  border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border);
  font-weight: 600; color: var(--ink);
  transition: transform .06s, filter .12s, background .12s;
  user-select: none; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.btn-ok      { background: var(--ok);     color: #fff; border-color: transparent; }
.btn-danger  { background: var(--danger); color: #fff; border-color: transparent; }
.btn-ghost   { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-lg      { min-height: 60px; font-size: 1.05rem; }
.btn-block   { width: 100%; }
/* `.small` shrinks the label, never the hit area: 44px is the minimum a
   finger can reliably hit, and this app is used on tablets all day. */
.btn.small   { font-size: .84rem; padding: 0 .7rem; min-height: 44px; }

/* ---------------------------------------------------------- surfaces */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.pill {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .2rem .6rem; border-radius: 999px;
  font-size: .75rem; font-weight: 700;
  background: var(--surface-2); color: var(--ink-2);
}
.pill-ok    { background: color-mix(in srgb, var(--ok) 15%, transparent);     color: var(--ok); }
.pill-warn  { background: color-mix(in srgb, var(--warn) 18%, transparent);   color: #b45309; }
.pill-danger{ background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

/* ---------------------------------------------------------- utility */
.row     { display: flex; align-items: center; gap: .6rem; }
.col     { display: flex; flex-direction: column; gap: .6rem; }
.grow    { flex: 1; }
.muted   { color: var(--ink-3); }
.small   { font-size: .82rem; }
.mono    { font-variant-numeric: tabular-nums; }
.right   { text-align: right; }
.hidden  { display: none !important; }
.scroll  { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.center  { display: grid; place-items: center; }

/* ------------------------------------------------------------ toast */
#toasts {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  z-index: 9999; display: flex; flex-direction: column; gap: .5rem; align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--ink); color: var(--bg);
  padding: .75rem 1.15rem; border-radius: 999px;
  box-shadow: var(--shadow-lg); font-weight: 600; font-size: .9rem;
  animation: toast-in .22s ease-out;
  max-width: 90vw;
}
.toast-err { background: var(--danger); color: #fff; }
.toast-ok  { background: var(--ok);     color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px); } }

/* ------------------------------------------------------------ modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(2,6,23,.55);
  display: grid; place-items: center; z-index: 500; padding: 1rem;
  animation: fade .15s;
}
.modal {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); width: min(560px, 100%);
  max-height: 88vh; display: flex; flex-direction: column;
  animation: pop .18s cubic-bezier(.2,.9,.3,1.2);
}
.modal-head { padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--border);
              display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 1.05rem; }
.modal-body { padding: 1.25rem; overflow-y: auto; }
.modal-foot { padding: 1rem 1.25rem; border-top: 1px solid var(--border);
              display: flex; gap: .6rem; justify-content: flex-end; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop  { from { opacity: 0; transform: scale(.96) translateY(8px); } }

/* ----------------------------------------------------------- spinner */
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------- offline */
.offline-bar {
  background: var(--warn); color: #422006;
  text-align: center; padding: .35rem; font-size: .8rem; font-weight: 700;
}
