:root {
    --tinta: #1f2933;
    --suave: #6b7280;
    --borde: #dfe3e8;
    --fondo: #f4f6f8;
    --acento: #2563eb;
    --lateral: #1f2933;
}

body {
    background: var(--fondo);
    color: var(--tinta);
    font-size: 0.9rem;
}

.app { display: flex; min-height: 100vh; }

.lateral {
    width: 224px;
    flex: 0 0 224px;
    background: var(--lateral);
    color: #cbd2d9;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.marca { display: flex; gap: .6rem; align-items: center; padding: 1rem; border-bottom: 1px solid #323f4b; }
.marca strong { color: #fff; display: block; line-height: 1.1; }
.marca small { color: #9aa5b1; font-size: .7rem; }
.marca-icono {
    width: 34px; height: 34px; border-radius: 8px; background: var(--acento);
    color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .8rem;
}

.menu { flex: 1; overflow-y: auto; padding: .6rem 0; }
.menu a {
    display: block; padding: .45rem 1rem; color: #cbd2d9;
    text-decoration: none; font-size: .86rem; border-left: 3px solid transparent;
}
.menu a:hover { background: #323f4b; color: #fff; }
.menu a.activo { background: #323f4b; color: #fff; border-left-color: var(--acento); font-weight: 600; }
.menu-grupo {
    display: block; padding: .8rem 1rem .25rem; font-size: .65rem;
    text-transform: uppercase; letter-spacing: .08em; color: #7b8794;
}

.usuario { padding: .8rem; border-top: 1px solid #323f4b; }
.usuario-nombre { font-size: .75rem; color: #9aa5b1; margin-bottom: .4rem; word-break: break-all; }

.principal { flex: 1; padding: 1.2rem 1.6rem; max-width: 100%; overflow-x: auto; }

.acceso { min-height: 100vh; display: grid; place-items: center; background: var(--lateral); }

.cabecera-pagina {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.cabecera-pagina h1 { font-size: 1.35rem; margin: 0; font-weight: 600; }
.cabecera-pagina .subtitulo { color: var(--suave); font-size: .82rem; }

.tarjeta { background: #fff; border: 1px solid var(--borde); border-radius: 8px; }
.tarjeta > .tarjeta-cabecera {
    padding: .6rem .9rem; border-bottom: 1px solid var(--borde);
    font-weight: 600; font-size: .85rem; background: #fafbfc;
    border-radius: 8px 8px 0 0;
}
.tarjeta > .tarjeta-cuerpo { padding: .9rem; }

.kpi { background: #fff; border: 1px solid var(--borde); border-radius: 8px; padding: .8rem .9rem; height: 100%; }
.kpi .etiqueta { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--suave); }
.kpi .valor { font-size: 1.5rem; font-weight: 600; line-height: 1.2; }
.kpi .pie { font-size: .74rem; color: var(--suave); }

table.tabla { width: 100%; background: #fff; border-collapse: collapse; font-size: .84rem; }
table.tabla th {
    background: #fafbfc; border-bottom: 1px solid var(--borde); padding: .5rem .6rem;
    font-weight: 600; font-size: .74rem; text-transform: uppercase;
    letter-spacing: .03em; color: var(--suave); white-space: nowrap;
}
table.tabla td { border-bottom: 1px solid var(--borde); padding: .45rem .6rem; vertical-align: middle; }
table.tabla tbody tr:hover { background: #f8fafc; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.etiqueta-estado {
    display: inline-block; padding: .12rem .5rem; border-radius: 999px;
    font-size: .7rem; font-weight: 600; white-space: nowrap;
}
.e-gris { background: #eef1f4; color: #52606d; }
.e-azul { background: #dbeafe; color: #1d4ed8; }
.e-verde { background: #d1fae5; color: #047857; }
.e-rojo { background: #fee2e2; color: #b91c1c; }
.e-ambar { background: #fef3c7; color: #b45309; }

/* Editor de líneas */
.editor-lineas { background: #fff; border: 1px solid var(--borde); border-radius: 8px; overflow-x: auto; }
.editor-lineas table { width: 100%; min-width: 940px; border-collapse: collapse; font-size: .82rem; }
.editor-lineas th {
    background: #fafbfc; padding: .4rem .35rem; font-size: .68rem; text-transform: uppercase;
    letter-spacing: .03em; color: var(--suave); border-bottom: 1px solid var(--borde); font-weight: 600;
}
.editor-lineas td { padding: .18rem .25rem; border-bottom: 1px solid #eef1f4; }
.editor-lineas input, .editor-lineas select, .editor-lineas textarea {
    width: 100%; border: 1px solid transparent; background: transparent;
    padding: .2rem .3rem; font-size: .82rem; border-radius: 4px;
}
.editor-lineas input:focus, .editor-lineas select:focus, .editor-lineas textarea:focus {
    border-color: var(--acento); background: #fff; outline: none;
}
.editor-lineas tr.fila-capitulo { background: #eef2f7; font-weight: 600; }
.editor-lineas tr.fila-texto { background: #fcfcfd; font-style: italic; color: var(--suave); }
.editor-lineas .col-mover { width: 26px; color: var(--suave); cursor: grab; text-align: center; }
.editor-lineas .importe-linea { font-variant-numeric: tabular-nums; text-align: right; padding-right: .4rem; }

.totales { font-size: .86rem; }
.totales .fila { display: flex; justify-content: space-between; padding: .22rem 0; border-bottom: 1px solid var(--borde); }
.totales .fila.destacado { font-weight: 600; }
.totales .total-final {
    display: flex; justify-content: space-between; background: var(--lateral); color: #fff;
    padding: .5rem .7rem; border-radius: 6px; margin-top: .5rem; font-size: 1.05rem; font-weight: 600;
}

.form-label { font-size: .76rem; font-weight: 600; color: var(--suave); margin-bottom: .15rem; }
.form-control, .form-select { font-size: .85rem; }
.text-mono { font-variant-numeric: tabular-nums; }

/* Buscador de cliente con autocompletado */
.selector { position: relative; }

.selector-lista {
    position: absolute;
    z-index: 1080;
    top: 100%;
    left: 0;
    right: 0;
    margin: 2px 0 0;
    padding: 0;
    list-style: none;
    background: #fff;
    border: 1px solid var(--borde);
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(31, 41, 51, .12);
    max-height: 280px;
    overflow-y: auto;
}

.selector-lista li {
    padding: .35rem .6rem;
    cursor: pointer;
    font-size: .82rem;
    border-bottom: 1px solid #f1f3f5;
}

.selector-lista li:last-child { border-bottom: none; }
.selector-lista li:hover,
.selector-lista li.activo { background: #eef2f7; }

.selector-lista .detalle { color: var(--suave); font-size: .72rem; }
.selector-lista .vacio { color: var(--suave); cursor: default; }
.selector-lista .vacio:hover { background: #fff; }

.selector-lista .nuevo {
    color: var(--acento);
    font-weight: 600;
    border-top: 1px solid var(--borde);
    position: sticky;
    bottom: 0;
    background: #fff;
}
