/* ==========================================================================
   MAJEST · Web de cliente — sistema de estilos
   Basado en el del panel de administración, con la identidad de marca de MAJEST
   (violeta #635BFF sobre azul noche #0B1220) e integración de iconos SVG inline.
   ========================================================================== */

:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;

    /* Marca MAJEST */
    --navy: #0b1220;
    --violet: #635bff;

    --sidebar-bg: #0b1220;
    --sidebar-fg: #94a3b8;
    --sidebar-fg-active: #ffffff;
    --sidebar-active: #1e293b;

    --primary: #635bff;
    --primary-hover: #4b45d6;
    --primary-fg: #ffffff;

    --green: #15803d;   --green-bg: #dcfce7;
    --amber: #b45309;   --amber-bg: #fef3c7;
    --slate: #475569;   --slate-bg: #e2e8f0;
    --violet-fg: #4338ca; --violet-bg: #e0e7ff;
    --danger: #dc2626;  --danger-hover: #b91c1c;

    --radius: 10px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow: 0 1px 3px rgba(15, 23, 42, .1), 0 1px 2px rgba(15, 23, 42, .06);
}

@media print {
    .tpv-topbar, #blazor-error-ui { display: none !important; }
    .tpv-shell, .tpv-body { min-height: 0 !important; background: white !important; }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; }
h1:focus { outline: none; }
h2 { font-size: 1.1rem; margin: 0; }
.muted { color: var(--muted); }
.center { text-align: center; }
code { background: #f1f5f9; padding: 1px 5px; border-radius: 5px; font-size: .85em; }

/* ---------- Iconos SVG compartidos ---------- */
.mj-icon {
    background-color: currentColor;
    display: inline-block;
    flex: 0 0 auto;
    height: var(--mj-icon-size, 1.25rem);
    width: var(--mj-icon-size, 1.25rem);
    /* Propiedades largas por compatibilidad. Aun así, esta técnica **no funciona dentro de un WebView**: al
       renderizar el SVG como máscara se pierde su `stroke="currentColor"` y el icono queda vacío. En navegador
       (web de cliente y panel) sí funciona; el escritorio MAUI arrastra ese defecto y se resuelve como en la
       app de Fichajes, con SVG en línea. */
    -webkit-mask-image: var(--mj-icon-url);
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    mask-image: var(--mj-icon-url);
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
}

/* ---------- Logo de empresa ---------- */
.company-logo {
    width: 40px;
    height: 40px;
    border-radius: 9px;
    object-fit: contain;
    background: #fff;
    flex: 0 0 auto;
}
.company-logo--mono {
    display: grid;
    place-items: center;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    text-transform: uppercase;
    user-select: none;
}

/* ---------- Shell con sidebar ---------- */
.app-shell {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--sidebar-bg);
    color: var(--sidebar-fg);
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 8px 18px;
}
.brand-logo-mark.company-logo { width: 36px; height: 36px; border-radius: 8px; flex: 0 0 auto; }
.brand-name {
    color: #fff;
    font-weight: 700;
    letter-spacing: .01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
}

/* Botón de contraer/expandir la barra a rail de iconos (ADR-0027) */
.rail-toggle {
    flex: 0 0 auto;
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--sidebar-fg);
    cursor: pointer;
}
.rail-toggle:hover { background: var(--sidebar-active); color: var(--sidebar-fg-active); }

/* Buscador del menú: acceso directo a cualquier pantalla escribiendo su nombre */
.nav-buscador { position: relative; margin: 0 4px 10px; }
.nav-buscador-ico {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    display: inline-flex; color: var(--sidebar-fg); opacity: .7; pointer-events: none;
}
.nav-buscador-input {
    width: 100%;
    padding: 8px 10px 8px 32px;
    border: 1px solid #1e293b;
    border-radius: 8px;
    background: #111c2e;
    color: #e2e8f0;
    font-size: .88rem;
}
.nav-buscador-input::placeholder { color: var(--sidebar-fg); opacity: .7; }
.nav-buscador-input:focus { outline: none; border-color: var(--primary); }

