/*
 * Capa de modernización visual (no funcional)
 * Mantiene contratos y estructura legacy; solo mejora presentación/usabilidad.
 */

:root {
    --ui-bg: #f5f7fb;
    --ui-surface: #ffffff;
    --ui-surface-soft: #f8fafc;
    --ui-border: #d6dbe6;
    --ui-text: #1f2937;
    --ui-text-soft: #5b6472;
    --ui-primary: #2f4fa3;
    --ui-primary-hover: #233e86;
    --ui-success: #127944;
    --ui-danger: #b42318;
    --ui-radius: 8px;
    --ui-shadow: 0 2px 10px rgba(16, 24, 40, 0.08);
}

html,
body {
    background: var(--ui-bg);
    color: var(--ui-text);
}

body {
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    line-height: 1.4;
}

* {
    box-sizing: border-box;
}

#wrapper {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

@media (min-width: 1025px) {
    #wrapper {
        display: grid;
        grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
        grid-template-areas:
            "sidebar content"
            "footer footer";
        column-gap: 18px;
        padding: 0 10px 12px;
    }

    #wrapper > nav {
        grid-area: sidebar;
        float: none;
        width: auto;
        margin: 16px 0;
    }

    #wrapper > #vista {
        grid-area: content;
        float: none;
        width: auto;
        margin: 16px 0;
    }

    #wrapper > footer {
        grid-area: footer;
    }
}

#wrapper > footer {
    margin: 8px 10px 4px;
    padding: 6px 10px 2px;
    border-top: 1px solid #dbe3f1;
}

.app-footer-text {
    margin: 0;
    text-align: center;
    font-size: 12px;
    line-height: 1.4;
    color: #667085;
}

.topmenu {
    background: linear-gradient(90deg, #0f172a 0%, #1e293b 100%);
    border-bottom: 1px solid #0b1222;
    height: auto;
    min-height: 34px;
    padding: 6px 10px;
    box-sizing: border-box;
}

.topmenu .left,
.topmenu .right {
    margin-top: 2px;
}

.topmenu .right {
    font-size: 13px;
    color: #d7deee;
}

.topmenu .right a {
    color: #ffffff;
}

.topmenu .right a:hover {
    color: #c7d2fe;
    text-decoration: none;
}

.topmenu h3 {
    font-size: 18px;
    line-height: 22px;
    margin: 0;
    letter-spacing: 0.3px;
}

nav {
    background: var(--ui-surface);
    border-right: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    box-shadow: var(--ui-shadow);
    margin: 16px 10px 16px 10px;
    padding: 14px 12px;
    box-sizing: border-box;
}

nav h4 {
    color: #0f172a;
    font-size: 20px;
    margin-bottom: 8px;
}

nav p {
    color: #344054;
    margin: 6px 0 4px 0;
}

nav hr {
    border-top: 1px solid #e5e9f2;
    margin: 10px 0;
}

a {
    color: var(--ui-primary);
}

a:hover {
    color: var(--ui-primary-hover);
}

a,
button,
input[type="submit"],
.button {
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

#vista {
    margin-top: 16px;
    background: var(--ui-surface);
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    box-shadow: var(--ui-shadow);
    min-height: 420px;
    padding: 16px 18px;
    box-sizing: border-box;
}

.box_center {
    background: var(--ui-surface);
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    box-shadow: var(--ui-shadow);
    margin: 120px auto;
    padding: 18px;
}

.box_center h1 {
    font-size: 34px;
    line-height: 40px;
    margin-bottom: 8px;
    color: #0f172a;
}

.box_center form {
    margin-top: 10px;
}

.box_center label {
    display: inline-block;
    margin: 6px 0 3px;
    color: #334155;
    font-weight: 600;
}

.box_center input[type="text"],
.box_center input[type="password"] {
    width: 100%;
    max-width: 100%;
    margin-bottom: 6px;
}

.box_center input[type="submit"] {
    width: auto;
    min-width: 120px;
    margin-top: 8px;
}

input,
select,
textarea {
    border: 1px solid var(--ui-border);
    border-radius: 6px;
    background: #fff;
    color: var(--ui-text);
    padding: 6px 8px;
    box-sizing: border-box;
}

input,
select,
textarea,
input[type="submit"],
button,
.button {
    min-height: 34px;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(47, 79, 163, 0.18);
    border-color: var(--ui-primary);
}

input[type="submit"],
button,
.button {
    background: var(--ui-primary);
    color: #fff;
    border: 1px solid var(--ui-primary);
    border-radius: 6px;
    cursor: pointer;
    padding: 7px 12px;
}

input[type="submit"]:hover,
button:hover,
.button:hover {
    background: var(--ui-primary-hover);
    border-color: var(--ui-primary-hover);
    color: #fff;
}

label {
    color: #334155;
    font-weight: 600;
}

table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}

th,
td {
    padding: 6px 8px;
}

th {
    background: #e8eefc;
    color: #1d2a4a;
    border-bottom: 1px solid #cfd9f2;
}

tr:nth-child(odd) {
    background: #f8fafc;
}

tr:nth-child(even) {
    background: #ffffff;
}

nav .sangria {
    display: block;
    margin: 2px 0;
    padding: 3px 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    text-decoration: none;
    transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}

nav .sangria + br {
    display: none;
}

nav .sangria:hover {
    text-decoration: none;
    background: #e8eefc;
    border-color: #d6def6;
    color: #1d2a4a;
    transform: translateX(2px);
}

nav .sangria:focus-visible,
nav .sangria[aria-current="page"] {
    background: #e8eefc;
    border-color: #c7d5f8;
    color: #1d2a4a;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid #1d4ed8;
    outline-offset: 1px;
}

.error {
    border-color: var(--ui-danger) !important;
    box-shadow: 0 0 0 2px rgba(180, 35, 24, 0.12);
}

@media (max-width: 1200px) {
    nav {
        width: 250px;
    }
}

@media (max-width: 1024px) {
    nav {
        float: none;
        width: auto;
        margin: 12px;
    }

    #vista {
        float: none;
        margin: 0 12px 12px 12px;
    }
}

/* =========================================================
   Fase C.1 - Informes (com/comp/ven/pedidos)
   ========================================================= */

#vista p > b {
    color: #0f172a;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: 0.2px;
}

#vista p {
    margin: 0 0 10px;
}

#vista .report-filter-panel {
    width: fit-content;
    max-width: 100%;
    margin: 0;
}

#vista form[action$=".php"] > table,
#vista .report-filter-table {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 1px 6px rgba(16, 24, 40, 0.05);
    width: auto;
    min-width: 360px;
}

#vista form[action$=".php"] > table td,
#vista .report-filter-table td {
    padding: 8px 10px;
    vertical-align: middle;
}

#vista form[action$=".php"] > table td:first-child,
#vista .report-filter-table td:first-child {
    color: #334155;
    font-weight: 400;
    min-width: 95px;
}

#vista form[action$=".php"] > table td:first-child[style*="font-weight:bold"],
#vista .report-filter-table td:first-child[style*="font-weight:bold"] {
    font-weight: 400 !important;
}

#vista form[action$=".php"] > table td:first-child b,
#vista form[action$=".php"] > table td:first-child strong,
#vista .report-filter-table td:first-child b,
#vista .report-filter-table td:first-child strong {
    font-weight: 400;
}

#vista form[action$=".php"] select,
#vista form[action$=".php"] input[type="text"],
#vista .report-filter-table select,
#vista .report-filter-table input[type="text"] {
    width: 250px;
    max-width: 100%;
}

#vista form[action$=".php"] input[type="button"],
#vista .report-filter-table input[type="button"] {
    min-width: 128px;
    font-weight: 600;
}

#vista .report-date-field,
#vista .legacy-date-field,
#vista .kpi-period-input,
#vista input.hasDatepicker {
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='%23334155' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M16 3v4M8 3v4M3 10h18'/%3E%3C/g%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px 12px;
}

