:root {
  --navy: #0f2a3d;
  --navy-2: #173a52;
  --ice: #2b8fd6;
  --ice-soft: #e6f2fb;
  --snow: #f6f8fa;
  --line: #dde3e9;
  --text: #15232f;
  --muted: #5f7080;
  --ok: #1f8a4c;
  --ok-soft: #e3f4ea;
  --warn: #b7791f;
  --warn-soft: #fdf3e1;
  --bad: #c53030;
  --bad-soft: #fde8e8;
  --card: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 42, 61, .06), 0 2px 8px rgba(15, 42, 61, .06);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; color: var(--text); background: var(--snow);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.hidden { display: none !important; }

/* ── shell ── */
.shell { display: grid; grid-template-columns: 88px 1fr; height: 100vh; }
.nav { background: var(--navy); color: #cfe0ee; display: flex; flex-direction: column; align-items: stretch; padding: 10px 0; gap: 2px; overflow-y: auto; }
.nav .brand { color: #fff; font-weight: 800; letter-spacing: .5px; text-align: center; font-size: 13px; padding: 4px 0 14px; }
.nav .brand b { display: block; font-size: 22px; }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; color: inherit; text-decoration: none; font-size: 12px; border-left: 3px solid transparent; }
.nav a svg { width: 24px; height: 24px; }
.nav a:hover { background: var(--navy-2); color: #fff; }
.nav a.active { background: var(--navy-2); color: #fff; border-left-color: var(--ice); }
.nav .spacer { flex: 1; }
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 18px; background: #fff; border-bottom: 1px solid var(--line); min-height: 56px; }
.topbar .title { font-weight: 700; font-size: 17px; flex: 1; }
.content { flex: 1; overflow: auto; padding: 18px; }
.content.flush { padding: 0; overflow: hidden; }

/* ── controles ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; padding: 9px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; min-height: 40px; white-space: nowrap; text-decoration: none; color: inherit; }
.btn:hover { border-color: #b9c4cf; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--ice); color: #fff; border-color: var(--ice); }
.btn.primary:hover { background: #1f7cc0; }
.btn.dark { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.big { min-height: 56px; font-size: 17px; padding: 12px 20px; }
.btn.sm { min-height: 32px; padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
input[type=text], input[type=number], input[type=date], input[type=search], input[type=password], input[type=tel], input[type=email], select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; background: #fff; min-height: 40px; width: 100%; color: var(--text); font-weight: 400;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ice); outline-offset: -1px; border-color: var(--ice); }
textarea { min-height: 70px; resize: vertical; }
.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 16px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button.active { color: var(--navy); border-bottom-color: var(--ice); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--ice-soft); color: #1b5f91; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.grey { background: #eef1f4; color: var(--muted); }
.notice { padding: 10px 14px; border-radius: 8px; background: var(--ice-soft); color: #1b5f91; font-size: 14px; }
.notice.warn { background: var(--warn-soft); color: #8a5a12; }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.empty { padding: 40px 10px; text-align: center; color: var(--muted); }

table.list { width: 100%; border-collapse: collapse; background: #fff; }
table.list th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; position: sticky; top: 0; }
table.list td { padding: 10px 12px; border-bottom: 1px solid #eef1f4; vertical-align: middle; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: #f5f9fd; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; background: #fff; }

/* ── login ── */
.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, var(--navy) 0%, #1d4f73 60%, #2b8fd6 100%); padding: 16px; }
.login .box { background: #fff; border-radius: 16px; padding: 28px; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login .logo { text-align: center; margin-bottom: 18px; }
.login .logo b { font-size: 30px; color: var(--navy); letter-spacing: 1px; }
.login .users { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; justify-content: center; }
.pin-dots { display: flex; justify-content: center; gap: 12px; margin: 14px 0; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--navy); }
.pin-dots span.on { background: var(--navy); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button { min-height: 58px; font-size: 22px; font-weight: 600; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.keypad button:active { background: var(--ice-soft); }

/* ── TPV ── */
.pos { display: grid; grid-template-columns: 1fr 400px; height: 100%; }
.pos-left { display: flex; flex-direction: column; min-width: 0; padding: 14px; gap: 10px; overflow: hidden; }
.pos-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; align-content: start; padding-bottom: 10px; }
.prod { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; text-align: left; min-height: 140px; box-shadow: var(--shadow); }
.prod:hover { border-color: var(--ice); }
.prod .img { height: 70px; border-radius: 6px; background: var(--ice-soft) center/contain no-repeat; display: grid; place-items: center; color: #7aa6c8; font-weight: 800; font-size: 20px; }
.prod .img.photo { height: 90px; background-color: #fff; background-size: contain; }
.prod > * { flex-shrink: 0; }   /* que la tarjeta crezca con el contenido en vez de aplastarlo */
.pos-grid { grid-auto-rows: max-content; }
.prod .season { display: inline-block; font-size: 11px; font-weight: 700; padding: 0 5px; border-radius: 4px; background: #eef1f5; color: #5a6b80; vertical-align: 1px; }
.prod .season.new { background: #e3f4e8; color: #1f7a3a; }
.prod .sizes { color: #3c4b5c; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prod .t { font-size: 13px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.prod .p { margin-top: auto; display: flex; justify-content: space-between; align-items: baseline; gap: 4px; }
.prod .p b { font-size: 15px; }
.prod .p s { font-size: 12px; color: var(--muted); }
.pos-ticket { background: #fff; border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.pos-ticket .head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.pos-ticket .lines { flex: 1; overflow-y: auto; }
.tline { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 14px; border-bottom: 1px solid #eef1f4; cursor: pointer; }
.tline:hover { background: #f8fafc; }
.tline .d { font-size: 14px; font-weight: 600; }
.tline .meta { font-size: 12px; color: var(--muted); }
.tline .qty { display: flex; align-items: center; gap: 6px; }
.tline .qty button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 18px; cursor: pointer; }
.totals { padding: 12px 14px; border-top: 1px solid var(--line); background: #fafbfc; }
.totals .r { display: flex; justify-content: space-between; padding: 2px 0; font-size: 14px; }
.totals .r.total { font-size: 26px; font-weight: 800; padding-top: 6px; }
.pos-ticket .actions { padding: 12px 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pos-ticket .actions .btn.big { grid-column: 1 / -1; }

/* ── panel ── */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { padding: 14px 16px; }
.kpi .l { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.kpi .v { font-size: 26px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 13px; color: var(--muted); margin-top: 2px; }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bars .b i { display: block; width: 100%; max-width: 46px; background: var(--ice); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.bars .b span { font-size: 11px; color: var(--muted); }
.bars .b em { font-size: 11px; font-style: normal; font-weight: 700; }
.alerts { display: flex; flex-direction: column; gap: 8px; }
.alert-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; background: #fafbfc; border: 1px solid var(--line); cursor: pointer; }

/* ── kanban taller ── */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; align-items: start; }
.kcol { background: #eef2f6; border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 200px; }
.kcol h3 { display: flex; justify-content: space-between; padding: 2px 4px 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.kcard { background: #fff; border-radius: 8px; padding: 10px; border: 1px solid var(--line); cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.kcard:hover { border-color: var(--ice); }

/* ── modal ── */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 25, 38, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { max-width: 860px; }
.modal .mh { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal .mh h2 { flex: 1; }
.modal .mb { padding: 18px; overflow-y: auto; }
.modal .mf { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.pay-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pay-methods .btn.sel { background: var(--navy); color: #fff; border-color: var(--navy); }
.pay-total { text-align: center; font-size: 40px; font-weight: 800; margin: 6px 0 14px; font-variant-numeric: tabular-nums; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.change { text-align: center; font-size: 20px; font-weight: 700; padding: 10px; border-radius: 8px; background: var(--ok-soft); color: var(--ok); }
.change.short { background: var(--bad-soft); color: var(--bad); }
.variant-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.variant-grid button { padding: 12px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; display: flex; flex-direction: column; gap: 2px; align-items: center; }
.variant-grid button b { font-size: 17px; }
.variant-grid button:hover { border-color: var(--ice); }
.pick-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.pick-list .it { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: #fff; }
.pick-list .it:hover { border-color: var(--ice); }
.pick-list .it.sel { border-color: var(--ice); background: var(--ice-soft); }

.toast-wrap { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); font-weight: 600; max-width: 90vw; }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }

/* ── impresión de tickets (80 mm) ── */
#print-area { display: none; }
@media print {
  @page { size: 80mm auto; margin: 3mm; }
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { display: block; position: absolute; left: 0; top: 0; width: 74mm; font-family: "Courier New", monospace; font-size: 11px; color: #000; }
  .tk h1 { font-size: 15px; text-align: center; }
  .tk .c { text-align: center; }
  .tk hr { border: 0; border-top: 1px dashed #000; margin: 6px 0; }
  .tk table { width: 100%; border-collapse: collapse; }
  .tk td { padding: 1px 0; vertical-align: top; }
  .tk .r { text-align: right; white-space: nowrap; }
  .tk .big { font-size: 15px; font-weight: bold; }
  .tk .sign { margin-top: 26px; border-top: 1px solid #000; padding-top: 2px; text-align: center; }
}

/* ── responsive ── */
@media (max-width: 1100px) {
  .pos { grid-template-columns: 1fr 340px; }
  .kanban { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .nav { order: 2; flex-direction: row; padding: 0; overflow-x: auto; }
  .nav .brand, .nav .spacer { display: none; }
  .nav a { border-left: 0; border-top: 3px solid transparent; min-width: 70px; }
  .nav a.active { border-top-color: var(--ice); }
  .main { height: auto; min-height: 0; }
  .shell { height: 100vh; }
  .content { padding: 12px; }
  .pos { grid-template-columns: 1fr; grid-template-rows: 1fr auto; height: 100%; }
  .pos-ticket { border-left: 0; border-top: 1px solid var(--line); max-height: 52vh; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: 1fr; }
}

/* columnas que no deben desbordar (tablas y listas largas dentro de rejillas) */
.grid2 > *, .grid3 > * { min-width: 0; }
.content { overflow-x: hidden; }
.content.flush { overflow: hidden; }
select.tariff-select { min-height: 32px; padding: 4px 6px; width: 100%; min-width: 150px; max-width: 260px; }

select.fit-select { min-height: 30px; padding: 3px 6px; width: auto; max-width: 140px; font-size: 13px; }
input.fit-input { min-height: 30px; padding: 3px 6px; width: 80px; font-size: 13px; }

/* las ventanas nunca más anchas que la pantalla: la tabla se desplaza dentro */
.modal { min-width: 0; max-width: min(560px, 100%); }
.modal.wide { max-width: min(980px, 100%); }
.modal .mb { overflow-x: hidden; }
.modal .table-wrap { overflow-x: auto; max-width: 100%; }
.modal-bg { overflow: hidden; }

/* ── iconos de material y líneas cobradas ── */
.mat-ico { display: inline-block; width: 1.5em; text-align: center; font-size: 1.15em; vertical-align: -1px; }
tr.paid-line > td { background: var(--ok-soft); }
.day-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.day-card.late { border-color: var(--bad); }
.day-card .lines-mini { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 6px 0; }
.day-card .lines-mini label { display: inline-flex; gap: 4px; align-items: center; }
.week-grid td, .week-grid th { text-align: center; white-space: nowrap; }
.week-grid td:first-child, .week-grid th:first-child { text-align: left; }
.mat-ico { width: auto; min-width: 1.5em; margin-right: 3px; }
.mat-ico.pack { background: var(--line, #e5e7eb); border-radius: 7px; padding: 0 4px; letter-spacing: -2px; }
.ico-svg { width: 1.25em; height: 1.25em; vertical-align: -3px; }
.mat-ico.pack .ico-svg { margin-left: 1px; }
.ico-svg { width: 1.45em; height: 1.45em; vertical-align: -5px; }

/* ── personal: cuadrante de turnos ── */
.shift-chip { display: inline-block; min-width: 26px; padding: 1px 5px; border-radius: 5px; font-size: 11px; font-weight: 700; text-align: center; }
.shift-chip.s-morning, td.s-morning { background: #fef3c7; color: #92400e; }
.shift-chip.s-afternoon, td.s-afternoon { background: #dbeafe; color: #1e40af; }
.shift-chip.s-reinforcement, td.s-reinforcement { background: #dcfce7; color: #166534; }
.shift-chip.s-block, td.s-block { background: #fee2e2; color: #991b1b; }
.shift-grid td, .shift-grid th { padding: 4px 6px; }
.shift-grid tr.emp-last td { border-bottom: 2px solid var(--line); }
.shift-grid th.weekend { background: var(--bg-soft, #f6f7f9); }

/* ── personal: cuadrante con horas ── */
.plan-grid td.plan-cell { min-width: 96px; vertical-align: top; }
.plan-grid td.plan-cell.click:hover { background: var(--bg-soft, #f6f7f9); }
.pchip { display: inline-block; margin: 1px 2px 2px 0; padding: 2px 6px; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; }
.pchip.s-work { background: #dbeafe; color: #1e40af; }
.pchip.s-off { background: #e5e7eb; color: #374151; }
.pchip.s-vac { background: #dcfce7; color: #166534; }
.pchip.s-sick { background: #fee2e2; color: #991b1b; }
.bad-text { color: var(--bad); }
.ok-t { color: #1f7a3a; }