.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--sidebar-fg);
    font-weight: 500;
    text-decoration: none;
}
.nav-link:hover { background: var(--sidebar-active); color: var(--sidebar-fg-active); text-decoration: none; }
.nav-link.active { background: var(--primary); color: #fff; }
.nav-ico { width: 20px; display: inline-flex; justify-content: center; flex: 0 0 auto; }
.nav-etiqueta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Cabecera de grupo plegable (acordeón: a lo sumo un grupo abierto) */
.nav-grupo {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    padding: 9px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--sidebar-fg);
    font: inherit;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
}
.nav-grupo:hover { background: var(--sidebar-active); color: var(--sidebar-fg-active); }
.nav-grupo.abierto { color: var(--sidebar-fg-active); }
.nav-chevron { margin-left: auto; opacity: .6; font-size: 1rem; line-height: 1; }

.nav-sub {
    display: flex; flex-direction: column; gap: 2px;
    margin: 2px 0 6px 21px;
    padding-left: 10px;
    border-left: 1px solid #1e293b;
}
.nav-link--sub { padding: 7px 10px; font-size: .92rem; }

/* Resultado del buscador: la entrada, con su grupo como pista */
.nav-pista {
    margin-left: auto;
    font-size: .7rem; letter-spacing: .04em; text-transform: uppercase;
    opacity: .5;
}
.nav-vacio { color: var(--sidebar-fg); opacity: .7; font-size: .88rem; padding: 8px 12px; }

/* Rail: la barra contraída pinta todas las entradas como iconos */
.app-shell--rail { grid-template-columns: 68px 1fr; }
.app-shell--rail .sidebar { padding: 18px 10px; align-items: center; }
.app-shell--rail .brand { flex-direction: column; gap: 10px; padding: 8px 0 14px; }
.app-shell--rail .brand-name, .app-shell--rail .powered-by { display: none; }
.app-shell--rail .rail-toggle {
    width: 32px; height: 32px;
    border-color: #1e293b;
    background: #111c2e;
}
.app-shell--rail .rail-toggle svg { transform: rotate(180deg); }
.nav--rail { align-items: center; }
.nav--rail .nav-link { justify-content: center; padding: 10px; width: 44px; }

.sidebar-foot { margin-top: auto; padding: 12px 8px 4px; }
.powered-by { height: 20px; opacity: .55; }

/* ---------- Zona principal ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: 60px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar-user { display: flex; align-items: center; gap: 14px; }
.user-name { color: var(--text); font-size: .9rem; font-weight: 600; }

.content { padding: 26px 28px; max-width: 1120px; width: 100%; }

.page-head { margin-bottom: 20px; }
.page-head h1 { margin-bottom: 4px; }

/* ---------- Tarjetas ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 20px;
}
.card-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px;
}

/* ---------- Tarjetas de estadística ---------- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px;
    display: flex;
    gap: 14px;
    align-items: center;
}
.stat-ico {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: grid; place-items: center;
    background: var(--violet-bg);
    color: var(--violet-fg);
    flex: 0 0 auto;
}
.stat-body { min-width: 0; }
.stat-label { color: var(--muted); font-size: .85rem; margin-bottom: 4px; }
.stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1; }
.stat-value--text { font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
}
table.table thead th {
    text-align: left;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.table tbody td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.table tbody tr:last-child td { border-bottom: none; }
table.table tbody tr:hover { background: #f8fafc; }
.cell-user { display: flex; align-items: center; gap: 10px; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    background: var(--slate-bg);
    color: var(--slate);
}
.badge-activo { background: var(--green-bg); color: var(--green); }
.badge-inactivo { background: var(--slate-bg); color: var(--slate); }
.badge-admin { background: var(--violet-bg); color: var(--violet-fg); }
.badge-usuario { background: var(--slate-bg); color: var(--slate); }

/* ---------- Botones ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    background: var(--surface);
    color: var(--text);
    line-height: 1.2;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: .82rem; }
.btn-xs { padding: 1px 7px; font-size: .8rem; line-height: 1.3; }
.orden-btns { display: inline-flex; flex-direction: column; gap: 2px; }
tr.row-inactiva > td { opacity: .55; }
.btn-primary { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: #f8fafc; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }
form.inline { display: inline; margin: 0; }

/* ---------- Formularios ---------- */
.form-field { margin-bottom: 16px; max-width: 460px; }
.form-field label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 6px; }
.form-field .hint { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .95rem;
    background: #fff;
    color: var(--text);
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 91, 255, .15); }