#vista .report-filter-actions {
    display: flex;
    justify-content: center;
    margin: 18px 0 4px;
    width: 100%;
}

#vista .report-filter-actions input[type="button"] {
    min-width: 136px;
    padding: 7px 18px;
    background: var(--ui-primary);
    border-color: var(--ui-primary);
    color: #fff;
}

#vista .report-filter-actions input[type="button"]:hover {
    background: var(--ui-primary-hover);
    border-color: var(--ui-primary-hover);
}

#vista .report-mail-title {
    margin: 4px 0 12px;
}

#vista .report-mail-panel {
    width: 100%;
    max-width: 1060px;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
}

#vista .report-mail-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 1px 6px rgba(16, 24, 40, 0.05);
    overflow: hidden;
}

#vista .report-mail-table th,
#vista .report-mail-table td {
    padding: 10px 14px;
    vertical-align: middle;
    border-bottom: 1px solid #dbe4f2;
}

#vista .report-mail-table th {
    width: 190px;
    text-align: left;
    white-space: nowrap;
    color: #334155;
    border-right: 1px solid #edf1f7;
    font-weight: 700;
}

#vista .report-mail-table tr:nth-child(odd) th,
#vista .report-mail-table tr:nth-child(odd) td {
    background: #f8fafc;
}

#vista .report-mail-table tr:nth-child(even) th,
#vista .report-mail-table tr:nth-child(even) td {
    background: #f1f5f9;
}

#vista .report-mail-table td {
    color: #1f2937;
}

#vista .report-mail-table tr:last-child th,
#vista .report-mail-table tr:last-child td {
    border-bottom: 0;
}

#vista .report-mail-table input[type="text"],
#vista .report-mail-table .campo_mail {
    width: 100% !important;
    max-width: 560px !important;
}

#vista .report-mail-table .report-mail-section {
    background: #e8eefc !important;
    color: #1d2a4a;
    font-weight: 700;
}

#vista .report-mail-actions {
    display: flex;
    justify-content: center;
    margin-top: 12px;
    padding: 4px 12px 0;
    background: transparent;
    border-top: 0;
}

#vista .report-mail-actions input[type="button"] {
    min-width: 140px;
    padding: 8px 24px;
    background: var(--ui-primary);
    border-color: var(--ui-primary);
    color: #fff;
    font-weight: 600;
}

#vista .report-mail-actions input[type="button"]:hover {
    background: var(--ui-primary-hover);
    border-color: var(--ui-primary-hover);
}

#vista #mensaje,
#vista #mensaje2 {
    margin: 0 0 14px;
}

#vista #mensaje:empty,
#vista #mensaje2:empty {
    display: none;
}

#vista .mail-status {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid transparent;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.07);
    text-align: left;
}

#vista .mail-status__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    align-self: center;
}

#vista .mail-status__content {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
}

#vista .mail-status__title {
    display: block;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.15;
}

#vista .mail-status__meta {
    display: block;
    margin-top: 4px;
    font-size: 13px;
    line-height: 1.45;
    word-break: break-word;
}

#vista .mail-status.is-success {
    color: #166534;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    border-color: #bbf7d0;
}

#vista .mail-status.is-success .mail-status__icon {
    color: #15803d;
    background: #dcfce7;
}

#vista .mail-status.is-error {
    color: #991b1b;
    background: linear-gradient(135deg, #fef2f2 0%, #fff1f2 100%);
    border-color: #fecaca;
}

#vista .mail-status.is-error .mail-status__icon {
    color: #b91c1c;
    background: #fee2e2;
}

#vista form[action$=".php"] > table tr:last-child td,
#vista .report-filter-table tr:last-child td {
    padding-top: 12px;
}

#vista a[onclick*="imprimirFrame"],
#vista a[onclick*="volver_informe"],
#vista a[onclick*="mail_informes_intermedio"] {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 4px 10px 6px 0;
    padding: 5px 9px;
    min-height: 34px;
    line-height: 1;
    border: 1px solid #dbe3f2;
    border-radius: 6px;
    background: #f8fbff;
}

#vista a[onclick*="imprimirFrame"] img,
#vista a[onclick*="volver_informe"] img,
#vista a[onclick*="mail_informes_intermedio"] img {
    display: block;
    width: 18px;
    height: 18px;
    object-fit: contain;
}

#vista a.minutes-back-link[onclick*="volver_informe"] {
    position: relative;
    top: 1px;
}

#vista a[onclick*="imprimirFrame"]:hover,
#vista a[onclick*="volver_informe"]:hover,
#vista a[onclick*="mail_informes_intermedio"]:hover {
    background: #edf2ff;
    border-color: #cbd7f1;
    text-decoration: none;
}

#vista iframe[id^="imprimir"] {
    width: 100% !important;
    max-width: 980px;
    min-height: 760px;
    border: 1px solid #d6dbe6;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(16, 24, 40, 0.08);
}

#vista .minutes-toolbar-actions.minutes-back-actions {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
}

#vista .minutes-toolbar-actions.minutes-back-actions + .minutes-toolbar-actions.minutes-back-actions {
    margin-top: 2px;
}

#vista .minutes-toolbar-actions.minutes-back-actions + iframe[id^="imprimir"] {
    margin-top: 8px;
}

#vista .excel-download-notice {
    margin-top: 10px;
    max-width: 760px;
    padding: 10px 12px;
    border: 1px solid #b7e4c7;
    border-radius: 8px;
    background: #ecfdf3;
    color: #166534;
    font-weight: 600;
}

#vista .excel-download-actions {
    margin: 6px 0 10px;
    gap: 10px;
}

#vista .excel-download-actions .toolbar-btn {
    background: #f8fbff;
    border-color: #d8e0f0;
    color: #2f4fa3;
    padding: 6px 10px;
    min-height: 34px;
}

#vista .excel-download-actions .toolbar-btn:hover {
    background: #edf2ff;
    border-color: #c8d5f0;
}

#vista .excel-download-actions .toolbar-btn img {
    display: inline-block;
    width: 18px;
    height: 18px;
    object-fit: contain;
}

#vista .excel-download-frame {
    position: absolute;
    width: 1px;
    height: 1px;
    border: 0;
    margin: 0;
    padding: 0;
    opacity: 0;
    pointer-events: none;
}

@media (max-width: 1024px) {
    #vista .report-filter-panel {
        width: 100%;
    }

    #vista .report-mail-panel {
        max-width: 100%;
    }

    #vista .report-mail-table th,
    #vista .report-mail-table td {
        display: block;
        width: 100%;
    }

    #vista .report-mail-table th {
        border-bottom: 0;
        padding-bottom: 4px;
    }

    #vista .report-mail-table td {
        padding-top: 0;
    }

    #vista form[action$=".php"] > table,
    #vista .report-filter-table {
        min-width: 0;
        width: 100%;
    }

    #vista form[action$=".php"] select,
    #vista form[action$=".php"] input[type="text"],
    #vista .report-filter-table select,
    #vista .report-filter-table input[type="text"] {
        width: 100%;
    }

    #vista iframe[id^="imprimir"] {
        min-height: 620px;
    }
}

/* =========================================================
   Fase B.1 - Listados y formularios operativos
   ========================================================= */

article {
    width: auto;
    max-width: 1120px;
}

article > h4 {
    color: #0f172a;
    font-size: 22px;
    margin-bottom: 4px;
}

#vista usuario > h4 {
    margin-bottom: 16px;
}

#vista article {
    padding: 2px 4px;
    overflow-x: hidden;
    width: auto !important;
    max-width: none !important;
}

#vista article > hr {
    margin-left: 12px;
    margin-right: 12px;
}

article > hr {
    border-top: 1px solid #e5e9f2;
    margin: 10px 0;
}

.ancha {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    height: auto;
    min-height: 30px;
}

.ancha .left,
.ancha .right {
    float: none;
    color: var(--ui-text-soft);
}

.ancha .left > a,
.ancha .right > a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    border-radius: 6px;
}

.ancha .left > a:hover,
.ancha .right > a:hover {
    background: #edf2ff;
    text-decoration: none;
}

