/* RepairDesk — blue/gray theme with light/dark modes */
:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --raised: #f8fafc;
  --line: #e2e8f0;
  --ink: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --accent-soft: #dbeafe;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
}
[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #101a2e;
  --raised: #16233c;
  --line: #23324e;
  --ink: #e6edf7;
  --muted: #8fa3bf;
  --accent: #3b82f6;
  --accent-ink: #ffffff;
  --accent-soft: #1e3a8a;
  --danger: #f87171;
  --danger-soft: #451a1a;
  --ok: #4ade80;
  --ok-soft: #14311f;
  --warn: #fbbf24;
  --warn-soft: #3a2c0e;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }

/* ---- Shell layout ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1rem; font-weight: 700; font-size: 1.05rem; }
.brand-mark {
  display: inline-grid; place-items: center; width: 32px; height: 32px;
  background: var(--accent); color: var(--accent-ink); border-radius: 8px; font-size: .8rem; font-weight: 800;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; padding: .5rem; flex: 1; }
.sidebar nav a {
  display: flex; align-items: center; gap: .65rem; padding: .55rem .75rem;
  border-radius: 8px; color: var(--muted); font-weight: 500;
}
.sidebar nav a svg { width: 18px; height: 18px; }
.sidebar nav a:hover { background: var(--raised); color: var(--ink); text-decoration: none; }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav-bell { position: relative; display: inline-flex; margin-left: auto; color: var(--danger); }
.nav-bell svg { width: 14px; height: 14px; }
.nav-bell-dot { position: absolute; top: -3px; right: -3px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); border: 1.5px solid var(--surface); }
.nav-bell-count {
  position: absolute; top: -7px; right: -9px; min-width: 15px; height: 15px; padding: 0 3px;
  border-radius: 8px; background: var(--danger); color: #fff; border: 1.5px solid var(--surface);
  font-size: .62rem; font-weight: 700; line-height: 15px; text-align: center;
}
[data-theme="dark"] .sidebar nav a.active { color: #bfdbfe; }
.sidebar-foot { padding: 1rem; border-top: 1px solid var(--line); font-size: .85rem; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: .7rem; padding: .7rem 1.25rem;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.avatar {
  display: inline-grid; place-items: center; width: 30px; height: 30px;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .8rem;
}
[data-theme="dark"] .avatar { color: #bfdbfe; }
.content { padding: 1.5rem; max-width: 1200px; width: 100%; margin: 0 auto; }
.content.bare { max-width: none; padding: 0; min-height: 100vh; display: grid; place-items: center; }
.content.wide { max-width: none; }

.backdrop { display: none; }

@media (max-width: 480px) {
  .topbar { padding: .55rem .6rem; gap: .4rem; }
  .topbar .btn-primary { padding: .4rem .55rem; font-size: .8rem; }
  .content { padding: .75rem; }
  .card { padding: .85rem .9rem; }
  h1 { font-size: 1.25rem; }
  .page-head { margin-bottom: .8rem; }
  .stat-value { font-size: 1.5rem; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: -240px; transition: left .2s ease; z-index: 40; }
  .sidebar.open { left: 0; }
  .backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 30; }
  .menu-btn { display: inline-grid; }
  .user-name { display: none; }
  .content { padding: 1rem; }
}

/* ---- Components ---- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 1.1rem 1.25rem; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 1rem; }
.grid > * { min-width: 0; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1000px) { .grid-4, .grid-5 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-4, .grid-2, .grid-3, .grid-5 { grid-template-columns: 1fr; } }

.stat-label { color: var(--muted); font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; }

.btn {
  display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .9rem;
  border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: .9rem;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(1.05); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--raised); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: .3rem .6rem; font-size: .82rem; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; font-size: 1rem;
  border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
}
.icon-btn:hover { background: var(--raised); text-decoration: none; }
/* Compact icon-only action buttons (reorder arrows, row removal ✕) — kept visually
   tight but still large enough to tap reliably on a phone. */
.btn-tap { padding: .4rem .55rem; min-width: 34px; min-height: 34px; }

.field {
  width: 100%; padding: .55rem .7rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit;
}
.field:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
textarea.field { resize: vertical; min-height: 80px; }
.lbl { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin: 0 0 .3rem; }
.form-row { margin-bottom: .9rem; }

.phone-field { display: flex; gap: .4rem; }
.phone-field-country { flex: 0 0 auto; width: auto; max-width: 46%; }
.phone-field-local { flex: 1 1 auto; min-width: 0; }

table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th {
  text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: .55rem .75rem; border-bottom: 1px solid var(--line);
}
table.data td { padding: .65rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--raised); }
.table-wrap { overflow-x: auto; }