/* Accesibilidad de teclado: foco visible en elementos interactivos (no en clic de ratón). */
.btn:focus-visible,
.nav-link:focus-visible,
a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 6px;
}
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; }

/* ---------- Lista de datos (perfil) ---------- */
.data-list { display: grid; grid-template-columns: max-content 1fr; gap: 12px 24px; align-items: center; margin: 0; }
.data-list dt { color: var(--muted); font-size: .85rem; }
.data-list dd { margin: 0; font-weight: 600; }

/* ---------- Zona pública (portada / login) ---------- */
.public-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: radial-gradient(1200px 600px at 50% -10%, #1e293b 0%, #0b1220 60%);
    padding: 20px;
}
.auth-card {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 24px 50px rgba(2, 6, 23, .40);
    padding: 34px;
    width: 100%;
    max-width: 400px;
}
.auth-card .brand-logo { display: block; height: 34px; margin: 0 auto 18px; }
.auth-card h1 { font-size: 1.25rem; text-align: center; margin-bottom: 6px; }
.auth-card > .muted.center { margin-top: 0; margin-bottom: 22px; }
.auth-card .btn-primary { width: 100%; margin-top: 4px; }
.auth-card.center { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.auth-card.center .btn { width: auto; margin-top: 14px; }

.company-login-head { text-align: center; margin-bottom: 20px; }
.company-login-head .company-logo { width: 64px; height: 64px; border-radius: 14px; margin: 0 auto 12px; }
.company-login-head .company-logo--mono { font-size: 1.7rem; }

.empty-ico { color: var(--muted); margin: 6px 0; }

.api-status {
    display: flex; align-items: center; justify-content: center; gap: 7px;
    margin-top: 20px;
    font-size: .82rem;
    color: var(--muted);
}
.api-status.is-ok { color: var(--green); }
.api-status.is-off { color: var(--danger); }

.alert {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: .88rem;
    margin-bottom: 14px;
}
.alert-warn { background: var(--amber-bg); color: var(--amber); border-color: #fde68a; }
.alert-success { background: var(--green-bg); color: var(--green); border-color: #bbf7d0; }

/* ---------- Editor de logo (ajustes de empresa) ---------- */
.logo-editor { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.logo-current { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.logo-current-label { color: var(--muted); font-size: .8rem; }
.logo-lg.company-logo { width: 96px; height: 96px; border-radius: 16px; font-size: 2.2rem; }
.logo-controls { flex: 1 1 260px; min-width: 240px; }
.logo-controls .form-field { max-width: none; }
.logo-file-info { display: flex; align-items: center; gap: 6px; font-size: .85rem; margin: 0 0 12px; }
/* El selector de archivos usa .input pero con altura automática (el botón nativo del navegador). */
input[type="file"].input { padding: 7px 10px; height: auto; line-height: 1.4; }

/* ---------- Estados de página ---------- */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
}
.empty-state .empty-ico { display: flex; justify-content: center; margin-bottom: 10px; }

/* ---------- Select (reutiliza el aspecto de .input) ---------- */
select.input { appearance: none; background-image: none; cursor: pointer; }

/* ---------- Acciones de fila (tabla de usuarios) ---------- */
.row-actions { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.tag-you {
    display: inline-block; margin-left: 6px;
    font-size: .7rem; font-weight: 700; color: var(--violet-fg);
    background: var(--violet-bg); border-radius: 999px; padding: 1px 7px;
    vertical-align: middle;
}

/* ---------- Modal ---------- */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 50;
    background: rgba(2, 6, 23, .55);
    display: grid; place-items: center;
    padding: 20px;
}
.modal {
    background: var(--surface);
    border-radius: 14px;
    box-shadow: 0 24px 50px rgba(2, 6, 23, .40);
    width: 100%; max-width: 440px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 1.1rem; }
.modal-close {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; padding: 0;
    border: none; border-radius: 8px; cursor: pointer;
    background: transparent; color: var(--muted);
}
.modal-close:hover { background: #f1f5f9; color: var(--text); }
.modal-body { padding: 20px; }
.modal-body .form-field { max-width: none; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.form-check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: .9rem; cursor: pointer; }
.form-check input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

.perm-group {
    border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 12px 10px; margin-bottom: 10px;
    display: flex; flex-wrap: wrap; gap: 8px 18px;
}
.perm-group legend { font-size: .78rem; font-weight: 700; color: var(--muted); padding: 0 4px; }
.perm-group .form-check { font-weight: 500; }

/* Buscador dentro del selector de permisos (roles y usuarios). */
.perm-buscador { margin-bottom: 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: static; height: auto; flex-direction: row;
        flex-wrap: wrap; align-items: center;
    }
    .brand { padding: 6px 8px; }
    .nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar-foot { display: none; }
    .topbar { padding: 0 16px; }
    .content { padding: 18px 16px; }
}

@media (max-width: 480px) {
    /* En pantallas muy estrechas el nombre del usuario cede sitio; quedan rol y "Salir". */
    .topbar-user .user-name { display: none; }
    .topbar-user { gap: 10px; }
    .auth-card { padding: 26px 20px; }
}

/* ---------- Barra de herramientas (buscador + acción) ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .search { position: relative; flex: 1 1 260px; max-width: 380px; }
.toolbar .search .input { padding-left: 34px; }
.toolbar .search .search-ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; display: inline-flex; }

/* ---------- Pestañas (ficha con secciones) ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 22px; flex-wrap: wrap; }
.tab {
    appearance: none; background: transparent; border: none;
    padding: 10px 14px; font-size: .9rem; font-weight: 600; cursor: pointer;
    color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
    display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover:not(:disabled) { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Sub-pestañas (grupos de configuración por módulo, ADR-0020) ---------- */
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.subtab {
    appearance: none; cursor: pointer;
    padding: 7px 14px; font-size: .85rem; font-weight: 600;
    color: var(--muted); background: var(--surface);
    border: 1px solid var(--border); border-radius: 999px;
}
.subtab:hover:not(.active) { color: var(--text); border-color: var(--muted); }
.subtab.active { color: var(--primary-fg); background: var(--primary); border-color: var(--primary); }

/* ---------- Acordeón (secciones desplegables de configuración) ---------- */
.accordion { display: flex; flex-direction: column; }
.acc-item { border-bottom: 1px solid var(--border); }
.acc-item:last-child { border-bottom: none; }
.acc-head {
    appearance: none; width: 100%; cursor: pointer;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 16px 2px; background: transparent; border: none;
    font-size: 1rem; font-weight: 600; color: var(--text); text-align: left;
}
.acc-head:hover { color: var(--primary); }
.acc-caret { color: var(--muted); transition: transform .15s ease; font-size: .8rem; }
.acc-item.open .acc-caret { transform: rotate(180deg); }
.acc-body { padding: 2px 2px 20px; }
.acc-desc { margin-top: -2px; margin-bottom: 14px; }

/* ---------- Rejilla de formulario (2 columnas) ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; }
.form-grid .form-field { max-width: none; }
.form-grid .form-field.col-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------- Documentos de venta ---------- */
.document-head { display:flex; align-items:center; justify-content:space-between; gap:16px; }
.document-lines .line-main { min-width:300px; }
.document-lines .input-sm { min-width:90px; padding:6px 8px; margin-bottom:4px; }
.document-lines select.input-sm { min-width:260px; }
.document-lines .num { width:90px; text-align:right; }
.document-summary { display:grid; grid-template-columns:minmax(0,1fr) 340px; gap:20px; }
.document-summary h2 { margin-bottom:12px; }
.summary-row { display:flex; justify-content:space-between; gap:16px; padding:5px 0; }
.grand-total { border-top:2px solid var(--primary); margin-top:7px; padding-top:12px; font-size:1.12rem; color:var(--primary); }
.document-actions { flex-wrap:wrap; padding-bottom:24px; }
@media (max-width: 760px) { .document-summary { grid-template-columns:1fr; } }
.series-row { display: flex; gap: .65rem; align-items: center; }
.series-row .input { flex: 1; }

/* Cabecera de ficha (volver) y estado bloqueado */
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .85rem; margin-bottom: 12px; }
.badge-bloqueado { background: var(--amber-bg); color: var(--amber); }
.fieldset-title { font-size: .95rem; font-weight: 700; margin: 6px 0 12px; padding-top: 14px; border-top: 1px solid var(--border); }
.fieldset-title:first-child { border-top: none; padding-top: 0; }

/* ---------- Validación de Blazor / error boundary ---------- */
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid var(--danger); }
.validation-message { color: var(--danger); font-size: .85rem; }

/* ---------- Árbol de familias (catálogo, Fase 9) ---------- */
.tree { display: flex; flex-direction: column; }
.tree-row {
  display: flex; align-items: center; gap: 8px;
  padding-top: 6px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.tree-row:last-child { border-bottom: 0; }
.tree-branch { color: var(--muted); font-family: monospace; white-space: pre; }
.tree-name { font-weight: 600; }
.tree-edit { max-width: 320px; }
.tree-actions { display: inline-flex; gap: 2px; margin-left: auto; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 30px; padding: 0 6px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
  cursor: pointer; line-height: 1; font-size: .8rem;
}
.icon-btn:hover:not(:disabled) { background: var(--bg); }
.icon-btn:disabled { opacity: .5; cursor: default; }

/* ---------- Ejes de variación / chips (catálogo, Fase 9) ---------- */
.eje-block { padding: 10px 0; border-bottom: 1px solid var(--border); }
.eje-block:last-child { border-bottom: 0; }
.eje-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--border); font-size: .85rem;
}
.chip-x { border: 0; background: transparent; cursor: pointer; color: var(--muted); font-size: 1rem; line-height: 1; padding: 0; }
.chip-x:hover { color: var(--danger); }
.chip-input { max-width: 120px; height: 30px; padding: 2px 8px; }

/* ---------- Matriz de precios (catálogo, Fase 9) ---------- */
.precio-input { max-width: 110px; height: 32px; text-align: right; }

/* ==========================================================================
   Panel de inicio configurable (ADR-0028)
   ========================================================================== */

.page-head--acciones {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}

.widgets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    align-items: start;
    /* Con widgets de anchos distintos, «dense» rellena los huecos que deja un widget ancho. */
    grid-auto-flow: row dense;
}
/* El tamaño lo decide el widget: una serie necesita ancho; una métrica, no. */
.widget--mediano { grid-column: span 1; }
@media (min-width: 900px) {
    .widget--mediano { grid-column: span 2; }
    .widget--grande { grid-column: 1 / -1; }
}

