:root {
    --sidebar-bg: #0d1b2a;
    --sidebar-accent: #1b263b;
    --page-bg: #edf2f7;
    --panel-bg: #ffffff;
    --text-main: #1f2937;
    --text-soft: #6b7280;
    --primary: #1c5d99;
    --primary-soft: #d8e8f7;
    --positive: #1f8a70;
    --positive-soft: #dcf4ec;
    --warning: #d97b29;
    --warning-soft: #fde8d8;
    --risk: #c94f4f;
    --risk-soft: #f7dada;
    --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body.app-shell {
    margin: 0;
    min-height: 100vh;
    font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top right, rgba(28, 93, 153, 0.08), transparent 28%),
        linear-gradient(180deg, #f7fafc 0%, var(--page-bg) 100%);
    color: var(--text-main);
}

.alert {
    border: 0;
    border-radius: 14px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
    padding: 0.9rem 1rem;
    margin-bottom: 1rem;
}

.alert-success {
    background: linear-gradient(90deg, rgba(31, 138, 112, 0.14), rgba(31, 138, 112, 0.05));
    color: #065f46;
}

.alert-danger {
    background: linear-gradient(90deg, rgba(201, 79, 79, 0.14), rgba(201, 79, 79, 0.05));
    color: #7f1d1d;
}

.alert-warning {
    background: linear-gradient(90deg, rgba(217, 123, 41, 0.14), rgba(217, 123, 41, 0.05));
    color: #7c2d12;
}

.alert-info {
    background: linear-gradient(90deg, rgba(28, 93, 153, 0.14), rgba(28, 93, 153, 0.05));
    color: #0f3f66;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 300px;
    padding: 24px 20px;
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, #16263a 100%);
    color: rgba(255, 255, 255, 0.92);
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 1040;
}

.mobile-nav-overlay,
.mobile-nav-toggle,
.mobile-sidebar-head {
    display: none;
}

.mobile-nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 17, 29, 0.56);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 1035;
}

.mobile-sidebar-title {
    display: block;
    margin-top: 0.2rem;
    font-size: 1rem;
    font-weight: 700;
}

.mobile-nav-close,
.mobile-nav-toggle {
    border: 0;
    background: transparent;
    color: inherit;
}

.mobile-nav-close {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.92);
    font-size: 1rem;
}

.brand-block h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.brand-block p,
.sidebar-note p {
    color: rgba(255, 255, 255, 0.72);
    margin: 0;
    line-height: 1.6;
}

.brand-kicker,
.small-label,
.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.72rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.55);
}

.nav-menu {
    gap: 5px;
}

.nav-menu .nav-link {
    border-radius: 12px;
    padding: 9px 12px;
    color: rgba(255, 255, 255, 0.82);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.92rem;
    line-height: 1.2;
}

.nav-group {
    display: grid;
    gap: 6px;
}

.nav-group summary {
    list-style: none;
    cursor: pointer;
}

.nav-group summary::-webkit-details-marker {
    display: none;
}

.nav-group-toggle {
    justify-content: space-between;
}