/* Minutes list toolbar / pagination */
.minutes-toolbar {
    gap: 10px;
}

.minutes-toolbar-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.minutes-toolbar-actions .toolbar-btn,
a.toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border: 1px solid #d8e0f0;
    border-radius: 6px;
    background: #f8fbff;
}

.minutes-toolbar-actions .toolbar-btn span,
a.toolbar-btn span {
    display: inline-flex;
    align-items: center;
    font-size: 14px;
    line-height: 1;
    font-weight: 500;
}

a.toolbar-btn img {
    display: block;
    flex: 0 0 auto;
}

.minutes-toolbar-actions .toolbar-btn:hover,
a.toolbar-btn:hover {
    background: #edf2ff;
    border-color: #c8d5f0;
    text-decoration: none;
}

.minutes-toolbar-pagination {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.minutes-toolbar-pagination .page-label {
    color: #475467;
    font-weight: 600;
    font-size: 14px;
    line-height: 1.2;
    margin: 0 4px;
}

.minutes-toolbar-pagination .page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid #d8e0f0;
    border-radius: 6px;
    background: #f8fbff;
    padding: 0;
}

.minutes-toolbar-pagination .page-btn:hover {
    background: #edf2ff;
    border-color: #c8d5f0;
}

.minutes-toolbar-bottom {
    justify-content: flex-end;
}

.list-page > hr {
    display: none;
}

.list-page > h4 {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: 0.2px;
    color: #0f172a;
    margin-top: 0;
    margin-bottom: 14px;
}

.list-page .minutes-toolbar {
    margin: 14px 0 16px;
}

.list-page #lista {
    margin: 12px 0 16px;
}

#lista {
    border: 1px solid #d9e2f2;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}

#lista th,
#lista td {
    padding: 10px 12px;
    vertical-align: middle;
    border-bottom: 1px solid #e9eef7;
}

#lista th {
    background: #5159ad;
    color: #ffffff;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.1px;
    border-bottom-color: #4a51a0;
}

#lista tr:last-child td {
    border-bottom: 0;
}

#lista tr {
    background: transparent;
}

#lista tr.fila:nth-of-type(odd) {
    background: #ffffff;
}

#lista tr.fila:nth-of-type(even) {
    background: #f6f8fc;
}

#lista tr.fila td {
    color: #1f2937;
}

#lista tr.fila:hover {
    background: #eaf1ff !important;
}

#lista td > a {
    color: #163b8a;
    font-weight: 600;
}

#lista td > a:hover {
    color: #122f6e;
}

#lista td[style*="text-align:right"] {
    font-variant-numeric: tabular-nums;
}

/* Usuarios: fijar rejilla de columnas para alinear cabeceras/filas */
#lista.usuarios-table {
    table-layout: fixed;
}

#lista.usuarios-table th:nth-child(1),
#lista.usuarios-table td:nth-child(1) {
    width: 18%;
}

#lista.usuarios-table th:nth-child(2),
#lista.usuarios-table td:nth-child(2) {
    width: 9%;
    text-align: center;
}

#lista.usuarios-table th:nth-child(3),
#lista.usuarios-table td:nth-child(3) {
    width: 9%;
    text-align: center;
}

#lista.usuarios-table th:nth-child(4),
#lista.usuarios-table td:nth-child(4) {
    width: 24%;
}

#lista.usuarios-table th:nth-child(5),
#lista.usuarios-table td:nth-child(5) {
    width: 40%;
}

#lista.usuarios-table tr.buscador th:nth-child(2) input,
#lista.usuarios-table tr.buscador th:nth-child(3) input {
    text-align: center;
}

/* Clients / Proveidors / Articles: rejilla fija para mantener alineación */
#lista.clients-table,
#lista.proveidors-table,
#lista.articles-table,
#lista.certificados-table,
#lista.condiciones-table {
    table-layout: fixed;
}

#lista.clients-table th,
#lista.clients-table td {
    padding-top: 7px;
    padding-bottom: 7px;
    line-height: 1.2;
}

#lista.clients-table td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#lista.clients-table td > a {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#lista.clients-table th:nth-child(1),
#lista.clients-table td:nth-child(1) {
    width: 30%;
}

#lista.clients-table th:nth-child(2),
#lista.clients-table td:nth-child(2) {
    width: 14%;
}

#lista.clients-table th:nth-child(3),
#lista.clients-table td:nth-child(3) {
    width: 20%;
}

#lista.clients-table th:nth-child(4),
#lista.clients-table td:nth-child(4) {
    width: 20%;
}

#lista.clients-table th:nth-child(5),
#lista.clients-table td:nth-child(5) {
    width: 16%;
}

#lista.proveidors-table th:nth-child(1),
#lista.proveidors-table td:nth-child(1) {
    width: 24%;
}

#lista.proveidors-table th:nth-child(2),
#lista.proveidors-table td:nth-child(2) {
    width: 13%;
}

#lista.proveidors-table th:nth-child(3),
#lista.proveidors-table td:nth-child(3) {
    width: 17%;
}

#lista.proveidors-table th:nth-child(4),
#lista.proveidors-table td:nth-child(4) {
    width: 17%;
}

#lista.proveidors-table th:nth-child(5),
#lista.proveidors-table td:nth-child(5) {
    width: 15%;
}

#lista.proveidors-table th:nth-child(6),
#lista.proveidors-table td:nth-child(6) {
    width: 14%;
}

#lista.articles-table th:nth-child(1),
#lista.articles-table td:nth-child(1) {
    width: 45%;
}

#lista.articles-table th:nth-child(2),
#lista.articles-table td:nth-child(2) {
    width: 55%;
}

#lista.certificados-table th:nth-child(1),
#lista.certificados-table td:nth-child(1),
#lista.condiciones-table th:nth-child(1),
#lista.condiciones-table td:nth-child(1) {
    width: 100%;
}

#lista tr.buscador th {
    background: #eef2f8;
}

#lista tr.buscador {
    display: none;
}

#lista tr.buscador.is-open {
    display: table-row;
}

#lista tr.buscador input,
#lista tr.buscador select {
    width: 100%;
    min-width: 68px;
    font-size: 12px;
    padding: 5px 7px;
}

#lista tr.buscador input.minutes-search-id {
    width: 78px;
    min-width: 78px;
}

#lista tr.buscador input.minutes-search-delivery-date {
    width: 96px;
    min-width: 96px;
}

#form > table:first-of-type {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 1px 6px rgba(16, 24, 40, 0.05);
}

#form > table:first-of-type th {
    width: 190px;
    text-align: left;
    vertical-align: middle;
    color: #334155;
    background: #f8fafc;
    border-right: 1px solid #edf1f7;
    border-bottom: 0;
    padding: 10px 14px;
    line-height: 1.35;
}

#form > table:first-of-type td {
    padding: 8px 12px;
}

#form > table:first-of-type tr:nth-child(odd) th,
#form > table:first-of-type tr:nth-child(odd) td {
    background: #f8fafc;
}

#form > table:first-of-type tr:nth-child(even) th,
#form > table:first-of-type tr:nth-child(even) td {
    background: #f1f5f9;
}

#form > table:first-of-type tr + tr th,
#form > table:first-of-type tr + tr td {
    border-top: 1px solid #dbe4f2;
}

/* Client > modificar: tabla principal más proporcionada */
#form > table.client-main-table {
    width: 100%;
    max-width: none;
    table-layout: auto;
}

#form > table.client-main-table th {
    border-bottom: 0;
}

#form > table.client-main-table tr + tr th,
#form > table.client-main-table tr + tr td {
    border-top: 1px solid #dbe4f2;
}

/* Proveïdors > inserir/modificar: bordes consistentes con client */
#form > table.provider-main-table {
    width: 100%;
    max-width: none;
    table-layout: auto;
}

#form > table.provider-main-table th {
    border-bottom: 0;
}

#form > table.provider-main-table tr + tr th,
#form > table.provider-main-table tr + tr td {
    border-top: 1px solid #dbe4f2;
}

