/* Fonotaller — sistema de diseño (base Fonotaller: petróleo + ámbar sobre papel cálido,
   con patrones de disposición tipo RepairDesk). Extraído del prototipo original. */
:root {
  --ink: #142429; --ink-2: #3b4a4f; --muted: #6a7579; --line: #e4e1d8; --line-2: #d6d2c6;
  --bg: #f5f3ee; --panel: #ffffff; --panel-2: #faf9f6;
  --brand: #0e3b43; --brand-2: #17616a; --brand-soft: #e3eff0; --accent: #e8833a; --accent-soft: #fcefe3;
  --ok: #15803d; --ok-soft: #e7f5ec; --warn: #b45309; --warn-soft: #fdf3e2; --bad: #b91c1c; --bad-soft: #fdecec; --purple: #7c3aed;
  --radius: 10px; --radius-sm: 7px; --shadow: 0 1px 2px rgba(20,36,41,.06), 0 4px 14px rgba(20,36,41,.05);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--brand-2); text-decoration: none; } a:hover { text-decoration: underline; }
h1,h2,h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
.num, td.num, .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }

/* Estructura */
.app { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.sidebar { background: var(--brand); color: #d6e4e6; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 700; font-size: 18px; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; stroke: none; }
.sidebar nav { display: flex; flex-direction: column; padding: 6px 10px; gap: 2px; flex: 1; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: #c9dadd; font-weight: 500; cursor: pointer; }
.sidebar nav a:hover { background: #ffffff12; color: #fff; text-decoration: none; }
.sidebar nav a.active { background: #ffffff1f; color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav-sep { height: 1px; background: #ffffff1a; margin: 8px 6px; }
.sidebar-foot { padding: 12px 18px 16px; border-top: 1px solid #ffffff1a; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.me { display: flex; flex-direction: column; color: #fff; min-width: 0; }
.me span { color: #9fbcc0; font-size: 12px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.topbar .menu-btn { display: none; }
.global-search { position: relative; flex: 1; max-width: 640px; display: flex; align-items: center; }
.global-search > svg { position: absolute; left: 11px; color: var(--muted); }
.global-search input { width: 100%; padding: 9px 12px 9px 36px; border: 1px solid var(--line-2); border-radius: 99px; background: var(--panel-2); font: inherit; }
.global-search input:focus { outline: 2px solid var(--brand-2); background: #fff; }
.content { padding: 22px 24px 60px; max-width: 1400px; width: 100%; }

/* Avisos */
.flash { margin: 14px 0 0; padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid; font-weight: 500; }
.flash-ok { background: var(--ok-soft); border-color: #b9e2c7; color: #14532d; }
.flash-error { background: var(--bad-soft); border-color: #f3c0c0; color: #7f1d1d; }
.flash-warn { background: var(--warn-soft); border-color: #f2d49f; color: #78350f; }

/* Componentes */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--panel-2); border-color: #c4bfb1; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--brand-2); cursor: pointer; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card-body { padding: 14px 16px; }
.card + .card, .stack > * + * { margin-top: 14px; }
.grid { display: grid; gap: 14px; }
.cols-main { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; color: color-mix(in srgb, var(--c,#64748b) 78%, #000); background: color-mix(in srgb, var(--c,#64748b) 13%, #fff); border: 1px solid color-mix(in srgb, var(--c,#64748b) 28%, #fff); }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c,#64748b); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 5px; font-size: 11.5px; font-weight: 600; background: #eef0ef; color: var(--ink-2); }
.empty-state { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty-state strong { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
dl.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; margin: 0; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* Tablas */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); white-space: nowrap; }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr.row-link { cursor: pointer; }
table.t tbody tr:hover { background: #fbfaf7; }
table.t td.num, table.t th.num { text-align: right; }

/* Formularios */
label { display: block; font-weight: 600; font-size: 12.5px; color: var(--ink-2); margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); font: inherit; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: -1px; border-color: transparent; }
.field { margin-bottom: 12px; min-width: 0; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { margin: 0; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--ink); position: relative; overflow: hidden; box-shadow: var(--shadow); cursor: pointer; }
.kpi:hover { border-color: var(--brand-2); text-decoration: none; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--t, var(--brand)); }
.kpi .v { font-size: 30px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--ink-2); font-weight: 600; font-size: 13px; }
.kpi.t-ok { --t: var(--ok); } .kpi.t-warn { --t: var(--accent); } .kpi.t-bad { --t: var(--bad); } .kpi.t-purple { --t: var(--purple); } .kpi.t-neutral { --t: #94a3b8; }

/* Tabs ficha */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; cursor: pointer; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--accent); }

/* Cargando / JSON debug */
.loading { padding: 40px; text-align: center; color: var(--muted); }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--line-2); border-top-color: var(--brand); border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
details.raw { margin-top: 16px; }
details.raw summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
details.raw pre { background: #0f1a1d; color: #cfe6e9; padding: 12px; border-radius: 8px; overflow: auto; font: 12px/1.5 var(--mono); max-height: 420px; }

/* Responsive */
@media (max-width: 1100px) { .cols-main { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; transform: translateX(-100%); transition: transform .2s; z-index: 50; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .topbar .menu-btn { display: inline-flex; }
  .content { padding: 16px 12px 60px; }
}
.icon-btn { background: none; border: 1px solid var(--line-2); border-radius: 8px; padding: 6px; cursor: pointer; color: var(--ink); display: inline-flex; }
select.st-sel { padding: 5px 8px; font-size: 12.5px; font-weight: 600; min-width: 160px; width: auto; }
select.st-sel:disabled { opacity: .6; }

/* ---------- Tablero (columnas por estado, arrastrar entre ellas) ---------- */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.board-col { background: #ecebe5; border-radius: var(--radius); padding: 8px; min-width: 262px; max-width: 300px; flex: 0 0 auto; max-height: calc(100vh - 190px); display: flex; flex-direction: column; }
.board-col.drop { outline: 2px dashed var(--brand-2); outline-offset: -2px; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; font-weight: 700; font-size: 13px; }
.col-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.col-count { margin-left: auto; background: #fff; border-radius: 99px; padding: 0 8px; font-size: 12px; color: var(--ink-2); }
.col-cards { overflow-y: auto; flex: 1; min-height: 44px; display: flex; flex-direction: column; gap: 8px; }
.board-card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; box-shadow: 0 1px 1px rgba(0,0,0,.03); cursor: grab; touch-action: none; }
.board-card:hover { border-color: var(--brand-2); }
.board-card.dragging { opacity: .5; outline: 2px dashed var(--pos-teal, #0d9488); cursor: grabbing; }
.bc-top { display: flex; justify-content: space-between; gap: 6px; font-size: 12.5px; }
.bc-cli { font-weight: 600; margin-top: 3px; }
.board-empty { color: var(--muted); font-size: 12px; text-align: center; padding: 14px 4px; }

/* ---------- Ventana emergente (modal) ---------- */
.modal-ov { position: fixed; inset: 0; background: rgba(20,36,41,.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal { background: var(--panel); border-radius: var(--radius); box-shadow: 0 24px 60px rgba(0,0,0,.3); width: 100%; max-width: 460px; max-height: 92vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 16px 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--panel); }
.expand-btn { background: none; border: 0; color: var(--brand-2); font: inherit; font-weight: 600; cursor: pointer; padding: 8px 0; }
.pick-list .add-row { color: var(--brand-2); font-weight: 600; }
.pick-list .add-row:hover { background: var(--accent-soft); }

/* Recepción */
.step { counter-increment: step; }
.step-title { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.step-title::before { content: counter(step); width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 700; flex: none; }
.steps { counter-reset: step; }
.pick-list { border: 1px solid var(--line); border-radius: var(--radius-sm); max-height: 260px; overflow: auto; margin-top: 8px; }
.pick-list button { display: flex; justify-content: space-between; gap: 12px; width: 100%; text-align: left; padding: 9px 12px; background: #fff; border: 0; border-bottom: 1px solid var(--line); font: inherit; cursor: pointer; }
.pick-list button:last-child { border-bottom: 0; }
.pick-list button:hover { background: var(--brand-soft); }
.selected-box { display: flex; justify-content: space-between; align-items: center; gap: 10px; border: 1px solid #b9d5d8; background: var(--brand-soft); border-radius: var(--radius-sm); padding: 10px 12px; }
.selected-box .sb-main { font-weight: 600; }
.inline-row { display: flex; gap: 8px; align-items: flex-end; }
.inline-row .field { flex: 1; margin: 0; }
.create-foot { position: sticky; bottom: 0; background: var(--panel); border-top: 1px solid var(--line); padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; border-radius: 0 0 var(--radius) var(--radius); }
.rc-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.rc-chips button { padding: 8px 14px; border: 1px solid var(--line-2); background: #fff; border-radius: 99px; font: inherit; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.rc-chips button:hover { border-color: var(--brand-2); }
.rc-chips button.sel { background: var(--brand); border-color: var(--brand); color: #fff; }
.rc-crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.rc-crumbs b { color: var(--ink); }

/* ---------- Recepción estilo POS (replica de RepairDesk) ---------- */
.pos { --pos-teal: #0d9488; --pos-teal-dark: #134e4a; --pos-green: #4bc651; --pos-bd: #e5e7eb;
  display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 16px; align-items: start; }
.pos-col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pos-left { display: flex; flex-direction: column; }
.pos-cust { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.pos-cust .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pos-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--brand-soft); color: var(--pos-teal-dark); display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.pos-lines { min-height: 180px; }
.pos-lines table { width: 100%; border-collapse: collapse; }
.pos-lines th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--line); }
.pos-lines td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 13px; }
.pos-lines .rm { color: var(--bad); cursor: pointer; background: none; border: 0; font-size: 16px; line-height: 1; }
.pos-empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.pos-tot { padding: 12px 16px; border-top: 1px solid var(--line); }
.pos-tot .r { display: flex; justify-content: space-between; padding: 3px 0; color: var(--ink-2); }
.pos-tot .grand { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 2px solid var(--ink); font-size: 20px; font-weight: 700; }
.pos-actions { padding: 12px 16px; display: flex; gap: 8px; }
.btn-pos { flex: 1; background: var(--pos-teal); border: 1px solid var(--pos-teal); color: #fff; font-weight: 700; padding: 12px; border-radius: var(--radius-sm); cursor: pointer; font: inherit; font-weight: 700; }
.btn-pos:hover { background: #0c857a; }
.btn-pos[disabled] { opacity: .5; pointer-events: none; }
.btn-pos.green { background: var(--pos-green); border-color: var(--pos-green); }

.pos-right { padding: 14px 16px; }
.pos-crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
.pos-crumbs button { background: none; border: 0; font: inherit; font-weight: 600; color: var(--pos-teal); cursor: pointer; padding: 2px 4px; border-radius: 4px; }
.pos-crumbs button:disabled { color: var(--ink); cursor: default; }
.pos-crumbs .sep { color: var(--line-2); }
.pos-search { width: 100%; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); margin-bottom: 14px; }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.pos-tile { border: 1px solid var(--pos-bd); background: #fff; border-radius: var(--radius); padding: 14px 10px; min-height: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; cursor: pointer; text-align: center; color: var(--ink); font: inherit; }
.pos-tile:hover { border-color: var(--pos-teal); box-shadow: 0 2px 10px rgba(13,148,136,.12); }
.pos-tile.sel { background: var(--pos-teal); border-color: var(--pos-teal); color: #fff; }
.pos-tile img { width: 48px; height: 48px; object-fit: contain; }
.pos-tile .ph { width: 48px; height: 48px; border-radius: 10px; background: var(--brand-soft); color: var(--pos-teal-dark); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; }
.pos-tile .nm { font-weight: 600; font-size: 13px; line-height: 1.25; }
.pos-tile .pr { font-weight: 700; color: var(--pos-teal-dark); font-variant-numeric: tabular-nums; }
.pos-tile.sel .pr, .pos-tile.sel .nm { color: #fff; }
.pos-tile.draggable { touch-action: none; }
.pos-tile.dragging { opacity: .45; outline: 2px dashed var(--pos-teal); outline-offset: -2px; cursor: grabbing; }
.pos-hint { font-size: 12px; color: var(--muted); margin: -6px 0 10px; display: flex; align-items: center; gap: 6px; }
@media (max-width: 900px) { .pos { grid-template-columns: 1fr; } }