.nav-group.is-active .nav-group-toggle,
.nav-group[open] .nav-group-toggle {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.nav-group.is-active .nav-group-toggle {
    box-shadow: inset 3px 0 0 rgba(255, 255, 255, 0.65);
}

.nav-caret {
    font-size: 0.78rem;
    transition: transform 0.2s ease;
}

.nav-group[open] .nav-caret {
    transform: rotate(180deg);
}

.nav-submenu {
    display: grid;
    gap: 4px;
    padding: 2px 0 2px 14px;
    margin-left: 8px;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-sublink {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
    font-size: 0.84rem;
    line-height: 1.2;
    transition: all 0.2s ease;
    position: relative;
}

.nav-sublink:hover,
.nav-sublink.active {
    background: rgba(255, 255, 255, 0.07);
    color: #ffffff;
}

.nav-sublink.active {
    box-shadow: inset 2px 0 0 rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.11);
}

.nav-subicon {
    width: 14px;
    font-size: 0.78rem;
    text-align: center;
    opacity: 0.82;
    flex-shrink: 0;
}

.nav-sublink span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-menu .nav-link:hover,
.nav-menu .nav-link.active {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.nav-menu .nav-link.active {
    box-shadow: inset 3px 0 0 rgba(255, 255, 255, 0.65);
}

.nav-icon {
    font-size: 0.88rem;
    width: 16px;
    text-align: center;
    opacity: 0.88;
}

.nav-menu .nav-link.disabled {
    opacity: 0.45;
}

.sidebar-note {
    margin-top: auto;
    padding: 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.05);
}

.main-panel {
    margin-left: 300px;
    min-height: 100vh;
}

.topbar {
    padding: 18px 28px 10px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.topbar h2,
.panel-head h3,
.section-title {
    margin: 0;
    font-weight: 700;
}

.topbar h2 {
    font-size: 1.55rem;
    line-height: 1.15;
}

.mobile-nav-toggle {
    width: 48px;
    height: 48px;
    margin-bottom: 10px;
    border-radius: 16px;
    display: none;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border: 1px solid rgba(28, 93, 153, 0.14);
    box-shadow: var(--shadow);
    color: #16324f;
    font-size: 1.5rem;
}

.topbar-badge {
    background: var(--panel-bg);
    border: 1px solid rgba(28, 93, 153, 0.12);
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 0.8rem;
    color: var(--text-soft);
    box-shadow: var(--shadow);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.user-pill {
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(28, 93, 153, 0.12);
    border-radius: 18px;
    padding: 8px 10px 8px 14px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow);
}

.user-pill-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.user-pill-body {
    min-width: 0;
}

.user-pill-collapse {
    display: grid;
    gap: 10px;
    min-width: 0;
}

.user-pill-toggle {
    display: none;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: rgba(28, 93, 153, 0.08);
    color: #184a78;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    transition: transform 0.2s ease, background 0.2s ease;
}

.user-pill.is-collapsed .user-pill-toggle i {
    transform: rotate(180deg);
}

.user-pill-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-soft);
}

.content-wrap {
    padding: 0 28px 24px;
}

.panel-card,
.metric-card {
    background: var(--panel-bg);
    border-radius: 22px;
    box-shadow: var(--shadow);
}

.panel-card {
    padding: 24px;
}

.chart-panel canvas {
    min-height: 280px;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.metric-card {
    padding: 22px;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border: 1px solid transparent;
}

.metric-card span {
    color: var(--text-soft);
    font-size: 0.92rem;
}

.metric-card strong {
    font-size: 1.8rem;
    line-height: 1.2;
}

.metric-card.positive {
    background: linear-gradient(180deg, var(--panel-bg) 0%, var(--positive-soft) 100%);
    border-color: rgba(31, 138, 112, 0.18);
}

.metric-card.info {
    background: linear-gradient(180deg, var(--panel-bg) 0%, var(--primary-soft) 100%);
    border-color: rgba(28, 93, 153, 0.16);
}

.metric-card.warning {
    background: linear-gradient(180deg, var(--panel-bg) 0%, var(--warning-soft) 100%);
    border-color: rgba(217, 123, 41, 0.18);
}

.metric-card.risk {
    background: linear-gradient(180deg, var(--panel-bg) 0%, var(--risk-soft) 100%);
    border-color: rgba(201, 79, 79, 0.18);
}

.metric-card.neutral {
    border-color: rgba(148, 163, 184, 0.16);
}

.data-table thead th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-soft);
    border-bottom: 1px solid #e5e7eb;
}

.data-table tbody td {
    border-bottom: 1px solid #eef2f7;
}

.document-list-table {
    table-layout: auto;
}

.document-list-table .table-nowrap {
    white-space: nowrap;
}