#form .campos[type="text"],
#form .campos[type="number"],
#form .campos[type="password"],
#form textarea,
#form select {
    width: 100%;
    max-width: 360px;
}

#form textarea[name="cli_obs1"],
#form textarea[name="cli_obs2"] {
    min-height: 110px;
    resize: vertical;
}

#form textarea[name="pro_obs3"] {
    min-height: 110px;
    resize: vertical;
}

#form select:not([multiple]):not([size]),
#vista select:not([multiple]):not([size]) {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23334155' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px 8px;
}

#form select:not([multiple]):not([size])::-ms-expand,
#vista select:not([multiple]):not([size])::-ms-expand {
    display: none;
}

/* Minutas > editar ficha: selector €/% ajustado al contenido */
#form select#min_tipocomision {
    width: auto !important;
    min-width: 64px;
    max-width: 84px;
    display: inline-block;
    padding-right: 26px;
    background-position: right 8px center;
}

#form .button {
    display: inline-block;
    margin: 4px 6px 4px 0;
    min-width: 120px;
    line-height: 18px;
    font-weight: 600;
    text-align: center;
}

#form .minutes-form-actions {
    clear: both;
    margin: 12px 0 4px;
    padding: 8px 0;
    width: min(1040px, 100%);
    margin-left: auto;
    margin-right: auto;
    padding-left: 196px;
    text-align: left;
}

#form .minutes-form-actions .button {
    margin: 4px 6px 4px 0;
}

article > a[onclick] {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 6px;
}

article > a[onclick]:hover {
    background: #edf2ff;
    text-decoration: none;
}

.table-insert-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.table-insert-link:hover {
    text-decoration: none;
}

.table-insert-link.toolbar-btn {
    margin: 2px 0;
}

.table-row-action.toolbar-btn {
    justify-content: center;
    min-width: 82px;
    padding: 4px 8px;
}

#vista article .minutes-back-link {
    margin-top: 16px;
}

#vista .minutes-back-actions .minutes-back-link {
    margin-top: 0;
}

#vista .minutes-back-actions {
    margin: 6px 0 10px;
}

#vista article > h4 + .minutes-back-actions {
    margin-top: 10px;
}

#vista article .minutes-back-actions {
    margin: 4px 0 20px;
}

#vista .minutes-back-actions .toolbar-btn img,
#vista article .minutes-back-link img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

/* Fitxa proveïdor > enviament a client */
#vista article.provider-ficha-mail-page {
    width: min(1080px, 100%);
}

#vista article.provider-ficha-mail-page > h4 {
    margin-bottom: 14px;
}

#vista article.provider-ficha-mail-page .minutes-back-actions {
    margin-top: 0;
    margin-bottom: 16px;
}

#vista article.provider-ficha-mail-page .provider-ficha-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

#vista article.provider-ficha-mail-page .provider-ficha-controls label {
    margin: 0;
    font-weight: 600;
    color: #334155;
}

#vista article.provider-ficha-mail-page .provider-ficha-controls select {
    width: min(500px, 100%);
    max-width: 100%;
}

#vista article.provider-ficha-mail-page .provider-ficha-send-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    line-height: 1;
    text-decoration: none;
}

#vista article.provider-ficha-mail-page .provider-ficha-send-btn img {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

#vista article.provider-ficha-mail-page .provider-ficha-preview-card {
    width: min(760px, 100%);
    margin: 14px auto 0;
    background: #fff;
    border: 1px solid #dbe3f2;
    border-radius: 8px;
    box-shadow: 0 1px 8px rgba(16, 24, 40, 0.05);
    padding: 10px;
}

#vista article.provider-ficha-mail-page .provider-ficha-preview-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

#vista article.provider-ficha-mail-page .provider-ficha-preview-table th,
#vista article.provider-ficha-mail-page .provider-ficha-preview-table td {
    padding: 8px 10px;
    vertical-align: top;
    font-size: 14px;
    line-height: 1.35;
}

#vista article.provider-ficha-mail-page .provider-ficha-preview-table .provider-ficha-preview-title {
    text-align: center;
    font-size: 18px;
    color: #0f172a;
    background: #eef3ff;
    font-weight: 700;
    letter-spacing: 0.2px;
}

#vista article.provider-ficha-mail-page .provider-ficha-preview-table tr + tr th,
#vista article.provider-ficha-mail-page .provider-ficha-preview-table tr + tr td {
    border-top: 1px solid #c7d5f8;
}

#vista article.provider-ficha-mail-page .provider-ficha-preview-table tr th,
#vista article.provider-ficha-mail-page .provider-ficha-preview-table tr td {
    border-bottom: 0;
}

#vista article.provider-ficha-mail-page .provider-ficha-preview-table tr:last-child th,
#vista article.provider-ficha-mail-page .provider-ficha-preview-table tr:last-child td {
    border-bottom: 1px solid #c7d5f8;
}

#vista article.provider-ficha-mail-page .provider-ficha-preview-table tr th {
    width: 34%;
    color: #1e293b;
    background: #f8fafc;
    font-weight: 700;
    border-right: 1px solid #d6def6;
}

#vista article .client-related-section-title {
    width: min(1040px, 100%);
    margin: 18px auto 8px;
    padding: 0 2px;
    color: #0f172a;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
}

#vista article .related-table-actions {
    width: min(1040px, 100%);
    margin: 8px auto 14px;
    text-align: center;
}

.tabla_mails,
.tabla_direcciones,
.tabla_proveedores_riesgo {
    float: none;
    width: min(1040px, 100%);
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 1px 6px rgba(16, 24, 40, 0.05);
    margin: 10px auto 0;
}

.tabla_mails th,
.tabla_direcciones th,
.tabla_proveedores_riesgo th,
.tabla_mails td,
.tabla_direcciones td,
.tabla_proveedores_riesgo td {
    padding: 7px 9px;
    vertical-align: middle;
}

#vista article .tabla_mails tr th:last-child,
#vista article .tabla_direcciones tr th:last-child,
#vista article .tabla_proveedores_riesgo tr th:last-child,
#vista article .tabla_mails tr td:last-child,
#vista article .tabla_direcciones tr td:last-child,
#vista article .tabla_proveedores_riesgo tr td:last-child {
    text-align: center;
}

#vista article .tabla_mails tr:last-child td[colspan],
#vista article .tabla_direcciones tr:last-child td[colspan],
#vista article .tabla_proveedores_riesgo tr:last-child td[colspan] {
    text-align: center;
}

.tabla_mails input[type="button"],
.tabla_direcciones input[type="button"],
.tabla_proveedores_riesgo input[type="button"] {
    width: auto;
    min-width: 88px;
}

.activacion {
    color: #fff;
    font-weight: 600;
    text-align: center;
}

#lista .status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 74px;
    padding: 3px 10px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1.2;
    font-weight: 700;
}

#lista .status-pill-active {
    color: #166534;
    background: #dcfce7;
    border-color: #86efac;
}

#lista .status-pill-inactive {
    color: #991b1b;
    background: #fee2e2;
    border-color: #fecaca;
}

#form .activation-cell {
    text-align: left;
    color: #1e293b;
    transition: background-color 120ms ease;
}

#form .activation-cell.status-active {
    color: #1e293b;
}

#form .activation-cell.status-inactive {
    color: #1e293b;
}

#form .activation-cell .campos {
    width: 100%;
    max-width: 360px;
    margin: 0;
    background-color: #fff;
}

#form .activation-cell.status-active .campos {
    background: #dcfce7;
    border-color: #86efac;
    color: #166534;
}

#form .activation-cell.status-inactive .campos {
    background: #fee2e2;
    border-color: #fecaca;
    color: #991b1b;
}

#form .activation-cell .campos option[value="1"] {
    color: #166534;
    background: #dcfce7;
    font-weight: 600;
}

#form .activation-cell .campos option[value="0"] {
    color: #991b1b;
    background: #fee2e2;
    font-weight: 600;
}

