/* Panel de control — Constructora Roma */

:root {
  --sidebar-w: 244px;
  --sidebar-w-collapsed: 62px;
  --topbar-h: 58px;
  --side-bg: #1a1a1a;          /* negro elegante (como Comercial Roma) */
  --side-accent: #0fa3a3;      /* turquesa profundo (acento de marca) */
  --trans: .22s ease;
}

.panel { background: #eef0f3; font-family: 'Nunito', system-ui, sans-serif; display: flex; min-height: 100vh; }

/* ── Input con "X" para limpiar + foco iluminado (regla permanente) ── */
.cr-input-wrap { position: relative; display: block; margin-bottom: .25rem; }
.cr-input-wrap input,
.cr-input-wrap textarea {
  width: 100%;
  padding: .6rem 2rem .6rem .7rem;
  border: 1.5px solid var(--cr-borde);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.cr-input-wrap input:focus,
.cr-input-wrap textarea:focus {
  outline: none;
  border-color: var(--side-accent);
  box-shadow: 0 0 0 3px rgba(15, 163, 163, .22);
}
/* La X aparece solo cuando hay texto (clase has-text vía JS). */
.cr-input-x {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: .55rem;
  display: none;
  background: none;
  border: none;
  font-size: 1.2rem;
  line-height: 1;
  color: #999;
  cursor: pointer;
}
.cr-input-wrap.has-text .cr-input-x { display: block; }
.cr-input-x:hover { color: #444; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--side-bg);
  min-height: 100vh;
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width var(--trans);
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }
/* Estado pre-pintado (evita el parpadeo del sidebar al recargar). */
html.side-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
html.side-collapsed .main { margin-left: var(--sidebar-w-collapsed); }

.sidebar__logo {
  padding: .9rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex; align-items: center; justify-content: center;
  min-height: 64px; overflow: hidden;
}
.sidebar__logo-chip {
  width: 100%; display: flex; align-items: center; justify-content: center;
}
.sidebar__logo-chip img { width: 100%; max-height: 48px; object-fit: contain; display: block; }
.sidebar__logo-mini { display: none; width: 32px; height: auto; }
.sidebar.collapsed .sidebar__logo-chip { display: none; }
.sidebar.collapsed .sidebar__logo-mini { display: block; }

.sidebar__toggle {
  display: flex; align-items: center; gap: .6rem;
  margin: .5rem .8rem 0; padding: .45rem .8rem;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px; color: rgba(255,255,255,.5);
  font: 700 .78rem 'Nunito', sans-serif; cursor: pointer;
  white-space: nowrap; overflow: hidden; width: calc(100% - 1.6rem);
  transition: all var(--trans);
}
.sidebar__toggle:hover { background: rgba(255,255,255,.12); color: rgba(255,255,255,.9); }
.sidebar__toggle .toggle-icon { transition: transform var(--trans); flex-shrink: 0; }
.sidebar.collapsed .sidebar__toggle .toggle-icon { transform: rotate(180deg); }
.sidebar.collapsed .sidebar__toggle { justify-content: center; }
.sidebar.collapsed .sidebar__toggle-text { display: none; }

.sidebar__nav { flex: 1; padding: .6rem 0; overflow: hidden; }
.sidebar__section {
  font-size: .65rem; font-weight: 800; color: rgba(255,255,255,.35);
  text-transform: uppercase; letter-spacing: .08em;
  padding: .9rem 1.4rem .3rem; white-space: nowrap; overflow: hidden;
  transition: opacity var(--trans);
}
.sidebar.collapsed .sidebar__section { opacity: 0; }

.sidebar__link {
  display: flex; align-items: center; gap: .8rem;
  padding: .65rem 1.2rem; color: rgba(255,255,255,.72);
  font-weight: 600; font-size: .88rem; text-decoration: none;
  border-left: 3px solid transparent; white-space: nowrap; overflow: hidden;
  position: relative; transition: all .15s;
}
.sidebar__link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar__link.active {
  background: rgba(15,163,163,.16); color: var(--side-accent);
  border-left-color: var(--side-accent);
}
.sidebar__link i { width: 20px; text-align: center; font-size: 1rem; flex-shrink: 0; }
.sidebar__link-text { transition: opacity var(--trans); }
.sidebar.collapsed .sidebar__link-text { opacity: 0; }
/* Tooltip al estar compacto */
.sidebar.collapsed .sidebar__link:hover::after,
.sidebar.collapsed .btn-salir:hover::after {
  content: attr(data-tooltip);
  position: absolute; left: calc(var(--sidebar-w-collapsed) + 8px); top: 50%;
  transform: translateY(-50%); background: var(--side-bg); color: #fff;
  padding: .3rem .7rem; border-radius: 6px; font-size: .82rem; font-weight: 700;
  white-space: nowrap; box-shadow: 0 2px 10px rgba(0,0,0,.3); z-index: 200;
}

.sidebar__footer { padding: 1rem 1.1rem; border-top: 1px solid rgba(255,255,255,.1); white-space: nowrap; overflow: hidden; }
.sidebar__user { color: rgba(255,255,255,.6); font-size: .8rem; margin-bottom: .7rem; transition: opacity var(--trans); }
.sidebar__user strong { display: block; color: #fff; font-size: .88rem; }
.sidebar.collapsed .sidebar__user { opacity: 0; height: 0; margin: 0; }
.btn-salir { display: flex; align-items: center; gap: .6rem; color: rgba(255,255,255,.5); font-size: .85rem; font-weight: 600; text-decoration: none; position: relative; transition: color .15s; }
.btn-salir:hover { color: #e74c3c; }
.btn-salir i { width: 20px; text-align: center; flex-shrink: 0; }
.sidebar.collapsed .btn-salir-text { opacity: 0; }

/* ── MAIN ── */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; transition: margin-left var(--trans); min-width: 0; }
.main.collapsed { margin-left: var(--sidebar-w-collapsed); }
.topbar {
  background: #fff; padding: .7rem 1.4rem; display: flex; align-items: center; gap: 1rem;
  box-shadow: 0 2px 12px rgba(0,0,0,.06); position: sticky; top: 0; z-index: 50;
  min-height: var(--topbar-h);
}
/* Cabecera de página que se mantiene fija al hacer scroll (debajo del topbar). */
.panel-head--sticky {
  position: sticky; top: var(--topbar-h); z-index: 30; background: #eef0f3;
  margin: -1.5rem -1.8rem 1rem; padding: 1rem 1.8rem; border-bottom: 1px solid #e0e2e6;
}

/* Badges de estado */
.badge { font-size: .72rem; font-weight: 800; padding: .2rem .6rem; border-radius: 20px; white-space: nowrap; }
.badge--ok { background: #e3f4e6; color: #1e6b32; }
.badge--pend { background: #fdecd2; color: #9a6212; }
.topbar__info { display: flex; align-items: center; gap: .55rem; flex-shrink: 0; }
.topbar__titulo { font-weight: 800; font-size: 1.1rem; color: var(--cr-azul); white-space: nowrap; }
.topbar__count { background: rgba(15,163,163,.1); color: var(--cr-azul); font-size: .74rem; font-weight: 800; padding: .15rem .55rem; border-radius: 20px; white-space: nowrap; }
.topbar__buscador { flex: 1; max-width: 460px; }
.topbar__buscador .cr-input-wrap { margin-bottom: 0; }
.topbar__acciones { display: flex; align-items: center; gap: .5rem; margin-left: auto; flex-shrink: 0; }
.btn-versitio { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; background: var(--cr-gris); color: var(--cr-azul); border: none; border-radius: 8px; cursor: pointer; text-decoration: none; }
.btn-versitio:hover { background: #e6e8ec; }
.contenido { padding: 1.5rem 1.8rem; max-width: 1200px; width: 100%; }

.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.2rem; gap: 1rem; flex-wrap: wrap; }
.panel-head h1 { color: var(--cr-azul); margin: 0; font-size: 1.5rem; }
.panel-subtit { color: var(--cr-azul); margin-top: 2rem; }

/* ── Mensajes ── */
.panel-msgs { margin-bottom: 1rem; }
.panel-msg { padding: .7rem 1rem; border-radius: 8px; margin-bottom: .5rem; }
.panel-msg--success { background: #e3f4e6; color: #1e6b32; }
.panel-msg--error { background: #fde6e4; color: #a02216; }

/* ── Grid de obras ── */
.panel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.2rem; }
.panel-obra { background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,.08); display: flex; flex-direction: column; }
.panel-obra__img { aspect-ratio: 4 / 3; background: var(--cr-gris); }
.panel-obra__img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.panel-obra__info { padding: .8rem 1rem; display: flex; flex-direction: column; gap: .15rem; }
.panel-obra__info span { color: #777; font-size: .9rem; }
.panel-obra__info small { color: #999; }
.panel-obra__acciones { display: flex; gap: .5rem; padding: 0 1rem 1rem; margin-top: auto; }
.panel-obra__acciones .cr-btn { flex: 1; text-align: center; text-decoration: none; }
.panel-obra__acciones form { flex: 1; }
.panel-obra__acciones form .cr-btn { width: 100%; }

/* ── Formulario ── */
.panel-form { background: #fff; border-radius: 10px; padding: 1.5rem; max-width: 680px; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.panel-form label { display: block; font-weight: 600; margin: .8rem 0 .2rem; }
.panel-form__fila { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.panel-form input[type="file"] { margin-bottom: 1rem; }
.panel-form .cr-btn { margin-top: 1rem; }

.panel-fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-top: 1rem; }
.panel-foto { background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.panel-foto img { width: 100%; display: block; }
.panel-foto form { padding: .5rem; text-align: center; }

/* ── Catálogos ── */
.cat-busqueda { display: flex; gap: .6rem; align-items: flex-start; margin-bottom: 1.2rem; max-width: 520px; }
.cat-busqueda .cr-input-wrap { flex: 1; margin-bottom: 0; }

.cat-tabla { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.cat-tabla th, .cat-tabla td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid #eef0f3; }
.cat-tabla th { background: var(--cr-gris); color: var(--cr-azul); font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }
.cat-tabla td.num, .cat-tabla th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cat-tabla.sortable thead th:not(.no-sort) { cursor: pointer; user-select: none; }
.cat-tabla.sortable thead th[data-dir="asc"]::after { content: " ▲"; font-size: .7em; }
.cat-tabla.sortable thead th[data-dir="desc"]::after { content: " ▼"; font-size: .7em; }
.cat-tabla a, .mat-nombre a { color: var(--cr-azul); text-decoration: none; }   /* links no azul-browser (#13) */
.cat-tabla a:hover, .mat-nombre a:hover { text-decoration: underline; color: var(--cr-naranja); }
.cat-tabla tr:last-child td { border-bottom: none; }
.cat-tabla td.acc { white-space: nowrap; text-align: right; }
.cat-tabla td.acc .cr-btn { text-decoration: none; }
.cat-tabla td.acc form { display: inline-block; margin-left: .3rem; }
.cat-inactivo { opacity: .55; }

/* select y checkbox en formularios */
.panel-form select { width: 100%; padding: .6rem .7rem; border: 1px solid var(--cr-borde); border-radius: 6px; font-size: 1rem; font-family: inherit; }
.cr-check { display: flex; align-items: center; gap: .5rem; font-weight: 600; margin: 1rem 0 .2rem; }
.cr-check input { width: auto; }
.num-input { text-align: right; }

/* ── Constructor de presupuestos ── */
.pre-layout { display: grid; grid-template-columns: 1fr 300px; gap: 1.5rem; align-items: start; }
.pre-main { min-width: 0; }
.pre-cab { max-width: none; }
.pre-params { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .8rem; margin-top: 1rem; }
.pre-params label { display: block; font-weight: 600; margin-bottom: .2rem; font-size: .85rem; }
.pre-params input[type="text"] { width: 100%; padding: .5rem; border: 1px solid var(--cr-borde); border-radius: 6px; text-align: right; }
.pre-iva { display: flex; align-items: flex-end; }

.pre-partida { background: #fff; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.08); padding: 1rem; margin-bottom: 1.2rem; }
.pre-partida__head { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding-bottom: .8rem; border-bottom: 1px solid #eef0f3; }
.pre-partida__nombre { flex: 1; min-width: 160px; padding: .5rem; border: 1px solid var(--cr-borde); border-radius: 6px; font-weight: 600; }
.pre-dias { font-size: .9rem; color: #555; }
.num-dias { width: 60px; padding: .4rem; border: 1px solid var(--cr-borde); border-radius: 6px; text-align: right; }
.pre-grupo summary { cursor: pointer; color: var(--cr-azul); font-size: .9rem; }
.pre-grupo__lista { display: flex; flex-direction: column; gap: .3rem; margin-top: .5rem; padding: .5rem; background: var(--cr-gris); border-radius: 6px; }
.pre-grupo__lista label { font-weight: 400; font-size: .9rem; }

.pre-bloque { margin-top: .9rem; }
.pre-bloque__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: .4rem; }
.pre-vacio { color: #999; font-size: .9rem; font-style: italic; margin: .3rem 0; }

.mat-lista { display: flex; flex-direction: column; }
.mat-row { display: grid; grid-template-columns: 2fr .7fr auto; align-items: center; gap: .5rem; padding: .35rem 0; border-bottom: 1px solid #f1f2f4; }
.mat-row--head { font-size: .75rem; text-transform: uppercase; color: #888; letter-spacing: .03em; }
.mat-row--head span:nth-child(3), .mat-row--head span:nth-child(4), .mat-row--head span:nth-child(5) { display: none; }
.mat-edit { display: flex; align-items: center; gap: .4rem; justify-content: flex-end; }
.mat-edit .inp-cant { width: 48px; }
.mat-edit .inp-precio { width: 80px; }
.mat-edit input { padding: .35rem; border: 1px solid var(--cr-borde); border-radius: 5px; text-align: right; }
.mat-sub { min-width: 70px; font-variant-numeric: tabular-nums; }
.mat-nombre { overflow-wrap: anywhere; }

.pre-arriendo { display: flex; align-items: center; gap: .6rem; padding: .3rem 0; }
.pre-arriendo span:first-child { flex: 1; }
.pre-arriendo-add { display: flex; gap: .4rem; margin-top: .4rem; }
.pre-arriendo-add input { padding: .4rem; border: 1px solid var(--cr-borde); border-radius: 6px; }
.pre-arriendo-add input[name="nombre"] { flex: 1; }
.pre-arriendo-add input[name="valor"] { width: 100px; text-align: right; }

.pre-partida__pie { display: flex; align-items: center; justify-content: space-between; margin-top: .9rem; padding-top: .7rem; border-top: 1px solid #eef0f3; }
.pre-add-partida { display: flex; gap: .5rem; margin-top: .5rem; }
.pre-add-partida input { flex: 1; padding: .6rem; border: 1px solid var(--cr-borde); border-radius: 6px; }

.pre-resumen { background: #fff; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.08); padding: 1.2rem; position: sticky; top: 1rem; }
.pre-resumen h3 { margin: 0 0 .8rem; color: var(--cr-azul); }
.pre-resumen table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.pre-resumen td { padding: .3rem 0; }
.pre-resumen td.num { text-align: right; font-variant-numeric: tabular-nums; }
.pre-resumen .pre-sub td { border-top: 1px solid #eef0f3; font-weight: 600; }
.pre-resumen .pre-total td { border-top: 2px solid var(--cr-azul); font-weight: 700; font-size: 1.05rem; color: var(--cr-azul); padding-top: .5rem; }

/* Modal buscador */
.buscador-box { width: min(94vw, 640px); }
.buscador-fila { display: flex; gap: .8rem; align-items: center; margin-bottom: .8rem; }
.buscador-fila .cr-input-wrap { flex: 1; margin-bottom: 0; }
.buscador-cant { font-size: .9rem; white-space: nowrap; }
.buscador-cant .inp-cant { width: 60px; padding: .45rem; border: 1px solid var(--cr-borde); border-radius: 6px; text-align: right; }
.buscador-resultados { max-height: 50vh; overflow-y: auto; }
.bus-titulo { margin: .8rem 0 .3rem; color: var(--cr-azul); font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }
.bus-row { display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: .6rem; padding: .4rem 0; border-bottom: 1px solid #f1f2f4; }
.bus-nombre { overflow-wrap: anywhere; }
.bus-tag { font-size: .72rem; color: #888; background: var(--cr-gris); padding: .15rem .4rem; border-radius: 4px; white-space: nowrap; }
.bus-tag--web { color: #1e6b32; background: #e3f4e6; }
.bus-precio { font-variant-numeric: tabular-nums; min-width: 60px; }
.bus-manual { display: flex; align-items: center; gap: .5rem; padding: .5rem; background: var(--cr-gris); border-radius: 6px; }
.bus-manual span { flex: 1; }
.bus-manual-precio { width: 90px; padding: .4rem; border: 1px solid var(--cr-borde); border-radius: 6px; text-align: right; }

/* ── Equipo de trabajo ── */
.panel-sub { color: #8a8d93; font-size: .9rem; margin: .25rem 0 0; }
.clave-box { max-width: 440px; background: #fff; border: 0.5px solid var(--cr-borde); border-radius: 12px; padding: 1.4rem 1.6rem; }
.clave-box .panel-sub { margin-bottom: 1rem; }
.clave-box .cr-modal__acciones { margin-top: 1.4rem; }

.btn-nuevo-trab, .cr-btn i { margin-right: .35rem; }

/* Chip de código en la tabla */
.trab-cod {
  display: inline-block; min-width: 38px; text-align: center;
  background: rgba(15,163,163,.14); color: #0a6d6d;
  font-weight: 800; font-size: .78rem; letter-spacing: .02em;
  padding: .2rem .5rem; border-radius: 6px;
}
.cat-tabla td.acc { white-space: nowrap; text-align: right; }
.cat-tabla td.acc .icon-btn { vertical-align: middle; }
.cat-tabla td.acc form { display: inline-block; margin-left: .3rem; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 8px; border: 0.5px solid var(--cr-borde);
  background: #fff; color: #666; cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; transition: all .15s;
}
.icon-btn:hover { background: var(--cr-gris); color: var(--cr-azul); }
.icon-btn--peligro:hover { background: #fde6e4; color: #c0392b; border-color: #f3b6b0; }

.cr-empty { text-align: center; padding: 3rem 1rem; color: #8a8d93; }
.cr-empty i { font-size: 2.4rem; color: var(--cr-borde); margin-bottom: .8rem; }
.cr-empty p { margin: 0 0 1rem; }

/* Modal formulario (crear/editar) */
.cr-modal__box--form { width: min(94vw, 460px); text-align: left; }
.cr-modal__box--form .cr-modal__titulo { margin-bottom: 1rem; }
.modal-label { display: block; font-weight: 700; font-size: .85rem; margin: .7rem 0 .25rem; color: #444; }
.modal-fila { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.modal-fila select, #trab-unidad {
  width: 100%; padding: .6rem .7rem; border: 1.5px solid var(--cr-borde);
  border-radius: 8px; font-size: 1rem; font-family: inherit; background: #fff;
}
.trab-aviso { color: #c0392b; font-size: .82rem; margin: .4rem 0 0; }
.mat-neto { margin: .5rem 0 0; font-size: .82rem; color: #1e6b32; background: #e9f6ec; padding: .4rem .6rem; border-radius: 7px; }
.modal-nota { margin: 1rem 0 0; font-size: .82rem; color: #777; }
.modal-nota i { color: var(--cr-naranja); }

/* Material: historial / pills */
.mat-hist { font-size: .7rem; background: rgba(15,163,163,.1); color: var(--cr-azul); padding: .1rem .45rem; border-radius: 5px; margin-left: .4rem; }
.badge-doc { font-size: .7rem; background: #fff1e6; color: #0a6d6d; padding: .1rem .45rem; border-radius: 5px; margin-left: .4rem; }

/* Fusionar duplicados (#5) */
.dup-par { background: #fff; border: 0.5px solid var(--cr-borde); border-radius: 10px; padding: 1rem; margin-bottom: .9rem; }
.dup-lados { display: flex; align-items: center; gap: 1rem; }
.dup-lado { flex: 1; display: flex; flex-direction: column; gap: .2rem; }
.dup-lado strong { color: var(--cr-azul); }
.dup-lado span { color: #777; font-size: .85rem; }
.dup-vs { color: #aaa; font-size: 1.3rem; }
.dup-acc { display: flex; align-items: center; gap: .7rem; margin-top: .8rem; padding-top: .8rem; border-top: 1px solid #eef0f3; flex-wrap: wrap; }
.dup-acc .cr-check { margin-right: auto; }
.bus-cod { color: #999; font-size: .72rem; }
.pill { font-size: .74rem; font-weight: 700; padding: .15rem .55rem; border-radius: 6px; }
.pill--compra { background: #e3f4e6; color: #1e6b32; }
.pill--cotizacion { background: rgba(15,163,163,.1); color: var(--cr-azul); }
.pill--manual { background: #fff1e6; color: #0a6d6d; }
.pill--gasto { background: #fdecd2; color: #9a6212; }
.pill--sueldo { background: rgba(15,163,163,.1); color: var(--cr-azul); }
.pill--mpd { background: #e3f4e6; color: #1e6b32; }
.pill--mod { background: rgba(15,163,163,.1); color: var(--cr-azul); }
.pill--gg { background: #fdecd2; color: #9a6212; }
.pill--arr { background: #fff1e6; color: #0a6d6d; }
.icon-btn--ok { color: #1e6b32; border-color: #bfe3c8; }
.icon-btn--ok:hover { background: #e3f4e6; }

/* Ejecución (seguimiento de costos) */
.ejec-top { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.2rem; }
.ejec-top .btn-gasto-nuevo { margin-left: auto; }
.ejec-resumen { margin-bottom: .5rem; }
.ejec-resumen td, .ejec-resumen th { font-variant-numeric: tabular-nums; }
.ejec-rojo { color: #c0392b; font-weight: 700; }
.ejec-verde { color: #1e6b32; font-weight: 700; }
.cr-vacio { color: #8a8d93; background: #fafbfc; border: 1px dashed var(--cr-borde); border-radius: 10px; padding: 1.2rem; text-align: center; }
.panel-head__acc { display: flex; gap: .5rem; align-items: center; }
#modal-gasto select, #modal-gasto input[type="date"] { width: 100%; padding: .6rem .7rem; border: 1.5px solid var(--cr-borde); border-radius: 8px; font-family: inherit; font-size: 1rem; background: #fff; }

/* Subir documento */
.file-input { display: block; margin-bottom: 1rem; padding: .6rem; border: 1.5px dashed var(--cr-borde); border-radius: 8px; width: 100%; background: #fafbfc; }
.chk-fila { display: flex; flex-direction: column; gap: .5rem; margin: 1rem 0; }

/* Revisar documento */
.reevaluar-box { display: flex; gap: .6rem; align-items: flex-start; margin-bottom: 1.2rem; background: #fff7ec; border: 1px solid #f0d9b5; border-radius: 10px; padding: .8rem; }
.reevaluar-box .cr-input-wrap { flex: 1; margin-bottom: 0; }
.reevaluar-box .cr-btn { white-space: nowrap; }
.rev-cab { display: grid; grid-template-columns: 1.4fr 1fr 1fr auto; gap: 1rem; align-items: start; background: #fff; border: 0.5px solid var(--cr-borde); border-radius: 10px; padding: 1rem; margin-bottom: 1rem; }
.rev-cab select, .rev-cab input[type="date"] { width: 100%; padding: .6rem .7rem; border: 1.5px solid var(--cr-borde); border-radius: 8px; font-size: 1rem; font-family: inherit; background: #fff; }
.rev-cab__chks { display: flex; flex-direction: column; gap: .5rem; padding-top: 1.6rem; }
.revisar-aviso { background: #fff7ec; border: 1px solid #f0d9b5; color: #8a5a12; padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.revisar-aviso i { color: var(--cr-naranja); }
.revisar-tabla input { padding: .45rem .5rem; border: 1.5px solid var(--cr-borde); border-radius: 7px; font-family: inherit; font-size: .92rem; transition: border-color .15s, box-shadow .15s; }
.revisar-tabla input:focus { outline: none; border-color: var(--side-accent); box-shadow: 0 0 0 3px rgba(15,163,163,.2); }
.rev-nombre { width: 100%; }
.rev-coinc { font-size: .82rem; max-width: 320px; }
.rev-hint { color: #aaa; }
.rev-ok { color: #1e6b32; }
.rev-warn { color: #b06a12; font-weight: 700; }
.rev-chip { background: rgba(15,163,163,.08); border: 1px solid rgba(15,163,163,.2); color: var(--cr-azul); border-radius: 6px; padding: .2rem .5rem; font-size: .8rem; margin: .15rem .15rem 0 0; cursor: pointer; }
.rev-chip:hover { background: rgba(15,163,163,.16); }
.rev-vinc { color: #1e6b32; font-weight: 700; display: inline-flex; align-items: center; gap: .4rem; }
.rev-desvinc { background: none; border: none; color: var(--cr-naranja); text-decoration: underline; cursor: pointer; font-size: .8rem; }
.revisar-acciones { display: flex; justify-content: flex-end; gap: .7rem; margin-top: 1.5rem; }
.revisar-acciones .cr-btn { text-decoration: none; }
.trab-sugerido {
  margin-top: .4rem; background: rgba(15,163,163,.12); color: #0a6d6d;
  border: none; border-radius: 7px; padding: .35rem .6rem; font-size: .8rem;
  font-weight: 700; cursor: pointer; font-family: inherit;
}
.trab-sugerido:hover { background: rgba(15,163,163,.22); }
.cr-modal__box--form .cr-modal__acciones { margin-top: 1.3rem; }

/* ── Constructor de presupuestos v2 ── */
.collapsible:not(.is-open) > .partida__body,
.collapsible:not(.is-open) > .seccion__body,
.collapsible:not(.is-open) > .params__body,
.collapsible:not(.is-open) > .pre-panel__body { display: none; }
.chevron { transition: transform .15s; font-size: .8rem; }
.collapsible:not(.is-open) .chevron { transform: rotate(-90deg); }

.cr-modal__box { position: relative; }
.modal-x { position: absolute; top: .5rem; right: .7rem; background: none; border: none; font-size: 1.6rem; line-height: 1; color: #aaa; cursor: pointer; }
.modal-x:hover { color: #555; }
.icon-btn--sm { width: 28px; height: 28px; font-size: .8rem; }

/* Parámetros */
.params { background: #fff; border: 0.5px solid var(--cr-borde); border-radius: 10px; margin-bottom: 1.2rem; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.params__head { display: flex; align-items: center; gap: .5rem; padding: .7rem 1rem; cursor: pointer; }
.params__resumen { color: #888; font-size: .82rem; margin-left: auto; }
.params__body { padding: 0 1rem 1rem; }
.params__grid { display: flex; flex-wrap: wrap; gap: .8rem; align-items: end; }
.params__grid > div { display: flex; flex-direction: column; }
.params__grid label { font-size: .78rem; font-weight: 700; color: #555; margin-bottom: .2rem; }
.params__grid input { width: 120px; padding: .45rem .6rem; border: 1.5px solid var(--cr-borde); border-radius: 7px; text-align: right; }

.pre-layout { display: grid; grid-template-columns: 1fr 320px; gap: 1.5rem; align-items: start; }
.pre-main { min-width: 0; }

/* Partida */
.partida { background: #fff; border: 0.5px solid var(--cr-borde); border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.06); margin-bottom: 1.1rem; overflow: hidden; }
.partida__head { display: flex; align-items: center; gap: .5rem; padding: .7rem .9rem; border-bottom: 1px solid #eef0f3; }
.collapse-btn { background: none; border: none; cursor: pointer; color: var(--cr-azul); width: 26px; flex-shrink: 0; }
.partida__head { cursor: default; }
.partida__titulo-form { flex: 1; min-width: 0; margin: 0; }
.partida__nombre { width: 100%; border: 1px solid transparent; border-radius: 6px; padding: .35rem .5rem; font-weight: 800; color: var(--cr-azul); font-size: 1rem; background: transparent; }
.partida__nombre:hover { border-color: var(--cr-borde); }
.partida__nombre:focus { outline: none; border-color: var(--side-accent); background: #fff; box-shadow: 0 0 0 3px rgba(15,163,163,.18); }
.partida__total { font-weight: 800; color: var(--cr-azul); font-variant-numeric: tabular-nums; white-space: nowrap; padding: 0 .4rem; }
.partida__body { padding: .6rem .9rem .9rem; }

/* Secciones MOD / MPD / Arriendos */
.seccion { border-radius: 9px; margin-top: .6rem; overflow: hidden; border: 0.5px solid #edeef1; }
.seccion__head { display: flex; align-items: center; gap: .5rem; padding: .5rem .8rem; cursor: pointer; }
.seccion__titulo { font-weight: 700; font-size: .9rem; }
.seccion__total { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.seccion__body { padding: .5rem .8rem .7rem; background: #fff; }
.seccion--mod .seccion__head { background: #eef0fb; } .seccion--mod .seccion__titulo, .seccion--mod .seccion__total, .seccion--mod .chevron { color: #3b357e; }
.seccion--mpd .seccion__head { background: #eaf6ee; } .seccion--mpd .seccion__titulo, .seccion--mpd .seccion__total, .seccion--mpd .chevron { color: #1e6b32; }
.seccion--arr .seccion__head { background: #fdf3e6; } .seccion--arr .seccion__titulo, .seccion--arr .seccion__total, .seccion--arr .chevron { color: #9a6212; }

.mod-info { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .88rem; color: #555; }
.mod-grupo { display: flex; flex-direction: column; gap: .35rem; max-height: 220px; overflow-y: auto; background: var(--cr-gris); border-radius: 7px; padding: .6rem; }
.mod-grupo label { font-weight: 400; font-size: .9rem; }

.mat-lista { display: flex; flex-direction: column; }
.mat-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: .5rem; padding: .3rem 0; border-bottom: 1px solid #f3f4f6; }
.mat-nombre { overflow-wrap: anywhere; font-size: .9rem; }
.mat-edit { display: flex; align-items: center; gap: .35rem; }
.mat-edit input { padding: .3rem; border: 1px solid var(--cr-borde); border-radius: 5px; text-align: right; }
.mat-edit .inp-cant { width: 46px; } .mat-edit .inp-precio { width: 78px; }
.mat-x { color: #aaa; }
.mat-sub { min-width: 68px; font-variant-numeric: tabular-nums; }

.arr-row { display: flex; align-items: center; gap: .6rem; padding: .3rem 0; }
.arr-row span:first-child { flex: 1; }
.pre-vacio { color: #999; font-size: .85rem; font-style: italic; margin: .2rem 0; }

/* Resumen + paneles */
.pre-aside { position: sticky; top: calc(var(--topbar-h) + 1rem); display: flex; flex-direction: column; gap: 1rem; }
.pre-resumen { background: #fff; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.08); padding: 1.1rem; }
.pre-resumen h3 { margin: 0 0 .7rem; color: var(--cr-azul); }
.pre-resumen table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.pre-resumen td { padding: .28rem 0; }
.pre-resumen td.num { text-align: right; font-variant-numeric: tabular-nums; }
.pre-resumen .pre-sub td { border-top: 1px solid #eef0f3; font-weight: 700; }
.pre-resumen .pre-total td { border-top: 2px solid var(--cr-azul); font-weight: 800; font-size: 1.05rem; color: var(--cr-azul); padding-top: .5rem; }
.pre-panel { background: #fff; border: 0.5px solid var(--cr-borde); border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.pre-panel__head { display: flex; align-items: center; gap: .5rem; padding: .7rem 1rem; cursor: pointer; color: var(--cr-azul); }
.pre-panel__body { padding: 0 1rem 1rem; min-height: 60px; }

/* Modal buscador v2 */
.buscador-box { width: min(96vw, 720px); }
.buscador-fijo { position: sticky; top: 0; background: #fff; padding-bottom: .6rem; z-index: 2; }
.buscador-manual { display: flex; gap: .4rem; margin-top: .5rem; }
.buscador-manual input { padding: .4rem .55rem; border: 1px solid var(--cr-borde); border-radius: 6px; }
.buscador-manual #bm-nombre { flex: 1; }
.buscador-manual #bm-precio { width: 90px; text-align: right; }
.buscador-resultados { max-height: 52vh; overflow-y: auto; }
.bus-titulo { margin: .7rem 0 .3rem; color: var(--cr-azul); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.bus-row { display: grid; grid-template-columns: 1fr auto auto auto auto; align-items: center; gap: .55rem; padding: .4rem .3rem; border-bottom: 1px solid #f1f2f4; border-radius: 6px; cursor: pointer; }
.bus-row:hover, .bus-row.is-sel { background: rgba(15,163,163,.1); }
.bus-nombre { overflow-wrap: anywhere; font-size: .9rem; }
.bus-nombre small { color: #999; }
.bus-tag { font-size: .7rem; color: #888; background: var(--cr-gris); padding: .12rem .45rem; border-radius: 4px; white-space: nowrap; }
.bus-tag--web { color: #1e6b32; background: #e3f4e6; }
.bus-precio { font-variant-numeric: tabular-nums; min-width: 58px; }
.bus-link { color: var(--cr-azul); padding: 0 .2rem; }
.bus-tag--imperial { background: #e6f1fb; color: #185fa5; }
.bus-tag--sodimac { background: #fdeaea; color: #c0392b; }
.bus-tag--ml { background: #fff7d6; color: #8a6d00; }
.bus-tag--compra { background: #e3f4e6; color: #1e6b32; }
.bus-tag--coti { background: rgba(15,163,163,.1); color: var(--cr-azul); }
.bus-tag--manual { background: #fff1e6; color: #0a6d6d; }
.bus-tag--bd { background: var(--cr-gris); color: #777; }

/* Barra fija de acciones del presupuesto */
.pre-bar { position: sticky; top: var(--topbar-h); z-index: 25; display: flex; align-items: center; gap: .6rem; background: #eef0f3; margin: -1.5rem -1.8rem .9rem; padding: .7rem 1.8rem; border-bottom: 1px solid #e0e2e6; }
.pre-bar__right { margin-left: auto; display: flex; gap: .5rem; align-items: center; }
.cr-btn--ok { background: #2d7a3a; color: #fff; }
.cr-btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn--off { color: #c2c5cc; cursor: not-allowed; }
.icon-btn--off:hover { background: #fff; color: #c2c5cc; }

/* Neto al lado del título cuando el Resumen está contraído (#1) */
.pre-panel__head { justify-content: flex-start; }
.pre-panel__neto { margin-left: auto; font-weight: 800; color: var(--cr-azul); font-variant-numeric: tabular-nums; }
.pre-panel.is-open .pre-panel__neto { display: none; }

/* Grilla de secciones MPD/MOD/ARR (#3) */
.pre-grid { font-size: .85rem; box-shadow: none; border: 0.5px solid #eef0f3; }
.pre-grid th { background: #f7f8fa; font-size: .72rem; }
.pre-grid td, .pre-grid th { padding: .38rem .55rem; }
.pre-grid input { padding: .25rem .35rem; border: 1px solid var(--cr-borde); border-radius: 5px; text-align: right; }
.pre-grid .inp-cant { width: 52px; } .pre-grid .inp-precio { width: 84px; }
.pre-grid__pie td { border-top: 1px solid var(--cr-borde); font-weight: 700; }

/* Calculadora (#7) */
.calc-display { width: 100%; text-align: right; font-size: 1.2rem; padding: .5rem .6rem; border: 1.5px solid var(--cr-borde); border-radius: 8px; margin-bottom: .5rem; font-variant-numeric: tabular-nums; background: #fff; }
.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; }
.calc-b { padding: .55rem; border: 1px solid var(--cr-borde); border-radius: 8px; background: #fff; cursor: pointer; font: 1rem 'Nunito', sans-serif; }
.calc-b:hover { background: var(--cr-gris); }
.calc-op { color: var(--cr-azul); font-weight: 700; }
.calc-fn { background: #f1f2f4; }
.calc-eq { background: var(--cr-naranja); color: #fff; }
.calc-zero { grid-column: span 2; }

/* Notas (#8) */
.notas__add { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .7rem; }
.notas__add textarea { width: 100%; padding: .5rem; border: 1.5px solid var(--cr-borde); border-radius: 8px; font-family: inherit; resize: vertical; }
.notas__lista { display: flex; flex-direction: column; gap: .4rem; }
.nota { display: flex; gap: .5rem; align-items: flex-start; background: var(--cr-gris); border-radius: 8px; padding: .5rem .6rem; font-size: .88rem; }
.nota span { flex: 1; overflow-wrap: anywhere; }

/* Tabla del resumen (dentro del panel acordeón) */
.pre-resumen__tabla { width: 100%; border-collapse: collapse; font-size: .9rem; }
.pre-resumen__tabla td { padding: .28rem 0; }
.pre-resumen__tabla td.num { text-align: right; font-variant-numeric: tabular-nums; }
.pre-resumen__tabla .pre-sub td { border-top: 1px solid #eef0f3; font-weight: 700; }
.pre-resumen__tabla .pre-total td { border-top: 2px solid var(--cr-azul); font-weight: 800; font-size: 1.05rem; color: var(--cr-azul); padding-top: .5rem; }

/* ── Login ── */
.panel--login { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.login-box { background: #fff; border-radius: 12px; padding: 2rem; width: min(92vw, 380px); box-shadow: 0 10px 40px rgba(0,0,0,.15); }
.login-box h1 { color: var(--cr-azul); margin: 0; font-size: 1.5rem; text-align: center; }
.login-sub { text-align: center; color: #888; margin: .2rem 0 1.2rem; }
.login-box label { display: block; font-weight: 600; margin: .6rem 0 .2rem; }
.login-btn { width: 100%; margin-top: 1.2rem; }
