/* ---------- Estructura ---------- */
#shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .2s var(--ease); }
#shell.hidden { display: none; }
#shell.collapsed { grid-template-columns: 72px minmax(0, 1fr); }

.side {
  --side-bg: #0a1628; --side-text: #c9d0de; --side-muted: #7d879c; --side-hover: rgba(255,255,255,.06); --side-active: rgba(255,255,255,.1);
  background: var(--side-bg); color: var(--side-text);
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 14px 12px; z-index: 30;
}
:root[data-theme="dark"] .side { --side-bg: #050a14; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .side { --side-bg: #050a14; } }
.side-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: 2px 4px 14px; }
.brand { display: flex; align-items: center; gap: .65rem; color: #fff; font-weight: 750; letter-spacing: .04em; font-size: 1rem; text-decoration: none; min-width: 0; }
.brand:hover { text-decoration: none; }
.brand img { width: 38px; height: 38px; object-fit: contain; flex: none; filter: drop-shadow(0 2px 8px rgba(232,88,0,.35)); }
.brand small { display: block; font-size: .68rem; color: var(--side-muted); font-weight: 600; letter-spacing: .08em; }
.side .btn-icon { color: var(--side-muted); }
.side .btn-icon:hover { background: var(--side-hover); color: #fff; }
#nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -4px; padding: 0 4px; }
.nav-group { font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--side-muted); padding: 14px 10px 6px; white-space: nowrap; }
#nav a {
  display: flex; align-items: center; gap: .75rem; padding: .55rem .7rem; border-radius: 9px;
  color: var(--side-text); font-weight: 550; font-size: .9rem; text-decoration: none; position: relative; white-space: nowrap;
}
#nav a:hover { background: var(--side-hover); color: #fff; }
#nav a.active { background: rgba(245,166,35,.12); color: #fff; }
#nav a.active .icon { color: var(--brand); opacity: 1; }
#nav a.active::before { content: ""; position: absolute; left: -4px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--brand); box-shadow: 0 0 10px var(--brand); }
#nav a .icon { opacity: .85; }
#nav a .badge { margin-left: auto; background: var(--accent); color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 .45rem; font-weight: 750; }
.side-user { display: flex; align-items: center; gap: .6rem; padding: 10px 6px 2px; border-top: 1px solid rgba(255,255,255,.08); margin-top: 8px; }
.side-user .who { min-width: 0; flex: 1; }
.side-user .who b { display: block; color: #fff; font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .who span { font-size: .74rem; color: var(--side-muted); }
#shell.collapsed .brand span, #shell.collapsed .nav-group, #shell.collapsed #nav a span, #shell.collapsed .side-user .who, #shell.collapsed #nav a .badge { display: none; }
#shell.collapsed #nav a { justify-content: center; padding: .6rem; }
#shell.collapsed .side-top { flex-direction: column; }
#shell.collapsed .side-user { flex-direction: column; }

.workspace { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .6rem;
  padding: .7rem 2rem; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; align-items: center; gap: .4rem; font-size: .88rem; color: var(--muted); min-width: 0; flex: 1; white-space: nowrap; overflow: hidden; }
.crumbs a { color: var(--muted); }
.crumbs b { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.search-btn {
  background: var(--surface); color: var(--muted); border: 1px solid var(--border); font-weight: 500;
  min-width: 280px; justify-content: flex-start; gap: .55rem;
}
.search-btn:hover { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.search-btn kbd { margin-left: auto; }
kbd {
  font: 600 .72rem ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: .05rem .35rem;
}
#btn-menu { display: none; }
main { padding: 1.6rem 2rem 4rem; max-width: 1360px; width: 100%; outline: none; }
.view { animation: view-in .28s var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin-top: .25rem; font-size: .92rem; }
.toolbar { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar .search-input { flex: 1; min-width: 220px; max-width: 420px; }

/* ---------- Menú emergente ---------- */
.pop {
  position: fixed; z-index: 60; min-width: 210px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; animation: pop .15s var(--ease);
}
.pop button {
  width: 100%; justify-content: flex-start; background: transparent; color: var(--text); font-weight: 500;
  border: 0; min-height: 36px; padding: .45rem .65rem; border-radius: 8px; gap: .6rem;
}
.pop button:hover, .pop button:focus-visible { background: var(--surface-2); outline: none; }
.pop button.danger { color: var(--bad); }
.pop hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.pop kbd { margin-left: auto; }

/* ---------- Paleta de búsqueda (⌘K) ---------- */
.palette-bg { position: fixed; inset: 0; z-index: 80; background: rgba(8,14,11,.45); backdrop-filter: blur(3px); display: flex; justify-content: center; padding: 11vh 16px 16px; animation: fade .15s; }
.palette { width: min(640px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column; max-height: 70vh; animation: pop .18s var(--ease); align-self: flex-start; }
.palette .pinput { display: flex; align-items: center; gap: .7rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); }
.palette .pinput input { border: 0; box-shadow: none; padding: 0; font-size: 1.05rem; min-height: 30px; background: transparent; }
.palette .pinput input:focus { box-shadow: none; }
.palette .plist { overflow-y: auto; padding: 6px; }
.palette .pgroup { font-size: .7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; padding: .6rem .7rem .3rem; }
.palette .pitem { display: flex; align-items: center; gap: .75rem; padding: .55rem .7rem; border-radius: 10px; cursor: pointer; }
.palette .pitem .t { font-weight: 550; }
.palette .pitem .d { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette .pitem .txt { min-width: 0; flex: 1; }
.palette .pitem.sel { background: var(--brand-soft); }
.palette .pitem.sel .t { color: var(--brand-text); }
.palette .pitem .ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); flex: none; }
.palette .pfoot { border-top: 1px solid var(--border); padding: .55rem 1rem; display: flex; gap: 1rem; font-size: .76rem; color: var(--muted); flex-wrap: wrap; }

/* ---------- Inicio ---------- */
.hello { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.hello h1 { font-size: 1.75rem; margin: 0; }
.hello .date { color: var(--muted); margin-top: .2rem; }
.stat .trend { font-size: .76rem; margin-top: .1rem; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.feed li:last-child { border-bottom: 0; }
.feed .txt { min-width: 0; flex: 1; font-size: .9rem; }
.feed .meta { font-size: .78rem; color: var(--muted); }
.funnel { display: flex; flex-direction: column; gap: .35rem; }
.funnel-row { display: grid; grid-template-columns: minmax(110px, 170px) 1fr 28px; align-items: center; gap: .6rem; font-size: .84rem; }
.funnel-row .bar { height: 10px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.funnel-row .bar i { display: block; height: 100%; border-radius: 6px; background: var(--brand); min-width: 0; transition: width .5s var(--ease); }
.funnel-row b { text-align: right; font-variant-numeric: tabular-nums; }
.funnel-row.zero { color: var(--muted); }
.funnel-tipo + .funnel-tipo { margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* Filas de lista */
.li { display: flex; align-items: center; gap: .75rem; padding: .65rem 0; border-bottom: 1px solid var(--border); }
.li:last-child { border-bottom: 0; }
.li .grow { min-width: 0; flex: 1; }
.li .t { font-weight: 600; }
.li .d { font-size: .8rem; color: var(--muted); }
.li .actions-hover { opacity: 0; transition: opacity .15s; display: flex; gap: .2rem; }
.li:hover .actions-hover, .li:focus-within .actions-hover { opacity: 1; }
@media (hover: none) { .li .actions-hover { opacity: 1; } }
.date-pill { width: 46px; flex: none; text-align: center; border-radius: 10px; background: var(--surface-2); padding: .25rem 0; line-height: 1.1; }
.date-pill b { display: block; font-size: 1.05rem; }
.date-pill span { font-size: .66rem; text-transform: uppercase; color: var(--muted); font-weight: 700; letter-spacing: .05em; }

/* Tareas */
.task { display: flex; align-items: flex-start; gap: .7rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.task:last-child { border-bottom: 0; }
.task input[type=checkbox] { margin-top: 3px; width: 18px; height: 18px; border-radius: 50%; }
.task .grow { min-width: 0; flex: 1; }
.task .t { font-weight: 550; transition: color .2s; }
.task.done .t { text-decoration: line-through; color: var(--muted); }
.task .d { font-size: .79rem; color: var(--muted); display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .1rem; }
.quick-add { display: flex; gap: .5rem; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.quick-add input[type=text] { flex: 1 1 260px; border: 0; box-shadow: none; }
.quick-add input[type=text]:focus { box-shadow: none; }
.quick-add input[type=date], .quick-add select { width: auto; flex: 0 1 auto; }
.quick-inline { display: flex; gap: .4rem; margin-top: .7rem; }
.quick-inline input { min-height: 36px; }
.quick-inline input[name=titulo] { flex: 1; min-width: 0; }
.quick-inline input[type=date] { flex: 0 0 auto; width: 150px !important; }
.dash { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; align-items: start; }
@media (max-width: 1000px) { .dash { grid-template-columns: minmax(0, 1fr); } }
.stat .num { white-space: nowrap; }

/* ---------- Clientes ---------- */
.client-cell { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.client-cell .t { font-weight: 600; color: var(--text); }
.client-cell .d { font-size: .78rem; color: var(--muted); }
.call-link { display: inline-flex; align-items: center; gap: .35rem; color: var(--text-2); }

/* ---------- Ficha ---------- */
.profile { display: flex; gap: 1.1rem; align-items: flex-start; flex-wrap: wrap; }
.profile .info { flex: 1; min-width: 240px; }
.profile h1 { margin: 0 0 .3rem; font-size: 1.5rem; }
.profile .meta { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: .88rem; }
.quick-actions { display: flex; gap: .45rem; flex-wrap: wrap; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--border); border-radius: 12px; overflow: hidden; margin-top: 1.1rem; border: 1px solid var(--border); }
.kpis div { background: var(--surface); padding: .7rem .9rem; }
.kpis b { display: block; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.kpis span { font-size: .76rem; color: var(--muted); }
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--border); margin: 1.2rem 0 1.2rem; overflow-x: auto; }
.tabs a {
  padding: .65rem .9rem; color: var(--muted); font-weight: 600; font-size: .9rem; border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: .45rem; align-items: center; text-decoration: none;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--brand-text); border-bottom-color: var(--brand); }
.tabs a .n { background: var(--surface-3); color: var(--text-2); border-radius: 999px; font-size: .72rem; padding: 0 .45rem; }
.tabs a.on .n { background: var(--brand-soft); color: var(--brand-text); }

.inm-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.inm-card + .inm-card { margin-top: 1rem; }
.inm-head { display: flex; gap: .9rem; align-items: center; padding: 1rem 1.2rem; flex-wrap: wrap; }
.inm-head .grow { flex: 1; min-width: 200px; }
.inm-body { padding: 0 1.2rem 1rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: .8rem; }
.supply { border: 1px solid var(--border); border-radius: 12px; padding: .85rem .95rem; background: var(--surface-2); position: relative; }
.supply .top { display: flex; gap: .6rem; align-items: center; justify-content: space-between; }
.supply .kv { margin-top: .6rem; font-size: .84rem; }
.supply.add { display: grid; place-items: center; border-style: dashed; background: transparent; color: var(--muted); cursor: pointer; min-height: 120px; font-weight: 600; }
.supply.add:hover { color: var(--brand-text); border-color: var(--brand); background: var(--brand-soft); }

.proj { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); padding: 1.1rem 1.2rem; }
.proj + .proj { margin-top: 1rem; }
.stepper { display: flex; gap: 4px; margin: .9rem 0 .6rem; overflow-x: auto; padding-bottom: 2px; }
.stepper button {
  flex: 1 0 auto; min-height: 30px; padding: .25rem .6rem; border-radius: 8px; font-size: .76rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted); border: 1px solid transparent;
}
.stepper button:hover { border-color: var(--border-strong); background: var(--surface-2); color: var(--text); }
.stepper button.done { background: var(--brand-soft); color: var(--brand-text); }
.stepper button.now { background: var(--accent); color: #fff; }
.proj .facts { display: flex; gap: 1.2rem; flex-wrap: wrap; font-size: .86rem; margin-top: .4rem; }
.proj .facts span { color: var(--muted); }
.proj .facts b { color: var(--text); }

.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 1.6rem; text-align: center; color: var(--muted);
  cursor: pointer; transition: all .15s; background: var(--surface);
}
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-text); }
.dropzone .icon { width: 28px; height: 28px; margin-bottom: .3rem; }
.file-ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none; font-size: .64rem; font-weight: 800; letter-spacing: .03em; }

/* ---------- Tablero de proyectos ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: .9rem; overflow-x: auto; padding-bottom: .8rem; align-items: start; }
.col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem; min-height: 220px; transition: background .15s, border-color .15s; }
.col.over { background: var(--brand-soft); border-color: var(--brand); border-style: dashed; }
.col-head { display: flex; justify-content: space-between; align-items: center; font-size: .82rem; font-weight: 700; color: var(--text-2); padding: .1rem .2rem .5rem; }
.col-head .n { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 0 .5rem; font-size: .74rem; color: var(--muted); }
.col-head .step { color: var(--muted); font-weight: 600; margin-right: .3rem; }
.kcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .75rem .8rem; margin-top: .55rem;
  box-shadow: var(--shadow-sm); cursor: grab; transition: transform .12s var(--ease), box-shadow .12s, opacity .12s;
}
.kcard:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.kcard.dragging { opacity: .45; transform: rotate(1.5deg); }
.kcard .top { display: flex; gap: .55rem; align-items: center; }
.kcard .t { font-weight: 600; font-size: .9rem; color: var(--text); line-height: 1.25; }
.kcard .t:hover { color: var(--brand-text); }
.kcard .d { font-size: .78rem; color: var(--muted); margin-top: .35rem; }
.kcard .foot { display: flex; justify-content: space-between; align-items: center; margin-top: .55rem; gap: .3rem; }
.kcard .moves { display: flex; gap: 2px; }
.col .drop-hint { border: 1.5px dashed var(--border-strong); border-radius: 10px; padding: .9rem; text-align: center; font-size: .78rem; color: var(--muted); margin-top: .55rem; }

/* ---------- Calendario ---------- */
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1rem; align-items: start; }
.cal-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .8rem; }
.cal-head h2 { margin: 0 auto 0 .3rem; font-size: 1.2rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-radius: 12px; overflow: hidden; border: 1px solid var(--border); gap: 1px; background: var(--border); }
.cal-dow { background: var(--surface-2); text-align: center; font-size: .72rem; font-weight: 700; color: var(--muted); padding: .45rem 0; text-transform: uppercase; letter-spacing: .06em; }
.cal-day { background: var(--surface); min-height: 104px; padding: .35rem; cursor: pointer; transition: background .12s; display: flex; flex-direction: column; gap: 3px; min-width: 0; border: 0; border-radius: 0; color: var(--text); font-weight: 400; justify-content: flex-start; align-items: stretch; text-align: left; }
.cal-day:hover { background: var(--surface-2); }
.cal-day.out { background: var(--surface-2); color: var(--muted); }
.cal-day.out .n { opacity: .5; }
.cal-day.sel { box-shadow: inset 0 0 0 2px var(--brand); }
.cal-day .n { font-size: .8rem; font-weight: 650; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.cal-day.today .n { background: var(--accent); color: #fff; }
.cal-ev { font-size: .7rem; font-weight: 600; padding: .1rem .35rem; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev.fin_contrato { background: var(--bad-soft); color: var(--bad); }
.cal-ev.tarea { background: var(--info-soft); color: var(--info); }
.cal-ev.evento { background: var(--accent-soft); color: var(--accent-ink); }
.cal-more { font-size: .68rem; color: var(--muted); padding-left: .3rem; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: .7rem; }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }

.copy-box { display: flex; gap: .5rem; }
.copy-box input { font-family: ui-monospace, Menlo, monospace; font-size: .8rem; }

/* ---------- Móvil ---------- */
@media (max-width: 1100px) { .cal-layout { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  #shell, #shell.collapsed { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 264px; transform: translateX(-105%); transition: transform .25s var(--ease); box-shadow: var(--shadow-lg); }
  #shell.nav-open .side { transform: none; }
  #shell.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(8,14,11,.4); z-index: 25; }
  #shell.collapsed .brand span, #shell.collapsed .nav-group, #shell.collapsed #nav a span, #shell.collapsed .side-user .who { display: initial; }
  #btn-collapse { display: none; }
  #btn-menu { display: inline-flex; }
  .topbar { padding: .6rem 16px; }
  .search-btn { min-width: 0; width: 40px; padding: 0; justify-content: center; }
  .search-btn span, .search-btn kbd, #btn-nuevo span { display: none; }
  main { padding: 1.1rem 16px 4rem; }
  .cal-day { min-height: 64px; }
  .cal-ev { font-size: 0; padding: 0; height: 6px; border-radius: 3px; }
  .board { grid-auto-columns: minmax(78vw, 1fr); scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: start; }
}

/* Tarjetas que son botones (totales de pagos) */
button.card { background: var(--surface); color: var(--text); font-weight: inherit; text-align: left; white-space: normal; }
button.card:hover { background: var(--surface); }

/* ---------- Comisiones ---------- */
.calc-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 1rem; align-items: start; }
.calc-form { position: sticky; top: 76px; }
.tablas-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 1rem; align-items: start; }
.com-list { padding: .5rem; position: sticky; top: 76px; }
.com-list a { display: flex; align-items: center; gap: .55rem; padding: .45rem .55rem; border-radius: 9px; color: var(--text); font-weight: 550; font-size: .9rem; text-decoration: none; }
.com-list a:hover { background: var(--surface-2); }
.com-list a.on { background: var(--brand-soft); color: var(--brand-text); }
.com-list a .n { margin-left: auto; font-size: .74rem; color: var(--muted); font-weight: 500; }
.aviso { display: flex; gap: .55rem; align-items: flex-start; background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: .6rem .8rem; font-size: .86rem; margin-bottom: .8rem; }
.aviso.info { background: var(--info-soft); color: var(--info); }
.aviso .icon { margin-top: 2px; }
.com-row { border-bottom: 1px solid var(--border); }
.com-row:last-child { border-bottom: 0; }
.com-row summary { list-style: none; display: flex; align-items: center; gap: .75rem; padding: .7rem .2rem; cursor: pointer; }
.com-row summary::-webkit-details-marker { display: none; }
.com-row summary:hover { background: var(--surface-2); border-radius: 8px; }
.com-row summary .grow { min-width: 0; flex: 1; }
.com-row summary .t { font-weight: 650; }
.com-row summary .d { font-size: .8rem; color: var(--muted); }
.com-row summary > .icon { color: var(--muted); transition: transform .15s; }
.com-row[open] summary > .icon { transform: rotate(90deg); }
.com-row .importe { font-size: 1.05rem; min-width: 110px; text-align: right; }
.bar-mini { width: 120px; height: 8px; border-radius: 5px; background: var(--surface-2); overflow: hidden; flex: none; }
.bar-mini i { display: block; height: 100%; background: var(--brand); border-radius: 5px; }
.com-detalle { padding: 0 0 .8rem 2.6rem; overflow-x: auto; }
.com-detalle table { font-size: .86rem; }
table.matriz td, table.matriz th { white-space: nowrap; padding: .45rem .55rem; }
table.matriz tbody tr:hover td { background: var(--surface-2); }
@media (max-width: 1000px) {
  .calc-layout, .tablas-layout { grid-template-columns: minmax(0, 1fr); }
  .calc-form, .com-list { position: static; }
  .com-list { display: flex; overflow-x: auto; gap: .3rem; }
  .com-list a { white-space: nowrap; }
  .bar-mini { display: none; }
  .com-detalle { padding-left: 0; }
}

/* ---------- App de clientes (desde el CRM) ---------- */
.app-layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.chat-crm { padding: 0; overflow: hidden; }
.chat-crm .card-head { padding: 1rem 1.2rem 0; }
.chat-crm .chat { height: 460px; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .5rem; background: var(--surface-2); margin-top: .8rem; }
.msg { max-width: 80%; padding: .55rem .8rem; border-radius: 16px; font-size: .92rem; }
.msg.yo { align-self: flex-end; background: var(--navy); color: #fff; border-bottom-right-radius: 5px; }
.msg.ellos { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.msg-autor { font-size: .7rem; font-weight: 700; opacity: .8; margin-bottom: .1rem; }
.msg-txt { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-hora { font-size: .68rem; opacity: .7; margin-top: .2rem; text-align: right; }
.msg-doc { display: inline-flex; gap: .35rem; align-items: center; margin-top: .35rem; font-size: .84rem; font-weight: 600; color: inherit; text-decoration: underline; }
.chat-form { display: flex; gap: .5rem; padding: .6rem; border-top: 1px solid var(--border); align-items: flex-end; }
.chat-form textarea { min-height: 42px; resize: none; border-radius: 21px; padding: .55rem .9rem; }
.chat-form select { width: 56px; flex: none; padding: .3rem; }
.chat-form button { width: 42px; min-height: 42px; border-radius: 50%; padding: 0; flex: none; }
.pedir-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.pedir-grid button { justify-content: flex-start; }
.li-link { color: var(--text); text-decoration: none; border-radius: 8px; }
.li-link:hover { background: var(--surface-2); text-decoration: none; }
.modal-bg.dialog .modal.wide, .modal-bg .modal.wide { width: min(460px, 100%); }
.phone-frame { width: 100%; max-width: 400px; height: 70vh; margin: 0 auto; border: 10px solid #111; border-radius: 34px; overflow: hidden; background: var(--bg); }
.phone-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
@media (max-width: 1000px) { .app-layout { grid-template-columns: minmax(0, 1fr); } }

.cambio { border: 1px solid var(--border); border-radius: 12px; padding: .7rem .8rem; }
.cambio + .cambio { margin-top: .6rem; }
.cambio.pendiente { border-color: var(--warn); background: var(--warn-soft); }
.diff { margin: .4rem 0; font-size: .86rem; }
.diff td { padding: .25rem .4rem; border: 0; }
.diff .antes { text-decoration: line-through; color: var(--muted); }

/* ---------- Tareas delegadas ---------- */
.task-link { background: none; border: 0; padding: 0; min-height: 0; color: var(--text); font: inherit; font-weight: 550; text-align: left; justify-content: flex-start; white-space: normal; }
.task-link:hover { background: none; color: var(--brand-text); text-decoration: underline; }
.task .delegada { color: var(--text-2); display: inline-flex; align-items: center; gap: .25rem; }
.estado-tarea { display: flex; gap: .4rem; margin-top: 1rem; }
.hilo .com { padding: .6rem 0; border-top: 1px solid var(--border); }
.hilo .com:first-child { border-top: 0; }
.hilo .com.ext .quien { color: var(--accent-ink); }
.hilo .quien { font-size: .78rem; font-weight: 700; color: var(--brand-text); }
.hilo .txt { white-space: pre-wrap; font-size: .9rem; overflow-wrap: anywhere; }
.hilo .cuando { font-size: .72rem; color: var(--muted); }

/* ---------- Empresas ---------- */
.selector-empresa { display: inline-flex; align-items: center; gap: .4rem; margin: 0; padding: 0 .3rem 0 .7rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--muted); }
.selector-empresa select { border: 0; min-height: 38px; padding: .3rem .4rem; background: transparent; font-weight: 600; color: var(--text); width: auto; max-width: 220px; }
.selector-empresa select:focus { box-shadow: none; }
.empresa-card.inactiva { opacity: .65; }
.empresa-card .kpis { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .selector-empresa select { max-width: 120px; } }

/* ---- Red de empresas: tramitación, derivaciones, actividad ---- */
.checklist { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .55rem; }
.checklist .ck { display: inline-flex; align-items: center; gap: .25rem; font-size: .75rem; padding: .15rem .5rem; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.checklist .ck.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.checklist .ck.falta { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.tram-fila { display: flex; gap: .8rem; padding: .85rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tram-fila:last-child { border-bottom: 0; }
.tram-fila .t { font-weight: 650; display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }
.tram-fila .d { font-size: .82rem; color: var(--muted); margin-top: .15rem; }
.deriv-box { margin-top: .7rem; padding: .65rem .8rem; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.deriv-box .nota { font-size: .84rem; margin-top: .35rem; overflow-wrap: anywhere; }
.deriv-box .quien { font-weight: 650; color: var(--brand-text); }
.aviso.bad { display: flex; gap: .5rem; align-items: flex-start; padding: .55rem .75rem; border-radius: 10px; background: var(--bad-soft); color: var(--bad); font-size: .86rem; }
.ico-act { flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.mini-select { width: auto; display: inline-block; font-size: .75rem; padding: .1rem 1.4rem .1rem .45rem; min-height: 0; height: auto; border-radius: 8px; margin: 0 .2rem; }
.inst-card .inst-inm { margin-top: .7rem; padding-top: .6rem; border-top: 1px dashed var(--border); }
.stepper button:disabled { cursor: default; opacity: 1; }

/* ---- Comisiones a mano ---- */
.com-emp + .com-emp { margin-top: 1rem; }
.com-emp .card-head h2 { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.com-sum { display: flex; gap: 1.2rem; flex-wrap: wrap; font-size: .86rem; color: var(--muted); margin: -.2rem 0 .6rem; }
.com-sum b { color: var(--text); }
.com-tabla td { vertical-align: middle; }
.com-tabla td.center, .com-tabla th.center { text-align: center; }
.com-tabla .com-in { width: 110px; text-align: right; padding: .35rem .5rem; min-height: 0; }
.com-tabla .com-nota { width: 160px; text-align: left; }
.com-tabla .com-in.guardado { border-color: var(--ok); box-shadow: 0 0 0 2px var(--ok-soft); }
.com-tabla input[type=checkbox] { width: 18px; height: 18px; }
.com-tabla td[data-pct] { white-space: nowrap; }
.com-pct { display: inline-flex; align-items: center; gap: .4rem; font-size: .88rem; font-weight: 600; margin: 0; }
.com-pct input { width: 84px; text-align: right; padding: .35rem .5rem; min-height: 0; }

/* Empresas con app de clientes propia (marca) */
.marca-app { display: flex; align-items: center; gap: .7rem; margin-top: .8rem; padding: .6rem .75rem; border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius-sm); background: var(--surface-2); }
.marca-app img { width: 48px; height: 48px; object-fit: contain; flex: none; background: #fff; border-radius: 8px; padding: 3px; }
.marca-app a { word-break: break-all; }

/* =====================================================================
   Estética profesional del CRM (15/11/2026): la misma que la app de clientes
   - Modo oscuro por defecto (se puede cambiar con el botón del sol/luna).
   - Colores 60-30-10: 60 % neutro, 30 % azul marino, 10 % el naranja exacto del logo (#E85801)
     solo en lo que se toca o hay que mirar. Verde, ámbar y rojo, solo para estados.
   - Cristal («liquid glass») en la barra lateral y la superior, sin MAYÚSCULAS, más aire.
   ===================================================================== */
:root, :root:not([data-theme="light"]), :root[data-theme="dark"] {
  --brand: #E85801; --brand-hover: #F46A16; --brand-ink: #ffffff;
  --brand-soft: color-mix(in srgb, #E85801 14%, var(--surface)); --brand-text: #C94C00;
  --accent: #E85801; --accent-ink: #C94C00; --accent-soft: color-mix(in srgb, #E85801 14%, var(--surface));
  --tinta: #0f2140; --tinta-suave: color-mix(in srgb, #0f2140 7%, var(--surface));
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --brand-text: #FF7A2E; --accent-ink: #FF8A47; --tinta: var(--text); --tinta-suave: var(--surface-2); } }
:root[data-theme="dark"] { --brand-text: #FF7A2E; --accent-ink: #FF8A47; --tinta: var(--text); --tinta-suave: var(--surface-2); }

/* Iconos: uno solo de acento (naranja del logo) en vez de arcoíris */
.tone-info, .tone-violet, .tone-ok, .tone-accent, .tone-brand, .stat .ico { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }
/* Etiquetas de categoría neutras; las de estado (ok / warn / bad) conservan su color */
.tag.info, .tag.violet, .tag.brand, .tag.marca { background: var(--tinta-suave); color: var(--tinta); }
.tag.accent { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand-text); }

/* Sin MAYÚSCULAS */
.nav-group, .palette .pgroup, .date-pill span, .cal-dow, .form-section, th { text-transform: none; letter-spacing: 0; }
.nav-group { font-size: .74rem; font-weight: 650; }
th { font-size: .78rem; font-weight: 650; }
.form-section { font-size: .86rem; color: var(--text); font-weight: 700; }

/* Barra lateral de cristal oscuro con la pestaña activa en «lente» */
.side { --side-bg: #0a1628;
  background: linear-gradient(180deg, color-mix(in srgb, var(--side-bg) 92%, #1b3358) 0%, var(--side-bg) 55%), var(--side-bg);
  border-right: 1px solid rgba(255,255,255,.06); box-shadow: inset -1px 0 0 rgba(255,255,255,.03); }
#nav a { border-radius: 11px; transition: background .15s, color .15s; }
#nav a.active { background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,.04)); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), inset 0 0 0 1px rgba(255,255,255,.07), 0 6px 16px -10px rgba(0,0,0,.6); }
#nav a.active::before { background: var(--brand); box-shadow: 0 0 10px color-mix(in srgb, var(--brand) 70%, transparent); }
#nav a .badge { background: var(--brand); }

/* Barra superior de cristal */
.topbar { background: color-mix(in srgb, var(--bg) 70%, transparent); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent); }
.search-btn { border-radius: 999px; background: color-mix(in srgb, var(--surface) 80%, transparent); }

/* Botones: texto blanco sobre el naranja; secundarios en cápsula */
button:not([class]), button[type=submit], .btn, .btn-ghost, .btn-soft, .btn-danger, #btn-nuevo { border-radius: 999px; }
.btn-soft { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand-text); }

/* Tarjetas con algo más de aire y sombra suave */
.card { border-radius: 18px; }
.stat .num { letter-spacing: -.03em; }

/* Ventanas (formularios) con borde de cristal */
.modal { border-color: color-mix(in srgb, var(--border) 80%, transparent); box-shadow: 0 30px 80px -20px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.06); }
.modal-bg { background: rgba(5, 10, 20, .5); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.stepper button.now, .cal-day.today .n { background: var(--brand); }
