/* ==========================================================================
   Badulaque Central · estilo "Terminal TPV" (versión 8)
   Grafito oscuro, teclas con relieve, números en monoespaciada y visor LCD.
   ========================================================================== */
:root {
  --bg: #0e1013;
  --rail: #14171b;
  --panel: #14171b;
  --panel-2: #1a1e23;
  --key: #171a1f;
  --key-2: #1d2228;
  --line: #262b32;
  --line-2: #2f353d;
  --text: #e6e9ee;
  --muted: #8c96a3;
  --accent: #3aa0ff;
  --accent-dark: #1b6fc2;
  --accent-soft: #8fcaff;
  --accent-bg: #13263b;
  --ok: #6fe2ac;
  --warn: #f2bf7a;
  --danger: #ff9b86;
  --lcd-bg: #04120d;
  --lcd-line: #1d2a24;
  --lcd: #7cffc4;
  --radius: 12px;
  --f-ui: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --f-lcd: "VT323", "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--f-ui);
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; }
h2 { font-size: 1.15rem; }
h3 { font-size: 0.95rem; margin: 14px 0 8px; }
.muted { color: var(--muted); }
.warn { color: var(--warn); }

/* --- Estructura: barra lateral + contenido ---------------------------- */
.app-layout { display: flex; min-height: 100vh; }

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  width: 92px;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 0;
  background: var(--rail);
  border-right: 1px solid var(--line);
  z-index: 50;
}
.rail-logo { width: 56px; height: 56px; object-fit: contain; margin-bottom: 14px; }

.tabs { display: flex; flex-direction: column; gap: 8px; }

.tab, .rail-btn {
  position: relative;
  width: 74px;
  height: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: #9aa3ae;
  font: 600 12px var(--f-ui);
  cursor: pointer;
}
.tab:hover, .rail-btn:hover { background: var(--key-2); color: var(--text); filter: none; }
.tab.is-active {
  border-color: var(--accent);
  background: rgba(58, 160, 255, 0.14);
  color: var(--accent-soft);
  font-weight: 700;
}
.tab-lock { position: absolute; top: 7px; right: 9px; opacity: 0.7; }
.rail-btn { margin-top: auto; height: 62px; border-color: var(--line); font-size: 11px; }

.app-shell {
  position: relative;
  flex: 1;
  min-width: 0;
  padding: 18px 20px 12px;
}

/* --- Cabecera ----------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.topbar-logo { display: none; width: 36px; height: 36px; object-fit: contain; }
.topbar h1 { font-size: 1.4rem; letter-spacing: 0.01em; }
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(78, 214, 150, 0.14);
  color: var(--ok);
  font: 600 12px var(--f-mono);
  letter-spacing: 0.06em;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(111, 226, 172, 0.2); }
.topbar-search {
  margin-left: auto;
  width: 320px;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
}
.topbar-search:focus-within { border-color: var(--accent); }
.topbar-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: 500 15px var(--f-ui);
  outline: none;
}
body:not(.is-caja) .topbar-search { display: none; }

/* --- Pestañas ----------------------------------------------------------- */
.tab-panel { display: none; }
.tab-panel.is-active { display: block; animation: fade 160ms ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.split { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; }
#tab-conta .split, #tab-craft .split { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }

.card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 14px;
  padding: 16px;
}
#tab-caja .split > .card:first-child { background: transparent; border: 0; padding: 0; }
.card > h2 { margin-bottom: 12px; }
.card-head-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.product-count { font: 500 12px var(--f-mono); }
#btn-add-product { margin-left: auto; display: none; }