.widget {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.widget-head { display: flex; align-items: center; gap: 10px; }
.widget-ico {
    width: 34px; height: 34px;
    border-radius: 9px;
    display: grid; place-items: center;
    background: var(--violet-bg);
    color: var(--violet-fg);
    flex: 0 0 auto;
}
.widget-titulo { display: flex; flex-direction: column; min-width: 0; }
.widget-nombre {
    font-weight: 600; font-size: .92rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.widget-grupo {
    color: var(--muted);
    font-size: .68rem; letter-spacing: .05em; text-transform: uppercase;
}
.widget-enlace { margin-left: auto; color: var(--muted); display: inline-flex; }
.widget-enlace:hover { color: var(--primary); }

.widget-cuerpo { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.widget-cifra { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.widget-valor { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.widget-valor-sufijo { color: var(--muted); font-size: .95rem; }
.widget-variacion { font-size: .8rem; font-weight: 600; }
.widget-variacion.sube { color: var(--green); }
.widget-variacion.baja { color: var(--danger); }
.widget-detalle { color: var(--muted); font-size: .84rem; margin: 0; }
.widget-detalle strong { color: var(--text); }
.widget-detalle .muted { margin-left: 4px; }
.widget-nota { color: var(--muted); font-size: .8rem; font-style: italic; margin: 0; }
.widget-vacio { color: var(--muted); font-size: .86rem; margin: 0; }

/* Widget de lista */
.widget-lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.widget-fila {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 0;
    border-top: 1px solid var(--border);
    font-size: .88rem;
}
.widget-fila:first-child { border-top: 0; }
.widget-fila-estado { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--slate); }
.widget-fila-estado.estado-ok { background: var(--green); }
.widget-fila-estado.estado-aviso { background: var(--amber); }
.widget-fila-estado.estado-alerta { background: var(--danger); }
.widget-fila-texto { display: flex; flex-direction: column; min-width: 0; }
.widget-fila-sub { color: var(--muted); font-size: .78rem; }
.widget-fila-valor { margin-left: auto; font-weight: 600; white-space: nowrap; }

/* Widget de serie: barras proporcionales, sin librerías */
.widget-serie {
    display: flex; align-items: flex-end; gap: 6px;
    height: 140px;
    padding-top: 8px;
    overflow-x: auto;
}
.serie-col { flex: 1 1 0; min-width: 28px; display: flex; flex-direction: column; align-items: center; height: 100%; }
.serie-barra {
    width: 100%;
    min-height: 2px;
    margin-top: auto;
    background: linear-gradient(180deg, var(--primary), #8b84ff);
    border-radius: 5px 5px 0 0;
}
.serie-etiqueta { color: var(--muted); font-size: .68rem; padding-top: 6px; white-space: nowrap; }

/* Selector de widgets (modal «Personalizar mi panel») */
.selector-titulo {
    font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    color: var(--muted);
    margin: 18px 0 8px;
}
.selector-elegidos { margin-top: 6px; }
.selector-orden { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.selector-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    font-size: .88rem;
}
.selector-ico { color: var(--violet-fg); display: inline-flex; flex: 0 0 auto; }
.selector-nombre { font-weight: 600; }
.selector-acciones { margin-left: auto; display: flex; gap: 4px; }

.selector-grupo { display: flex; flex-direction: column; gap: 6px; }
.selector-opcion {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
}
.selector-opcion:hover { border-color: var(--primary); }
.selector-opcion.elegida { border-color: var(--primary); background: var(--violet-bg); }
.selector-opcion input { margin-top: 3px; flex: 0 0 auto; }
.selector-opcion-cuerpo { display: flex; flex-direction: column; gap: 2px; font-size: .88rem; min-width: 0; }
/* Terminal compartido de fichajes: superficie limpia, táctil y sin navegación del ERP. */
.terminal-fichajes-shell { min-height: 100vh; padding: 1rem; background: var(--surface-subtle, #f4f6f8); }
.terminal-fichajes-shell .btn { min-height: 3rem; }
.terminal-fichajes-shell .input { min-height: 3rem; font-size: 1.1rem; }

/* ── Reparto de jornada por día de la semana (ADR-0052) ── */
.reparto-semanal__dias {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr));
  gap: .5rem;
}
.reparto-semanal__dia { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; }
.reparto-semanal__total { display: flex; align-items: baseline; gap: .5rem; margin-top: .75rem; }
.reparto-semanal__atajos { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