.badge {
  display: inline-block; padding: .18rem .6rem; border-radius: 99px;
  font-size: .76rem; font-weight: 700; white-space: nowrap;
  background: var(--raised); color: var(--muted); /* default for custom (non-canonical) stage names */
}
.st-received { background: var(--accent-soft); color: var(--accent); }
[data-theme="dark"] .st-received { color: #bfdbfe; }
.st-diagnosing { background: var(--warn-soft); color: var(--warn); }
.st-waiting-for-parts { background: #f3e8ff; color: #9333ea; }
[data-theme="dark"] .st-waiting-for-parts { background: #3b0764; color: #d8b4fe; }
.st-repairing { background: #ffedd5; color: #ea580c; }
[data-theme="dark"] .st-repairing { background: #431407; color: #fdba74; }
.st-ready-for-pickup { background: #cffafe; color: #0891b2; }
[data-theme="dark"] .st-ready-for-pickup { background: #164e63; color: #a5f3fc; }
.st-completed { background: var(--ok-soft); color: var(--ok); }
.quote-pending { background: var(--warn-soft); color: var(--warn); }
.quote-approved { background: var(--ok-soft); color: var(--ok); }
.quote-rejected { background: var(--danger-soft); color: var(--danger); }
.inv-pending { background: var(--warn-soft); color: var(--warn); }
.inv-issued { background: var(--ok-soft); color: var(--ok); }
.inv-void { background: var(--raised); color: var(--muted); }
.inv-error { background: var(--danger-soft); color: var(--danger); }
.pay-pendiente { background: var(--warn-soft); color: var(--warn); }
.pay-aprobado { background: var(--ok-soft); color: var(--ok); }
.pay-rechazado { background: var(--danger-soft); color: var(--danger); }

/* Pipeline stepper */
.pipeline { display: flex; gap: 0; overflow-x: auto; padding: .25rem 0; }
.pipe-step { display: flex; align-items: center; flex: 1; min-width: 110px; }
.pipe-btn {
  display: flex; flex-direction: column; align-items: center; gap: .35rem; width: 100%;
  background: none; border: none; cursor: pointer; font: inherit; color: var(--muted); padding: .35rem .25rem; border-radius: 8px;
}
.pipe-btn:hover { background: var(--raised); }
.pipe-dot {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--line); background: var(--surface); font-size: .72rem; font-weight: 800; color: var(--muted);
}
.pipe-step.done .pipe-dot { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pipe-step.current .pipe-dot { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.pipe-step.current .pipe-label { color: var(--ink); font-weight: 700; }
.pipe-label { font-size: .72rem; text-align: center; line-height: 1.2; }
.pipe-bar { height: 2px; flex: 1; background: var(--line); min-width: 8px; }
.pipe-step.done + .pipe-step .pipe-bar-lead,
.pipe-bar.filled { background: var(--accent); }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0 0 0 1.35rem; position: relative; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline li { position: relative; padding: 0 0 1.1rem .4rem; }
.timeline li::before {
  content: ""; position: absolute; left: -1.35rem; top: .35rem; width: 12px; height: 12px;
  border-radius: 50%; background: var(--accent); border: 2px solid var(--surface);
}
.timeline li.internal::before { background: var(--warn); }
.tl-meta { font-size: .78rem; color: var(--muted); }
.tl-delete {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: .78rem; padding: 0 0 0 .5rem; line-height: 1;
}
.tl-delete:hover { color: var(--danger, #dc2626); }
.tl-internal-tag {
  font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  color: var(--warn); background: var(--warn-soft); border-radius: 5px; padding: .05rem .4rem; margin-left: .4rem;
}

/* Toasts */
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 100; }
.toast {
  background: var(--ink); color: var(--bg); padding: .65rem 1rem; border-radius: 10px;
  box-shadow: var(--shadow); font-size: .9rem; font-weight: 600; max-width: 340px;
  animation: toast-in .25s ease;
}
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--ok); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Misc */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip {
  padding: .3rem .75rem; border-radius: 99px; border: 1px solid var(--line);
  font-size: .82rem; font-weight: 600; color: var(--muted); background: var(--surface);
}
.chip:hover { text-decoration: none; background: var(--raised); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.settings-tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: 1.4rem; flex-wrap: wrap; }
.settings-tabs a { padding: .6rem 1rem; font-weight: 700; font-size: .9rem; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.settings-tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.settings-tabs a:hover { color: var(--ink); text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.mt { margin-top: 1rem; }
.mb { margin-bottom: 1rem; }
.flex { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.right { margin-left: auto; }
.empty { text-align: center; color: var(--muted); padding: 2.2rem 1rem; }
.attach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; }
.attach {
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--raised);
  display: flex; flex-direction: column;
}
.attach img { width: 100%; height: 96px; object-fit: cover; display: block; }
.attach .doc { height: 96px; display: grid; place-items: center; font-size: 1.6rem; }
.attach-meta { padding: .45rem .55rem; font-size: .75rem; }
.login-card { width: min(400px, 92vw); }
.login-brand { display: flex; align-items: center; gap: .7rem; justify-content: center; margin-bottom: 1.2rem; font-weight: 800; font-size: 1.2rem; }

/* Print / invoice */
@media print {
  body { background: #fff; color: #000; }
  .no-print { display: none !important; }
  .print-sheet { box-shadow: none !important; border: none !important; }
  .content { padding: 0; max-width: none; }
}
.invoice-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; border-bottom: 2px solid var(--ink); padding-bottom: 1rem; margin-bottom: 1.25rem; }
.invoice-total td { font-weight: 800; font-size: 1.05rem; border-top: 2px solid var(--ink) !important; }
/* Detalle de factura (inc/invoice_lines.php): en celular solo Concepto + Total, con
   "cant. × valor unit." debajo del nombre — sin desplazamiento horizontal. */
.invoice-lines .inv-compact { display: none; }
.invoice-sum { margin-top: .25rem; }
@media screen and (max-width: 560px) {
  .invoice-lines .inv-col { display: none; }
  .invoice-lines .inv-compact { display: block; }
}

/* Lightbox gallery */
.lb-overlay {
  position: fixed; inset: 0; z-index: 200; background: rgba(8, 12, 20, .92);
  display: flex; align-items: center; justify-content: center; padding: 2.5rem;
}
.lb-overlay img, .lb-overlay video {
  max-width: 92vw; max-height: 84vh; border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.6);
  background: #000;
}
.lb-btn {
  position: fixed; z-index: 201; background: rgba(255,255,255,.12); color: #fff;
  border: none; border-radius: 50%; width: 46px; height: 46px; font-size: 1.3rem;
  cursor: pointer; display: grid; place-items: center;
}
.lb-btn:hover { background: rgba(255,255,255,.25); }
.lb-close { top: 1rem; right: 1rem; }
.lb-prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.lb-next { right: 1rem; top: 50%; transform: translateY(-50%); }
.lb-count { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); color: #cbd5e1; font-size: .85rem; z-index: 201; }

/* Searchable customer picker */
.csearch { position: relative; }
.csearch-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 50;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15,23,42,.12); max-height: 260px; overflow-y: auto;
  padding: .3rem;
}
.csearch-item {
  padding: .55rem .7rem; border-radius: 7px; cursor: pointer; font-size: .92rem;
  display: flex; justify-content: space-between; gap: .6rem;
}
.csearch-item:hover, .csearch-item.active { background: var(--raised); }
.csearch-item .cname { font-weight: 600; }
.csearch-item .cphone { color: var(--muted); font-size: .82rem; white-space: nowrap; }
.csearch-empty { padding: .6rem .7rem; color: var(--muted); font-size: .88rem; }
/* Departamento + ciudad (inc/colombia.php): dentro de otro .grid ocupa la fila completa */
.grid > .geo-picker { grid-column: 1 / -1; }
.geo-hint { margin-top: .25rem; min-height: 1.1em; }
.csearch-clear {
  position: absolute; right: .5rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1rem; padding: .2rem .4rem;
}

/* Loading overlay (form saves with data-loading-on-submit) */
.rd-loading-overlay {
  position: fixed; inset: 0; z-index: 300; background: rgba(8, 12, 20, .55);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .9rem;
}
.rd-spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: rd-spin .7s linear infinite;
}
.rd-loading-text { color: #fff; font-weight: 600; font-size: .95rem; }
@keyframes rd-spin { to { transform: rotate(360deg); } }

/* Vehicle damage map (automotriz) */
.damage-map { max-width: 360px; }
.dmg-zone {
  fill: var(--surface); stroke: var(--muted); stroke-width: 1.5; cursor: pointer;
  transition: fill .12s ease, stroke .12s ease;
}
.dmg-zone:hover { fill: var(--accent-soft); stroke: var(--accent); }
.dmg-zone.active { fill: var(--danger-soft); stroke: var(--danger); }
.dmg-zone[role="img"] { cursor: default; }
.dmg-zone[role="img"]:hover { fill: var(--surface); stroke: var(--muted); }
.dmg-zone[role="img"].active:hover { fill: var(--danger-soft); stroke: var(--danger); }
.dmg-legend { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: center; margin-top: .7rem; }
.dmg-chip {
  padding: .25rem .6rem; border-radius: 99px; border: 1px solid var(--line);
  font: inherit; font-size: .78rem; font-weight: 600; color: var(--muted); background: var(--surface); cursor: pointer;
}
button.dmg-chip { cursor: pointer; }
span.dmg-chip { cursor: default; }
.dmg-chip:hover { background: var(--raised); }
.dmg-chip.active { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

/* ---- Punto de venta (pos.php / assets/pos.js) ---- */
.pos-quick.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.topbar .pos-quick ~ .icon-btn, .topbar .pos-quick ~ .user-chip { flex-shrink: 0; }
@media (max-width: 359px) { .topbar .pos-quick { display: none; } }
.pos-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 420px); gap: 1rem; align-items: start; }
.pos-layout [hidden], .pos-modal[hidden] { display: none !important; }
.pos-search { font-size: 1.05rem; padding: .7rem .8rem; }
.pos-results { margin-top: .7rem; display: flex; flex-direction: column; gap: .35rem; max-height: 62vh; overflow-y: auto; }
.pos-hint { padding: .4rem .1rem; }
.pos-item {
  display: flex; justify-content: space-between; align-items: center; gap: .8rem; width: 100%; text-align: left;
  padding: .65rem .75rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  color: var(--ink); font: inherit; cursor: pointer; min-height: 48px;
}
.pos-item:hover { background: var(--raised); border-color: var(--accent); }
.pos-item > span:first-child { display: flex; flex-direction: column; min-width: 0; }
.pos-item-meta { display: flex; flex-direction: column; align-items: flex-end; white-space: nowrap; }
.pos-nostock { color: var(--danger); font-weight: 600; }
.pos-cart-card { position: sticky; top: 4.2rem; }
.pos-cart { margin: .7rem 0; display: flex; flex-direction: column; gap: .5rem; max-height: 46vh; overflow-y: auto; }
.pos-cart .empty { padding: 1.2rem .5rem; }
.pos-line { border: 1px solid var(--line); border-radius: 10px; padding: .55rem .6rem; background: var(--raised); }
.pos-line-head { display: flex; justify-content: space-between; gap: .5rem; align-items: flex-start; }
.pos-line-ctrls { display: flex; align-items: center; gap: .45rem; margin-top: .45rem; flex-wrap: wrap; }
.pos-qty { display: flex; align-items: center; gap: .25rem; }
.pos-qty .field { width: 58px; text-align: center; padding: .4rem .3rem; }
.pos-disc { display: flex; gap: .3rem; }
.pos-disc select.field { width: auto; flex: 0 0 auto; }
.pos-line-disc .field { padding: .4rem .45rem; }
.pos-line-disc input.field { width: 84px; }
.pos-line-total { margin-left: auto; white-space: nowrap; }
.pos-row { margin-top: .8rem; }
.pos-customer { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .5rem .65rem; border: 1px solid var(--accent); border-radius: 10px; background: var(--accent-soft); }
.pos-customer > span { display: flex; flex-direction: column; }
.pos-customer-new { display: flex; flex-direction: column; gap: .4rem; margin-top: .5rem; padding: .6rem; border: 1px dashed var(--line); border-radius: 10px; }
.pos-totals { width: 100%; margin-top: 1rem; border-collapse: collapse; }
.pos-totals td { padding: .25rem 0; }
.pos-totals td:last-child { text-align: right; }
.pos-grand td { font-size: 1.35rem; font-weight: 800; border-top: 2px solid var(--line); padding-top: .5rem; }
.pos-pay-btn { width: 100%; justify-content: center; padding: .85rem 1rem; font-size: 1.05rem; margin-top: .6rem; }
.pos-pay-btn:disabled, .pos-mobile-bar .btn:disabled { opacity: .5; cursor: not-allowed; }
.pos-mobile-bar { display: none; }
.pos-modal { position: fixed; inset: 0; z-index: 150; background: rgba(8, 12, 20, .55); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.pos-modal-box { width: min(440px, 100%); max-height: 92vh; overflow-y: auto; }
.pos-due { font-size: 1.1rem; margin: .8rem 0; display: flex; justify-content: space-between; }
.pos-due strong { font-size: 1.5rem; }
.pos-pay-line { display: grid; grid-template-columns: 130px 1fr auto; gap: .4rem; align-items: center; margin-bottom: .45rem; }
.pos-pay-line label { font-weight: 600; font-size: .9rem; }
.pos-quick-cash { display: flex; gap: .35rem; flex-wrap: wrap; margin: .3rem 0 .6rem; }
.pos-quick-cash .chip { cursor: pointer; font: inherit; font-size: .82rem; }
.pos-pay-status { min-height: 1.6em; font-size: 1.05rem; }
.pos-change { font-size: 1.4rem; color: var(--ok); }
@media (max-width: 860px) {
  .pos-layout { grid-template-columns: 1fr; }
  .pos-cart-card { position: static; }
  .pos-cart { max-height: none; }
  .pos-results { max-height: 40vh; }
  .pos-mobile-bar {
    display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    position: sticky; bottom: 0; z-index: 25; margin: 1rem -1rem -1rem; padding: .7rem 1rem;
    background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 12px rgba(15,23,42,.08);
  }
  .pos-mobile-bar strong { font-size: 1.25rem; }
  .pos-mobile-bar .btn { padding: .75rem 1.4rem; font-size: 1rem; }
}
@media (max-width: 480px) {
  .pos-mobile-bar { margin: .75rem -.75rem -.75rem; }
  .pos-pay-line { grid-template-columns: 1fr auto; }
  .pos-pay-line label { grid-column: 1 / -1; }
  .pos-head .flex .btn { padding: .35rem .5rem; }
  .topbar .pos-quick { padding: .4rem .55rem; font-size: .8rem; }
}

/* ---- Acordeones de Ajustes (accordion_open() en inc/layout.php) ---- */
.settings-accs { max-width: 780px; }
.acc {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); margin-bottom: .75rem; scroll-margin-top: 5rem;
}
.acc > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: .75rem;
  padding: .85rem 1.1rem; min-height: 60px; border-radius: 12px; -webkit-tap-highlight-color: transparent;
}
.acc > summary::-webkit-details-marker { display: none; }
.acc > summary::marker { content: ""; }
.acc > summary:hover { background: var(--raised); }
.acc > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.acc[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom: 1px solid var(--line); }
.acc-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.acc-title { font-weight: 700; font-size: 1rem; line-height: 1.3; }
.acc-sub { color: var(--muted); font-size: .82rem; line-height: 1.35; margin-top: .1rem; }
.acc-status { flex-shrink: 0; }
.acc-chevron {
  flex-shrink: 0; width: 10px; height: 10px; margin: 0 .2rem 0 .1rem;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -2px); transition: transform .15s ease;
}
.acc[open] > summary .acc-chevron { transform: rotate(-135deg) translate(-2px, -2px); }
.acc-body { padding: 1rem 1.1rem 1.1rem; }
.acc-body > :last-child { margin-bottom: 0; }
.acc.acc-flash { animation: acc-flash 1.6s ease; }
@keyframes acc-flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); border-color: var(--accent); } }
.acc-note { margin-bottom: .75rem; }
.acc-inset { padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 8px; background: var(--raised); }
.badge.tone-ok { background: var(--ok-soft); color: var(--ok); }
.badge.tone-warn { background: var(--warn-soft); color: var(--warn); }
.badge.tone-danger { background: var(--danger-soft); color: var(--danger); }
.badge.tone-off { background: var(--raised); color: var(--muted); border: 1px solid var(--line); }
@media (max-width: 560px) {
  .acc > summary { padding: .8rem .85rem; gap: .55rem; flex-wrap: wrap; }
  .acc-text { flex-basis: calc(100% - 2rem); }
  .acc-status { order: 3; margin-left: 0; }
  .acc > summary { position: relative; padding-right: 2.4rem; }
  .acc-chevron { position: absolute; right: 1.05rem; top: 1.35rem; }
  .acc-body { padding: .85rem .85rem 1rem; }
}

