/* =========================================================================
   Ecoenergía · panel de gestión
   Estilo limpio tipo Stripe: fondo claro, tarjetas blancas, sombras suaves.
   Colores del logo de Ecoenergía Asturias: gris azulado #2b4246, turquesa #20b098
   y verde lima #98c878. Menú lateral plegable.
   ========================================================================= */

:root {
    --bg: #f6f8fa;
    --surface: #ffffff;
    --surface-2: #f6f8fa;
    --navy: #2b4246;
    --text: #24363a;
    --muted: #5a6b6f;
    --soft: #8a9a9d;
    --line: #e3e8ee;
    --line-2: #edf1f5;
    --turquesa: #20b098;
    --lima: #98c878;
    --accent: #158f7b;
    --accent-hover: #0f7565;
    --accent-soft: #e1f5f0;
    --violet: #635bff;
    --ok: #0e9f6e;
    --ok-soft: #e3f7ef;
    --warn: #c47f00;
    --warn-soft: #fff4dc;
    --danger: #d9363e;
    --danger-soft: #fde8e8;
    --radius: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 1px rgba(0, 0, 0, .03), 0 2px 5px rgba(60, 66, 87, .08), 0 0 0 1px rgba(60, 66, 87, .06);
    --shadow: 0 2px 5px -1px rgba(50, 50, 93, .2), 0 1px 3px -1px rgba(0, 0, 0, .25);
    --shadow-lg: 0 30px 60px -12px rgba(50, 50, 93, .3), 0 18px 36px -18px rgba(0, 0, 0, .35);
    --gradiente: linear-gradient(120deg, #2b4246 0%, #23635f 35%, #20b098 68%, #98c878 100%);
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --barra: 60px;
    --lateral: 248px;
    --lateral-plegado: 68px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    background: var(--bg); color: var(--text); font-family: var(--font);
    font-size: 14.5px; line-height: 1.5;
    -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; color: var(--navy); }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
kbd {
    font: 600 11px var(--font); color: var(--soft); background: var(--surface);
    border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px;
}
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.soft { color: var(--soft); }
.small { font-size: 13px; }
.hidden { display: none !important; }
button { font-family: inherit; }
.icono { flex: none; display: block; }

/* ---------- Estructura -------------------------------------------------------- */

.app { display: flex; min-height: 100vh; }
.principal { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- Menú lateral ------------------------------------------------------ */

.lateral {
    position: sticky; top: 0; height: 100vh; height: 100dvh;
    width: var(--lateral); flex: none;
    display: flex; flex-direction: column;
    background: var(--surface); border-right: 1px solid var(--line);
    transition: width .2s ease;
    z-index: 50;
}
.lateral-cabeza { height: var(--barra); display: flex; align-items: center; padding: 0 16px; border-bottom: 1px solid var(--line-2); }
.marca { display: flex; align-items: center; gap: 10px; color: var(--navy); white-space: nowrap; overflow: hidden; }
.marca:hover { color: var(--navy); }
.marca-img { height: 42px; width: auto; display: block; }
.marca-casa { height: 22px; width: auto; display: none; }
.marca-texto { display: flex; flex-direction: column; line-height: 1.15; padding-left: 10px; border-left: 1px solid var(--line); }
.marca-texto b { font-size: 13px; letter-spacing: -.01em; }
.marca-texto small { font-size: 11px; color: var(--soft); font-weight: 500; }

.lateral-buscar {
    margin: 12px 12px 4px; height: 36px; padding: 0 10px;
    display: flex; align-items: center; gap: 8px;
    border: 0; border-radius: 8px; cursor: pointer;
    background: var(--surface-2); color: var(--soft); font-size: 13.5px; text-align: left;
    box-shadow: inset 0 0 0 1px var(--line-2); transition: box-shadow .15s, color .15s;
}
.lateral-buscar:hover { color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.lateral-buscar span { flex: 1; }

.menu { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px 12px 12px; scrollbar-width: thin; }
.menu-bloque + .menu-bloque { margin-top: 10px; }
.menu-seccion {
    height: 26px; display: flex; align-items: center; padding: 0 10px;
    font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--soft);
}
.menu-item {
    position: relative; display: flex; align-items: center; gap: 11px; width: 100%;
    height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; cursor: pointer;
    color: var(--muted); font-size: 14px; font-weight: 550; white-space: nowrap; text-align: left;
    transition: background .15s, color .15s;
}
.menu-item:hover { background: var(--surface-2); color: var(--navy); }
.menu-item.activo { background: var(--accent-soft); color: var(--accent); }
.menu-item.activo::before {
    content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0;
    background: var(--accent);
}
.menu-item.pendiente { opacity: .5; }
.menu-externo { margin-left: auto; color: var(--soft); }
.menu-etiqueta {
    margin-left: auto; font-size: 10.5px; font-weight: 700; letter-spacing: .02em;
    color: var(--violet); background: #efeefe; padding: 1px 7px; border-radius: 99px;
}
.lateral-pie { padding: 8px 12px 12px; border-top: 1px solid var(--line-2); }

/* Plegado (escritorio) */
.menu-plegado .lateral { width: var(--lateral-plegado); }
.menu-plegado .lateral .ocultable, .menu-plegado .marca-texto, .menu-plegado .marca-img { display: none; }
.menu-plegado .marca-casa { display: block; }
.menu-plegado .lateral-cabeza { justify-content: center; padding: 0; }
.menu-plegado .lateral-buscar { justify-content: center; margin-inline: 14px; padding: 0; }
.menu-plegado .menu-item { justify-content: center; padding: 0; }
.menu-plegado .menu-seccion { height: 1px; margin: 8px 10px; padding: 0; background: var(--line-2); }
.menu-plegado #plegar .icono { transform: scaleX(-1); }
.menu-plegado .menu-item:hover::after {
    content: attr(data-tooltip); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
    background: var(--navy); color: #fff; font-size: 12.5px; font-weight: 600; padding: 5px 9px; border-radius: 6px;
    white-space: nowrap; box-shadow: var(--shadow); pointer-events: none; z-index: 60;
}

/* ---------- Barra superior ------------------------------------------------------- */

.barra {
    position: sticky; top: 0; z-index: 40;
    height: var(--barra); display: flex; align-items: center; gap: 14px; padding: 0 24px;
    background: rgba(255, 255, 255, .85); backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
}
.barra::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
    background: var(--gradiente); opacity: .85;
}
.barra-titulo { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.barra-titulo > span { font-weight: 650; color: var(--navy); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.migas { font-size: 12px; color: var(--soft); }
.migas a { color: var(--soft); }
.migas a:hover { color: var(--accent); }
.barra-dcha { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.barra-buscar { color: var(--soft); font-weight: 500; }
.usuario { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; white-space: nowrap; }
.avatar {
    width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
    color: #fff; font-weight: 700; font-size: 13px; background: var(--gradiente);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .5);
}
.solo-movil { display: none; }

/* ---------- Página ------------------------------------------------------------- */

.pagina { width: 100%; max-width: 1280px; margin: 0 auto; padding: 28px 28px 64px; }
.cabeza { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.cabeza p { margin: 4px 0 0; color: var(--muted); }
.cabeza-acciones { display: flex; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mb { margin-bottom: 16px; }

.card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 22px; border-bottom: 1px solid var(--line-2); }
.card-head a { font-size: 13px; font-weight: 600; }

.stat { padding: 18px 20px; }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 550; display: flex; align-items: center; gap: 7px; }
.stat-valor { font-size: 27px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; color: var(--navy); }
.stat-sub { color: var(--soft); font-size: 13px; margin-top: 2px; }
.stat-destacada { background: var(--navy); position: relative; overflow: hidden; }
.stat-destacada .stat-valor { color: #fff; }
.stat-destacada .stat-label, .stat-destacada .stat-sub { color: #b4c7c6; }
.stat-destacada::after {
    content: ""; position: absolute; right: -40px; top: -40px; width: 170px; height: 170px; border-radius: 50%;
    background: var(--gradiente); opacity: .5; filter: blur(30px);
}

/* ---------- Botones y formularios ----------------------------------------------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 36px; padding: 0 14px; border-radius: 8px; border: 0;
    font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
    background: var(--surface); color: var(--navy); box-shadow: var(--shadow-sm);
    transition: transform .08s, box-shadow .15s, background .15s, color .15s; user-select: none;
}
.btn:hover { box-shadow: var(--shadow); color: var(--navy); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primario { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.12), inset 0 1px 0 rgba(255,255,255,.15); }
.btn-primario:hover { background: var(--accent-hover); color: #fff; }
.btn-oscuro { background: var(--navy); color: #fff; }
.btn-oscuro:hover { background: #22363a; color: #fff; }
.btn-peligro { color: var(--danger); }
.btn-peligro:hover { background: var(--danger-soft); color: var(--danger); }
.btn-fantasma { background: transparent; box-shadow: none; color: var(--muted); }
.btn-fantasma:hover { background: var(--line-2); box-shadow: none; }
.btn-grande { height: 46px; padding: 0 20px; font-size: 15px; border-radius: 10px; }
.btn-bloque { width: 100%; }
.btn-icono { width: 36px; padding: 0; }

.campo { display: flex; flex-direction: column; gap: 6px; }
.campo label, .etiqueta { font-size: 13px; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input {
    width: 100%; height: 38px; padding: 0 12px; border: 0; border-radius: 8px; background: var(--surface);
    font: inherit; font-size: 14.5px; color: var(--navy);
    box-shadow: 0 0 0 1px var(--line), 0 1px 1px rgba(0,0,0,.03); transition: box-shadow .15s;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
.input:focus { outline: 0; box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px rgba(32, 176, 152, .18); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 550; color: var(--muted); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.filtros { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.filtros .input { width: auto; min-width: 160px; }
.filtros .input-ancho { flex: 1; min-width: 260px; }

/* ---------- Badges, tablas, avisos -------------------------------------------- */

.badge {
    display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px;
    font-size: 12px; font-weight: 600; background: var(--line-2); color: var(--muted); white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-peligro { background: var(--danger-soft); color: var(--danger); }
.badge-acento { background: var(--accent-soft); color: var(--accent); }
.badge-violeta { background: #efeefe; color: var(--violet); }

.tabla-wrap { overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabla th {
    text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
    color: var(--soft); padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tabla th a { color: inherit; }
.tabla td { padding: 11px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tabla tr:last-child td { border-bottom: 0; }
.tabla tbody tr:hover td { background: #fafbfd; }
.tabla .dcha { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tabla .nw { white-space: nowrap; }

.aviso { padding: 12px 16px; border-radius: 10px; font-weight: 550; font-size: 14px; margin-bottom: 20px; display: flex; gap: 10px; align-items: center; }
.aviso-ok { background: var(--ok-soft); color: #06714f; }
.aviso-error { background: var(--danger-soft); color: #a8102e; }
.aviso-info { background: #eef4ff; color: #1d4ed8; }

.vacio { text-align: center; padding: 48px 20px; color: var(--soft); }
.vacio .icono-grande { font-size: 40px; margin-bottom: 8px; }

.paginacion { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--line-2); color: var(--muted); font-size: 13px; }
.paginacion nav { display: flex; gap: 6px; }

/* ---------- Buscador ⌘K ------------------------------------------------------- */

.paleta-fondo {
    position: fixed; inset: 0; z-index: 200; display: flex; justify-content: center; align-items: flex-start;
    padding: 12vh 16px 16px; background: rgba(43, 66, 70, .4); backdrop-filter: blur(3px); animation: aparecer .12s;
}
.paleta { width: 100%; max-width: 580px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; }
.paleta-entrada { display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 54px; border-bottom: 1px solid var(--line-2); color: var(--soft); }
.paleta-entrada input { flex: 1; border: 0; outline: 0; font: inherit; font-size: 16px; color: var(--navy); background: transparent; }
.paleta-lista { list-style: none; margin: 0; padding: 8px; max-height: 50vh; overflow-y: auto; }
.paleta-lista li a {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 9px 12px; border-radius: 8px; color: var(--navy); font-weight: 550;
}
.paleta-lista li a small { color: var(--soft); font-weight: 500; }
.paleta-lista li.activo a { background: var(--accent-soft); color: var(--accent); }
.paleta-vacia { padding: 18px; text-align: center; color: var(--soft); }

/* ---------- Toasts y animaciones ------------------------------------------------ */

.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 550; box-shadow: var(--shadow-lg); animation: subir .2s; }
.toast-error { background: var(--danger); }
@keyframes subir { from { opacity: 0; transform: translateY(8px); } }
@keyframes aparecer { from { opacity: 0; } }
@keyframes degradado { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }

/* ---------- Acceso ------------------------------------------------------------ */

.acceso { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden; }
.acceso::before {
    content: ""; position: absolute; left: -10%; right: -10%; top: -40%; height: 85%;
    background: var(--gradiente); background-size: 200% 200%;
    transform: skewY(-12deg); transform-origin: 0; animation: degradado 14s ease infinite;
}
.acceso-caja { position: relative; width: 100%; max-width: 400px; background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 32px 28px 28px; }
.acceso-caja .acceso-logo { display: block; width: 200px; height: auto; margin: 0 auto 18px; }
.acceso-caja h1 { font-size: 22px; text-align: center; }
.acceso-caja .muted { text-align: center; margin: 4px 0 22px; font-size: 14px; }
.acceso-caja form { display: grid; gap: 14px; }

/* ---------- Responsive --------------------------------------------------------- */

@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
    .lateral { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); width: var(--lateral) !important; }
    .menu-abierto .lateral { transform: none; }
    .menu-plegado .lateral .ocultable, .menu-plegado .marca-texto, .menu-plegado .marca-img { display: revert; }
    .menu-plegado .marca-casa { display: none; }
    .velo { position: fixed; inset: 0; background: rgba(43, 66, 70, .4); z-index: 45; display: none; }
    .menu-abierto .velo { display: block; }
    .solo-movil { display: inline-flex; }
    .barra { padding: 0 14px; }
    .barra-buscar span, .barra-buscar kbd, .usuario-nombre { display: none; }
    .pagina { padding: 20px 16px 48px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    #plegar { display: none; }
}
@media (max-width: 560px) { .grid-4 { grid-template-columns: 1fr; } }

/* ---------- Empresas, puntos, gráfica -------------------------------------------- */

.emp { display: inline-grid; place-items: center; min-width: 26px; height: 20px; padding: 0 5px; border-radius: 5px; font: 700 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--line-2); color: var(--muted); vertical-align: 1px; }
.emp-01 { background: #fff1d6; color: #9a5b00; } .emp-02 { background: #f1e3ff; color: #7438b5; }
.emp-03 { background: #ddeeff; color: #0b5cad; } .emp-05 { background: #dcf5e3; color: #1a7f37; }
.emp-06 { background: #ffe4ec; color: #b4235a; } .emp-79 { background: #e9ecef; color: #444; }
.punto { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.punto-ok { background: var(--ok); } .punto-warn { background: var(--warn); } .punto-violeta { background: var(--violet); }
.recorte { max-width: 340px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.leyenda { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.leyenda i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.l1 { background: #c9d6e6; } .l2 { background: var(--accent); } .l3 { background: var(--violet); }
.grafico { display: flex; align-items: flex-end; gap: 8px; height: 240px; padding: 20px 22px 14px; overflow-x: auto; }
.grafico-col { flex: 1; min-width: 44px; height: 100%; display: flex; flex-direction: column; align-items: center; }
.grafico-barras { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.grafico-barras i { width: 28%; max-width: 15px; min-height: 2px; border-radius: 4px 4px 1px 1px; transition: opacity .15s; }
.grafico-col:hover .grafico-barras i { opacity: .8; }
.grafico-anio { margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--muted); }

/* ---------- Listados y fichas ---------------------------------------------------- */

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.fila-enlace { cursor: pointer; }
.tabla tr.anulada td { color: var(--soft); text-decoration: line-through; }
.segmentado { display: flex; padding: 3px; gap: 3px; background: var(--line-2); border-radius: 10px; }
.segmentado a { padding: 6px 14px; border-radius: 8px; font-weight: 600; font-size: 13.5px; color: var(--muted); }
.segmentado a.activo { background: var(--surface); color: var(--navy); box-shadow: var(--shadow-sm); }
.ficha-titulo { margin: 6px 0 4px; font-size: 16px; font-weight: 650; }
.card-pad p { margin: 4px 0; }
.etiqueta { text-transform: uppercase; letter-spacing: .05em; font-size: 11px; color: var(--soft); }
.datos { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 8px 0 0; font-size: 14px; }
.datos dt { color: var(--muted); }
.datos dd { margin: 0; }
.texto { white-space: normal; color: var(--text); }
.texto .etiqueta { margin-bottom: 6px; }
.totales { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; margin: 12px 0 0; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.totales dt { color: var(--muted); }
.totales dd { margin: 0; text-align: right; }
.totales .total { font-weight: 700; font-size: 15px; padding-top: 6px; border-top: 1px solid var(--line); color: var(--navy); }
.totales-claro { position: relative; z-index: 1; }
.totales-claro dt { color: #b4c7c6; }
.totales-claro dd { color: #fff; }
.totales-claro .total { border-color: rgba(255, 255, 255, .2); color: #fff; }
.tabla-lineas .concepto { min-width: 280px; max-width: 620px; }
.tabla-lineas .fila-capitulo td { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.tabla-lineas .fila-subtotal td { text-align: right; color: var(--muted); font-weight: 600; background: #fafbfc; }
details summary { cursor: pointer; }
.rejilla-tablas { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.rejilla-tablas a { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; color: var(--navy); font: 500 13px ui-monospace, Menlo, monospace; }
.rejilla-tablas a small { color: var(--soft); }
.rejilla-tablas a.vacia { opacity: .55; }
.rejilla-tablas a[hidden] { display: none; }
.tabla-cruda td { white-space: nowrap; font-size: 12.5px; }

/* ---------- Empresa activa (barra superior) --------------------------------------- */

.selector-empresa { position: relative; }
.empresa-activa {
    display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 8px 0 10px;
    border: 0; border-radius: 9px; cursor: pointer; font: 600 13.5px var(--font); color: var(--navy);
    background: var(--accent-soft); box-shadow: inset 0 0 0 1px #c6ebe2; transition: box-shadow .15s;
}
.empresa-activa:hover { box-shadow: inset 0 0 0 1px var(--turquesa); }
.empresa-nombre { max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lapicerin { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; background: #fff; color: var(--accent); box-shadow: var(--shadow-sm); }
.emp-todas { background: var(--navy); color: #fff; }
.empresa-menu {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; width: 340px; padding: 8px;
    background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); animation: aparecer .12s;
}
.empresa-menu-titulo { padding: 6px 10px 8px; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--soft); }
.empresa-menu button {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px;
    background: transparent; cursor: pointer; text-align: left; font: 550 13.5px var(--font); color: var(--navy);
}
.empresa-menu button:hover { background: var(--surface-2); }
.empresa-menu button.activa { background: var(--accent-soft); color: var(--accent); }
.empresa-menu button.activa::after { content: "✓"; margin-left: auto; font-weight: 700; }
.en-linea { display: inline; }
button.enlace { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
@media (max-width: 900px) { .empresa-nombre, .barra-asistente span { display: none; } }

/* ---------- Asistente (chat) ---------------------------------------------------- */

.chat { display: flex; flex-direction: column; height: calc(100vh - 210px); min-height: 440px; overflow: hidden; }
.chat-mensajes { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; background: linear-gradient(180deg, #fbfcfd, #f6f8fa); }
.burbuja { max-width: min(780px, 92%); padding: 11px 15px; border-radius: 16px; line-height: 1.5; font-size: 14.5px; animation: subir .18s; }
.burbuja.bot { background: var(--surface); align-self: flex-start; border-bottom-left-radius: 5px; box-shadow: var(--shadow-sm); }
.burbuja.yo { background: var(--accent); color: #fff; align-self: flex-end; border-bottom-right-radius: 5px; }
.burbuja ul { margin: 6px 0; padding-left: 20px; }
.burbuja code { background: var(--accent-soft); color: var(--accent); padding: 1px 6px; border-radius: 5px; font-size: 13px; }
.opciones { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.opciones button { border: 0; border-radius: 9px; padding: 8px 12px; cursor: pointer; text-align: left; font: 550 13px var(--font); background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px #c6ebe2; }
.opciones button:hover:not(:disabled) { background: var(--accent); color: #fff; }
.opciones button:disabled { opacity: .45; cursor: default; }
.chat-entrada { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line-2); background: var(--surface); }
.chat-tabla { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
.chat-tabla th, .chat-tabla td { padding: 5px 8px; border-bottom: 1px solid var(--line-2); text-align: left; }
.chat-tabla th { font-size: 11px; text-transform: uppercase; color: var(--soft); }
.chat-tabla .dcha { text-align: right; white-space: nowrap; }
.chat-tabla .cap td { font-weight: 650; color: var(--accent); background: var(--accent-soft); }
.chat-total { text-align: right; margin-top: 8px; font-size: 13.5px; }
.chat-guardado { margin-top: 8px; font-size: 12.5px; font-weight: 600; color: var(--ok); }
.escribiendo i { display: inline-block; width: 6px; height: 6px; margin: 0 2px; border-radius: 50%; background: var(--soft); animation: bote 1s infinite; }
.escribiendo i:nth-child(2) { animation-delay: .15s; } .escribiendo i:nth-child(3) { animation-delay: .3s; }
@keyframes bote { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

/* ---------- Editor de presupuestos ------------------------------------------------ */

.campos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; margin-top: 10px; }
.campos .ancho2 { grid-column: 1 / -1; }
.capitulos { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-top: 10px; }
.capitulos .campo { min-width: 200px; }
.tabla-editor td { padding: 6px 6px; vertical-align: top; }
.tabla-editor .input { height: 34px; font-size: 13.5px; padding: 0 8px; }
.tabla-editor textarea.input { height: auto; min-height: 34px; padding: 7px 8px; field-sizing: content; }
.input-mini { width: 110px; } .input-cod { width: 110px; } .input-concepto { min-width: 300px; }
.input-num { width: 90px; text-align: right; } .input-corto { width: 66px; text-align: right; }
.tabla-editor td.importe { padding-top: 13px; font-weight: 650; }
.anadir { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line-2); }
.resultados { flex-basis: 100%; display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow-y: auto; }
.resultados button { text-align: left; border: 0; border-radius: 8px; padding: 8px 12px; background: var(--surface-2); cursor: pointer; font: 500 13.5px var(--font); color: var(--navy); }
.resultados button:hover { background: var(--accent-soft); color: var(--accent); }
.barra-guardar { position: sticky; bottom: 0; z-index: 30; display: flex; justify-content: space-between; gap: 10px; padding: 14px 0; background: linear-gradient(transparent, var(--bg) 35%); }

/* ---------- Cobros y pago público --------------------------------------------- */
.campos-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.campos-4 .ancho2 { grid-column: span 2; } .campos-4 .ancho3 { grid-column: span 3; }
.botones-linea { grid-column: 1 / -1; display: flex; gap: 8px; }
.enlace-pago { display: flex; gap: 8px; margin: 10px 0; }
.pizarra-txt { color: var(--navy); }
.pago-caja { text-align: center; }
.pago-caja h1 { margin-bottom: 6px; }
.pago-concepto { font-weight: 600; color: var(--navy); margin: 14px 0 0; }
.importe-pago { font-size: 38px; font-weight: 800; letter-spacing: -.02em; color: var(--navy); margin: 6px 0 20px; }
@media (max-width: 900px) { .campos-4 { grid-template-columns: 1fr 1fr; } .campos-4 .ancho3 { grid-column: 1 / -1; } }

/* ---------- Saltoki y usuarios --------------------------------------------------- */
.rojo-txt { color: var(--danger); font-weight: 600; }
.ambar-txt { color: var(--warn); font-weight: 600; }
.verde-txt { color: var(--ok); font-weight: 600; }
.usuario-cabeza { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.token { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.plan { background: linear-gradient(135deg, #f3faf8, #f6f5ff); border-radius: 12px; padding: 10px 14px; margin: -2px -4px; }
.plan ol { margin: 6px 0 2px; padding-left: 20px; }
.plan li { margin: 3px 0; }
.acceso-nuevo { border: 1px solid #c6ebe2; background: var(--accent-soft); }
.acceso-nuevo pre { white-space: pre-wrap; font: 13px/1.5 ui-monospace, Menlo, monospace; background: #fff; border-radius: 8px; padding: 12px 14px; margin: 10px 0; }

/* ───────────── Inicio: filtro por año y comparativa ───────────── */
.segmentado.anios { overflow-x: auto; max-width: 100%; }
.segmentado.anios a { white-space: nowrap; }
.segmentado-peque a { padding: 4px 11px; font-size: 12.5px; }
a.grafico-anio { color: var(--muted); }
a.grafico-anio:hover { color: var(--accent); }
.grafico-col-activa .grafico-anio { color: var(--navy); }
.grafico-col-apagada .grafico-barras i { opacity: .35; }
.comparativa-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border-bottom: 1px solid var(--line-2); }
.comparativa-kpi { padding: 18px 22px; border-right: 1px solid var(--line-2); }
.comparativa-kpi:last-child { border-right: 0; }
.comparativa-valor { font-size: 23px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; color: var(--navy); font-variant-numeric: tabular-nums; }
.comparativa-previo { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 6px; font-size: 12.5px; color: var(--soft); }
.delta { display: inline-flex; align-items: center; gap: 3px; padding: 2px 7px; border-radius: 999px; font-weight: 650; font-size: 12px; font-variant-numeric: tabular-nums; }
.delta-sube { background: var(--ok-soft); color: var(--ok); }
.delta-baja { background: var(--danger-soft); color: var(--danger); }
.comparativa-grafico-cabeza { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 22px 0; flex-wrap: wrap; }
.grafico-meses { height: 220px; }
.grafico-meses .grafico-barras i { width: 34%; max-width: 18px; }
.c-previo { background: #c9d6e6; }
.c-actual { background: var(--accent); }
.grafico-col-futura .grafico-anio { opacity: .5; }
@media (max-width: 1100px) {
    .comparativa-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .comparativa-kpi:nth-child(3) { border-right: 0; }
    .comparativa-kpi:nth-child(n+4) { border-top: 1px solid var(--line-2); }
}
@media (max-width: 640px) {
    .comparativa-kpis { grid-template-columns: 1fr 1fr; }
    .comparativa-kpi { border-right: 0; border-top: 1px solid var(--line-2); }
    .comparativa-kpi:nth-child(-n+2) { border-top: 0; }
    .comparativa-kpi:nth-child(odd) { border-right: 1px solid var(--line-2); }
    .grafico-meses .grafico-col { min-width: 30px; }
}

/* Formularios plegables (nuevo cliente, editar datos) */
details.plegable > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
details.plegable > summary::-webkit-details-marker { display: none; }
details.plegable > summary::after { content: '▾'; color: var(--soft); margin-left: auto; transition: transform .15s; }
details.plegable[open] > summary::after { transform: rotate(180deg); }
details.plegable:not([open]) { display: none; }

/* Por facturar: barra de avance de lo facturado */
.avance { height: 8px; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.avance i { display: block; height: 100%; border-radius: 99px; background: var(--warn); }
.avance i.avance-ok { background: var(--ok); }
.punto-peligro { background: var(--danger); }

/* ---------- Calendario ------------------------------------------------------------ */
.cal-linea { display: flex; align-items: center; gap: 6px; }
.cal-linea .input { min-width: 0; }
.input-color { width: 44px; padding: 3px; cursor: pointer; flex: none; }
.tipos-cita { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px 12px; margin-top: 8px; }
.tipo-cita { display: flex; align-items: center; gap: 6px; }

.calendario { overflow: hidden; }
.cal-barra { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.cal-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-nav .btn-icono { font-size: 20px; line-height: 1; }
.cal-titulo { margin: 0 0 0 6px; font-size: 18px; }
select.cal-agenda { width: auto; height: 36px; }
.cal-cab { background: none; border: 0; font: 600 12px var(--font); text-transform: uppercase; letter-spacing: .04em; color: var(--soft); padding: 8px 6px; text-align: left; }
button.cal-cab { cursor: pointer; }
.cal-cab b { font-size: 15px; color: var(--navy); letter-spacing: 0; }
.cal-cab.hoy b { background: var(--accent); color: #fff; border-radius: 999px; padding: 1px 7px; }

/* Mes */
.cal-mes { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); }
.cal-mes > .cal-cab { border-bottom: 1px solid var(--line-2); }
.cal-dia { min-height: 112px; padding: 4px 4px 6px; border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 2px; cursor: pointer; min-width: 0; }
.cal-dia.fuera { background: var(--surface-2); }
.cal-dia.fuera .cal-num { color: var(--soft); }
.cal-num { align-self: flex-start; border: 0; background: none; font: 600 13px var(--font); color: var(--navy); padding: 2px 6px; border-radius: 999px; cursor: pointer; }
.cal-num:hover { background: var(--line-2); }
.cal-dia.hoy .cal-num { background: var(--accent); color: #fff; }
.cal-mas { border: 0; background: none; font: 600 12px var(--font); color: var(--muted); text-align: left; padding: 1px 6px; cursor: pointer; }
.cal-mas:hover { color: var(--accent); }

/* Etiqueta de una cita */
.cal-ev { --c: var(--accent); font-size: 12.5px; line-height: 1.35; padding: 2px 6px; border-radius: 6px; background: color-mix(in srgb, var(--c) 14%, #fff); border-left: 3px solid var(--c); color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.cal-ev:hover { background: color-mix(in srgb, var(--c) 24%, #fff); }
.cal-ev b { font-weight: 650; }
.cal-ev.hecho { opacity: .55; text-decoration: line-through; }
.cal-ev.arrastrando { opacity: .35; }
.cal-ev-quien { color: var(--muted); font-size: 11.5px; }
.soltar-aqui { background: var(--accent-soft) !important; }

/* Semana y día */
.cal-semana { --ancho-horas: 56px; }
.cal-sem-fila { display: grid; grid-template-columns: var(--ancho-horas) repeat(var(--cols), minmax(0, 1fr)); }
.cal-sem-cab { border-bottom: 1px solid var(--line-2); }
.cal-sem-cab .cal-cab { text-align: center; }
.cal-sem-todo { border-bottom: 1px solid var(--line); }
.cal-hora-et { font-size: 11px; color: var(--soft); padding: 6px 6px; text-align: right; }
.cal-todo-col { min-height: 30px; padding: 3px; border-left: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 2px; cursor: pointer; min-width: 0; }
.cal-rejilla { max-height: calc(100vh - 330px); min-height: 360px; overflow-y: auto; }
.cal-rejilla .cal-sem-fila { position: relative; }
.cal-horas div { height: var(--alto-hora); font-size: 11px; color: var(--soft); text-align: right; padding-right: 8px; transform: translateY(-7px); }
.cal-horas div:first-child { transform: none; }
.cal-col { position: relative; border-left: 1px solid var(--line-2); min-width: 0; }
.cal-col.hoy { background: color-mix(in srgb, var(--accent) 3%, #fff); }
.cal-franja { height: calc(var(--alto-hora) / 2); border-top: 1px solid var(--line-2); cursor: pointer; }
.cal-franja.media { border-top: 1px dashed #f1f4f7; }
.cal-franja:hover { background: var(--surface-2); }
.cal-ev-hora { position: absolute; white-space: normal; padding: 3px 6px; box-shadow: 0 1px 2px rgba(0, 0, 0, .06); z-index: 1; }
.cal-ev-hora small { display: block; color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ahora { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 2; pointer-events: none; }
.cal-ahora::before { content: ''; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }

/* Agenda */
.cal-agenda-lista { padding: 6px 0; }
.cal-agenda-dia { padding: 8px 18px; border-bottom: 1px solid var(--line-2); }
.cal-agenda-dia:last-child { border-bottom: 0; }
.cal-agenda-fecha { border: 0; background: none; padding: 4px 0; font: 700 13.5px var(--font); color: var(--navy); cursor: pointer; }
.cal-agenda-fecha.hoy { color: var(--accent); }
.cal-agenda-fila { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.cal-agenda-fila:hover { background: var(--surface-2); }
.cal-agenda-fila.hecho .cal-agenda-texto b { text-decoration: line-through; color: var(--soft); }
.cal-agenda-hora { width: 110px; flex: none; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cal-agenda-texto { min-width: 0; font-size: 14px; }

/* Ficha de la cita */
.dialogo { border: 0; border-radius: var(--radius-lg); padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 24px); box-shadow: var(--shadow-lg); color: var(--text); }
.dialogo::backdrop { background: rgba(36, 54, 58, .35); }
.dialogo form { padding: 20px 22px; }
.dialogo [hidden] { display: none !important; }
.dialogo-cabeza { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dialogo-cabeza h2 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dialogo-pie { display: flex; gap: 8px; margin-top: 18px; }
.dialogo label a { margin-left: 6px; font-weight: 600; }
.cita-cliente { position: relative; }
.cita-cliente .resultados { position: absolute; top: 100%; left: 0; right: 0; z-index: 5; margin-top: 4px; background: var(--surface); box-shadow: var(--shadow); border-radius: 10px; padding: 4px; }

@media (max-width: 760px) {
    .cal-dia { min-height: 78px; }
    .cal-mes .cal-ev b { display: none; }
    .cal-semana { --ancho-horas: 42px; }
    .cal-ev-hora small { display: none; }
    .cal-agenda-hora { width: 78px; }
    .dialogo .campos { grid-template-columns: 1fr; }
}

/* ---------- Usuarios: rol y permisos ----------------------------------------------- */
.ancho-total { grid-column: 1 / -1; }
.roles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.rol { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.rol:has(input:checked) { box-shadow: 0 0 0 2px var(--accent); background: var(--accent-soft); }
.rol input { margin-top: 3px; accent-color: var(--accent); }
.rol b { display: block; color: var(--navy); font-size: 14px; }
.rol small, .permiso small { display: block; color: var(--soft); font-size: 12px; font-weight: 400; }
.permisos-usuario { margin-top: 4px; }
form:has(input[name="rol"][value="admin"]:checked) .permisos-usuario { display: none; }
.permisos-cabeza { display: flex; justify-content: space-between; align-items: baseline; margin-top: 14px; }
.permisos-lista { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; margin-top: 6px; }
.permiso { display: flex; gap: 8px; align-items: flex-start; padding: 7px 10px; border-radius: 8px; background: var(--surface-2); cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--navy); }
.permiso:has(input:checked) { background: var(--accent-soft); }
.permiso input { margin-top: 2px; width: 15px; height: 15px; accent-color: var(--accent); flex: none; }
@media (max-width: 560px) { .roles { grid-template-columns: 1fr; } }

/* ---------- Fichaje ------------------------------------------------------------------ */
.reloj-fichaje { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.reloj-cabeza { display: flex; align-items: center; gap: 10px; }
.reloj-hora { font-size: 52px; font-weight: 800; letter-spacing: -.02em; color: var(--navy); font-variant-numeric: tabular-nums; line-height: 1.1; margin-top: 10px; }
.reloj-fecha { color: var(--muted); }
.reloj-hoy { margin-top: 10px; font-size: 15px; color: var(--muted); }
.reloj-hoy b { color: var(--navy); }
.reloj-botones { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 18px; }
.reloj-botones .btn { min-width: 150px; justify-content: center; }
.reloj-aviso { margin: 12px 0 0; }
.estado-fichaje { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; font-size: 13px; padding: 3px 10px; border-radius: 999px; background: var(--line-2); color: var(--muted); white-space: nowrap; }
.estado-fichaje .punto { background: var(--soft); }
.estado-trabajando { background: var(--ok-soft); color: var(--ok); }
.estado-trabajando .punto { background: var(--ok); box-shadow: 0 0 0 3px rgba(14, 159, 110, .2); }
.estado-en_pausa { background: var(--warn-soft); color: var(--warn); }
.estado-en_pausa .punto { background: var(--warn); }
.linea-fichaje { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.fichajes-dia { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.fichaje-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--navy); }
.fichaje-chip.corregido { background: #f0efff; }
.fichaje-chip.anulado { text-decoration: line-through; color: var(--soft); }
.chip-anular { border: 0; background: none; color: var(--soft); cursor: pointer; padding: 0 0 0 2px; font-size: 11px; }
.chip-anular:hover { color: var(--danger); }

/* ---------- Tickets ------------------------------------------------------------------- */
.filtros-tickets { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.filtros-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filtros-form .input { width: auto; min-width: 180px; }
.persona { display: inline-flex; align-items: center; gap: 7px; }
.avatar-mini { width: 22px; height: 22px; font-size: 11px; color: #fff; }
.ticket-cliente { position: relative; }
.ticket-cliente .resultados { position: absolute; top: 100%; left: 0; right: 0; z-index: 5; margin-top: 4px; background: var(--surface); box-shadow: var(--shadow); border-radius: 10px; padding: 4px; }
.ticket-rejilla { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.ticket-lateral { position: sticky; top: calc(var(--barra) + 16px); display: flex; flex-direction: column; gap: 4px; }
.ticket-lateral .campo { margin-bottom: 8px; }
.ticket-texto { font-size: 14.5px; line-height: 1.6; margin-top: 6px; white-space: normal; }
.plegable-editar { margin-top: 14px; }
.plegable-editar summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.ticket-datos { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.ticket-datos .soft { display: inline-block; min-width: 88px; }
.hilo { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.hilo-cambio { font-size: 12.5px; color: var(--muted); padding-left: 12px; }
.hilo-cambio .punto { background: var(--line); margin-right: 4px; }
.hilo-comentario { display: flex; gap: 10px; align-items: flex-start; }
.hilo-comentario .avatar { color: #fff; flex: none; }
.hilo-burbuja { background: var(--surface-2); border-radius: 4px 14px 14px 14px; padding: 9px 13px; max-width: 640px; font-size: 14px; line-height: 1.5; }
.hilo-comentario.mio .hilo-burbuja { background: var(--accent-soft); }
.hilo-nuevo { display: flex; gap: 8px; align-items: flex-end; }
.hilo-nuevo textarea { flex: 1; }
@media (max-width: 1000px) { .ticket-rejilla { grid-template-columns: 1fr; } .ticket-lateral { position: static; } }

/* ---------- Calendario: dónde está cada uno ------------------------------------------ */
.equipo-tarjetas { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.equipo-persona { border-top: 3px solid var(--c); display: flex; flex-direction: column; gap: 10px; }
.equipo-cabeza { display: flex; align-items: center; gap: 10px; }
.equipo-cabeza .avatar { color: #fff; flex: none; }
.equipo-nombre { flex: 1; min-width: 0; }
.equipo-linea { display: grid; grid-template-columns: 64px 1fr; gap: 8px; font-size: 13.5px; align-items: baseline; }
.equipo-etiqueta { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--soft); }
.mapa-equipo { height: 360px; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.equipo-col-cab { text-align: center; display: flex; align-items: center; justify-content: center; gap: 6px; text-transform: none; letter-spacing: 0; }
.equipo-col-cab b { font-size: 13px; }
.personas-tickets { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.persona-ticket { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; min-width: 190px; padding: 12px 14px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-sm); color: var(--navy); }
.persona-ticket .small { grid-column: 1 / -1; }
.persona-ticket-num { font-size: 22px; font-weight: 800; color: var(--accent); line-height: 1; grid-row: span 2; align-self: center; }
.persona-ticket.activa { box-shadow: 0 0 0 2px var(--accent); background: var(--accent-soft); }
.persona-todas { min-width: 0; display: flex; align-items: center; color: var(--muted); }

/* ---------- Alarmas ------------------------------------------------------------------ */
.campana { position: relative; }
.campana-num { position: absolute; top: 2px; right: 0; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 800; line-height: 17px; text-align: center; box-shadow: 0 0 0 2px var(--surface); }
.alarmas-resumen { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.alarma { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.alarma:last-child { border-bottom: 0; }
.alarma-icono { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 19px; background: var(--surface-2); }
.alarma.urgente .alarma-icono { background: var(--danger-soft); }
.alarma.aviso .alarma-icono { background: var(--warn-soft); }
.alarma-titulo { font-weight: 650; color: var(--navy); }
.alarma-titulo a { color: inherit; }
.alarma-detalle { font-size: 13px; color: var(--muted); margin-top: 2px; }
.alarma-acciones { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.alarma-acciones select { width: auto; height: 34px; font-size: 13px; }
.alarma.resuelta { opacity: .65; }
@media (max-width: 760px) { .alarma { grid-template-columns: 40px 1fr; } .alarma-acciones { grid-column: 1 / -1; justify-content: flex-start; } }

/* ---------- Presupuestos: años y contadores ------------------------------------------- */
.anio-num { font-size: 11px; font-weight: 600; color: var(--soft); margin-left: 3px; font-variant-numeric: tabular-nums; }
.segmentado a.activo .anio-num { color: var(--accent); }
.contadores-ppto { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.contadores-ppto .stat { display: block; color: inherit; transition: box-shadow .15s, transform .15s; }
.contadores-ppto .stat:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.contadores-ppto .stat-valor { font-size: 24px; }
.contadores-ppto .contador-activo:not(.stat-destacada) { box-shadow: 0 0 0 2px var(--accent); }
.contadores-ppto .stat-destacada:not(.contador-activo) { opacity: .82; }
.contadores-ppto .contador-vacio { opacity: .55; }
@media (max-width: 1200px) { .contadores-ppto { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .contadores-ppto { grid-template-columns: 1fr 1fr; } }
.aviso-empresa { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; width: 100%; }
.aviso-empresa .btn { margin-left: auto; }

/* ---------- Calendario: asistente y agendas del equipo -------------------------------- */
.asistente-cita { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: linear-gradient(135deg, #f3faf8, #f6f5ff); }
.asistente-cita .input { flex: 1; background: #fff; }
.asistente-cita-icono { font-size: 20px; padding-left: 4px; }
.cal-leyenda { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 18px; border-bottom: 1px solid var(--line-2); }
.cal-persona { --c: var(--accent); display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: color-mix(in srgb, var(--c) 10%, #fff); font: 600 12.5px var(--font); color: var(--navy); cursor: pointer; }
.cal-persona .punto { background: var(--c); }
.cal-persona.oculta { background: #fff; color: var(--soft); text-decoration: line-through; }
.cal-persona.oculta .punto { background: var(--line); }
@media (max-width: 640px) { .asistente-cita { flex-wrap: wrap; } .asistente-cita .btn { width: 100%; justify-content: center; } }

/* ---------- Facturas del panel --------------------------------------------------------- */
.partidas-modo { display: flex; flex-direction: column; gap: 8px; }
.partidas-modo .input-mini { display: inline-block; width: 80px; height: 30px; margin: 0 4px; }
.fila-capitulo td { background: var(--accent-soft); color: var(--accent-hover); padding: 7px 12px; }
.partida-hecha { opacity: .5; }
.partida-texto { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; max-width: 560px; }
.aviso-facturar { display: block; color: var(--danger); margin-bottom: 14px; }

/* ---------- Documentos y firmas -------------------------------------------------------- */
.doc-enviado { padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.doc-enviado:last-child { border-bottom: 0; }
.doc-cabeza { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.doc-progreso { display: flex; align-items: center; gap: 8px; }
.doc-personas { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.doc-persona { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); font-size: 12.5px; font-weight: 600; color: var(--muted); }
.doc-persona.firmado { background: var(--ok-soft); color: var(--ok); }
.doc-persona.rechazado { background: var(--danger-soft); color: var(--danger); }

/* ---------- Obras ----------------------------------------------------------------------- */
.obras-rejilla { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; margin-bottom: 14px; }
.obra-tarjeta { display: flex; flex-direction: column; gap: 6px; color: inherit; transition: box-shadow .15s, transform .15s; }
.obra-tarjeta:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.obra-cabeza { display: flex; gap: 8px; align-items: center; color: var(--navy); }
.obra-cifras { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.obra-cifras span { display: block; font-size: 11px; color: var(--soft); }
.obra-cifras b { font-size: 14px; color: var(--navy); font-variant-numeric: tabular-nums; }
.obra-barra { position: relative; height: 8px; border-radius: 99px; background: var(--line-2); overflow: hidden; margin-top: 6px; }
.obra-barra i { position: absolute; left: 0; top: 0; height: 100%; border-radius: 99px; }
.obra-barra .facturado { background: var(--ok); opacity: .55; }
.obra-barra .gastado { background: var(--warn); height: 50%; top: 25%; }
.obra-tipo { display: grid; grid-template-columns: 150px 1fr auto; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line-2); font-size: 13.5px; }
.asignar-obra { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.asignar-obra select { width: auto; max-width: 230px; height: 34px; font-size: 13px; }
.asignar-obra .input-corto { height: 34px; }

/* ---------- Albaranes -------------------------------------------------------------------- */
.lienzo-firma { width: 100%; height: 220px; margin-top: 10px; border: 2px dashed var(--line); border-radius: 12px; background: #fff; touch-action: none; cursor: crosshair; }
.firma-albaran { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line-2); text-align: center; }
.firma-albaran img { max-height: 90px; max-width: 100%; }
#articulos { position: relative; flex-basis: 100%; }