#vista article .tabla_mails td.activation-cell {
    text-align: center;
    font-weight: 600;
    transition: background-color 120ms ease;
}

#vista article .tabla_mails td.activation-cell.status-active {
    background: #dcfce7;
    color: #166534;
}

#vista article .tabla_mails td.activation-cell.status-inactive {
    background: #fee2e2;
    color: #991b1b;
}

/* Banda superior de acciones (minutas > editar ficha) */
#vista article table.minutes-mail-actions {
    display: table;
    margin: 4px 12px 14px !important;
    width: calc(100% - 24px) !important;
    max-width: calc(100% - 24px) !important;
    min-width: 0 !important;
    box-sizing: border-box;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
    padding: 0 !important;
    border: 1px solid #dbe3f2;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 8px rgba(16, 24, 40, 0.06);
}

#vista > article {
    width: auto !important;
    max-width: none !important;
}

#vista article table.minutes-mail-actions th,
#vista article table.minutes-mail-actions td {
    padding: 9px 12px;
    border-bottom: 1px solid #e8edf7;
}

#vista article table.minutes-mail-actions tr:first-child th:first-child {
    border-top-left-radius: 7px;
}

#vista article table.minutes-mail-actions tr:first-child th:last-child {
    border-top-right-radius: 7px;
}

#vista article table.minutes-mail-actions tr:last-child th:first-child {
    border-bottom-left-radius: 7px;
}

#vista article table.minutes-mail-actions tr:last-child td:last-child {
    border-bottom-right-radius: 7px;
}

#vista article table.minutes-mail-actions tr:last-child th,
#vista article table.minutes-mail-actions tr:last-child td {
    border-bottom: 0;
}

#vista article table.minutes-mail-actions th {
    background: #4f57a8;
    color: #fff;
}

#vista article table.minutes-mail-actions th[style*="background:white"] {
    background: #eef2ff !important;
    color: #1e293b !important;
}

#vista article table.minutes-mail-actions td a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
    border-radius: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    margin: 0 3px;
    padding: 0;
}

#vista article table.minutes-mail-actions td a:hover {
    background: transparent;
    border-color: transparent;
}

/* Minutas > inserir/modificar: preservar paridad estructural y visibilidad */
#vista article.minutes-edit-page #form > table.minutes-main-table {
    width: 100%;
    max-width: none;
    table-layout: auto;
}

#vista article.minutes-edit-page #form > table.minutes-main-table th {
    width: 190px;
}

#vista article.minutes-edit-page #form > table.minutes-main-table td {
    width: auto;
}

#vista article.minutes-edit-page #form .campos[type="text"],
#vista article.minutes-edit-page #form .campos[type="number"],
#vista article.minutes-edit-page #form .campos[type="password"],
#vista article.minutes-edit-page #form textarea,
#vista article.minutes-edit-page #form select {
    max-width: none;
}

#vista article.minutes-edit-page #form .minutes-form-actions {
    width: 100%;
    padding-left: 0;
    text-align: center;
}

#vista article.minutes-edit-page #form input[name="min_id"][readonly] {
    width: auto !important;
    max-width: none !important;
    padding: 0;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none;
    color: #334155;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: default;
}

#vista article.minutes-edit-page #form input[name="min_id"][readonly]:focus {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none;
}

#vista article.minutes-edit-page #form input[name="min_cantidad"] {
    display: inline-block;
    vertical-align: middle;
    width: 170px !important;
    max-width: 170px !important;
}

#vista article.minutes-edit-page #form input[name="min_cantidad"] + * {
    display: inline-block;
    vertical-align: middle;
    white-space: nowrap;
    margin-left: 6px;
}

#vista article.minutes-edit-page #form .minutes-inline-unit {
    display: inline-block;
    vertical-align: middle;
    white-space: nowrap;
    margin-left: 6px;
}

#vista article.minutes-edit-page #form input[name="min_comision"],
#vista article.minutes-edit-page #form #min_tipocomision {
    display: inline-block;
    vertical-align: middle;
}

#vista article.minutes-edit-page #form input[name="min_comision"] {
    width: 170px !important;
    max-width: 170px !important;
}

#vista article.minutes-edit-page #form #min_tipocomision {
    margin-left: 6px;
}

#vista article.minutes-edit-page #form .minutes-inline-comision {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    vertical-align: middle;
    white-space: nowrap;
}

#vista article.minutes-edit-page #form .minutes-inline-comision #min_tipocomision {
    margin-left: 0;
}

#vista article.minutes-edit-page #form textarea[name="min_observaciones"],
#vista article.minutes-edit-page #form textarea[name="min_observaciones2"] {
    min-height: 110px;
    resize: vertical;
}

/* Copies de seguretat */
#vista article.backup-section {
    margin: 8px 12px 16px;
    padding: 14px 16px;
    border: 1px solid #d9e1ef;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 1px 8px rgba(16, 24, 40, 0.05);
}

#vista article.backup-section .backup-header h4 {
    margin: 0;
    font-size: 31px;
    line-height: 1.2;
    color: #0f172a;
}

#vista article.backup-section .backup-header p {
    margin: 8px 0 0;
    color: #475569;
    font-size: 14px;
}

#vista article.backup-section .backup-status-card {
    margin-top: 14px;
    padding: 14px 16px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
}

#vista article.backup-section .backup-status-card h5 {
    margin: 0 0 9px;
    color: #1e293b;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

#vista article.backup-section .backup-status {
    margin: 0;
    padding: 10px 12px;
    border-radius: 6px;
    font-weight: 600;
    border: 1px solid transparent;
}

#vista article.backup-section .backup-status.is-success {
    color: #166534;
    background: #ecfdf5;
    border-color: #a7f3d0;
}

#vista article.backup-section .backup-status.is-warning {
    color: #92400e;
    background: #fffbeb;
    border-color: #fcd34d;
}

#vista article.backup-section .backup-status.is-error {
    color: #991b1b;
    background: #fef2f2;
    border-color: #fecaca;
}

#vista article.backup-section .backup-meta {
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 8px;
}

#vista article.backup-section .backup-meta li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-top: 8px;
    border-top: 1px dashed #dbe3f1;
    color: #334155;
    font-size: 13px;
}

#vista article.backup-section .backup-meta span {
    color: #64748b;
}

#vista article.backup-section .backup-meta code {
    background: #eef2ff;
    color: #1e3a8a;
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 12px;
}

#vista article.backup-section .backup-meta strong {
    color: #0f172a;
    font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}

@media (max-width: 1024px) {
    #form > table:first-of-type,
    .tabla_mails,
    .tabla_direcciones,
    .tabla_proveedores_riesgo {
        float: none;
        width: 100%;
        margin-left: 0;
    }

    #form .campos[type="text"],
    #form .campos[type="number"],
    #form .campos[type="password"],
    #form textarea,
    #form select {
        max-width: none;
    }

    #vista article.backup-section .backup-meta li {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Dashboard inicio KPI */
#vista .kpi-dashboard {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#vista .kpi-dashboard-head {
    display: grid;
    grid-template-columns: minmax(340px, 1fr) minmax(420px, 520px);
    align-items: start;
    column-gap: 22px;
    row-gap: 8px;
    margin-bottom: 6px;
}

#vista .kpi-dashboard-head-title {
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    max-width: none;
    align-self: start;
    min-height: 58px;
    padding-top: 0;
}

#vista .kpi-dashboard-head-side {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    max-width: 520px;
    width: max-content;
    justify-self: end;
    align-self: start;
}

#vista .kpi-dashboard-head-title h3 {
    margin: 0;
    color: #0f172a;
    font-size: clamp(19px, 1.6vw, 31px);
    line-height: 1.12;
    font-weight: 700;
    letter-spacing: -0.01em;
    text-transform: none !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#vista .kpi-dashboard-head-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 8px;
    border: 1px solid #cfd8ea;
    border-radius: 8px;
    background: #fff;
    flex: 0 1 auto;
    min-width: 0;
    margin-top: 0;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    width: max-content;
    box-sizing: border-box;
}