/* --- Botones: teclas ---------------------------------------------------- */
button {
  border: 1px solid var(--line-2);
  border-bottom-width: 4px;
  border-radius: 10px;
  background: var(--key-2);
  color: #d6dbe2;
  padding: 9px 14px;
  font: 700 14px var(--f-ui);
  cursor: pointer;
  transition: transform 60ms ease, border-bottom-width 60ms ease, filter 120ms;
}
button:hover { filter: brightness(1.12); }
button:active { transform: translateY(2px); border-bottom-width: 2px; }
button:focus-visible, .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button.primary { background: var(--accent); border-color: var(--accent-dark); color: #04121f; }
button.light { background: var(--text); border-color: #a9b4c2; color: var(--bg); }
button.danger { background: #2a1613; border-color: #6b2a22; color: var(--danger); }
button.ghost { background: transparent; border-color: var(--line-2); border-bottom-width: 1px; color: #c9d2dd; }
button.ghost:active { transform: none; }
button.small, .ghost.small { padding: 6px 10px; font-size: 13px; }

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

/* --- Caja: teclas de producto ------------------------------------------ */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.product-btn {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 10px;
  row-gap: 3px;
  align-content: center;
  align-items: center;
  height: 74px;
  padding: 0 12px 0 10px;
  border: 1px solid var(--line);
  border-bottom-width: 4px;
  border-radius: 12px;
  background: var(--key);
  color: var(--text);
  text-align: left;
}
.product-btn img { grid-row: 1 / 3; width: 44px; height: 44px; object-fit: contain; }
.product-btn strong { font-size: 14px; font-weight: 600; line-height: 1.15; align-self: end; }
.product-btn small { grid-column: 2; font: 600 13px var(--f-mono); color: var(--accent-soft); align-self: start; }
.product-btn .qty-badge { grid-column: 3; grid-row: 1 / 3; font: 700 15px var(--f-mono); color: var(--accent); }
.product-btn.in-ticket { background: var(--accent-bg); border-color: var(--accent); }
.product-btn[hidden] { display: none; }
.no-results { grid-column: 1 / -1; padding: 24px; text-align: center; color: var(--muted); border: 1px dashed var(--line-2); border-radius: 12px; }

/* --- Visor LCD ---------------------------------------------------------- */
.lcd {
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--lcd-bg);
  border: 2px solid var(--lcd-line);
  box-shadow: inset 0 0 24px rgba(124, 255, 196, 0.08);
  font-family: var(--f-lcd);
  color: var(--lcd);
}
.lcd-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.lcd-row:first-child { font-size: 20px; opacity: 0.8; min-height: 22px; }
.lcd-main { margin-top: 4px; }
.lcd-label { font-size: 26px; }
.lcd-total { font-family: var(--f-lcd); font-weight: 400; font-size: 60px; line-height: 1; white-space: nowrap; text-shadow: 0 0 12px rgba(124, 255, 196, 0.45); }
.lcd-last { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lcd-total[data-size="m"] { font-size: 50px; }
.lcd-total[data-size="s"] { font-size: 42px; }
.lcd-total[data-size="xs"] { font-size: 34px; }
.m-lcd { display: none; }

/* --- Ticket ------------------------------------------------------------- */
/* Concepto para el datafono (40 caracteres) */
.concept-info { margin: -4px 2px 0; min-height: 1em; color: var(--muted); font: 500 12px var(--f-mono); }
.concept-info.is-over { color: var(--warn); }
#charges-modal .charge-concept { font: 600 13.5px var(--f-mono); }
#charges-modal .charge-actions { white-space: nowrap; }
#charges-modal .charge-actions button + button { margin-left: 6px; }

.ticket-card { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 18px; }
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  max-height: 320px;
}
.ticket-table-wrap { max-height: 44vh; min-height: 120px; }
.ticket-table-wrap th:nth-child(3), .ticket-table-wrap td:nth-child(3) { display: none; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; border-bottom: 1px solid #22272d; font-size: 14px; }
th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  text-align: left;
  color: var(--muted);
  font: 600 11.5px var(--f-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
td.num, th.num { text-align: right; }
td.num { font-family: var(--f-mono); font-weight: 500; }
tbody tr:hover { background: #1a1f25; }
tbody tr.is-selected { background: #1c2c40; }
tbody tr.is-last { background: rgba(58, 160, 255, 0.10); }

.ticket-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ticket-actions button { height: 52px; }
.ticket-actions .key-wide { grid-column: span 2; height: 60px; font-size: 17px; }
.ticket-actions .light { height: 60px; }

input.qty-input {
  width: 58px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: #0f1216;
  color: var(--text);
  padding: 5px 6px;
  text-align: center;
  font: 600 14px var(--f-mono);
  appearance: textfield;
  -moz-appearance: textfield;
}
input.qty-input::-webkit-outer-spin-button,
input.qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.trash-btn {
  min-width: 34px;
  padding: 4px 8px;
  border-bottom-width: 3px;
  background: #2a1613;
  border-color: #6b2a22;
  font-size: 15px;
  line-height: 1;
}

/* --- Facturas / Crafteos ------------------------------------------------ */
textarea {
  width: 100%;
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0f1216;
  color: var(--text);
  padding: 12px;
  resize: vertical;
  font: 500 13px/1.5 var(--f-mono);
}
textarea:focus { outline: none; border-color: var(--accent); }

.summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mini-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; background: var(--panel-2); }
.mini-card h3 { margin: 2px 0 6px; color: var(--accent-soft); }
.mini-card p { margin: 5px 0; font: 500 13.5px var(--f-mono); }
#craft-total-items, #craft-total-sup { font: 600 15px var(--f-mono); margin: 6px 0; }

/* Total general como visor */
.kpi-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 12px 0 8px;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--lcd-bg);
  border: 2px solid var(--lcd-line);
  font-family: var(--f-lcd);
  color: var(--lcd);
}
.kpi-line span { font-size: 24px; }
.kpi-line strong { font-family: var(--f-lcd); font-weight: 400; font-size: 44px; line-height: 1; text-shadow: 0 0 10px rgba(124, 255, 196, 0.4); }
#conta-footer, #conta-loaded { font: 500 12.5px var(--f-mono); }

/* --- Pagos ------------------------------------------------------------- */
#tab-conta .pg-split { grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.4fr); }
.terminal-input { min-height: 300px; background: #070a08; border-color: var(--lcd-line); color: #b9f5d8; }
.terminal-input::placeholder { color: #4f7a66; }
.pg-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.pg-step { padding: 10px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12.5px; color: #c3cad3; line-height: 1.35; }
.pg-step b { display: block; font: 700 18px var(--f-mono); color: var(--accent); margin-bottom: 2px; }
.pg-step strong { color: var(--accent-soft); }

.pg-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.pg-kpi { min-width: 0; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); border-bottom-width: 3px; background: var(--key); }
.pg-kpi .lbl { display: flex; align-items: center; gap: 6px; font: 600 11px var(--f-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.pg-kpi .ic { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pg-kpi .val { margin-top: 6px; font: 700 22px var(--f-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-kpi .val.pg-kpi-name { font: 700 15px/1.2 var(--f-ui); white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; min-height: 36px; }
.pg-kpi .sub { margin-top: 3px; font-size: 12px; color: var(--muted); }
.pg-kpi.hl { background: var(--lcd-bg); border-color: var(--lcd-line); }
.pg-kpi.hl .val { font: 400 34px/1 var(--f-lcd); color: var(--lcd); text-shadow: 0 0 10px rgba(124, 255, 196, 0.4); }
.pg-kpi.hl .ic { stroke: var(--lcd); }

.pg-sec { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; margin: 4px 0 8px; }
.pg-sec h3 { margin: 0; font: 600 12px var(--f-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.pg-sec-note { font-size: 12px; }

.pg-list { display: grid; gap: 8px; }
.pg-empty { margin: 0; padding: 22px; text-align: center; border: 1px dashed var(--line-2); border-radius: 12px; }
.pg-row { display: grid; grid-template-columns: 22px 42px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 14px 10px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--key); }
.pg-row.first { border-color: var(--accent); background: var(--accent-bg); }
.pg-pos { font: 700 13px var(--f-mono); color: var(--muted); text-align: center; }
.pg-row.first .pg-pos { color: var(--accent); }
.pg-av { position: relative; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font: 700 14px var(--f-mono); color: #04121f; background: linear-gradient(135deg, var(--accent-soft), var(--accent)); }
.pg-av.np { background: #2a3038; color: #aab3be; }
.pg-av .crown { position: absolute; top: -8px; right: -6px; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; background: #f2bf7a; color: #2a1a04; font-size: 12px; border: 2px solid var(--panel); }
.pg-mid { min-width: 0; }
.pg-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 700; }
.pg-badge { padding: 2px 8px; border-radius: 6px; font: 600 11px var(--f-mono); letter-spacing: 0.03em; white-space: nowrap; }
.r-pruebas { background: #6fe2ac1f; color: #8de9bd; border: 1px solid #6fe2ac55; }
.r-cajero { background: #3aa0ff1f; color: #8fcaff; border: 1px solid #3aa0ff66; }
.r-exp { background: #b07cff1f; color: #cdb0ff; border: 1px solid #b07cff66; }
.r-encargado { background: #f2bf7a1f; color: #f6d39f; border: 1px solid #f2bf7a66; }
.r-jefe { background: var(--accent); color: #04121f; }
.r-tribal { background: #f2bf7a; color: #2a1a04; }
.w-iban { background: #f2bf7a14; color: var(--warn); border: 1px dashed #f2bf7a88; }
.w-nopay { background: #ffffff0d; color: #aab3be; border: 1px solid #ffffff26; }
.pg-bar { height: 6px; margin-top: 7px; border-radius: 999px; background: #22272d; overflow: hidden; }
.pg-bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent-dark), var(--accent-soft)); }
.pg-meta { margin-top: 4px; font: 500 12px var(--f-mono); color: var(--muted); }
.pg-amt { text-align: right; white-space: nowrap; }
.pg-amt small { display: block; font-size: 11.5px; color: var(--muted); }
.pg-amt b { display: block; font: 700 18px var(--f-mono); }
.pg-amt .pay { color: var(--lcd); }
.pg-amt .pg-dash { color: #7d8794; font-size: 15px; }

.pg-total { margin: 14px 0 0; }
.pg-total span { font-size: 22px; }
.pg-actions { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 8px; margin-top: 12px; }
.pg-actions button { height: 50px; }
.pg-copied { min-height: 1em; margin: 6px 2px 0; color: var(--ok); font: 500 12.5px var(--f-mono); }
.pg-detail { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.pg-detail summary { cursor: pointer; padding: 6px 0; color: var(--muted); font: 600 12.5px var(--f-mono); }
.pg-detail[open] summary { margin-bottom: 8px; color: var(--accent-soft); }

/* Gestion de empleados */
#employees-admin-modal { width: min(1120px, 96vw); }
.emp-list-title { margin: 14px 0 0; }
.emp-table-wrap { max-height: 46vh; }
.emp-table-wrap td { vertical-align: middle; }
.emp-table-wrap .text-input { height: 36px; padding: 6px 8px; font-size: 13px; }
.emp-rank-select { min-width: 250px; }
.emp-discord-input { min-width: 170px; font-family: var(--f-mono) !important; }
.emp-iban-input { width: 110px; text-transform: uppercase; font-family: var(--f-mono) !important; }
.emp-pct { font-family: var(--f-mono); color: var(--accent-soft); }
.emp-nopay-input { width: 18px; height: 18px; accent-color: var(--accent); }
th.center, td.center { text-align: center; }
.form-grid .emp-discord-new { grid-column: 1 / 3; }
#employees-modal { width: min(980px, 94vw); }

/* --- Sorteo ------------------------------------------------------------ */
.sx-subtabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.sx-subtab { border-bottom-width: 1px; border-radius: 999px; padding: 9px 16px; font: 600 12.5px var(--f-mono); letter-spacing: 0.05em; text-transform: uppercase; }
.sx-subtab.is-active { background: rgba(58, 160, 255, 0.14); border-color: var(--accent); color: var(--accent-soft); }
.sx-pane { display: none; }
.sx-pane.is-active { display: block; animation: fade 160ms ease-out; }
#tab-sorteo .sx-split { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.2fr); }

.sx-rules { display: grid; gap: 8px; }
.sx-rule { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); font-size: 13.5px; }
.sx-rule b { color: var(--accent-soft); }
.sx-ok { color: var(--lcd); font-weight: 800; }
.sx-set { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sx-set label { display: grid; gap: 4px; font: 600 11.5px var(--f-mono); letter-spacing: 0.04em; color: var(--muted); }
.sx-set label[hidden] { display: none; }
.sx-check { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13.5px; color: #c3cad3; cursor: pointer; }
.sx-check input { width: 18px; height: 18px; accent-color: var(--accent); }

.sx-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.sx-kpi { min-width: 0; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); border-bottom-width: 3px; background: var(--key); }
.sx-kpi .lbl { font: 600 11px var(--f-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.sx-kpi .val { margin-top: 6px; font: 700 24px var(--f-mono); }
.sx-kpi.hl { background: var(--lcd-bg); border-color: var(--lcd-line); }
.sx-kpi.hl .val { font: 400 36px/1 var(--f-lcd); color: var(--lcd); text-shadow: 0 0 10px rgba(124, 255, 196, 0.4); }
.sx-kpi.bad .val { color: var(--danger); }
.sx-h { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px; margin: 14px 0 8px; }
.sx-h h3 { margin: 0; font: 600 12px var(--f-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.sx-h span { font-size: 12px; color: var(--muted); }
.sx-row { display: grid; grid-template-columns: 42px minmax(0, 1fr) 70px 64px; gap: 12px; align-items: center; margin-bottom: 6px; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--key); }
.sx-mid { min-width: 0; }
.sx-tk { text-align: center; font: 700 18px var(--f-mono); color: var(--lcd); }
.sx-tk small { display: block; font: 500 11px var(--f-ui); color: var(--muted); }
.sx-pc { text-align: right; font: 600 13px var(--f-mono); }
.sx-bad { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; margin-bottom: 6px; padding: 8px 12px; border-radius: 10px; border: 1px dashed #6b2a22; background: #1a1210; font-size: 13px; }
.w-self { background: #ff9b861a; color: var(--danger); border: 1px solid #ff9b8666; }
.sx-part-actions { grid-template-columns: 1fr 1fr; }

.sx-combo { display: grid; grid-template-columns: 400px minmax(0, 1fr); gap: 16px; align-items: start; }
.sx-prog { display: flex; justify-content: space-between; margin: 0 2px 8px; font: 500 12px var(--f-mono); color: var(--muted); }
.sx-progbar { height: 8px; margin-bottom: 12px; border-radius: 9px; background: #22272d; overflow: hidden; }
.sx-progbar i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--accent-dark), var(--accent-soft)); transition: width 0.4s; }
.sx-pz { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; gap: 12px; align-items: center; margin-bottom: 8px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--key); }
.sx-pz .ico { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 12px; font-size: 24px; background: #0f1216; border: 1px solid var(--line-2); }
.sx-pz b { display: block; }
.sx-pz small { font-size: 12px; color: var(--muted); }
.sx-pz .who { text-align: right; }
.sx-pz .who b { color: var(--lcd); }
.sx-pz.done .ico { border-color: var(--lcd-line); background: var(--lcd-bg); }
.sx-pz.now, .sx-pz.next { border-color: var(--accent); background: var(--accent-bg); }
.sx-pz.now .who b { color: #fff; }
.sx-tools { display: flex; gap: 4px; }
.sx-tools button { padding: 4px 9px; }
.sx-add { display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; gap: 6px; margin-top: 6px; }
.sx-add[hidden] { display: none; }

/* Escenario: pantalla de caja registradora gigante */
.sx-stage { position: relative; overflow: hidden; padding: 22px 20px 18px; border-radius: 16px; text-align: center; background: var(--lcd-bg); border: 2px solid var(--lcd-line); box-shadow: inset 0 0 50px rgba(124, 255, 196, 0.08); }
.sx-tag { display: inline-block; padding: 5px 14px; border-radius: 6px; background: var(--accent); color: #04121f; font: 700 12px var(--f-mono); letter-spacing: 0.12em; }
.card .sx-stage h2 { margin: 12px 0 4px; font: 400 44px/1.05 var(--f-lcd); letter-spacing: 0.04em; text-transform: uppercase; color: var(--lcd); text-shadow: 0 0 14px rgba(124, 255, 196, 0.45); }
.sx-reel { position: relative; max-width: 560px; height: 168px; margin: 16px auto 10px; border-radius: 12px; overflow: hidden; border: 2px solid var(--lcd-line); background: #020a07; }
.sx-reel::before, .sx-reel::after { content: ""; position: absolute; left: 0; right: 0; z-index: 2; height: 52px; pointer-events: none; }
.sx-reel::before { top: 0; background: linear-gradient(#020a07, transparent); }
.sx-reel::after { bottom: 0; background: linear-gradient(transparent, #020a07); }
.sx-reel-line { position: absolute; left: 0; right: 0; top: 56px; z-index: 1; height: 56px; border-top: 2px solid var(--lcd); border-bottom: 2px solid var(--lcd); background: rgba(124, 255, 196, 0.08); }
.sx-reel ul { position: absolute; top: 0; left: 0; right: 0; margin: 0; padding: 0; list-style: none; text-align: center; }
.sx-reel li { height: 56px; padding: 0 12px; line-height: 56px; font: 400 32px/56px var(--f-lcd); color: #2f6b52; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sx-reel li.win { color: var(--lcd); font-size: 40px; text-shadow: 0 0 16px rgba(124, 255, 196, 0.8); }
.sx-odds { min-height: 1.2em; font: 500 13.5px var(--f-mono); color: #8fb5a4; }
.sx-odds b { color: var(--lcd); }
.sx-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 16px; }
.sx-btns button { height: 56px; padding: 0 26px; font-size: 16px; }
.sx-go:disabled { opacity: 0.55; cursor: not-allowed; }
.sx-seal { margin-top: 12px; font: 500 12px var(--f-mono); color: #8fb5a4; }
.sx-confetti { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.sx-confetti i { position: absolute; top: -20px; width: 8px; height: 14px; border-radius: 2px; animation-name: sx-fall; animation-timing-function: ease-in; animation-fill-mode: forwards; }
@keyframes sx-fall { to { top: 105%; transform: rotate(540deg); opacity: 0.2; } }

.sx-under { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 14px; margin-top: 14px; }
.sx-discord { max-height: 360px; margin: 0; padding: 14px 16px; overflow: auto; border-radius: 10px; background: #313338; color: #dbdee1; font: 14px/1.5 "gg sans", "Segoe UI", sans-serif; white-space: pre-wrap; word-break: break-word; }
.sx-side { display: grid; gap: 8px; align-content: start; }
.sx-side button { height: 50px; }
.sx-note { margin: 0; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); font-size: 13px; color: #c3cad3; }

/* --- Ventanas ----------------------------------------------------------- */
dialog { border: 0; padding: 0; background: transparent; width: min(940px, 94vw); color: var(--text); }
dialog::backdrop { background: rgba(4, 6, 9, 0.75); }
.modal-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
  padding: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.modal-head h3 { margin: 0; font-size: 1.1rem; }

.text-input, select.text-input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: #0f1216;
  color: var(--text);
  padding: 8px 12px;
  font: 500 14px var(--f-ui);
}
.text-input:focus { outline: none; border-color: var(--accent); }
.form-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.form-row .text-input { flex: 1 1 240px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.admin-grid { display: grid; grid-template-columns: 1fr 1.25fr; gap: 10px; }
.admin-block { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--panel-2); }
.admin-block h4 { margin-bottom: 4px; }

.access-card { width: min(520px, 94vw); margin: 0 auto; }
.access-help { margin: 6px 0 12px; }
#access-modal { width: min(560px, 94vw); }
#access-modal .form-row { align-items: stretch; }
#access-toggle { white-space: nowrap; }
.pass-wrap { display: flex; gap: 8px; align-items: center; flex: 1 1 260px; }
.pass-wrap .text-input { flex: 1 1 auto; min-width: 180px; }
.error-text { margin: 0; color: var(--danger); font-weight: 700; min-height: 18px; }

.copy-fallback-text {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0f1216;
  color: inherit;
  font-family: var(--f-mono);
}
#copy-fallback-modal .actions button { min-width: 140px; }
.icon-btn { padding: 4px 10px; border-bottom-width: 1px; background: transparent; }

/* Gestion de productos */
.subtabs { display: flex; gap: 8px; margin: 4px 0 14px; }
.subtab { border-bottom-width: 1px; border-radius: 999px; padding: 7px 14px; font-size: 13px; }
.subtab.is-active { background: rgba(58, 160, 255, 0.14); border-color: var(--accent); color: var(--accent-soft); }
.subtab-panel { display: none; }
.subtab-panel.is-active { display: block; animation: fade 160ms ease-out; }
.prod-thumb { width: 36px; height: 36px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: #0f1216; padding: 2px; }
.tag-pill { display: inline-block; border-radius: 6px; padding: 2px 8px; font: 600 11.5px var(--f-mono); border: 1px solid var(--line-2); letter-spacing: 0.04em; }
.tag-pill.tag-fijo { color: var(--accent-soft); }
.tag-pill.tag-agregado { color: var(--ok); }
.tag-pill.tag-oculto { color: var(--danger); }
.product-preview { margin: 10px 0; }
.product-preview img { width: 96px; height: 96px; object-fit: contain; border: 1px solid var(--line); border-radius: 12px; background: #0f1216; padding: 6px; }

/* Version de la pagina (pie) */
.app-version { text-align: center; color: var(--muted); font: 500 11.5px var(--f-mono); margin: 20px 0 6px; opacity: 0.7; letter-spacing: 0.04em; }

/* --- Pantallas medianas ------------------------------------------------- */
@media (max-width: 1100px) {
  .split, #tab-conta .split, #tab-craft .split { grid-template-columns: 1fr; }
  .ticket-card { position: static; }
}
@media (max-width: 1100px) {
  #tab-conta .pg-split, #tab-sorteo .sx-split, .sx-combo, .sx-under { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .summary-grid, .admin-grid, .form-grid { grid-template-columns: 1fr; }
  .form-grid .emp-discord-new { grid-column: auto; }
  .pg-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ==========================================================================
   Movil (hasta 700px): visor arriba, teclas en 2 columnas, botones fijos y
   barra de secciones abajo. En PC nada de esto cambia.
   ========================================================================== */
.m-actions { display: none; }

@media (max-width: 700px) {
  html, body { overflow-x: clip; }
  .app-layout { display: block; }

  /* La barra lateral pasa a ser la barra de secciones de abajo */
  .rail {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: auto;
    flex-direction: row;
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--line);
    z-index: 70;
  }
  .rail-logo, .rail-btn { display: none; }
  .tabs { flex: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
  .tab { width: auto; height: 56px; border-radius: 12px; font-size: 11.5px; }
  .tab.is-active { border-color: transparent; background: transparent; }
  .tab-lock { top: 6px; right: calc(50% - 22px); }

  .app-shell { padding: 0 14px calc(90px + env(safe-area-inset-bottom)); }
  body.is-caja .app-shell { padding-bottom: calc(160px + env(safe-area-inset-bottom)); }

  .topbar { margin: 0 -14px; padding: calc(12px + env(safe-area-inset-top)) 14px 10px; flex-wrap: wrap; gap: 10px; }
  .topbar-logo { display: block; }
  .topbar h1 { flex: 1; font-size: 1.1rem; }
  .status-badge { font-size: 11px; padding: 3px 8px; }
  .topbar-search { order: 5; margin: 0; width: 100%; height: 44px; }

  /* Visor fijo arriba en la Caja */
  body.is-caja .m-lcd {
    position: sticky;
    top: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 0 0 12px;
    padding: 10px 14px;
    box-shadow: 0 10px 20px rgba(14, 16, 19, 0.9), inset 0 0 20px rgba(124, 255, 196, 0.08);
  }
  .m-lcd .lcd-sub { display: flex; flex-direction: column; min-width: 0; font-size: 18px; line-height: 1.05; opacity: 0.85; }
  .m-lcd .lcd-total { font-size: 44px; }
  .m-lcd .lcd-total[data-size="m"] { font-size: 38px; }
  .m-lcd .lcd-total[data-size="s"] { font-size: 32px; }
  .m-lcd .lcd-total[data-size="xs"] { font-size: 28px; }
  .ticket-lcd { display: none; }

  .split { gap: 14px; }
  .card { padding: 12px; }
  #btn-add-product { display: inline-block; }

  /* Teclas en dos columnas */
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .product-btn { height: 60px; grid-template-columns: 32px minmax(0, 1fr) auto; column-gap: 8px; padding: 0 8px; border-bottom-width: 3px; border-radius: 10px; }
  .product-btn img { width: 32px; height: 32px; }
  .product-btn strong { font-size: 13px; line-height: 1.1; }
  .product-btn small { font-size: 12px; }
  .product-btn .qty-badge { font-size: 13px; }

  .ticket-table-wrap { max-height: none; }
  .ticket-table-wrap th, .ticket-table-wrap td { padding: 8px 6px; }
  .ticket-table-wrap .qty-input { width: 52px; }
  .ticket-actions button { height: 46px; font-size: 13px; }
  .ticket-actions .key-wide, .ticket-actions .light { height: 50px; }

  /* Botones fijos de la Caja, encima de la barra de secciones */
  body.is-caja .m-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(70px + env(safe-area-inset-bottom));
    z-index: 65;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px 14px;
    background: linear-gradient(180deg, rgba(14, 16, 19, 0), var(--bg) 30%);
  }
  .m-actions button { height: 50px; font-size: 15px; }

  textarea { min-height: 200px; }

  /* Sorteo en el movil */
  .sx-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .sx-set { grid-template-columns: 1fr; }
  .sx-row { grid-template-columns: 36px minmax(0, 1fr) 56px; gap: 10px; }
  .sx-row .pg-av { width: 36px; height: 36px; font-size: 12px; }
  .sx-pc { display: none; }
  .sx-bad { grid-template-columns: 1fr; }
  .sx-part-actions { grid-template-columns: 1fr; }
  .card .sx-stage h2 { font-size: 32px; }
  .sx-reel li { font-size: 26px; }
  .sx-reel li.win { font-size: 30px; }
  .sx-btns button { flex: 1 1 100%; }

  /* Pagos en el movil */
  .pg-kpis { gap: 8px; }
  .pg-kpi { padding: 10px; }
  .pg-kpi .val { font-size: 17px; }
  .pg-kpi.hl .val { font-size: 28px; }
  .pg-steps { grid-template-columns: 1fr; }
  .pg-row { grid-template-columns: 18px 36px minmax(0, 1fr); gap: 10px; padding: 9px 10px 9px 6px; }
  .pg-av { width: 36px; height: 36px; font-size: 12px; }
  .pg-amt { grid-column: 3; text-align: left; display: flex; align-items: baseline; gap: 8px; }
  .pg-amt small { display: inline; }
  .pg-actions { grid-template-columns: 1fr 1fr; }
  .pg-actions button:first-child { grid-column: 1 / -1; }
  .pg-total span { font-size: 17px; }
}

/* ==========================================================================
   Pantalla de arranque al abrir la app desde la pantalla de Inicio.
   Igual que la imagen de arranque del iPhone (iconos/splash-*.png).
   ========================================================================== */
.app-splash { display: none; }
.is-app .app-splash {
  display: grid;
  place-items: center;
  position: fixed;
  inset: 0;
  z-index: 100000;
  padding-bottom: 6vh;
  background: #0d1118;
  transition: opacity 0.45s ease, visibility 0.45s;
}
.is-app .app-splash-card {
  display: grid;
  place-items: center;
  width: 42vw;
  height: 42vw;
  max-width: 320px;
  max-height: 320px;
  border-radius: 22.5%;
  background: #ffffff;
}
.is-app .app-splash-card img { width: 84%; height: 84%; object-fit: contain; }
.is-app .app-splash.is-hidden { opacity: 0; visibility: hidden; }