.document-list-table .table-number {
    text-align: right;
    white-space: nowrap;
    word-break: keep-all;
    overflow-wrap: normal;
    font-variant-numeric: tabular-nums;
}

.document-list-table .table-action-cell {
    white-space: nowrap;
    width: 1%;
}

.table-nowrap {
    white-space: nowrap;
}

.table-number {
    text-align: right;
    white-space: nowrap;
    word-break: keep-all;
    overflow-wrap: normal;
    font-variant-numeric: tabular-nums;
}

.accounting-report-table {
    table-layout: auto;
}

.accounting-report-table th:first-child,
.accounting-report-table td:first-child {
    min-width: 240px;
}

.accounting-report-table th:not(:first-child) {
    min-width: 132px;
    width: 1%;
}

.accounting-report-value {
    text-align: right;
    white-space: nowrap;
    word-break: keep-all;
    overflow-wrap: normal;
    font-variant-numeric: tabular-nums;
    min-width: 132px;
}


.sales-document-table th:nth-child(1),
.sales-document-table td:nth-child(1) {
    width: 110px;
}

.sales-document-table th:nth-child(2),
.sales-document-table td:nth-child(2) {
    width: 140px;
}

.sales-document-table th:nth-child(3),
.sales-document-table td:nth-child(3) {
    width: 90px;
}

.sales-document-table th:nth-child(5),
.sales-document-table td:nth-child(5) {
    width: 130px;
}

.sales-document-table th:nth-child(6),
.sales-document-table td:nth-child(6),
.sales-document-table th:nth-child(7),
.sales-document-table td:nth-child(7),
.sales-document-table th:nth-child(8),
.sales-document-table td:nth-child(8) {
    min-width: 135px;
}

.stack-form {
    display: grid;
    gap: 18px;
}

.ranking-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 8px;
}

.ranking-list li {
    padding: 9px 0;
    border-bottom: 1px solid #eef2f7;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.ranking-list li span {
    color: #334155;
    font-size: 0.86rem;
    line-height: 1.25;
}

.ranking-list li strong {
    font-size: 0.86rem;
    line-height: 1.2;
    white-space: nowrap;
}

.ranking-list li:last-child {
    border-bottom: 0;
}

.detail-list {
    display: grid;
    gap: 14px;
}

.detail-list div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eef2f7;
}

.detail-list div:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.detail-list span {
    color: var(--text-soft);
}

.detail-list.compact div {
    padding-bottom: 10px;
}

.slim-panel {
    height: 100%;
}

.admin-form-card {
    border: 1px solid rgba(28, 93, 153, 0.12);
    background: linear-gradient(180deg, #ffffff 0%, #f9fbfe 100%);
}

.admin-form-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 22px;
}

.admin-form-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
}

.admin-form-section {
    padding: 18px 20px;
    border: 1px solid #e6edf5;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.88);
}

.admin-form-section-head {
    margin-bottom: 14px;
}

.admin-form-section-head h5 {
    margin: 4px 0 0;
    font-size: 1rem;
    font-weight: 700;
}

.admin-form-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding-top: 4px;
    flex-wrap: wrap;
}

.admin-form-switch {
    margin: 0;
    padding: 14px 16px 14px 2rem;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.04);
}

.admin-form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.admin-companies-card {
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
}

.admin-companies-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.admin-companies-summary-chip {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(28, 93, 153, 0.08);
    color: #1c5d99;
    font-size: 0.82rem;
    font-weight: 700;
}

.admin-companies-filters {
    margin-bottom: 18px;
    padding: 18px;
    border: 1px solid #e7eef6;
    border-radius: 18px;
    background: rgba(247, 250, 252, 0.9);
}

.admin-companies-filter-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.admin-companies-table-wrap {
    border: 1px solid #e7eef6;
    border-radius: 20px;
    overflow: hidden;
}

.admin-companies-table {
    margin-bottom: 0;
}