@media (min-width: 1200px) {
    #vista .kpi-dashboard-head {
        align-items: flex-start;
    }

    #vista .kpi-dashboard-head-controls {
        flex-wrap: nowrap;
        white-space: nowrap;
        gap: 7px;
        align-items: center;
    }

    #vista .kpi-dashboard-head-controls label,
    #vista .kpi-dashboard-head-controls span,
    #vista .kpi-dashboard-head-controls #kpi-period-apply {
        flex: 0 0 auto;
        align-self: center;
    }

    #vista .kpi-dashboard-head-controls label,
    #vista .kpi-dashboard-head-controls span {
        display: inline-flex;
        align-items: center;
        height: 40px;
        line-height: 40px;
    }

    #vista .kpi-dashboard-head-controls .kpi-period-input {
        flex: 0 0 132px;
        min-width: 132px;
        height: 38px;
        align-self: center;
    }

    #vista .kpi-dashboard-head-controls #kpi-period-apply {
        min-height: 38px;
        height: 38px;
        line-height: 20px;
    }
}

#vista .kpi-dashboard-head-controls label {
    font-weight: 700;
    color: #1f2937;
    margin-right: 6px;
    font-size: 13px;
}

#vista .kpi-dashboard-head-controls span {
    color: #4b5563;
    font-size: 13px;
    font-weight: 600;
}

#vista .kpi-dashboard-head-controls .kpi-period-input {
    min-width: 132px;
    flex: 0 1 132px;
    height: 38px;
    border-radius: 6px;
    border: 1px solid #c7d2e6;
    padding: 0 34px 0 10px;
    background-color: #ffffff;
    color: #0f172a;
}

#vista .kpi-dashboard-head-controls #kpi-period-apply {
    min-height: 38px;
    height: 38px;
    padding: 6px 16px;
    border-radius: 6px;
    background: #242830;
    border-color: #242830;
    font-size: 13px;
    font-weight: 700;
    transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.12s ease;
}

#vista .kpi-dashboard-head-controls #kpi-period-apply:disabled,
#vista .kpi-dashboard-head-controls #kpi-period-apply.is-loading {
    cursor: not-allowed;
    opacity: 0.75;
    transform: none;
}

#vista .kpi-dashboard-head-controls #kpi-period-apply:hover {
    background: #1b1f28;
    border-color: #1b1f28;
}

#vista .kpi-dashboard-head-controls #kpi-period-apply:active {
    transform: translateY(1px);
}

#vista .kpi-dashboard-head-controls .kpi-period-input:focus-visible,
#vista .kpi-dashboard-head-controls #kpi-period-apply:focus-visible {
    outline: 2px solid #2f4fa3;
    outline-offset: 2px;
}

#vista .kpi-dashboard-head-controls .kpi-period-input[aria-invalid="true"] {
    border-color: #d14343;
    box-shadow: 0 0 0 1px rgba(209, 67, 67, 0.18);
}

#vista .kpi-dashboard-head-message {
    min-height: 20px;
    margin: 1px 0 0;
    font-size: 13px;
    line-height: 1.3;
    color: #475569;
}

#vista .kpi-dashboard-head-message.is-info {
    color: #2f4fa3;
    font-weight: 600;
}

#vista .kpi-dashboard-head-message.is-error {
    color: #b91c1c;
    font-weight: 600;
}

.kpi-tooltip {
    pointer-events: none;
}

.kpi-tooltip .kpi-tooltip-card {
    min-width: 230px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: linear-gradient(165deg, rgba(15, 23, 42, 0.96), rgba(30, 41, 59, 0.96));
    box-shadow: 0 12px 28px rgba(2, 6, 23, 0.34);
    color: #e2e8f0;
}

.kpi-tooltip .kpi-tooltip-title {
    font-size: 12px;
    font-weight: 700;
    color: #f8fafc;
    letter-spacing: 0.01em;
}

.kpi-tooltip .kpi-tooltip-divider {
    height: 1px;
    margin: 7px 0 8px;
    background: rgba(148, 163, 184, 0.32);
}

.kpi-tooltip .kpi-tooltip-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.kpi-tooltip .kpi-tooltip-row + .kpi-tooltip-row {
    margin-top: 6px;
}

.kpi-tooltip .kpi-tooltip-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #cbd5e1;
    font-size: 12px;
    line-height: 1.3;
}

.kpi-tooltip .kpi-tooltip-swatch {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    box-shadow: 0 0 0 1px rgba(248, 250, 252, 0.16);
    flex: 0 0 auto;
}

.kpi-tooltip .kpi-tooltip-value {
    color: #f8fafc;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

#vista .kpi-dashboard-info {
    grid-column: 1 / -1;
    border: 1px solid #bfd2f2;
    background: #eef4ff;
    color: #2f4fa3;
    border-radius: 8px;
    padding: 12px 14px;
    font-weight: 600;
    font-size: 14px;
    margin-top: 2px;
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    column-gap: 8px;
    row-gap: 5px;
    align-items: start;
    width: 100%;
    box-sizing: border-box;
}

#vista .kpi-dashboard-info::before {
    content: "i";
    display: inline-flex;
    width: 18px;
    height: 18px;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
    border-radius: 50%;
    background: #4d78cd;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    margin-top: 1px;
    margin-right: 0;
}

#vista .kpi-dashboard-info-main,
#vista .kpi-dashboard-info-period {
    grid-column: 2;
}

#vista .kpi-dashboard-info-main {
    font-weight: 600;
    line-height: 1.4;
}

#vista .kpi-dashboard-info-period {
    font-size: 13px;
    line-height: 1.35;
    color: #2c467f;
}

#vista .kpi-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: stretch;
    margin-top: 16px;
}

#vista .kpi-card {
    border: 1px solid #ced9ee;
    background: #fff;
    overflow: hidden;
    min-width: 0;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

#vista .kpi-card-header {
    border-bottom: 1px solid #d5e0f2;
    background: #f7faff;
    padding: 12px 16px 10px;
}

#vista .kpi-card-header h3 {
    margin: 0;
    color: #233a79;
    font-size: 18px;
    line-height: 1.2;
    font-weight: 700;
    text-transform: none !important;
}

#vista .kpi-card-header p {
    margin: 5px 0 0;
    color: #51648f;
    font-size: 12.5px;
    line-height: 1.35;
    font-weight: 500;
    max-width: 68ch;
    text-transform: none !important;
}

#vista .kpi-card-body {
    padding: 16px;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

#vista .kpi-chart {
    min-height: 0;
    height: 286px;
    padding: 4px 0 0;
    overflow: hidden;
    min-width: 0;
}

#vista .kpi-echart {
    width: 100%;
    height: 100%;
    min-height: 0;
}

#vista .kpi-totals-table {
    display: table;
    width: 100%;
    margin-top: 0;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    border: 1px solid #d5e0f2;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

#vista .kpi-totals-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 8px;
}

#vista .kpi-card--vendes .kpi-totals-wrap {
    margin-top: 17px;
}

#vista .kpi-totals-table th,
#vista .kpi-totals-table td {
    padding: 10px 10px;
    text-align: center;
    vertical-align: middle;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    border-bottom: 1px solid #e5ebf7;
    border-right: 1px solid #edf2fb;
}

#vista .kpi-totals-table thead,
#vista .kpi-totals-table tbody,
#vista .kpi-totals-table tr {
    width: 100%;
}

#vista .kpi-totals-table--wide {
    min-width: 0;
}

#vista .kpi-totals-table--comissions {
    display: table;
    table-layout: fixed;
    margin-top: 10px;
}

#vista .kpi-totals-table--comissions col:nth-child(1),
#vista .kpi-totals-table--comissions col:nth-child(2) {
    width: 15%;
}

#vista .kpi-totals-table--comissions col:nth-child(3),
#vista .kpi-totals-table--comissions col:nth-child(4) {
    width: 35%;
}

