:root {
  --bg: #eef2f6;
  --bg-deep: #e3eaf2;
  --surface: #ffffff;
  --ink: #152033;
  --muted: #6b7a90;
  --line: #d7e0ea;
  --brand: #05558c;
  --brand-dark: #043f68;
  --accent: #0a7ea4;
  --ok: #147a4a;
  --ok-bg: #e7f7ef;
  --warn: #9a5b00;
  --danger: #c0392b;
  --danger-bg: #fdecec;
  --violet: #5b4bcc;
  --violet-bg: #ece9ff;
  --sale: #2d9f78;
  --sale-dark: #1e7a5a;
  --shadow: 0 12px 40px rgba(15, 35, 60, 0.08);
  --radius: 16px;
  --sidebar: 72px;
  --sidebar-expanded: 232px;
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Syne", "DM Sans", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(0,169,165,.12), transparent 55%),
    radial-gradient(900px 400px at 100% 0%, rgba(11,110,153,.12), transparent 50%),
    linear-gradient(180deg, var(--bg), var(--bg-deep));
  min-height: 100vh;
}

a { color: var(--brand); text-decoration: none; }
h1,h2,h3 { font-family: var(--display); margin: 0 0 .35rem; letter-spacing: -.02em; }
p { margin: 0; }
.muted { color: var(--muted); font-size: .92rem; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar);
  background: linear-gradient(180deg, #0d3148 0%, #0a2435 100%);
  color: #e8f2f8;
  padding: .85rem .55rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  transition: width .22s ease, padding .22s ease;
  overflow: hidden;
  flex-shrink: 0;
}
.sidebar.expanded {
  width: var(--sidebar-expanded);
  padding: 1rem .85rem;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .45rem .25rem .9rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: .75rem;
  min-height: 52px;
}
.brand-logo { height: auto; max-width: 100%; filter: brightness(0) invert(1); }
.brand-logo-full { width: 118px; display: none; }
.brand-logo-mini { width: 34px; display: block; }
.sidebar.expanded .brand-logo-full { display: block; }
.sidebar.expanded .brand-logo-mini { display: none; }
.sidebar-nav { display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.sidebar-nav a {
  color: rgba(232,242,248,.82);
  padding: .7rem;
  border-radius: 12px;
  font-weight: 500;
  transition: .18s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .65rem;
  white-space: nowrap;
}
.sidebar.expanded .sidebar-nav a {
  justify-content: flex-start;
  padding: .7rem .85rem;
}
.sidebar-nav a span { display: none; }
.sidebar.expanded .sidebar-nav a span { display: inline; }
.sidebar-nav a i { font-size: 1.2rem; opacity: .95; flex: 0 0 auto; }
.sidebar-nav a:hover, .sidebar-nav a.active {
  background: rgba(255,255,255,.12);
  color: #fff;
}
.sidebar-footer { margin-top: auto; padding-top: .85rem; border-top: 1px solid rgba(255,255,255,.08); }
.user-chip { display: none; margin-bottom: .65rem; padding: 0 .35rem; }
.sidebar.expanded .user-chip { display: block; }
.user-chip span { display: block; font-weight: 600; font-size: .9rem; }
.user-chip small { color: rgba(232,242,248,.65); }
.btn-logout { justify-content: center; padding: .65rem; }
.btn-logout span { display: none; }
.sidebar.expanded .btn-logout span { display: inline; }
.sidebar.expanded .btn-logout { justify-content: center; }

.main-wrap { flex: 1; min-width: 0; position: relative; }
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.25rem 1.5rem .5rem;
}
.topbar-left { flex: 1; min-width: 0; }
.topbar-brand {
  margin-left: auto;
  text-align: right;
  flex: 0 0 auto;
  padding: .35rem .15rem;
}
.topbar-brand strong {
  display: block;
  font-family: var(--display);
  font-size: 1.05rem;
  color: var(--brand-dark);
  line-height: 1.15;
}
.topbar-brand small {
  display: block;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 600;
}
.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  width: 40px; height: 40px;
  font-size: 1.15rem;
  cursor: pointer;
  flex: 0 0 auto;
  color: var(--brand-dark);
}
.menu-toggle:hover { background: #f3f8fc; }
.content { padding: .75rem 1.5rem 2rem; }

.card {
  background: var(--surface);
  border: 1px solid rgba(215,224,234,.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
.card + .card { margin-top: 1rem; }
.card-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.page-center {
  display: flex;
  justify-content: center;
  width: 100%;
}
.card-form {
  width: min(560px, 100%);
  margin: 0 auto;
}
.form-divider {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1rem 0 1.1rem;
}
.fecha-unica {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  white-space: nowrap;
  font-weight: 600;
}
.grid-3 .btn {
  min-height: 44px;
  padding: .75rem .9rem;
  text-align: center;
}
.stats .stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
}
.stats .stat strong { display: block; font-size: 1.55rem; font-family: var(--display); margin-top: .25rem; }
.stats .stat span { color: var(--muted); font-size: .9rem; }

label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: .28rem; color: #314055; }
.form-row { margin-bottom: .7rem; }
.form-row.inline { display: flex; gap: .5rem; align-items: end; }
.form-row.inline > * { flex: 1; }
.form-row.inline .btn { flex: 0 0 auto; }

input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="search"], select, textarea {
  width: 100%;
  border: 1px solid #c9d5e3;
  background: #fbfcfe;
  border-radius: 9px;
  padding: .48rem .7rem;
  font: inherit;
  font-size: .9rem;
  color: var(--ink);
  outline: none;
  transition: .15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(5,85,140,.12);
  background: #fff;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: none; border-radius: 10px;
  padding: .55rem .9rem;
  font: inherit; font-size: .9rem; font-weight: 650;
  cursor: pointer;
  transition: .15s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff; }
.btn-accent { background: linear-gradient(135deg, var(--accent), #066a8a); color: #fff; }
.btn-success { background: linear-gradient(135deg, var(--sale), var(--sale-dark)); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-lg { padding: .72rem 1rem; font-size: .95rem; border-radius: 12px; font-weight: 700; }
.btn-ghost {
  background: transparent; color: #d8e8f2;
  border: 1px solid rgba(255,255,255,.18);
}
.btn-light { background: #fff; color: var(--ink); border: 1px solid #c9d5e3; }
.btn-sm { padding: .38rem .65rem; border-radius: 8px; font-size: .82rem; }
.btn-block { width: 100%; }
.btn-icon {
  width: 32px; height: 32px; padding: 0; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-view { background: #1d6fd4; color: #fff; }
.btn-more { background: #eef2f6; color: #445; border: 1px solid var(--line); }

.alert {
  padding: .9rem 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  font-weight: 500;
}
.alert-success { background: var(--ok-bg); color: var(--ok); }
.alert-error { background: var(--danger-bg); color: var(--danger); }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}
.table-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  scrollbar-width: thin;
  scrollbar-color: #9eb4c8 transparent;
}
.table-scroll::-webkit-scrollbar { height: 8px; }
.table-scroll::-webkit-scrollbar-thumb {
  background: #9eb4c8;
  border-radius: 99px;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
  table-layout: auto;
}
.table-wrap .data.data-nowrap { min-width: 640px; }
.table-wrap { max-width: 100%; }
table.data.data-nowrap th,
table.data.data-nowrap td {
  white-space: nowrap;
}
table.data.data-nowrap td .product-list,
table.data.data-nowrap td .client-name {
  white-space: nowrap;
}
.text-ok { color: var(--ok); }
.check-line { display: flex; align-items: center; gap: .35rem; margin-top: .2rem; }
table.data th {
  text-align: center;
  font-size: .72rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--brand);
  font-weight: 800;
  background: #eef5fa;
  padding: .55rem .5rem;
  border-bottom: 2px solid #b9d0e3;
  white-space: nowrap;
}
table.data td {
  padding: .5rem .45rem;
  border-bottom: 1px solid #edf1f6;
  vertical-align: middle;
  font-size: .86rem;
  text-align: center;
}
table.data.table-compact th { padding: .45rem .4rem; font-size: .68rem; }
table.data.table-compact td { padding: .4rem .35rem; font-size: .82rem; }
table.data.data-center th,
table.data.data-center td {
  text-align: center;
}
table.data tr:nth-child(even) td { background: #fbfcfe; }
table.data tr:hover td { background: #f3f8fc; }
.comp-id { color: var(--brand); font-weight: 700; display: block; text-align: center; }
.comp-type { color: var(--muted); font-size: .78rem; font-weight: 700; letter-spacing: .03em; display: block; text-align: center; }
.client-name { font-weight: 700; text-transform: uppercase; text-align: center; }
.product-list { margin: 0; padding: 0; list-style: none; color: #334; text-align: center; }
.product-list li { margin: .15rem 0; }
.money { white-space: nowrap; font-variant-numeric: tabular-nums; text-align: center; }
select.select-center,
input.select-center {
  text-align: center;
  text-align-last: center;
}
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .28rem .7rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-violet { background: var(--violet-bg); color: var(--violet); }

/* Acciones de tabla: una sola fila de iconos */
.actions-cell .actions,
td.actions .actions,
.actions.actions-row {
  display: inline-flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: center !important;
  gap: .4rem;
  width: max-content;
  margin: 0 auto;
  white-space: nowrap !important;
}
.actions-cell .actions > a,
.actions-cell .actions > form,
.actions-cell .actions > button,
td.actions > a,
td.actions > form,
td.actions > button,
.actions.actions-row > a,
.actions.actions-row > form,
.actions.actions-row > button {
  display: inline-flex !important;
  flex: 0 0 auto !important;
  margin: 0 !important;
  width: auto !important;
}
.actions-cell .btn-icon,
.actions.actions-row .btn-icon,
td.actions .btn-icon {
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  margin: 0 !important;
  flex: 0 0 auto !important;
}
/* Footer de modales / botones de texto (NO forzar tamaño icono) */
.actions.actions-end {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: .55rem;
  width: 100%;
  margin: 0;
  white-space: normal;
}
.actions.actions-end .btn {
  width: auto !important;
  height: auto !important;
  min-width: 0 !important;
  padding: .55rem .95rem;
  flex: 0 0 auto;
}
th.actions-cell,
td.actions-cell,
table.data th.actions-cell,
table.data td.actions-cell {
  width: 1%;
  min-width: 132px;
  white-space: nowrap !important;
  word-break: keep-all !important;
  overflow-wrap: normal !important;
  vertical-align: middle;
}
.btn-edit { background: #0a7ea4; color: #fff; }

.filters {
  display: grid;
  grid-template-columns: 2fr 1.1fr 1.1fr 1.1fr auto;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1.15rem;
}
.filters .btn { min-width: 120px; }

/* Auth */
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(800px 400px at 20% 10%, rgba(0,169,165,.18), transparent 60%),
    radial-gradient(700px 380px at 90% 80%, rgba(11,110,153,.2), transparent 55%),
    linear-gradient(160deg, #0a2435, #0d3a52 45%, #0b6e99);
}
.auth-card {
  width: min(440px, 100%);
  background: rgba(255,255,255,.97);
  border-radius: 22px;
  padding: 2rem 1.75rem;
  box-shadow: 0 30px 80px rgba(0,0,0,.28);
}
.auth-card-token {
  width: min(420px, 100%);
  padding: 2.35rem 1.85rem 2.1rem;
  text-align: center;
  border: 1px solid rgba(255,255,255,.35);
}
.auth-card .logo-wrap { text-align: center; margin-bottom: 1.25rem; }
.auth-card .logo-wrap img { width: 120px; }
.auth-card h1 {
  text-align: center;
  font-family: Syne, "DM Sans", sans-serif;
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -.01em;
  margin: 0 0 .35rem;
  color: #0a2435;
}
.auth-card .lead {
  text-align: center;
  color: var(--muted);
  margin: 0 0 1.55rem;
  font-size: .95rem;
  font-weight: 500;
}
.tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: .4rem;
  background: #eef3f8; padding: .35rem; border-radius: 12px; margin-bottom: 1.2rem;
}
.tabs button {
  border: 0; background: transparent; padding: .65rem;
  border-radius: 10px; font: inherit; font-weight: 650; cursor: pointer; color: var(--muted);
}
.tabs button.active { background: #fff; color: var(--ink); box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.auth-hint {
  margin-top: 1rem; font-size: .82rem; color: var(--muted); text-align: center; line-height: 1.45;
}

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 20, 35, .55);
  display: none; align-items: center; justify-content: center;
  padding: 1rem; z-index: 100;
}
.modal-backdrop.open {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: .6rem;
}
.modal {
  width: min(860px, 100%);
  max-height: min(92vh, 980px);
  overflow: auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0,0,0,.28);
}
.modal.modal-cliente {
  width: min(460px, 94vw);
  max-height: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal.modal-cliente .modal-bar {
  position: static;
  flex: 0 0 auto;
  padding: 1rem 1.25rem;
}
.modal.modal-cliente .modal-body {
  flex: 0 0 auto;
  overflow: hidden;
  padding: 1.25rem 1.35rem 0.35rem;
}
.modal.modal-cliente .modal-foot {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .55rem;
  padding: 1rem 1.35rem 1.25rem;
  border-top: 1px solid #edf1f6;
  background: #fbfcfe;
}
.modal.modal-cliente .modal-foot .btn {
  width: auto;
  min-width: 120px;
  justify-content: center;
}
.modal.modal-cliente .inline-actions {
  flex-wrap: nowrap;
}
.modal.modal-cliente .inline-actions input {
  min-width: 0;
  flex: 1 1 auto;
}
.modal.modal-cliente .inline-actions .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}
.modal.modal-cliente .pos-client-msg {
  margin: .75rem 0 0;
}
.modal.modal-sm { width: min(400px, 100%); }
.modal.modal-receipt {
  width: min(680px, 96vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal.modal-receipt .modal-bar {
  padding: .65rem .9rem;
  flex: 0 0 auto;
}
.modal.modal-receipt .modal-body {
  /* El scroll (si hay) es solo del detalle; los botones quedan fijos abajo */
  overflow-x: hidden;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0;
  display: block;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.modal.modal-receipt .receipt-modal {
  border: 0;
  border-radius: 0;
  display: block;
  overflow: visible;
}
.modal.modal-receipt .modal-foot {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: .55rem;
  padding: .75rem 1rem;
  border-top: 1px solid #edf1f6;
  background: #fbfcfe;
}
.modal.modal-receipt .modal-foot[hidden] {
  display: none !important;
}
.modal.modal-receipt .modal-foot .btn {
  width: auto !important;
  height: auto !important;
  min-width: 120px !important;
  padding: .55rem 1rem;
  justify-content: center;
}
.inline-actions {
  display: flex; gap: .55rem; align-items: stretch;
}
.inline-actions input { flex: 1; }
.inline-actions .btn { flex: 0 0 auto; min-width: 100px; }
.inline-vendedor { margin: 0; }
.inline-vendedor .inline-actions { gap: .35rem; align-items: center; }
.inline-vendedor .inline-actions input {
  padding: .35rem .45rem;
  font-size: .78rem;
  min-width: 0;
}
.inline-vendedor .inline-actions .btn {
  min-width: 34px;
  padding: .35rem .45rem;
}

/* POS / Generar — compacto, sin scroll */
.pos-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(260px, .85fr);
  gap: .75rem;
  align-items: stretch;
  max-height: calc(100vh - 88px);
  overflow: hidden;
}
.pos-main, .pos-side { margin: 0; min-height: 0; }
.pos-main.card, .pos-side.card { padding: .85rem; }
.pos-main.card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pos-client-bar {
  display: flex; gap: .65rem; align-items: center; justify-content: space-between;
  flex-wrap: wrap; margin-bottom: .65rem;
  padding: .55rem .7rem;
  background: #f4f8fc;
  border: 1px solid #d5e3ef;
  border-radius: 10px;
  flex: 0 0 auto;
}
.pos-client-display {
  display: flex; gap: .55rem; align-items: center; min-width: 0;
}
.pos-client-display i { font-size: 1.45rem; color: var(--brand); }
.pos-client-display strong { display: block; font-size: .92rem; text-align: left; line-height: 1.2; }
.pos-client-display small { color: var(--muted); display: block; text-align: left; font-size: .78rem; }
.pos-client-display.ready strong { color: var(--brand-dark); }
.pos-section-label {
  font-size: .7rem; font-weight: 800; letter-spacing: .05em;
  text-transform: uppercase; color: var(--brand); margin-bottom: .4rem;
  text-align: left;
}
.pos-services { flex: 0 0 auto; }
.service-chips {
  display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .55rem;
  justify-content: flex-start;
}
.service-chip {
  border: 1px solid #c9d5e3;
  background: #fff;
  color: #2a3545;
  border-radius: 999px;
  padding: .28rem .7rem;
  font: inherit; font-weight: 650; font-size: .78rem;
  cursor: pointer; transition: .15s ease;
}
.service-chip:hover, .service-chip.active {
  background: var(--brand); color: #fff; border-color: var(--brand);
}
.pos-items-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  border-radius: 10px;
}
.pos-items-wrap.table-wrap,
.pos-items-wrap.table-scroll {
  overflow: hidden !important;
}
#itemsTable.data {
  min-width: 0 !important;
  width: 100%;
  table-layout: fixed;
}
#itemsTable th,
#itemsTable td {
  padding: .35rem .35rem !important;
  font-size: .78rem;
  text-align: center;
  vertical-align: middle;
}
#itemsTable th { padding: .45rem .35rem !important; font-size: .7rem; }
#itemsTable .table-select,
#itemsTable input[type="number"],
#itemsTable input[type="text"],
#itemsTable select {
  padding: .32rem .4rem;
  font-size: .78rem;
  border-radius: 7px;
  min-width: 0;
}
#itemsTable .btn-icon { width: 28px; height: 28px; border-radius: 7px; }
.pos-empty-row td {
  color: var(--muted); padding: 1.2rem .5rem !important; font-style: italic; text-align: center;
  font-size: .82rem !important;
}
.pos-side {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pos-side-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: .55rem; gap: .5rem; flex: 0 0 auto;
}
.pos-side-head h3 { margin: 0; font-size: 1.05rem; text-align: left; }
.pos-side .form-row { margin-bottom: .55rem; flex: 0 0 auto; }
.pos-side .form-row > label { text-align: left; font-size: .75rem; }
.pos-side input, .pos-side select {
  padding: .42rem .65rem;
  font-size: .85rem;
}
.pay-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem;
}
.pay-chip { cursor: pointer; margin: 0; }
.pay-chip input { display: none; }
.pay-chip span {
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  border: 1px solid #c9d5e3; background: #fff;
  border-radius: 8px; padding: .4rem .25rem;
  font-size: .72rem; font-weight: 700; min-height: 34px;
  transition: .15s ease;
}
.pay-chip input:checked + span {
  background: var(--brand); color: #fff; border-color: var(--brand);
}
.pos-totals {
  margin: .65rem 0;
  background: linear-gradient(135deg, #043f68, #05558c);
  color: #fff; border-radius: 10px; padding: .65rem .8rem;
  flex: 0 0 auto;
}
.pos-total-row {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  margin-bottom: .28rem;
}
.pos-total-row span { font-size: .85rem; }
.pos-total-row strong { font-size: 1.2rem; font-family: var(--display); }
.pos-total-row.muted-row span,
.pos-total-row.muted-row strong {
  font-size: .8rem;
  font-weight: 600;
  opacity: .88;
  font-family: inherit;
}
.pos-totals > .pos-total-row:last-child,
.pos-totals > .pos-total-row:last-of-type {
  margin-top: .2rem;
  margin-bottom: 0;
}
.pos-tax-block:not(.hidden) + .pos-total-row {
  margin-top: .2rem;
  padding-top: .4rem;
  border-top: 1px dashed rgba(255,255,255,.35);
}
.pos-client-msg {
  margin: .55rem 0; padding: .5rem .65rem; border-radius: 8px;
  font-size: .8rem; font-weight: 600; text-align: center;
}
.pos-client-msg.from-bd { background: var(--ok-bg); color: var(--ok); }
.pos-client-msg.from-api { background: #eef6fb; color: var(--brand-dark); }
.table-select { min-width: 0; width: 100%; }
.item-extra input { margin: .12rem 0; text-align: center; }
.item-extra .hidden { display: none !important; }
#btnCompletarVenta { margin-top: auto; flex: 0 0 auto; }
.pos-tax-block.hidden { display: none !important; }

@media (max-width: 980px) {
  .pos-layout {
    grid-template-columns: 1fr;
    max-height: none;
    overflow: visible;
  }
  .pos-side { order: -1; }
  .pay-grid { grid-template-columns: 1fr 1fr; gap: .4rem; }
  table.data { min-width: 720px; }
  #itemsTable.data { min-width: 0 !important; }
}
.modal-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.2rem; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: #fff; z-index: 2;
}
.modal-body { padding: 1.2rem; }

.receipt-modal {
  border: 1px solid #e5ebf2;
  border-radius: 14px;
  overflow: hidden;
}
.rm-header {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: .65rem;
  padding: .7rem .85rem;
  align-items: start;
  border-bottom: 1px solid #edf1f6;
  flex: 0 0 auto;
}
.rm-header img { width: 32px; height: 32px; }
.rm-header .company h2 {
  color: #05558c;
  font-size: .95rem;
  text-transform: uppercase;
  margin: 0 0 .15rem;
  line-height: 1.2;
}
.rm-header .company .muted { font-size: .75rem; }
.rm-box {
  border: 1.5px solid #c9d5e3;
  border-radius: 10px;
  padding: .45rem .6rem;
  text-align: center;
  min-width: 140px;
}
.rm-box strong { font-size: .78rem; display: block; }
.rm-box .muted { font-size: .72rem; }
.rm-box .pill {
  display: inline-block;
  margin-top: .25rem;
  background: #eef5fb;
  border: 1px solid #c9d8e8;
  border-radius: 999px;
  padding: .18rem .55rem;
  font-weight: 800;
  font-size: .78rem;
  color: var(--brand);
}
.rm-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  padding: .55rem .85rem;
  border-bottom: 1px solid #edf1f6;
  flex: 0 0 auto;
}
.rm-meta .label { color: var(--muted); font-size: .68rem; font-weight: 700; letter-spacing: .03em; }
.rm-meta .value { font-weight: 650; margin-top: .1rem; font-size: .84rem; }
.rm-table { width: 100%; border-collapse: collapse; flex: 0 0 auto; }
.rm-table th {
  background: #043f68;
  color: #fff;
  text-align: center;
  padding: .4rem .5rem;
  font-size: .68rem;
  letter-spacing: .04em;
}
.rm-table td {
  padding: .4rem .5rem;
  border-bottom: 1px solid #edf1f6;
  font-size: .8rem;
  text-align: center;
  vertical-align: middle;
}
.rm-table td:first-child { text-align: left; }
.rm-table td .muted { font-size: .72rem; }
.rm-totals { padding: .5rem .85rem; display: flex; justify-content: flex-end; flex: 0 0 auto; }
.rm-totals-box { width: min(260px, 100%); }
.rm-totals-box .row {
  display: flex; justify-content: space-between;
  margin-bottom: .2rem; color: #445; font-size: .8rem;
}
.rm-tax-row {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .28rem;
  color: #334;
  font-size: .82rem;
  font-weight: 650;
}
.rm-total-bar {
  margin-top: .3rem;
  background: #043f68;
  color: #fff;
  border-radius: 8px;
  padding: .5rem .7rem;
  display: flex; justify-content: space-between;
  font-weight: 800;
  font-size: .88rem;
}
.rm-pay { padding: 0 .85rem .55rem; text-align: left; flex: 0 0 auto; }
.rm-pay > strong {
  display: flex; align-items: center; gap: .35rem;
  font-size: .74rem; letter-spacing: .03em;
}
.rm-pay-box {
  margin-top: .35rem;
  border: 1px solid #d7e0ea;
  border-radius: 10px;
  background: #f8fafc;
  padding: .45rem .7rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  font-size: .82rem;
}
/* Acciones del ojito van en la barra del modal (siempre visibles) */
.rm-actions { display: none !important; }
.btn-ticket { background: #1d6fd4; color: #fff; }
.btn-pdf { background: #c0392b; color: #fff; }
.btn-wa { background: #25d366; color: #fff; }

.dropdown {
  position: relative;
}
.dropdown-menu {
  display: none;
  position: absolute;
  right: 0; top: calc(100% + 4px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  min-width: 140px;
  box-shadow: var(--shadow);
  z-index: 20;
  overflow: hidden;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu button, .dropdown-menu a {
  display: block; width: 100%; text-align: left;
  padding: .65rem .85rem; border: 0; background: #fff;
  font: inherit; cursor: pointer; color: var(--ink);
}
.dropdown-menu button:hover, .dropdown-menu a:hover { background: #f3f7fb; }
.dropdown-menu .danger { color: var(--danger); }

div.item-box {
  border: 1px dashed #c9d5e3;
  border-radius: 14px;
  padding: 1rem;
  background: #f8fafc;
  margin-bottom: .8rem;
}
tr.item-box { background: transparent; }
.hidden { display: none !important; }

@media (max-width: 980px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    width: var(--sidebar-expanded);
    padding: 1rem .85rem;
    transform: translateX(-105%);
    transition: transform .22s ease;
  }
  .sidebar .brand-logo-full { display: block; }
  .sidebar .brand-logo-mini { display: none; }
  .sidebar .sidebar-nav a { justify-content: flex-start; padding: .7rem .85rem; }
  .sidebar .sidebar-nav a span,
  .sidebar .user-chip,
  .sidebar .btn-logout span { display: initial; }
  .sidebar .user-chip { display: block; }
  .sidebar.open { transform: translateX(0); }
  .grid-2, .grid-3, .grid-4, .filters, .rm-meta, .rm-header {
    grid-template-columns: 1fr;
  }
  .rm-box { justify-self: start; }
  .pos-layout { grid-template-columns: 1fr; }
  .pos-side { order: -1; }
  .table-wrap .data.data-nowrap { min-width: 720px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .page-center { display: block; }
  .card-form { width: 100%; }
}

/* La impresión térmica va por iframe (80mm). Evita imprimir el sistema completo. */
@media print {
  .no-print { display: none !important; }
  body:not(.thermal-host) .app-shell,
  body:not(.thermal-host) .modal-backdrop,
  body:not(.thermal-host) .swal2-container {
    display: none !important;
  }
}


/* AJAX loader */
.ajax-loader {
  position: absolute; inset: 0;
  background: rgba(238, 242, 246, .55);
  backdrop-filter: blur(2px);
  display: grid; place-items: center;
  z-index: 50;
}
.ajax-loader[hidden] { display: none !important; }
.ajax-loader-box, .loading-inline {
  display: flex; align-items: center; gap: .75rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: .9rem 1.2rem;
  box-shadow: var(--shadow);
  font-weight: 600;
}
.spinner {
  width: 22px; height: 22px;
  border: 2.5px solid #d7e0ea;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* SweetAlert2 professional */
/* Alertas propias (sin SweetAlert) */
.app-alert {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(10, 24, 40, .48);
  backdrop-filter: blur(3px);
}
.app-alert[hidden] { display: none !important; }
.app-alert.open,
.app-alert:not([hidden]) { display: flex; }
.app-alert-card {
  width: min(380px, 100%);
  background: #fff;
  border-radius: 18px;
  padding: 1.35rem 1.25rem 1.15rem;
  box-shadow: 0 24px 70px rgba(10, 24, 40, .28);
  text-align: center;
  position: relative;
  animation: alertIn .18s ease;
}
.app-alert.auto-close .app-alert-card {
  padding: 1.15rem 1.2rem 1.35rem;
}
.app-alert.auto-close .app-alert-actions {
  display: none !important;
}
.app-alert.auto-close .app-alert-card p:empty {
  display: none;
}
.app-alert.auto-close .app-alert-card h3 {
  margin-bottom: .15rem;
  font-size: 1.02rem;
}
@keyframes alertIn {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.app-alert-icon {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: grid; place-items: center;
  margin: 0 auto .85rem;
  font-size: 1.55rem;
}
.app-alert.success .app-alert-icon { background: var(--ok-bg); color: var(--ok); }
.app-alert.error .app-alert-icon { background: var(--danger-bg); color: var(--danger); }
.app-alert.warning .app-alert-icon { background: #fff4e5; color: #b86e00; }
.app-alert.info .app-alert-icon { background: #eef6fb; color: var(--brand); }
.app-alert-card h3 {
  margin: 0 0 .4rem;
  font-size: 1.15rem;
  color: var(--ink);
}
.app-alert-card p {
  margin: 0 0 1.15rem;
  color: var(--muted);
  font-size: .94rem;
  line-height: 1.45;
}
.app-alert-actions {
  display: flex;
  gap: .65rem;
  justify-content: center;
  flex-wrap: wrap;
}
.app-alert-actions .btn { min-width: 110px; }
.app-alert-progress {
  position: absolute;
  left: 12px; right: 12px; bottom: 8px;
  height: 3px;
  border-radius: 99px;
  background: #e8eef5;
  overflow: hidden;
}
.app-alert-progress::after {
  content: "";
  display: block;
  height: 100%;
  width: 100%;
  background: var(--brand);
  transform-origin: left center;
  animation: alertBar linear forwards;
}
@keyframes alertBar {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

body:has(.pos-layout) .content { overflow: hidden; padding-bottom: .65rem; }
.topbar { padding: .85rem 1.25rem .45rem; }
.topbar h1 { font-size: 1.35rem; margin: 0 0 .15rem; }
.topbar-date { font-size: .86rem; }

.grid-2 > .card { min-width: 0; }
.grid-2 .table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
/* Tablas fluidas sin aplastar Acciones */
table.data.table-fill {
  width: 100%;
  min-width: 560px;
  table-layout: auto;
}
table.data.table-fill th,
table.data.table-fill td {
  word-break: normal;
  overflow-wrap: anywhere;
  white-space: normal;
  vertical-align: middle;
}
table.data.table-fill th {
  white-space: nowrap !important;
  word-break: keep-all !important;
}
table.data.table-fill th.actions-cell,
table.data.table-fill td.actions-cell,
table.data.table-fill th:last-child,
table.data.table-fill td.actions-cell {
  width: 1%;
  min-width: 132px;
  white-space: nowrap !important;
  word-break: keep-all !important;
  overflow-wrap: normal !important;
}
table.data.table-fill code {
  font-size: .78rem;
  word-break: break-all;
}

/* Responsive: scroll horizontal elegante, acciones intactas */
@media (max-width: 900px) {
  table.data.table-fill { min-width: 640px; }
  .actions-cell .btn-icon,
  .actions.actions-row .btn-icon {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
  }
}
.modal-body .btn-block { margin-top: .35rem; }
.check-list {
  display: grid;
  gap: .65rem;
  margin: .35rem 0 1.1rem;
}
.check-list label {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin: 0;
  font-weight: 550;
  color: var(--ink);
}
.auth-logo {
  width: min(220px, 70vw);
  height: auto;
  display: block;
  margin: 0 auto;
}
.auth-roles {
  margin-top: 1.1rem;
  display: grid;
  gap: .45rem;
  font-size: .88rem;
  color: var(--muted);
  background: #f3f7fb;
  border-radius: 12px;
  padding: .85rem 1rem;
}
.auth-roles span { color: var(--ink); font-weight: 700; }
.auth-roles i { color: var(--brand); margin-right: .25rem; }

.token-only-form {
  text-align: center;
  display: grid;
  gap: 1.15rem;
}
.token-field {
  display: grid;
  gap: .55rem;
  text-align: center;
}
.token-field label {
  display: block;
  text-align: center;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #5a6b7d;
  margin: 0;
}
.token-input,
.token-only-form input.token-input {
  width: 100%;
  text-align: center !important;
  font-family: "Courier New", Courier, ui-monospace, monospace;
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #0a2435;
  background: #f4f8fc;
  border: 1.5px solid #c5d5e6;
  border-radius: 14px;
  padding: 1rem .85rem;
  outline: none;
  caret-color: #0b6ba8;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.token-input::placeholder {
  color: #9aadc2;
  letter-spacing: .14em;
  font-weight: 700;
  opacity: 1;
}
.token-input:hover {
  border-color: #9eb6ce;
  background: #f7fafc;
}
.token-input:focus {
  border-color: #0b6ba8;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(11, 107, 168, .14);
}
.auth-copy {
  margin: 1.35rem 0 0;
  text-align: center;
  font-size: .74rem;
  font-weight: 550;
  letter-spacing: .02em;
  color: #8a9aab;
}
.btn-token-enter {
  margin-top: .15rem;
  min-height: 48px;
  font-weight: 700;
  letter-spacing: .02em;
  border-radius: 14px;
  justify-content: center;
}
.btn i { line-height: 1; }
.dropdown-menu a, .dropdown-menu button {
  display: flex !important;
  align-items: center;
  gap: .5rem;
}

/* QR en preview de boleta */
.rm-qr {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .85rem;
  padding: .65rem .85rem .75rem;
  border-top: 1px dashed #d7e0ea;
  background: #f8fafc;
}
.rm-qr img {
  width: 110px;
  height: 110px;
  border: 2px solid #0a2435;
  border-radius: 8px;
  background: #fff;
  padding: 4px;
}
.rm-qr-text {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  text-align: left;
  max-width: 180px;
}
.rm-qr-text strong {
  font-size: .82rem;
  color: #043f68;
}
.rm-qr-text .muted { font-size: .74rem; }

/* Vista pública al escanear QR */
body.boleta-public {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(0, 163, 224, .18), transparent 55%),
    linear-gradient(165deg, #e8f4fb 0%, #f4f7fa 45%, #eef2f6 100%);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 1.25rem .85rem 2rem;
}
.boleta-public-wrap {
  width: min(560px, 100%);
}
.boleta-public-toolbar {
  display: flex;
  gap: .55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-bottom: .75rem;
}
.boleta-public-toolbar .btn {
  min-width: 130px;
}
.boleta-public-card {
  background: #fff;
  box-shadow: 0 16px 48px rgba(10, 36, 53, .12);
}
.boleta-public-foot {
  text-align: center;
  margin: .85rem 0 0;
  font-size: .78rem;
}
body.boleta-download {
  background: #fff;
  padding: .5rem;
}
body.boleta-download .boleta-public-toolbar { display: none; }
@media print {
  body.boleta-public {
    background: #fff !important;
    padding: 0 !important;
  }
  .boleta-public-toolbar,
  .boleta-public-foot,
  .no-print { display: none !important; }
  .boleta-public-card { box-shadow: none !important; }
}
@media (max-width: 560px) {
  .rm-qr { flex-direction: column; text-align: center; }
  .rm-qr-text { text-align: center; max-width: none; }
  .rm-meta { grid-template-columns: 1fr; }
  .boleta-public-toolbar { justify-content: stretch; }
  .boleta-public-toolbar .btn { flex: 1; }
}