.admin-companies-head th {
    padding: 16px 18px;
    border-bottom: 1px solid #dfe8f2;
    background: #f5f8fc;
    color: #5b6b7d;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.admin-company-row td {
    padding: 18px;
    border-color: #edf2f7;
    vertical-align: top;
}

.admin-company-main {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.admin-company-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: linear-gradient(135deg, #1c5d99 0%, #5b8ec7 100%);
    color: #fff;
    font-weight: 800;
    font-size: 1rem;
    flex: 0 0 auto;
}

.admin-company-name {
    display: block;
    margin-bottom: 2px;
    font-size: 0.98rem;
}

.admin-company-nif {
    display: inline-flex;
    padding: 7px 10px;
    border-radius: 10px;
    background: #f4f7fb;
    color: #233142;
    font-weight: 700;
}

.admin-company-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.admin-company-chip {
    display: inline-flex;
    align-items: center;
    padding: 7px 10px;
    border-radius: 10px;
    background: #f7f9fc;
    border: 1px solid #e3ebf4;
    color: #4f6175;
    font-size: 0.82rem;
}

.admin-company-chip-email {
    max-width: 100%;
    overflow-wrap: anywhere;
}

.admin-company-db-path {
    max-width: 360px;
}

.admin-company-db-path code {
    display: block;
    padding: 10px 12px;
    border-radius: 12px;
    background: #0f172a;
    color: #d8e4f0;
    font-size: 0.77rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-company-db-state {
    margin-top: 8px;
    font-weight: 600;
}

.admin-company-status-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.admin-company-actions {
    display: inline-flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.admin-company-actions form {
    margin: 0;
}

.admin-company-avatar-lg {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    font-size: 1.2rem;
}

.admin-company-detail-card {
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.admin-company-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 18px;
}

.admin-company-detail-grid div {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px;
    border: 1px solid #e8eef5;
    border-radius: 16px;
    background: #fbfcfe;
}

.admin-company-detail-grid span {
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.admin-company-detail-grid strong {
    color: #172554;
    font-size: 0.96rem;
}

.admin-company-detail-grid-full {
    grid-column: 1 / -1;
}

.admin-company-detail-code {
    overflow-wrap: anywhere;
}

.admin-company-detail-code code {
    display: block;
    padding: 12px 14px;
    border-radius: 14px;
    background: #0f172a;
    color: #d8e4f0;
    font-size: 0.8rem;
}

.admin-company-danger-card {
    border-color: rgba(185, 28, 28, 0.18);
    background: linear-gradient(180deg, #fffefe 0%, #fff5f5 100%);
}

.admin-nav-shell {
    padding: 22px 24px;
    border: 1px solid rgba(28, 93, 153, 0.12);
    background:
        radial-gradient(circle at top right, rgba(28, 93, 153, 0.08), transparent 28%),
        linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.admin-nav-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 18px;
}

.admin-nav-head h3 {
    font-size: 1.18rem;
    font-weight: 700;
    margin: 6px 0 4px;
}

.admin-nav-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(28, 93, 153, 0.1);
    color: #184a78;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
}

.admin-nav-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.admin-nav-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 18px;
    border-radius: 18px;
    border: 1px solid #dbe7f3;
    background: rgba(255, 255, 255, 0.92);
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    min-height: 96px;
}

.admin-nav-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.08);
    border-color: rgba(28, 93, 153, 0.24);
}

.admin-nav-card.is-active {
    border-color: rgba(28, 93, 153, 0.36);
    background: linear-gradient(180deg, rgba(216, 232, 247, 0.72) 0%, rgba(255, 255, 255, 0.98) 100%);
    box-shadow: 0 18px 36px rgba(28, 93, 153, 0.12);
}

.admin-nav-card-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(28, 93, 153, 0.12);
    color: #184a78;
    font-size: 1rem;
    flex-shrink: 0;
}

.admin-nav-card strong {
    display: block;
    font-size: 0.98rem;
    margin-bottom: 4px;
    color: #16324f;
}