#vista .kpi-totals-table--comissions th,
#vista .kpi-totals-table--comissions td {
    padding: 8px 10px;
}

#vista .kpi-totals-table--comissions th:nth-child(-n+2),
#vista .kpi-totals-table--comissions td:nth-child(-n+2) {
    text-align: center;
}

#vista .kpi-totals-table--comissions th:nth-child(-n+2) {
    vertical-align: middle;
}

#vista .kpi-totals-table--comissions th:nth-child(n+3),
#vista .kpi-totals-table--comissions td:nth-child(n+3) {
    text-align: right;
    padding-right: 12px;
}

#vista .kpi-totals-table--comissions th {
    background: #f2f5fb;
}

#vista .kpi-totals-table th {
    color: #111827;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.25;
    background: linear-gradient(180deg, #f7faff 0%, #edf3ff 100%);
    overflow-wrap: anywhere;
}

#vista .kpi-totals-table td {
    color: #111827;
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.3;
    background: #fff;
    white-space: nowrap;
}

#vista .kpi-totals-table th:last-child,
#vista .kpi-totals-table td:last-child {
    border-right: 0;
}

#vista .kpi-totals-table thead th:first-child {
    border-top-left-radius: 10px;
}

#vista .kpi-totals-table thead th:last-child {
    border-top-right-radius: 10px;
}

#vista .kpi-totals-table tbody tr:last-child td:first-child {
    border-bottom-left-radius: 10px;
}

#vista .kpi-totals-table tbody tr:last-child td:last-child {
    border-bottom-right-radius: 10px;
}

#vista .kpi-totals-table .kpi-cell-date {
    text-align: center;
    font-variant-numeric: tabular-nums;
    color: #0f2a5f;
    font-weight: 600;
}

#vista .kpi-totals-table .kpi-cell-metric {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    letter-spacing: 0;
}

#vista .kpi-totals-table tbody tr:last-child td {
    border-bottom: 0;
}

#vista .kpi-totals-table--vendes {
    table-layout: fixed;
}

#vista .kpi-totals-table--vendes col:nth-child(1),
#vista .kpi-totals-table--vendes col:nth-child(2) {
    width: 14%;
}

#vista .kpi-totals-table--vendes col:nth-child(3),
#vista .kpi-totals-table--vendes col:nth-child(4),
#vista .kpi-totals-table--vendes col:nth-child(5),
#vista .kpi-totals-table--vendes col:nth-child(6) {
    width: 18%;
}

#vista .kpi-totals-table--vendes th {
    font-size: 9.75px;
    line-height: 1.2;
    vertical-align: bottom;
    white-space: normal;
    overflow-wrap: normal;
    word-break: keep-all;
}

#vista .kpi-totals-table--vendes td {
    font-size: 10.6px;
    line-height: 1.22;
    white-space: nowrap;
}

#vista .kpi-totals-table--vendes th,
#vista .kpi-totals-table--vendes td {
    padding: 7px 5px;
}

#vista .kpi-totals-table--vendes th:nth-child(-n+2),
#vista .kpi-totals-table--vendes td:nth-child(-n+2) {
    white-space: nowrap;
}

#vista .kpi-totals-table--vendes th:nth-child(-n+2) {
    vertical-align: middle;
    line-height: 1.1;
    padding-top: 0;
    padding-bottom: 0;
}

#vista .kpi-totals-table--vendes th:nth-child(n+3),
#vista .kpi-totals-table--vendes td:nth-child(n+3) {
    text-align: right;
    padding-right: 6px;
    white-space: normal;
    overflow-wrap: normal;
    word-break: keep-all;
}

#vista .kpi-totals-table .kpi-cell-metric .kpi-metric-nowrap {
    display: inline-block;
    white-space: nowrap;
}

#vista .kpi-totals-table--vendes td:nth-child(5),
#vista .kpi-totals-table--vendes td:nth-child(6) {
    white-space: nowrap;
}

#vista .kpi-totals-table--vendes th:nth-child(5),
#vista .kpi-totals-table--vendes td:nth-child(5) {
    padding-right: 6px;
}

#vista .kpi-totals-table--vendes tbody tr td {
    font-size: 10px;
}

#vista .kpi-totals-table--vendes th:nth-child(-n+2),
#vista .kpi-totals-table--vendes td:nth-child(-n+2) {
    text-align: center;
}

#vista .kpi-card--minutes {
    margin-top: 24px;
}

#vista .kpi-card--minutes .kpi-card-body {
    padding-bottom: 18px;
}

#vista .kpi-minutes-table-wrap {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
    margin-top: 8px;
}

#vista .kpi-minutes-table {
    min-width: 0;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    border: 1px solid #d5e0f2;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

#vista .kpi-minutes-table col:nth-child(1) {
    width: 11%;
}

#vista .kpi-minutes-table col:nth-child(2),
#vista .kpi-minutes-table col:nth-child(3),
#vista .kpi-minutes-table col:nth-child(4),
#vista .kpi-minutes-table col:nth-child(5) {
    width: 8%;
}

#vista .kpi-minutes-table col:nth-child(6),
#vista .kpi-minutes-table col:nth-child(7),
#vista .kpi-minutes-table col:nth-child(8),
#vista .kpi-minutes-table col:nth-child(9) {
    width: 14.25%;
}

#vista .kpi-minutes-table th,
#vista .kpi-minutes-table td {
    border-bottom: 1px solid #e5ebf7;
    border-right: 1px solid #edf2fb;
    padding: 10px 9px;
    text-align: center;
    color: #111827;
    vertical-align: middle;
}

#vista .kpi-minutes-table th {
    font-size: 11px;
    font-weight: 700;
    line-height: 1.25;
    background: linear-gradient(180deg, #f7faff 0%, #edf3ff 100%);
    white-space: normal;
    overflow-wrap: anywhere;
}

#vista .kpi-minutes-table td {
    font-size: 11.25px;
    font-weight: 500;
    line-height: 1.3;
}

#vista .kpi-minutes-table th:last-child,
#vista .kpi-minutes-table td:last-child {
    border-right: 0;
}

#vista .kpi-minutes-table thead th:first-child {
    border-top-left-radius: 10px;
}

#vista .kpi-minutes-table thead th:last-child {
    border-top-right-radius: 10px;
}

#vista .kpi-minutes-table tbody tr:last-child td:first-child {
    border-bottom-left-radius: 10px;
}

#vista .kpi-minutes-table tbody tr:last-child td:last-child {
    border-bottom-right-radius: 10px;
}

#vista .kpi-minutes-table tbody tr:first-child td {
    background: #f7faff;
    font-weight: 600;
}

#vista .kpi-minutes-table tbody tr:first-child td:first-child {
    color: #1f3f85;
    font-weight: 700;
}

#vista .kpi-minutes-table td:first-child,
#vista .kpi-minutes-table th:first-child {
    text-align: left;
}

#vista .kpi-minutes-table th:nth-child(2),
#vista .kpi-minutes-table td:nth-child(2),
#vista .kpi-minutes-table th:nth-child(n+5),
#vista .kpi-minutes-table td:nth-child(n+5) {
    text-align: right;
    padding-right: 10px;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

#vista .kpi-minutes-table th:nth-child(3),
#vista .kpi-minutes-table td:nth-child(3),
#vista .kpi-minutes-table th:nth-child(4),
#vista .kpi-minutes-table td:nth-child(4) {
    text-align: center;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

#vista .kpi-minutes-detail {
    margin-top: 8px;
    margin-left: 0;
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #1f3f85;
    font-size: 12.5px;
    font-weight: 700;
    text-decoration: none;
    border: 1px solid #cfd9ec;
    background: #ffffff;
    border-radius: 8px;
    padding: 7px 11px;
    min-height: 44px;
    cursor: pointer;
    box-shadow: none;
    transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, transform 0.12s ease, color 0.16s ease;
}

#vista .kpi-card--minutes .kpi-card-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-bottom: 12px;
}

#vista .kpi-minutes-detail:hover {
    color: #183770;
    background: #f8fbff;
    border-color: #bacae8;
    box-shadow: none;
    text-decoration: none;
}