/* ---- Acordeones del superadmin (sa_accordion_start() en superadmin.php) ----
   Clases propias (.sa-acc), separadas de .acc de Ajustes del taller, para que un cambio
   aquí no toque a los talleres. */
.sa-acc-tools { display: flex; justify-content: flex-end; gap: .4rem; flex-wrap: wrap; margin-bottom: .75rem; }
.sa-acc-tools[hidden] { display: none; }
.sa-acc-tools .btn { min-height: 36px; }
.sa-acc-intro { margin: 0 0 .9rem; }
.sa-acc {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); margin-bottom: 1rem; scroll-margin-top: 5rem; min-width: 0;
}
.sa-acc > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: .75rem;
  padding: .8rem 1.1rem; min-height: 56px; border-radius: 12px; -webkit-tap-highlight-color: transparent;
}
.sa-acc > summary::-webkit-details-marker { display: none; }
.sa-acc > summary::marker { content: ""; }
.sa-acc > summary:hover { background: var(--raised); }
.sa-acc > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sa-acc[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom: 1px solid var(--line); }
.sa-acc-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sa-acc-title { font-weight: 700; font-size: 1.02rem; line-height: 1.3; overflow-wrap: anywhere; }
.sa-acc-sub { color: var(--muted); font-size: .82rem; line-height: 1.35; margin-top: .1rem; }
.sa-acc-count {
  display: inline-block; min-width: 1.6em; padding: .05rem .45rem; margin-left: .2rem; border-radius: 99px;
  background: var(--raised); border: 1px solid var(--line); color: var(--muted);
  font-size: .75rem; font-weight: 700; text-align: center; vertical-align: .1em;
}
.sa-acc-badge { flex-shrink: 0; white-space: nowrap; }
.badge.info { background: var(--accent-soft); color: var(--accent); }
[data-theme="dark"] .badge.info { color: #bfdbfe; }
.sa-acc-chevron {
  flex-shrink: 0; width: 10px; height: 10px; margin: 0 .2rem 0 .1rem;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -2px); transition: transform .15s ease;
}
.sa-acc[open] > summary .sa-acc-chevron { transform: rotate(-135deg) translate(-2px, -2px); }
.sa-acc-body { padding: 1rem 1.1rem 1.1rem; min-width: 0; }
.sa-acc-body > :first-child { margin-top: 0; }
.sa-acc-body > :last-child { margin-bottom: 0; }
.sa-acc-body .sa-fields { gap: .2rem 1rem; }
.sa-acc.sa-acc-flash { animation: sa-acc-flash 1.6s ease; }
@keyframes sa-acc-flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); border-color: var(--accent); } }
/* Variante interna (secciones de la tarjeta de cada taller) */
.sa-acc-inner { background: transparent; box-shadow: none; border: 0; border-top: 1px solid var(--line); border-radius: 0; margin: 0; padding-top: .3rem; }
.sa-acc-inner > summary { min-height: 44px; padding: .3rem .2rem; gap: .5rem; border-radius: 8px; }
.sa-acc-inner > summary:hover { background: var(--raised); }
.sa-acc-inner[open] > summary { border-bottom: 0; border-radius: 8px; }
.sa-acc-inner .sa-acc-title { font-size: .88rem; font-weight: 600; }
.sa-acc-inner > .sa-acc-body { margin-top: .35rem; background: var(--raised); border: 1px solid var(--line); border-radius: 8px; padding: .75rem; }
.sa-acc-inner.sa-acc-flash { animation: none; }
.tenant-danger.sa-acc-inner { border-top: 0; padding-top: 0; }
.tenant-danger > summary .sa-acc-title { color: var(--danger); }
.tenant-danger > summary .sa-acc-chevron { border-color: var(--danger); }
@media (max-width: 560px) {
  .sa-acc > summary { position: relative; flex-wrap: wrap; gap: .45rem .55rem; padding: .75rem 2.4rem .75rem .85rem; }
  .sa-acc-text { flex-basis: 100%; }
  .sa-acc-chevron { position: absolute; right: 1rem; top: 1.3rem; margin: 0; }
  .sa-acc-body { padding: .85rem .85rem 1rem; }
  .sa-acc-body .sa-fields { grid-template-columns: 1fr; }
  .sa-acc-body .sa-fields > div { grid-column: auto !important; }
  .sa-acc-inner > summary { padding: .3rem 2rem .3rem .2rem; }
  .sa-acc-inner .sa-acc-chevron { right: .6rem; top: 1.05rem; }
  .sa-acc-tools { justify-content: stretch; }
  .sa-acc-tools .btn { flex: 1; justify-content: center; min-height: 44px; }
}