.admin-nav-card span {
    display: block;
    color: #5f7084;
    font-size: 0.84rem;
    line-height: 1.45;
}

.admin-subnav {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid rgba(28, 93, 153, 0.12);
}

.admin-subnav-label {
    display: inline-block;
    margin-bottom: 10px;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
}

.admin-subnav-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.admin-subnav-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid #dde7f1;
    background: #ffffff;
    color: #425466;
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.admin-subnav-link:hover {
    border-color: rgba(28, 93, 153, 0.28);
    color: #184a78;
    background: #f7fbff;
}

.admin-subnav-link.is-active {
    background: #1c5d99;
    color: #ffffff;
    border-color: #1c5d99;
    box-shadow: 0 12px 28px rgba(28, 93, 153, 0.18);
}

@media (max-width: 991.98px) {
    .admin-nav-grid {
        grid-template-columns: 1fr;
    }

    .admin-nav-head {
        flex-direction: column;
    }

    .admin-company-row td {
        padding: 14px;
    }

    .admin-company-db-path {
        max-width: 260px;
    }

    .admin-company-actions {
        justify-content: flex-start;
    }

    .admin-company-detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767.98px) {
    .admin-nav-shell {
        padding: 18px;
    }

    .admin-subnav-links {
        display: grid;
        grid-template-columns: 1fr;
    }

    .admin-subnav-link {
        justify-content: center;
    }
}

.executive-summary {
    background: linear-gradient(135deg, rgba(28, 93, 153, 0.08), rgba(255, 255, 255, 1));
}

.export-card p {
    color: var(--text-soft);
    min-height: 72px;
}

.quick-link-card {
    display: block;
    color: inherit;
    text-decoration: none;
    height: 100%;
}

.quick-link-card p,
.preview-block p {
    color: var(--text-soft);
}

.hr-nav {
    padding: 18px 20px;
}

.dashboard-toolbar {
    background: #fff;
    border-radius: 14px;
    padding: 0.75rem 1rem;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
    margin-bottom: 1rem;
}

.dashboard-toolbar h5 {
    color: #0f172a;
    font-weight: 700;
    font-size: 1rem;
}

.dashboard-section + .dashboard-section {
    margin-top: 0;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.9rem;
}

.kpi-card {
    min-height: 118px;
    padding: 0.95rem 1.05rem;
    border-radius: 14px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
    transition: all 0.2s ease-in-out;
}

.kpi-card-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 0.85rem;
    height: 100%;
}

.kpi-card-content {
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
}

.kpi-title {
    font-size: 0.7rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.45rem;
    line-height: 1.2;
}