#vista .kpi-minutes-detail:active {
    transform: none;
}

#vista .kpi-minutes-detail span[aria-hidden="true"] {
    font-size: 12px;
    line-height: 1;
    color: #2f4fa3;
}

#vista .kpi-minutes-detail:focus-visible {
    outline: 2px solid #2f4fa3;
    outline-offset: 2px;
}

#vista .kpi-dashboard-error {
    border: 1px solid #f1b5ba;
    background: #fff1f2;
    color: #9f1239;
    padding: 14px;
    border-radius: 6px;
    font-weight: 600;
}

#vista .kpi-dashboard-error p {
    margin: 0;
}

#vista .kpi-dashboard-error-retry {
    margin-top: 10px;
    border: 1px solid #f09ca7;
    background: #ffffff;
    color: #9f1239;
    border-radius: 6px;
    padding: 6px 12px;
    font-weight: 700;
    cursor: pointer;
}

#vista .kpi-dashboard-error-retry:hover {
    background: #fff6f7;
}

#vista .kpi-dashboard-error-retry:focus-visible {
    outline: 2px solid #9f1239;
    outline-offset: 2px;
}

#vista .kpi-dashboard-loading {
    border: 1px solid #ced9ee;
    background: #f8fbff;
    color: #1f2937;
    border-radius: 8px;
    padding: 14px;
    font-weight: 600;
}

#vista .kpi-card-empty {
    border: 1px dashed #c9d5ee;
    background: #f9fbff;
    color: #475569;
    border-radius: 8px;
    padding: 14px;
    font-size: 13px;
    line-height: 1.35;
}

@media (prefers-reduced-motion: reduce) {
    #vista .kpi-dashboard-head-controls #kpi-period-apply,
    #vista .kpi-minutes-detail,
    #vista .kpi-dashboard-error-retry {
        transition: none;
    }
}

@media (max-width: 1180px) {
    #vista .kpi-dashboard {
        gap: 16px;
    }

    #vista .kpi-dashboard-grid {
        grid-template-columns: 1fr;
    }

    #vista .kpi-totals-table--wide {
        min-width: 740px;
    }

    #vista .kpi-minutes-table {
        min-width: 900px;
    }

}

@media (min-width: 1200px) {
    #vista .kpi-dashboard-head-controls {
        justify-content: flex-end;
        margin-left: auto;
    }
}

@media (max-width: 992px) {
    #vista .kpi-dashboard-head {
        grid-template-columns: 1fr;
        align-items: stretch;
        row-gap: 12px;
    }

    #vista .kpi-dashboard-head-side {
        width: 100%;
        max-width: none;
        justify-self: stretch;
    }

    #vista .kpi-dashboard-head-title {
        min-height: 0;
    }

    #vista .kpi-dashboard-head-controls {
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
        padding: 10px 12px;
    }

    #vista .kpi-dashboard-head-controls .kpi-period-input {
        min-width: 116px;
        flex: 1 1 116px;
    }

    #vista .kpi-dashboard-head-controls #kpi-period-apply {
        flex: 0 0 auto;
    }

    #vista .kpi-card-body {
        overflow-x: visible;
    }

    #vista .kpi-totals-table {
        width: max-content;
        min-width: 100%;
        white-space: nowrap;
    }

    #vista .kpi-minutes-table {
        min-width: 860px;
        white-space: nowrap;
    }
}

@media (max-width: 768px) {
    #vista .kpi-dashboard-head-title h3 {
        font-size: clamp(21px, 6.2vw, 27px);
        line-height: 1.14;
    }

    #vista .kpi-card-header {
        padding: 10px 12px 9px;
    }

    #vista .kpi-card-header h3 {
        font-size: 18px;
    }

    #vista .kpi-card-header p {
        font-size: 13px;
    }

    #vista .kpi-card-body {
        padding: 12px;
    }

    #vista .kpi-chart {
        height: 260px;
        padding: 4px 0 0;
    }

    #vista .kpi-echart {
        height: 100%;
    }
}

@media (max-width: 768px) {
    #vista .kpi-totals-wrap {
        overflow-x: visible;
    }

    #vista .kpi-totals-table--comissions,
    #vista .kpi-totals-table--vendes {
        width: 100% !important;
        min-width: 0 !important;
        table-layout: auto;
        border: 0;
        box-shadow: none;
        margin-top: 8px;
    }

    #vista .kpi-totals-table--comissions thead,
    #vista .kpi-totals-table--vendes thead {
        display: none;
    }

    #vista .kpi-totals-table--comissions tbody,
    #vista .kpi-totals-table--vendes tbody,
    #vista .kpi-totals-table--comissions tr,
    #vista .kpi-totals-table--vendes tr {
        display: block;
        width: 100%;
    }

    #vista .kpi-totals-table--comissions tr,
    #vista .kpi-totals-table--vendes tr {
        border: 1px solid #d6e0f2;
        border-radius: 8px;
        background: #fbfdff;
        padding: 4px 10px;
    }

    #vista .kpi-totals-table--comissions td,
    #vista .kpi-totals-table--vendes td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 10px;
        width: 100%;
        padding: 7px 0;
        border-bottom: 1px dashed #dde5f3;
        white-space: normal;
        text-align: right !important;
    }

    #vista .kpi-totals-table--comissions td::before,
    #vista .kpi-totals-table--vendes td::before {
        content: attr(data-label);
        font-size: 11px;
        font-weight: 600;
        line-height: 1.25;
        color: #334155;
        text-align: left;
        white-space: normal;
        flex: 0 0 48%;
    }

    #vista .kpi-totals-table--comissions tr td:last-child,
    #vista .kpi-totals-table--vendes tr td:last-child {
        border-bottom: 0;
    }

    #vista .kpi-minutes-table-wrap {
        overflow-x: visible;
    }

    #vista .kpi-minutes-table {
        width: 100%;
        min-width: 0;
        table-layout: auto;
        border: 0;
        box-shadow: none;
    }

    #vista .kpi-minutes-table thead {
        display: none;
    }

    #vista .kpi-minutes-table tbody,
    #vista .kpi-minutes-table tr {
        display: block;
        width: 100%;
    }

    #vista .kpi-minutes-table tr {
        border: 1px solid #d6e0f2;
        border-radius: 8px;
        background: #fbfdff;
        padding: 4px 10px;
    }

    #vista .kpi-minutes-table td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 10px;
        width: 100%;
        padding: 7px 0;
        border-bottom: 1px dashed #dde5f3;
        white-space: normal;
        text-align: right !important;
    }

    #vista .kpi-minutes-table td::before {
        content: attr(data-label);
        font-size: 11px;
        font-weight: 600;
        line-height: 1.25;
        color: #334155;
        text-align: left;
        white-space: normal;
        flex: 0 0 48%;
    }

    #vista .kpi-minutes-table tr td:last-child {
        border-bottom: 0;
    }

    #vista .kpi-minutes-detail {
        align-self: flex-start;
        margin-top: 12px;
    }
}

@media (max-width: 576px) {
    #vista .kpi-dashboard {
        gap: 12px;
    }

    #vista .kpi-dashboard-head-controls {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: center;
        gap: 6px;
        padding: 10px 12px;
    }

    #vista .kpi-dashboard-head-controls label {
        grid-column: 1 / -1;
        margin: 0;
    }

    #vista .kpi-dashboard-head-controls span {
        display: none;
    }

    #vista .kpi-dashboard-head-controls .kpi-period-input,
    #vista .kpi-dashboard-head-controls #kpi-period-apply {
        min-width: 0;
        width: 100%;
        min-height: 44px;
        height: 44px;
    }

    #vista .kpi-dashboard-head-controls #kpi-period-apply {
        grid-column: 1 / -1;
    }

    #vista .kpi-dashboard-info {
        font-size: 13px;
        padding: 10px 12px;
    }

    #vista .kpi-echart {
        height: 248px;
        min-height: 0;
    }
}
