:root {
  --bg: #f5f1ec;
  --surface: #ffffff;
  --surface-2: #faf7f3;
  --text: #1f1813;
  --muted: #7b6e63;
  --line: #e6ddd3;
  --primary: #8a4b1f;
  --primary-ink: #ffffff;
  --primary-soft: #f3e4d6;
  --top: #2a1c13;
  --top-ink: #f6ece2;
  --green: #2f7d4f;  --green-soft: #e0f1e6;
  --blue: #2d64a8;   --blue-soft: #e2ecf8;
  --red: #b3372f;    --red-soft: #f8e1df;
  --amber: #a86a0c;  --amber-soft: #fbefd5;
  --gray-soft: #eee8e1;
  --wa: #1f9d55;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(40, 25, 15, .06), 0 2px 8px rgba(40, 25, 15, .05);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15110e; --surface: #201a16; --surface-2: #1a1512; --text: #f1e9e1; --muted: #a8998b; --line: #362c25;
    --primary: #d9904f; --primary-ink: #1b120c; --primary-soft: #3a2819;
    --top: #0f0b09;
    --green: #5fc189; --green-soft: #1b3326; --blue: #77a7e6; --blue-soft: #1a2839;
    --red: #ef7c72; --red-soft: #3c1f1c; --amber: #e5ad4f; --amber-soft: #392a12; --gray-soft: #2e2621;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
h1, h2 { margin: 0; }
.ico { width: 22px; height: 22px; flex: none; }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + var(--safe-t)) 10px 8px;
  background: var(--top); color: var(--top-ink);
}
.topbar h1 { flex: 1; font-size: 18px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .icon-btn { color: var(--top-ink); }
.top-actions { display: flex; gap: 2px; }
.brand {
  width: 36px; height: 36px; display: grid; place-items: center;
  font: 26px/1 "Segoe Script", "Brush Script MT", cursive; color: #e6b27e;
}
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border: 0; border-radius: 10px; background: transparent; color: inherit; cursor: pointer;
}
.icon-btn:active { background: rgba(127, 127, 127, .18); }
.icon-btn.sm { width: 34px; height: 34px; }
.icon-btn.sm .ico { width: 18px; height: 18px; }
.flip .ico { transform: scaleX(-1); }