.kpi-value {
    font-size: clamp(1.15rem, 0.8rem + 0.9vw, 1.65rem);
    font-weight: 700;
    color: #0f172a;
    line-height: 1.1;
    letter-spacing: -0.025em;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.kpi-subtitle {
    font-size: 0.71rem;
    color: #64748b;
    margin-top: 0.35rem;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    background: rgba(15, 23, 42, 0.06);
    color: #0f172a;
    flex-shrink: 0;
}

.kpi-card.success {
    border-left: 4px solid #16a34a;
}

.kpi-card.warning {
    border-left: 4px solid #f59e0b;
}

.kpi-card.danger {
    border-left: 4px solid #dc2626;
}

.kpi-card.info {
    border-left: 4px solid #2563eb;
}

.kpi-card.neutral {
    border-left: 4px solid #64748b;
}

.chart-card {
    border-radius: 14px;
    background: #fff;
    padding: 0.95rem;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
}

.chart-card canvas {
    max-height: 260px;
}

.dashboard-section-title {
    font-size: 0.84rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0.55rem;
    line-height: 1.2;
}

.dashboard-mini-table td,
.dashboard-mini-table th {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    font-size: 0.86rem;
}

.chart-card .btn.btn-sm,
.dashboard-toolbar .form-select-sm,
.dashboard-toolbar .small {
    font-size: 0.78rem;
}

.min-w-0 {
    min-width: 0;
}

.table a {
    color: var(--primary);
    text-decoration: none;
}

.table a:hover {
    text-decoration: underline;
}

.compact-plan-table th,
.compact-plan-table td {
    padding: 0.42rem 0.48rem;
    vertical-align: middle;
}

.compact-plan-table thead th {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #64748b;
    white-space: nowrap;
}

.compact-plan-input {
    min-height: 30px;
    padding: 0.18rem 0.42rem;
    font-size: 0.77rem;
}

.compact-plan-badge {
    font-size: 0.64rem;
    font-weight: 600;
    padding: 0.26rem 0.44rem;
}

.compact-plan-action {
    padding: 0.18rem 0.48rem;
    font-size: 0.71rem;
    line-height: 1.15;
}

.plan-list-table td:last-child,
.plan-list-table th:last-child {
    text-align: right;
    white-space: nowrap;
}

.plan-line-title {
    font-size: 0.82rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.plan-integrator-row td {
    color: #0f172a;
}

.balancete-filter-card {
    padding: 12px 14px;
    background:
        radial-gradient(circle at top right, rgba(28, 93, 153, 0.06), transparent 32%),
        linear-gradient(180deg, rgba(248, 250, 252, 0.85), #ffffff 42%);
}

.balancete-filter-card .panel-head {
    margin-bottom: 8px;
}

.balancete-filter-form {
    row-gap: 0.35rem !important;
}

.balancete-filter-badge {
    border-radius: 999px;
    padding: 0.28rem 0.58rem;
    font-weight: 600;
    font-size: 0.68rem;
}

.balancete-filter-card .form-label {
    font-size: 0.62rem;
    color: var(--text-soft);
    font-weight: 600;
}

.balancete-filter-card .form-select-sm,
.balancete-filter-card .form-control-sm {
    min-height: 30px;
    font-size: 0.73rem;
    border-radius: 8px;
    border-color: rgba(148, 163, 184, 0.25);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.03);
    padding-top: 0.2rem;
    padding-bottom: 0.2rem;
}

.balancete-filter-actions {
    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: nowrap;
}

.balancete-inline-check {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.3rem 0.55rem;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 10px;
    background: #f8fafc;
    white-space: nowrap;
}

.balancete-inline-check .form-check-input {
    margin: 0;
}

.balancete-inline-check .form-check-label {
    color: #475569;
    line-height: 1.1;
    font-size: 0.72rem;
}

.data-table tbody tr.financial-total-row > td,
.table.data-table tbody tr.financial-total-row > td,
.data-table tbody tr.financial-result-row > td,
.table.data-table tbody tr.financial-result-row > td {
    font-weight: 700 !important;
    background: linear-gradient(90deg, rgba(28, 93, 153, 0.14), rgba(28, 93, 153, 0.05)) !important;
    border-top: 2px solid rgba(28, 93, 153, 0.30) !important;
    border-bottom: 2px solid rgba(28, 93, 153, 0.20) !important;
    color: #0f172a !important;
}

.balancete-values-table .balancete-value-cell {
    text-align: left !important;
    white-space: nowrap;
    word-break: keep-all;
    overflow-wrap: normal;
    font-variant-numeric: tabular-nums;
}

.extracto-values-table .extracto-value-cell {
    text-align: left !important;
    white-space: nowrap;
    word-break: keep-all;
    overflow-wrap: normal;
    font-variant-numeric: tabular-nums;
}

@media (min-width: 1200px) {
    .balancete-filter-form > [class*="col-xl-"] {
        margin-top: 0 !important;
    }
}

.import-detail-header .btn {
    flex-shrink: 0;
}

.import-detail-file {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.import-detail-metric {
    min-height: 118px;
}

.import-detail-metric strong {
    font-size: clamp(1.25rem, 1rem + 0.5vw, 1.55rem);
    line-height: 1.15;
}

.import-detail-number {
    white-space: nowrap;
    word-break: keep-all;
    overflow-wrap: normal;
    font-variant-numeric: tabular-nums;
}

.imports-summary-value {
    white-space: nowrap;
    word-break: keep-all;
    overflow-wrap: normal;
    font-variant-numeric: tabular-nums;
}

.imports-batches-table {
    table-layout: auto;
}

.imports-batches-table td,
.imports-batches-table th {
    vertical-align: middle;
}

.imports-batches-table .imports-file-cell a {
    word-break: break-word;
    overflow-wrap: anywhere;
}

.hr-payroll-table {
    table-layout: auto;
}

.hr-payroll-table td,
.hr-payroll-table th {
    vertical-align: middle;
}

.import-detail-meta div {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) auto;
    align-items: start;
    gap: 14px;
}

.import-detail-value {
    text-align: right;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: none;
    min-width: 0;
}

.import-detail-value.import-detail-number {
    white-space: nowrap;
    word-break: keep-all;
    overflow-wrap: normal;
}

.import-detail-value.import-detail-compact {
    white-space: nowrap;
    word-break: keep-all;
    overflow-wrap: normal;
}

.import-detail-value.import-detail-softwrap {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.import-detail-meta-note {
    grid-template-columns: 1fr;
}

.import-detail-meta-note .import-detail-value {
    text-align: left;
}

.import-detail-table {
    table-layout: fixed;
}

.import-detail-table th:nth-child(1),
.import-detail-table td:nth-child(1) {
    width: 120px;
    white-space: nowrap;
}

.import-detail-table th:nth-child(2),
.import-detail-table td:nth-child(2) {
    width: 140px;
}

.import-detail-table td {
    vertical-align: top;
    overflow-wrap: anywhere;
}

body.login-page {
    margin: 0;
    min-height: 100vh;
    font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(28, 93, 153, 0.24), transparent 34%),
        radial-gradient(circle at bottom right, rgba(31, 138, 112, 0.18), transparent 28%),
        linear-gradient(135deg, #08111d 0%, #10233b 46%, #eef4fb 46%, #f8fafc 100%);
    color: var(--text-main);
}

.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(280px, 1.1fr) minmax(320px, 460px);
    align-items: center;
    gap: 40px;
    padding: 40px;
}

.login-hero {
    color: #ffffff;
    padding-right: 24px;
}

.login-kicker {
    display: inline-flex;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.09);
    border: 1px solid rgba(255, 255, 255, 0.14);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.login-hero h1 {
    font-size: clamp(2.2rem, 1.5rem + 2vw, 3.7rem);
    line-height: 1.02;
    margin-bottom: 1rem;
    max-width: 10ch;
}

.login-hero p {
    max-width: 56ch;
    color: rgba(255, 255, 255, 0.78);
    font-size: 1rem;
    line-height: 1.75;
}

.login-highlight {
    margin-top: 1.75rem;
    max-width: 360px;
    padding: 1rem 1.1rem;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.login-highlight strong {
    display: block;
    font-size: 1.08rem;
    margin-top: 0.2rem;
}

.login-highlight i {
    font-size: 1.6rem;
    opacity: 0.9;
}

.login-panel {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 28px;
    box-shadow: 0 28px 60px rgba(8, 17, 29, 0.24);
    padding: 32px;
}

.login-panel-head h2 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.login-panel-head p {
    color: var(--text-soft);
    margin-bottom: 1.4rem;
}

.login-form {
    display: grid;
    gap: 1rem;
}

.login-form .input-group-text {
    background: #f8fafc;
    border-color: #dbe3ee;
    color: #5b6b82;
}

.login-form .form-control {
    border-color: #dbe3ee;
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
}

.login-form .form-control:focus {
    border-color: rgba(28, 93, 153, 0.42);
    box-shadow: 0 0 0 0.24rem rgba(28, 93, 153, 0.14);
}

.login-form .btn-primary {
    margin-top: 0.4rem;
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
    border-radius: 14px;
    background: linear-gradient(135deg, #1c5d99 0%, #12395c 100%);
    border: 0;
}

@media (max-width: 992px) {
    .mobile-nav-overlay,
    .mobile-nav-toggle,
    .mobile-sidebar-head {
        display: flex;
    }

    .mobile-nav-overlay {
        display: block;
    }

    body.mobile-nav-open {
        overflow: hidden;
    }

    body.mobile-nav-open .mobile-nav-overlay {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(88vw, 320px);
        max-width: 320px;
        transform: translateX(-100%);
        transition: transform 0.28s ease;
        overflow-y: auto;
        padding-top: 20px;
    }

    body.mobile-nav-open .sidebar {
        transform: translateX(0);
    }

    .mobile-sidebar-head {
        align-items: center;
        justify-content: space-between;
        gap: 14px;
        padding-bottom: 18px;
        margin-bottom: 4px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .brand-block {
        display: none;
    }

    .main-panel {
        margin-left: 0;
    }

    .topbar,
    .content-wrap {
        padding-left: 20px;
        padding-right: 20px;
    }

    .topbar {
        flex-direction: column;
        align-items: stretch;
        padding-top: 16px;
    }

    .topbar-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .user-pill {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .user-pill .d-flex {
        flex-wrap: wrap;
    }

    .balancete-filter-actions {
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .import-detail-value {
        max-width: none;
    }
}

@media (min-width: 1400px) {
    .kpi-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .topbar,
    .content-wrap {
        padding-left: 16px;
        padding-right: 16px;
    }

    .topbar h2 {
        font-size: 1.32rem;
    }

    .topbar-badge {
        width: 100%;
        border-radius: 16px;
    }

    .topbar-actions .btn {
        width: 100%;
    }

    .user-pill .d-flex {
        display: grid !important;
        grid-template-columns: 1fr;
    }

    .user-pill {
        padding: 10px 12px;
        border-radius: 14px;
        gap: 10px;
        background: rgba(255, 255, 255, 0.86);
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
    }

    .user-pill strong {
        font-size: 0.95rem;
        font-weight: 600;
    }

    .user-pill-label {
        font-size: 0.64rem;
        letter-spacing: 0.06em;
    }

    .user-pill .small.text-muted {
        font-size: 0.74rem;
        line-height: 1.35;
        margin-top: 2px;
    }

    .user-pill-toggle {
        display: inline-flex;
    }

    .user-pill-actions {
        padding-top: 2px;
    }

    .topbar-actions {
        gap: 10px;
    }

    .user-pill .btn {
        min-height: 36px;
        padding-top: 0.35rem;
        padding-bottom: 0.35rem;
        font-size: 0.78rem;
        border-radius: 10px;
    }

    .panel-card {
        padding: 18px;
        border-radius: 18px;
    }

    .login-shell {
        grid-template-columns: 1fr;
        gap: 24px;
        padding: 20px;
    }

    .login-hero {
        padding-right: 0;
    }

    .login-hero h1 {
        max-width: none;
    }

    .login-panel {
        padding: 24px 18px;
        border-radius: 22px;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .kpi-card {
        min-height: 104px;
        padding: 0.8rem;
    }

    .kpi-value {
        font-size: 1.08rem;
    }

    .chart-card {
        padding: 0.85rem;
    }

    .compact-plan-table th,
    .compact-plan-table td {
        padding: 0.38rem;
    }

    .compact-plan-input {
        font-size: 0.75rem;
    }

    .balancete-filter-card {
        padding: 16px;
    }

    .balancete-inline-check {
        width: 100%;
        justify-content: flex-start;
    }

    .import-detail-metric {
        min-height: 102px;
    }

    .import-detail-meta div {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .import-detail-value {
        text-align: left;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
}