/* Validación en formularios (Datos del negocio) */
.field.is-invalid { border-color: var(--danger); background: var(--danger-soft); }
.field-error { color: var(--danger); font-size: .82rem; font-weight: 600; margin-top: .3rem; }
.nit-field { display: flex; align-items: center; gap: .4rem; }
.nit-field .field { flex: 1; min-width: 0; }
.nit-field .nit-dv { flex: 0 0 4.2rem; text-align: center; }
.nit-dash { font-weight: 700; color: var(--muted); }

/* Encabezado y pie legal de comprobantes / facturas (inc/invoice_lines.php) */
.invoice-biz { min-width: 0; flex: 1; }
.invoice-biz .biz-name { display: block; margin-bottom: .15rem; }
.invoice-biz .biz-line { color: var(--muted); line-height: 1.4; }
.invoice-doc { text-align: right; flex-shrink: 0; max-width: 45%; }
.invoice-title { font-size: 1.15rem; font-weight: 800; line-height: 1.2; }
.invoice-legal { display: flex; gap: 1rem; align-items: flex-start; margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.invoice-qr svg { display: block; border-radius: 4px; }
.invoice-footer-note { padding-top: .6rem; border-top: 1px dashed var(--line); }
@media screen and (max-width: 560px) {
  .invoice-head { flex-direction: column; }
  .invoice-doc { text-align: left; max-width: none; }
  .invoice-legal { flex-direction: column; }
}
@media print {
  .invoice-biz .biz-line { color: #333; }
}

/* ---- Menú lateral compacto en escritorio (☰, assets/app.js) ---- */
.menu-btn { display: inline-grid; }
@media (min-width: 861px) {
  .sidebar { transition: width .18s ease; }
  html.sb-compact .sidebar { width: 68px; }
  html.sb-compact .sidebar .brand { justify-content: center; padding: 1.1rem .4rem; }
  html.sb-compact .sidebar .brand-name { display: none; }
  html.sb-compact .sidebar .brand-logo { max-width: 48px !important; height: auto !important; max-height: 40px; }
  html.sb-compact .sidebar nav { padding: .5rem .55rem; }
  html.sb-compact .sidebar nav a { position: relative; justify-content: center; padding: .6rem 0; font-size: 0; gap: 0; }
  html.sb-compact .sidebar nav a svg { width: 20px; height: 20px; flex-shrink: 0; }
  html.sb-compact .sidebar .nav-bell { position: absolute; top: 3px; right: 6px; margin: 0; }
  html.sb-compact .sidebar .nav-bell > svg { display: none; }
  html.sb-compact .sidebar .nav-bell-dot,
  html.sb-compact .sidebar .nav-bell-count { position: static; display: inline-block; }
  html.sb-compact .sidebar-foot { display: none; }
  /* Tooltip con el nombre de la sección (data-tip lo pone app.js) */
  html.sb-compact .sidebar nav a[data-tip]:hover::after,
  html.sb-compact .sidebar nav a[data-tip]:focus-visible::after {
    content: attr(data-tip); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
    background: var(--ink); color: var(--bg); font-size: .8rem; font-weight: 600; white-space: nowrap;
    padding: .3rem .6rem; border-radius: 6px; box-shadow: var(--shadow); z-index: 60; pointer-events: none;
  }
}

/* ---- POS en pantalla completa / modo inmersivo (pos.php, assets/pos.js) ---- */
.pos-fs-exit { display: none; }
html.pos-immersive body.pos-sale .sidebar,
html.pos-immersive body.pos-sale .topbar,
html.pos-immersive body.pos-sale .backdrop { display: none !important; }
html.pos-immersive body.pos-sale .content { padding: .75rem 1rem; max-width: none; }
html.pos-immersive body.pos-sale .pos-cart-card { top: .75rem; }
html.pos-immersive body.pos-sale .pos-results { max-height: calc(100vh - 13rem); }
html.pos-immersive body.pos-sale .pos-cart { max-height: calc(100vh - 30rem); min-height: 8rem; }
html.pos-immersive body.pos-sale .pos-fs-exit {
  display: inline-flex; position: fixed; top: max(.6rem, env(safe-area-inset-top)); right: max(.6rem, env(safe-area-inset-right)); z-index: 140;
  box-shadow: 0 2px 10px rgba(15, 23, 42, .18);
}
html.pos-immersive body.pos-sale .pos-head { padding-right: 13rem; }
@media (max-width: 860px) {
  html.pos-immersive body.pos-sale .content { padding: .6rem .6rem 0; }
  html.pos-immersive body.pos-sale .pos-head { padding-right: 0; padding-top: 2.6rem; }
  html.pos-immersive body.pos-sale .pos-mobile-bar { margin: .75rem -.6rem 0; padding-bottom: max(.7rem, env(safe-area-inset-bottom)); }
  html.pos-immersive body.pos-sale .pos-results { max-height: 40vh; }
  html.pos-immersive body.pos-sale .pos-cart { max-height: none; }
}
html.pos-immersive body.pos-sale #posFullscreenBtn { display: none; }