/* ---------- Página ---------- */
.page { max-width: 760px; margin: 0 auto; padding: 14px 16px calc(96px + var(--safe-b)); }
.no-nav .page { padding-bottom: 32px; }
.hello { font-size: 20px; font-weight: 650; margin: 4px 0 12px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 4px 8px; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.fw-medium { font-weight: 500; }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack > p { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 520px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.grid2.fixed { grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2.fixed input[type="date"] { padding-left: 10px; padding-right: 8px; min-width: 0; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px;
}
.card h2 { font-size: 16px; margin-bottom: 10px; }
.stack > .card { margin-bottom: 0; }

/* ---------- Mensajes ---------- */
.flash { padding: 11px 14px; border-radius: 12px; margin-bottom: 12px; font-size: 15px; background: var(--green-soft); color: var(--green); transition: opacity .4s; }
.flash.err { background: var(--red-soft); color: var(--red); }
.flash.warn { background: var(--amber-soft); color: var(--amber); }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 15px; font-weight: 600; line-height: 1; cursor: pointer; text-align: center;
}
.btn .ico { width: 19px; height: 19px; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.block { display: flex; width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn-row.center { justify-content: center; margin: 16px 0 8px; }
.link { background: none; border: 0; padding: 4px 0; color: var(--primary); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link.danger { color: var(--red); }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2); color: var(--text);
  font-family: inherit; font-size: 16px; line-height: 1.3;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; background: var(--surface); }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; }
.check { display: flex; align-items: center; gap: 8px; }

.seg { display: flex; background: var(--gray-soft); border-radius: 12px; padding: 4px; gap: 4px; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 10px; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg input:focus-visible + span { outline: 2px solid var(--primary); }

.searchbar { position: relative; margin-bottom: 10px; }
.searchbar .ico { position: absolute; left: 12px; top: 11px; color: var(--muted); }
.searchbar input { padding-left: 42px; background: var(--surface); border-radius: 12px; }
.filters { margin-bottom: 12px; }
.filters select, .filters input { background-color: var(--surface); border-radius: 12px; min-width: 0; }

.suggest-wrap { position: relative; }
.suggest {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 30; margin-top: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .15);
}
.suggest button { display: block; width: 100%; text-align: left; padding: 11px 14px; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--text); font: inherit; cursor: pointer; }
.suggest button:last-child { border-bottom: 0; }
.suggest button small { display: block; color: var(--muted); }
.suggest button:hover, .suggest button:focus { background: var(--primary-soft); }
.linked { display: flex; align-items: center; gap: 6px; margin: 8px 0 12px; font-size: 14px; color: var(--green); }
.linked .ico { width: 18px; height: 18px; }
.linked[hidden] { display: none; }
.linked.nuevo { color: var(--muted); }
.input-btn { display: flex; gap: 6px; }
.input-btn input { flex: 1; min-width: 0; }
.btn.icon-only { width: 44px; padding: 0; flex: none; }

/* ---------- Diálogo tipo hoja (bottom sheet en el celular) ---------- */
dialog.sheet {
  width: min(560px, 100%); max-height: 92vh; margin: auto auto 0; padding: 18px 16px calc(18px + var(--safe-b));
  border: 0; border-radius: 20px 20px 0 0; background: var(--surface); color: var(--text);
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .25); overflow-y: auto;
}
dialog.sheet::backdrop { background: rgba(20, 12, 6, .5); }
dialog.sheet { scrollbar-width: thin; overscroll-behavior: contain; }
/* con una ventana abierta la página de atrás no scrollea: evita la doble barra vertical */
html:has(dialog[open]) { overflow: hidden; }
dialog.sheet h2 { font-size: 18px; }
/* confirmaciones y avisos (reemplazan confirm/alert del sistema) */
dialog.sheet.ask { width: min(420px, 100%); }
.ask-msg { margin: 4px 2px 18px; font-size: 16px; line-height: 1.45; white-space: pre-line; }
.ask-btns { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; }
@media (min-width: 620px) { dialog.sheet { margin: auto; border-radius: 20px; padding-bottom: 18px; } }
/* hoja a pantalla completa en el celular (ej. descripción del instrumento) */
@media (max-width: 619px) { dialog.sheet.full { width: 100%; max-width: 100%; height: 100%; max-height: 100%; border-radius: 0; margin: 0; padding-top: calc(18px + var(--safe-t)); } }
.card > .linked + .field { margin-top: 12px; }
.input-btn select { flex: 1; min-width: 0; }
#cliLinked:not([hidden]) + .grid2 { margin-top: 0; }
.suggest-wrap + .linked[hidden] + .grid2, .suggest-wrap + .grid2 { margin-top: 12px; }
.card > .field + .grid2, .card > .grid2 + .field, .card > .field + .field { margin-top: 12px; }
.card > .grid2 + input[type="hidden"] + .field { margin-top: 12px; }

.item-row { display: grid; grid-template-columns: 1fr 110px 34px; gap: 6px; align-items: center; margin-bottom: 8px; }
.item-row .price { text-align: right; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -6px -6px 8px 0; }
.card-head h2 { margin: 0; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; background: var(--gray-soft); border-radius: 10px; padding: 8px 12px; }
.card-title-row h2 { margin: 0; }
.card-title-row .tbl-total { padding: 0; margin-left: auto; }
.card-title-row .icon-btn { margin: -6px -8px -6px -4px; color: var(--primary); }
.card-head .icon-btn { color: var(--primary); }
.items-vacio { margin: 4px 0 8px; font-style: italic; }

