:root {
  /* Los colores de marca (--brand, --brand-dark, --brand-soft, --tint-*, --on-brand) los pone el servidor según Ajustes. */
  --brand: #4F46E5; --brand-dark: #3730A3; --brand-soft: #EEF2FF; --pink: #E0E7FF; --blue: #EEF2FF; --on-brand: #fff;
  --ink: #1F2328; --muted: #5F6670; --line: #E5E7EB; --bg: #F7F7F9; --surface: #FFFFFF;
  --ok: #1B7A4B; --ok-bg: #E2F5EB; --warn: #8A5A00; --warn-bg: #FFF3D6; --bad: #B00020; --bad-bg: #FDE7EA;
  --radius: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
h1 { font-size: 24px; margin: 0; color: var(--brand-dark); }
h2 { font-size: 17px; margin: 0 0 10px; color: var(--brand-dark); }
a { color: var(--brand-dark); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side img { width: 100%; margin-bottom: 14px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: var(--ink); font-weight: 500; }
.side nav a:hover { background: var(--brand-soft); }
.side nav a.on { background: var(--brand); color: var(--on-brand); }
.side .logout { margin-top: 16px; width: 100%; }
.pill { background: var(--bad); color: #fff; border-radius: 99px; font-size: 12px; font-weight: 700; padding: 0 7px; line-height: 20px; }
.content { padding: 24px; min-width: 0; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--brand-dark); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--brand-soft); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 32px; padding: 3px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
:focus-visible { outline: 3px solid #C77FD6; outline-offset: 1px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: inherit; display: block; }
.stat b { display: block; font-size: 24px; color: var(--brand-dark); font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }

.tbl-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card .tbl-wrap { border: 0; border-radius: 0; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.link { cursor: pointer; }
.tbl tr.link:hover td { background: var(--brand-soft); }
.tbl .num { text-align: right; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

.tag { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--brand-soft); color: var(--brand-dark); white-space: nowrap; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.notice { padding: 10px 14px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); margin-bottom: 16px; }
.notice.info { background: var(--brand-soft); color: var(--brand-dark); }

label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); }
input, select, textarea { display: block; width: 100%; min-height: 40px; margin-top: 4px; padding: 8px 10px; border: 1px solid #C9CDD3; border-radius: 8px; background: #fff; color: var(--ink); font: inherit; font-size: 16px; }
input[type=checkbox], input[type=radio] { display: inline-block; width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--brand); vertical-align: middle; }
input[readonly] { background: var(--brand-soft); font-weight: 600; }
textarea { min-height: 80px; resize: vertical; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 500; font-size: 14px; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.form .full { grid-column: 1 / -1; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.toolbar label { flex: 1 1 160px; }
.toolbar input, .toolbar select { margin-top: 2px; }

dialog { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); color: var(--ink); box-shadow: 0 16px 48px rgba(20, 20, 40, .3); }
dialog.wide { width: min(960px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(20, 20, 40, .45); }
.dlg-head { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; background: var(--brand); color: #fff; }
.dlg-head h2 { color: var(--on-brand); margin: 0; }
.dlg-head button { background: none; border: 0; color: var(--on-brand); font-size: 24px; cursor: pointer; width: 36px; height: 36px; }
.dlg-body { padding: 18px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs button.on { color: var(--brand-dark); border-color: var(--brand); }

.picker { position: relative; }
.picker-list { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin-top: 4px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(20, 20, 40, .18); max-height: 280px; overflow-y: auto; }
.picker-list button { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 9px 12px; font: inherit; cursor: pointer; }
.picker-list button:hover, .picker-list button:focus { background: var(--brand-soft); }
.chosen { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--brand-soft); border-radius: 10px; padding: 8px 12px; }

.price-box { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; background: var(--brand-soft); border-radius: 10px; padding: 12px; }
.price-box div b { display: block; font-size: 19px; color: var(--brand-dark); font-variant-numeric: tabular-nums; }
.price-box div span { font-size: 12px; color: var(--muted); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 3px solid var(--brand); padding: 4px 0 12px 12px; }
.timeline .meta { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.timeline p { margin: 2px 0 0; white-space: pre-wrap; }

.pos { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; }
.pos-search { font-size: 18px; min-height: 48px; }
.pos-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin-top: 12px; }
.pos-results button { text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px; font: inherit; cursor: pointer; min-height: 76px; }
.pos-results button:hover { border-color: var(--brand); background: var(--brand-soft); }
.pos-results b { display: block; color: var(--brand-dark); margin-top: 3px; }
.cart-line { display: grid; grid-template-columns: minmax(0, 1fr) 62px 80px 30px; gap: 6px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); }
.cart-line input { min-height: 34px; margin: 0; padding: 4px 6px; font-size: 15px; }
.cart-line .x { background: none; border: 0; color: var(--bad); font-size: 19px; cursor: pointer; }
.sum { display: flex; justify-content: space-between; padding: 3px 0; font-variant-numeric: tabular-nums; }
.sum.total { font-size: 25px; font-weight: 700; color: var(--brand-dark); border-top: 2px solid var(--brand); margin-top: 5px; padding-top: 7px; }
.pay { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0; }
.pay button { min-height: 46px; border: 1px solid var(--line); background: #fff; border-radius: 10px; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--brand-dark); }
.pay button.on { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }

#toast { position: fixed; right: 16px; bottom: 16px; z-index: 1000; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; max-width: calc(100vw - 32px); opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; }
#toast.show { opacity: 1; transform: none; }
#toast.err { background: var(--bad); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(135deg, var(--pink), var(--blue)); }
.login form { background: #fff; padding: 28px; border-radius: 18px; width: min(380px, 100%); display: grid; gap: 14px; box-shadow: 0 16px 48px rgba(20, 20, 40, .2); }
.login img { width: 100%; }
.login h1 { font-size: 20px; text-align: center; }
.error { color: var(--bad); margin: 0; min-height: 1em; }

@media (max-width: 1050px) { .pos { grid-template-columns: 1fr; } }
@media (max-width: 800px) {
  .shell { display: block; }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 12px; display: flex; align-items: center; gap: 8px; overflow-x: auto; }
  .side img { width: 92px; margin: 0; flex: none; }
  .side nav { flex-direction: row; }
  .side nav a { white-space: nowrap; padding: 8px 10px; gap: 6px; }
  .side .logout { width: auto; margin: 0; flex: none; }
  .content { padding: 16px; }
}

/* Marca blanca */
.brand-name { display: block; font-weight: 800; font-size: 20px; color: var(--brand-dark); line-height: 1.2; overflow-wrap: anywhere; }
.side .brand-name { margin-bottom: 14px; }
.login .brand-name { text-align: center; font-size: 26px; }
.signature { margin-top: 18px; font-size: 11px; color: var(--muted); text-align: center; }
.side .signature { margin-top: auto; padding-top: 18px; }
.side { display: flex; flex-direction: column; }
.module-list label.check { padding: 6px 0; }
.swatch { display: inline-block; width: 22px; height: 22px; border-radius: 6px; vertical-align: middle; border: 1px solid var(--line); }
.var-table input { min-height: 34px; margin: 0; padding: 4px 6px; font-size: 15px; }
.tag.var { background: var(--brand-soft); color: var(--brand-dark); }
@media (max-width: 800px) { .side .signature { display: none; } .content .signature { display: block; } }
@media (min-width: 801px) { .content .signature { display: none; } }