/* selector de trabajos (categorías → servicios) */
dialog.sheet.picker, dialog.sheet.full.picker { padding: 0 0 var(--safe-b); }
/* hojas con cabecera propia (selector de trabajos, instrumento): la cabecera va pegada arriba y el contenido con su margen */
dialog.sheet.headed, dialog.sheet.full.headed { padding: 0 0 var(--safe-b); }
.sheet-body { padding: 16px; }
/* cabecera igual a la barra superior de las pantallas */
.picker-head, .sheet-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px;
  padding: calc(8px + var(--safe-t)) 10px 8px; background: var(--top); color: var(--top-ink);
}
.picker-head h2, .sheet-head h2 { flex: 1; font-size: 18px; font-weight: 650; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-head .icon-btn, .sheet-head .icon-btn { color: var(--top-ink); }
.list.picker-list { border: 0; border-radius: 0; box-shadow: none; }
.picker-list .item-money .muted { font-weight: 400; }
.picker-list .item { cursor: pointer; min-height: 52px; }
.picker-list .pick-cat .item-title { font-weight: 600; }
.picker-list .pick-cat > .ico { color: var(--muted); width: 18px; }
.picker-list .pick-svc .item-title { font-weight: 400; }
.picker-list .pick-ico { display: inline-grid; place-items: center; width: 22px; color: var(--muted); }
.picker-list .pick-ico .ico { width: 16px; height: 16px; }
.picker-list .pick-libre { color: var(--primary); }
.picker-list .pick-libre .item-title, .picker-list .pick-libre .pick-ico { color: var(--primary); }
.picker-list .empty { border: 0; }
.total-line { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 2px 4px; font-size: 17px; }
.total-line strong { font-size: 20px; }
.total-line.sub { padding-top: 4px; font-size: 15px; color: var(--muted); }
.card .grid2 + .total-line { margin-top: 0; }
.total-line + .grid2 { margin-top: 10px; }
.save-btn .ico { width: 26px; height: 26px; stroke-width: 2.6; }
.save-btn.saving { opacity: .5; pointer-events: none; }

details.reveal { margin: 12px 0; }
details.reveal > summary { list-style: none; }
details.reveal > summary::-webkit-details-marker { display: none; }
details.reveal[open] > summary { display: none; }
details.reveal > form { margin-top: 0; }
.cc-add { margin: 12px 0; }
details.inline > summary { list-style: none; display: inline-block; margin-top: 4px; }
details.inline > summary::-webkit-details-marker { display: none; }
details.inline form { margin-top: 8px; max-width: 320px; }

/* ---------- Chips / badges ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0 10px; }
.chip {
  flex: none; display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 14px; font-weight: 600; line-height: 1; cursor: pointer; white-space: nowrap;
}
.chip.sm { min-height: 30px; font-size: 13px; padding: 0 11px; }
.chips + .chips { margin-top: -2px; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.estado-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.estado-bar .chip.on.gray { background: var(--muted); border-color: var(--muted); }
.estado-bar .chip.on.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.estado-bar .chip.on.green { background: var(--green); border-color: var(--green); color: #fff; }
.estado-bar .chip.on.red { background: var(--red); border-color: var(--red); color: #fff; }

.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; background: var(--gray-soft); color: var(--muted); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.muted { background: transparent; border: 1px solid var(--line); }

/* ---------- Listas ---------- */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.list.flat { border: 0; box-shadow: none; border-radius: 0; margin: -4px -14px 0; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-bottom: 1px solid var(--line); color: var(--text);
  width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; font: inherit; text-align: left;
}
.list > .item:last-child { border-bottom: 0; }
a.item:active, button.item:active { background: var(--surface-2); }
.item.dim { opacity: .55; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.item-title a { color: inherit; }
.item-sub { font-size: 13.5px; color: var(--muted); margin-top: 1px; }
.item-side { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; text-align: right; flex: none; }
.item-meta { font-size: 12.5px; color: var(--muted); }
.item-meta.late { color: var(--red); font-weight: 600; }
.item-money { font-weight: 650; font-size: 14.5px; white-space: nowrap; }
.item-money.pos { color: var(--green); }
.item-note { font-size: 13px; padding: 6px 14px 10px; margin-top: -1px; border-bottom: 1px solid var(--line); }
.item-note.warn { color: var(--amber); background: var(--amber-soft); padding-top: 8px; }
.menu .item > .ico:first-child { color: var(--primary); }
.menu .item > .ico:last-child { color: var(--muted); width: 18px; }
.more { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 14px; font-weight: 600; }
.more .ico { width: 16px; height: 16px; }

/* ---------- Dashboard ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
@media (min-width: 620px) { .tiles:not(.two) { grid-template-columns: repeat(4, 1fr); } }
.tile {
  display: flex; flex-direction: column; justify-content: space-between; gap: 6px; min-height: 86px;
  padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
  color: var(--text); box-shadow: var(--shadow);
}
.tile b { font-size: 30px; line-height: 1; font-weight: 700; }
.tile b.sm { font-size: 20px; }
.tile span { font-size: 13.5px; color: var(--muted); font-weight: 600; }
.tile.ok b { color: var(--green); }
.tile.warn { background: var(--red-soft); border-color: transparent; }
.tile.warn b { color: var(--red); }
.tile.sel { outline: 2px solid var(--primary); outline-offset: -2px; }

/* ---------- Trabajo ---------- */
.head-card { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin: 2px 2px 12px; }
.eyebrow { font-size: 13px; color: var(--muted); font-weight: 600; }
.head-title { font-size: 21px; font-weight: 700; line-height: 1.2; }
.dates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.dates span { display: block; font-size: 12px; color: var(--muted); }
.dates b { font-size: 15px; }
.dates .late b, .dates .late .date-inline { color: var(--red); }
/* fecha editable en la ficha: se ve como el resto de los valores, al tocarla abre el calendario */
.date-inline {
  width: 100%; min-height: 0; padding: 0; border: 0; background: none; box-shadow: none;
  font: inherit; font-size: 16px; font-weight: 700; color: var(--text); text-align: center; cursor: pointer;
}
.date-inline:focus { background: none; border-radius: 6px; }
.date-inline::-webkit-date-and-time-value { text-align: center; }
.row-link { display: flex; align-items: center; justify-content: space-between; color: var(--text); font-size: 17px; }
.row-link .ico { color: var(--muted); width: 18px; }
.specs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 0; }
.specs dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.specs dd { margin: 0; font-weight: 550; word-break: break-word; }
.obs { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin: 12px 0 0; font-size: 14.5px; white-space: normal; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl td { padding: 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl td.num { text-align: right; white-space: nowrap; padding-left: 12px; font-weight: 600; }
.tbl-top td { border-bottom: 0; border-top: 1px solid var(--line); }
.tbl-total { padding: 9px 0; text-align: right; white-space: nowrap; font-weight: 700; font-size: 16px; }

/* ---------- Comanda ---------- */
.comanda-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 2px 2px 10px; }
.comanda-brand { font-size: 22px; font-weight: 800; letter-spacing: -.02em; color: var(--primary); }
.comanda-nro { text-align: right; background: var(--primary-soft); color: var(--primary); border-radius: 12px; padding: 6px 12px; }
.comanda-nro span { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.comanda-nro b { font-size: 20px; }
.comanda-tags { display: flex; gap: 6px; margin: 0 2px 12px; }
.specs .wide { grid-column: 1 / -1; }
.comanda-legal { padding: 4px 4px 0; font-size: 12.5px; color: var(--muted); }
.comanda-legal h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.comanda-legal p { margin: 0 0 6px; }

/* ---------- Cuenta corriente ---------- */
.balance { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-radius: var(--radius); margin-bottom: 12px; }
.balance span { font-weight: 600; }
.balance b { font-size: 22px; }
.balance.due { background: var(--red-soft); color: var(--red); }
.balance.credit { background: var(--green-soft); color: var(--green); }
.balance.zero { background: var(--gray-soft); color: var(--muted); }
.month-nav { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 10px; font-size: 17px; }

/* ---------- Navegación inferior ---------- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  padding: 6px 6px calc(6px + var(--safe-b));
  background: var(--surface); border-top: 1px solid var(--line);
}
.bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.bottomnav a.on { color: var(--primary); }

/* ---------- Login ---------- */
.auth { background: var(--top); }
.auth .page { min-height: 100vh; display: grid; place-items: center; }
.auth-box { width: 100%; max-width: 380px; background: var(--surface); border-radius: 20px; padding: 28px 22px; }
.logo-big { font: 52px/1.1 "Segoe Script", "Brush Script MT", "Lucida Handwriting", cursive; text-align: center; color: var(--primary); }

@media (min-width: 900px) {
  .bottomnav { max-width: 760px; margin: 0 auto; border: 1px solid var(--line); border-bottom: 0; border-radius: 16px 16px 0 0; }
}
.company { font-weight: 650; margin-bottom: 2px; }
/* ---------- Árbol de categorías ---------- */
.tree-card { padding: 6px 6px 6px 4px; }
.cat-tree, .cat-tree ul { list-style: none; margin: 0; padding: 0; }
.cat-tree ul { padding-left: 22px; }
.cat-tree li { position: relative; }
/* líneas conectoras: vertical desde el padre y horizontal hasta cada nodo */
.cat-tree ul > li::before { content: ""; position: absolute; left: -7px; top: 0; bottom: 0; border-left: 1.5px solid var(--line); }
.cat-tree ul > li:last-child::before { bottom: auto; height: 22px; }
.cat-tree ul > li::after { content: ""; position: absolute; left: -7px; top: 22px; width: 10px; border-top: 1.5px solid var(--line); }
.cat-tree details > summary { list-style: none; }
.cat-tree details > summary::-webkit-details-marker { display: none; }
.node { display: flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 2px; border-radius: 10px; cursor: pointer; }
.node:hover { background: var(--surface-2); }
.node.flash-node { animation: flash-node 2.4s ease-out; }
@keyframes flash-node { 0%, 40% { background: var(--primary-soft); } 100% { background: transparent; } }
.twisty { display: inline-grid; place-items: center; width: 26px; height: 26px; flex: none; color: var(--muted); }
.twisty .ico { width: 16px; height: 16px; transition: transform .15s; }
details[open] > summary .twisty .ico { transform: rotate(90deg); }
.twisty.leaf::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
/* categorías: semi-negrita; servicios: texto normal, más chico y tono intermedio */
.node-name { flex: 1 1 auto; min-width: 0; color: var(--text); font-size: 16px; font-weight: 600; padding: 10px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-n { color: var(--muted); font-size: 14px; font-weight: 400; }
.node.svc { cursor: default; padding-right: 10px; }
.node.svc .node-name { color: color-mix(in srgb, var(--text) 78%, var(--muted)); font-weight: 400; }
.node.svc .twisty .ico { width: 15px; height: 15px; transform: none; }
.node.svc .node-name { font-size: 14.5px; }
.node-price { margin-left: auto; padding-left: 8px; font-size: 13.5px; color: var(--muted); white-space: nowrap; }
.node.svc.off { opacity: .55; }

/* ---------- Drag & drop del árbol ---------- */
.tree-hint { margin: 0 4px 8px; }
.cat-tree .node, .drop-root { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.cat-tree .node a { -webkit-user-drag: none; }
.drop-root[hidden] { display: none; }
.node.dragging { opacity: .35; }
.node.drop-target { background: var(--primary-soft); outline: 2px dashed var(--primary); outline-offset: -2px; }
.drop-root { justify-content: center; margin: 0 0 6px; border: 2px dashed var(--line); color: var(--muted); font-size: 14px; }
.drag-ghost {
  position: fixed; z-index: 60; pointer-events: none; max-width: 70vw;
  padding: 8px 12px; border-radius: 10px; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); box-shadow: 0 10px 26px rgba(0, 0, 0, .22);
  font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transform: translate(-50%, -140%);
}
body.tree-dragging { cursor: grabbing; }
.node-add { color: var(--muted); }
.node-add .ico { width: 18px; height: 18px; }
.node-add .ico { transition: transform .15s; }
.node-add[aria-expanded="true"] { background: var(--primary-soft); color: var(--primary); }
.node-add[aria-expanded="true"] .ico { transform: rotate(180deg); }
.node-menu {
  position: absolute; z-index: 40; min-width: 170px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .18);
}
.node-menu a, .node-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 12px;
  border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.node-menu .ico { width: 18px; height: 18px; color: var(--muted); }
.node-menu a:hover, .node-menu button:hover, .node-menu a:focus-visible, .node-menu button:focus-visible { background: var(--surface-2); outline: none; }
.node-menu .danger, .node-menu .danger .ico { color: var(--red); }
