@font-face {
    font-family: 'Estedad';
    src: url('/fonts/estedad.ttf') format('truetype');
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
}
:root {
    --font-base: 16px;
    --font-title: 0.875rem;
    --font-kpi: 3rem;
    --font-table: 0.875rem;
}
html { font-size: var(--font-base); }
/* Keep every web view, form control and generated tooltip on the bundled font. */
html, body, body *, body *::before, body *::after {
    font-family: 'Estedad', sans-serif !important;
}
.data-grid tbody > tr:nth-child(even) { background-color: #f1f5f9; }
.dark .data-grid tbody > tr:nth-child(even) { background-color: #1e293b; }
.data-grid tbody > tr:hover { background-color: #eef2ff; }
.dark .data-grid tbody > tr:hover { background-color: #334155; }
.card-title { font-size: var(--font-title) !important; }
.kpi-value {
    font-size: var(--font-kpi) !important;
    font-weight: bold;
    font-family: inherit;
    display: inline-flex;
    align-items: baseline;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.4em;
    line-height: 1.2;
}
.kpi-value > * { font-family: inherit; }
.kpi-unit {
    font-size: 0.34em;
    font-weight: 600;
    color: #64748b;
    white-space: nowrap;
}
.dark .kpi-unit { color: #94a3b8; }

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.dark ::-webkit-scrollbar-thumb { background: #334155; }

body { transition: background-color 0.3s ease, color 0.3s ease; }
.tab-btn { border-bottom: 2px solid transparent; }
.tab-active { border-bottom: 2px solid var(--bi-accent); color: #4f46e5; font-weight: bold; }
.dark .tab-active { color: #818cf8; }
.data-grid th { position: sticky; top: 0; z-index: 10; }

.drag-handle { cursor: grab; touch-action: none; }
.drag-handle:active { cursor: grabbing; }
.cursor-sw-resize { cursor: sw-resize; }
.row-span-7 { grid-row: span 7 / span 7 !important; }
.row-span-8 { grid-row: span 8 / span 8 !important; }
.row-span-9 { grid-row: span 9 / span 9 !important; }
.row-span-10 { grid-row: span 10 / span 10 !important; }
.row-span-11 { grid-row: span 11 / span 11 !important; }
.row-span-12 { grid-row: span 12 / span 12 !important; }

.dashboard-tabs-bar {
    min-height: 4.25rem;
}
.dashboard-tabs-scroll {
    direction: rtl;
    scroll-behavior: smooth;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
    scrollbar-color: #94a3b8 transparent;
}
.dashboard-tabs-scroll::-webkit-scrollbar { height: 5px; }
.dashboard-tabs-scroll::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 999px;
}
.dark .dashboard-tabs-scroll {
    scrollbar-color: #475569 transparent;
}
.dark .dashboard-tabs-scroll::-webkit-scrollbar-thumb { background: #475569; }
.dashboard-tab-scroll-button {
    width: 2.5rem;
    height: 2.75rem;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.75rem;
    transition: color 0.18s ease, background-color 0.18s ease, opacity 0.18s ease;
}
.dashboard-tab-item {
    width: clamp(8.5rem, 13vw, 13rem);
    min-width: 8.5rem;
    height: 2.75rem;
    border-radius: 0.8rem;
    position: relative;
    isolation: isolate;
}
.dashboard-tab-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tab-drag-ghost {
    opacity: 0.25 !important;
    border-style: dashed !important;
}
.tab-drag-chosen {
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18) !important;
    transform: scale(1.02);
}
.tab-dragging {
    opacity: 0.96 !important;
    cursor: grabbing !important;
    z-index: 1000 !important;
}
.tab-settings-item {
    min-height: 3.5rem;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
.tab-settings-drag-handle {
    width: 2.75rem;
    align-self: stretch;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    touch-action: none;
    user-select: none;
}
.tab-settings-drag-handle:active { cursor: grabbing; }

.refresh-spinner {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    border-radius: inherit;
    backdrop-filter: blur(2px);
}
.dark .refresh-spinner { background: rgba(0,0,0,0.5); }
.spinner {
    width: 30px;
    height: 30px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid var(--bi-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.preview-container {
    min-height: 160px;
    border: 1px dashed #94a3b8;
    border-radius: 0.5rem;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.dark .preview-container {
    background: #1e293b;
    border-color: #475569;
}
.preview-container .placeholder { color: #94a3b8; font-size: 0.9rem; }
.var-input { direction: ltr; text-align: right; }

@media print {
    body * { visibility: hidden; }
    .print-area, .print-area * { visibility: visible; }
    .print-area { position: absolute; left: 0; top: 0; width: 100%; }
    .no-print { display: none !important; }
}
.widget-actions button { background: transparent; border: none; cursor: pointer; padding: 2px 4px; }
.widget-actions button:hover { opacity: 0.7; }
.dashboard-card-header {
    min-width: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.dashboard-card-header-main {
    min-width: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.dashboard-card-title-group {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}
.dashboard-card-title-group .card-title {
    min-width: 0;
    flex: 1 1 auto;
}
.dashboard-card-header .widget-actions {
    flex: 0 0 auto;
    min-height: 1.5rem;
    display: inline-flex;
    align-items: center;
}
.dashboard-card-context {
    min-width: 0;
    max-width: 100%;
    flex: 1 1 auto;
    justify-content: flex-end;
}
.dashboard-card-context-shell {
    min-width: 0;
    max-width: 100%;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.35rem;
    flex-wrap: wrap;
    direction: ltr;
}
.dashboard-card-context-toggle {
    flex: 0 0 auto;
    min-height: 1.5rem;
    padding: 0.2rem 0.45rem;
    border: 1px solid rgb(100 116 139 / 0.45);
    border-radius: 0.35rem;
    background: rgb(15 23 42 / 0.35);
    color: rgb(148 163 184);
    font-size: 0.65rem;
    line-height: 1rem;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.dashboard-card-context-toggle:hover,
.dashboard-card-context-toggle:focus-visible {
    border-color: rgb(14 165 233 / 0.7);
    background: rgb(14 165 233 / 0.12);
    color: rgb(125 211 252);
    outline: none;
}
.dashboard-card-context-fields {
    min-width: 0;
    max-width: 100%;
    flex: 1 1 12rem;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.35rem;
    direction: rtl;
}
.dashboard-card-context .dashboard-card-context-field {
    min-width: 0;
    max-width: 100%;
}
.dashboard-card-context input,
.dashboard-card-context select {
    font-size: 0.65rem;
    line-height: 1rem;
    min-width: 0;
}
@media (max-width: 900px) {
    .dashboard-card-context-shell {
        width: 100%;
        align-items: flex-start;
    }
    .dashboard-card-context-fields {
        justify-content: flex-start;
    }
}
@media (max-width: 520px) {
    .dashboard-card-header {
        gap: 0.35rem;
    }
    .dashboard-card-context-shell {
        gap: 0.25rem;
    }
    .dashboard-card-context-fields {
        flex-basis: 11rem;
        gap: 0.25rem;
    }
    .dashboard-card-context input,
    .dashboard-card-context select {
        font-size: 0.6rem;
    }
    .dashboard-card-context select {
        max-width: 6rem;
    }
}
.widget-card[data-dashboard-date-picker-open="true"] {
    overflow: visible !important;
    z-index: 30;
}
.date-picker {
    touch-action: manipulation;
    overscroll-behavior: contain;
}
#varInputModal > div:has(.date-picker:not(.hidden)) {
    overflow: visible;
}
.widget-card[data-card-font-size="true"] .widget-content .data-grid,
.widget-card[data-card-font-size="true"] .widget-content .data-grid th,
.widget-card[data-card-font-size="true"] .widget-content .data-grid td {
    font-size: var(--datagrid-font-size) !important;
}
.widget-card[data-card-font-size-mode="content"] .widget-content {
    font-size: var(--card-font-size) !important;
}
.widget-card[data-card-font-size-mode="content"] .widget-content .kpi-value {
    font-size: var(--card-font-size) !important;
}
.compact-number-input::-webkit-inner-spin-button,
.compact-number-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.compact-number-input { -moz-appearance: textfield; }

.col-resizer {
    position: absolute;
    top: 0;
    left: 0;
    width: 5px;
    height: 100%;
    cursor: col-resize;
    z-index: 10;
    background-color: transparent;
    transition: background-color 0.2s;
}
.col-resizer:hover, .col-resizer.resizing {
    background-color: var(--bi-accent);
}
.data-grid-scroll {
    display: block;
    flex: 1 1 0%;
    height: 0;
    width: 100%;
    min-width: 0;
    min-height: 0;
    max-width: 100%;
    max-height: 100%;
    overflow-x: auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    overscroll-behavior-x: none;
    /* Modern iOS accelerates overflow scrolling by default.  The legacy
       touch value creates a stacking context and breaks nested grids. */
    -webkit-overflow-scrolling: auto;
    touch-action: pan-x pan-y;
    scrollbar-gutter: auto;
    /* Match the table direction in normal AND fullscreen views. Safari's
       horizontal bounce must not expose empty space beyond the first column. */
    direction: rtl;
}
.data-grid-host,
.data-grid-container,
.data-grid-toolbar,
.data-grid-group-toolbar,
.table-pagination {
    min-width: 0;
    max-width: 100%;
    direction: rtl;
}
.data-grid-host,
.data-grid-container {
    min-height: 0;
    overflow: hidden;
}
.data-grid-toolbar {
    flex: 0 0 auto;
    width: 100%;
}
.data-grid-group-toolbar {
    flex: 0 0 auto;
    width: 100%;
    touch-action: pan-x;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}
.table-pagination {
    flex: 0 0 auto;
    width: 100%;
    flex-wrap: wrap;
}
.data-grid-scroll > table {
    width: 100%;
    min-width: 100%;
    max-width: none;
    direction: rtl;
    table-layout: auto;
}
.widget-mobile-fullscreen {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    z-index: 1000 !important;
}
#main-app > main {
    min-height: 0;
}
.admin-scroll-view {
    min-height: 0;
    max-height: 100%;
    overflow-x: auto !important;
    overflow-y: auto !important;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
}
/* Dashboard interactions and browser-local presentation. */
.dashboard-tools-bar { display:flex; flex-wrap:wrap; align-items:flex-start; gap:.5rem; margin:0 0 .75rem; }
.dashboard-tools { flex:1 1 22rem; min-width:0; }
.dashboard-tools summary, #layoutTools button, .dashboard-tools-content button, .dashboard-cards-manager button, .card-preferences button, .linked-card-filter button {
    padding:.4rem .65rem; border:1px solid #94a3b870; border-radius:.45rem; cursor:pointer;
}
.dashboard-tools summary { min-height:36px; }
#dashboardSourceSummary { margin-inline-start:.5rem; font-size:.78em; opacity:.8; }
.dashboard-tools-content, #dashboardToolsLinks, .card-preferences, .card-link-fields, .card-color-options, #layoutTools {
    display:flex; flex-wrap:wrap; gap:.5rem; align-items:center;
}
.dashboard-tools-content { padding:.5rem 0; }
#dashboardToolsLinks > div { display:none; }
.dashboard-tools-content label, .card-preferences label { display:flex; align-items:center; gap:.35rem; flex-wrap:wrap; font-size:.8rem; }
.dashboard-tools-content select, .card-preferences select, .card-preferences input:not([type=checkbox]) {
    min-width:0; max-width:100%; padding:.25rem; border-radius:.4rem; border:1px solid #94a3b870; background:Canvas; color:CanvasText;
}
.dashboard-card-header-main { align-items:center; flex-wrap:wrap; }
.dashboard-card-actions { display:flex; gap:.15rem; flex-wrap:wrap; color:inherit; }
.card-action, .layout-card-controls > button { display:inline-grid; place-items:center; min-width:29px; min-height:29px; border-radius:.4rem; }
.card-action:hover, .card-action:focus-visible, .card-action[aria-pressed=true] { background:#818cf833; }
.card-action:disabled, .card-preferences button:disabled { opacity:.55; cursor:default; }
.card-action[aria-busy=true] svg { animation:spin 900ms linear infinite; }
.dashboard-card-actions .card-action[hidden] { display:none; }
.card-action-settings { padding:.65rem; border:1px solid #94a3b870; border-radius:.5rem; }
.card-preferences fieldset { min-width:0; flex:1 1 100%; }
.card-preferences legend { font-weight:600; margin-bottom:.4rem; }
.card-action-choices { display:flex; align-items:center; flex-wrap:wrap; gap:.4rem .9rem; }
.card-preferences input[name=fontSize] { width:5rem; }
.card-preferences input[name=colorPicker] { inline-size:2.5rem; block-size:2rem; }
.card-preferences > button[type=submit], #layoutTools button[data-layout=save] { background:var(--bi-accent); color:white; }
.card-preferences .card-swatch { width:23px; height:23px; padding:0; border-radius:50%; border:1px solid #64748b; }
.card-preferences [data-card-color][aria-pressed=true] { outline:2px solid currentColor; outline-offset:2px; }
.card-link-fields { border:1px solid #94a3b870; border-radius:.45rem; padding:.3rem; min-width:0; flex:1 1 100%; }
[data-card-tone] { background:var(--custom-card-color) !important; }
[data-card-tone] :is(.dashboard-card-header, .data-grid thead th, .data-grid tfoot tr) { background:var(--custom-card-color) !important; }
[data-card-tone=dark] { --card-ink:#f8fafc; --card-muted:#cbd5e1; }
[data-card-tone=light] { --card-ink:#0f172a; --card-muted:#475569; }
[data-card-tone], [data-card-tone] :is(.card-title, .card-action, .data-grid, .text-card-content, .kpi-value, .table-pagination) { color:var(--card-ink) !important; }
.card-variable-form { flex:0 0 auto; max-height:45%; overflow:auto; }
.widget-content:has(.card-variable-form) { justify-content:start; }
.widget-content:has(.card-variable-form) > [id^=widget-wrapper-] { flex:1 1 auto; min-height:0; }
.card-request-status { padding:.2rem .45rem; font-size:.8rem; align-self:center; }
.card-request-status[role=alert] { border:1px solid #ef4444; border-radius:.4rem; }
.linked-card-filter { display:flex; flex-wrap:wrap; gap:.5rem; align-items:center; margin-bottom:.5rem; font-size:.8rem; }
.dashboard-cards-manager { background:Canvas; color:CanvasText; width:min(94vw,48rem); max-height:80vh; margin:auto; padding:1rem; border-radius:.8rem; }
.dashboard-cards-manager::backdrop { background:#0f172a88; }
.dashboard-cards-manager header, .dashboard-cards-manager li { display:flex; align-items:center; gap:.45rem; padding:.45rem 0; border-bottom:1px solid #94a3b870; flex-wrap:wrap; }
.dashboard-cards-manager header h2, .dashboard-cards-manager li span { flex:1 1 12rem; overflow-wrap:anywhere; }
#dashboardGrid.free-card-layout { grid-auto-rows:56px; grid-template-columns:repeat(12,minmax(0,1fr)); gap:10px; }
.layout-card-controls { display:none; }
.editing-card-layout .layout-card-controls { display:flex; position:absolute; inset-block-end:.25rem; inset-inline: .25rem; align-items:center; justify-content:space-between; padding:.25rem; z-index:40; background:Canvas; color:CanvasText; border:1px dashed #64748b; border-radius:.4rem; }
#dashboardGrid > :is(:fullscreen, :-webkit-full-screen, .widget-mobile-fullscreen) > .layout-card-controls { display:none; }
.layout-card-controls > button { touch-action:none; background:#94a3b82d; }
[data-layout-handle=move] { cursor:move; }
[data-layout-handle=resize] { cursor:nesw-resize; }
#layoutTools[hidden], .linked-card-filter[hidden], #dashboardToolsLinks [hidden] { display:none; }
.card-type-picker { display:grid; grid-template-columns:repeat(auto-fit,minmax(74px,1fr)); gap:.35rem; margin:.4rem 0; }
.card-type-picker button { padding:.35rem; border:1px solid #94a3b870; border-radius:.45rem; text-align:center; }
.card-type-picker button[aria-pressed=true] { border-color:var(--bi-accent); background:var(--bi-tint); }
.column-presentation { width:100%; border-collapse:collapse; font-size:.8rem; }
.column-presentation td, .column-presentation th { padding:.3rem; border-bottom:1px solid #94a3b850; text-align:start; }
.column-presentation select, .column-presentation input[type=number] { max-width:7rem; background:Canvas; color:CanvasText; border:1px solid #94a3b870; border-radius:.3rem; }
@media (max-width:899px) {
    #layoutTools, .editing-card-layout .layout-card-controls { display:none; }
    #dashboardGrid.free-card-layout { grid-template-columns:minmax(0,1fr); grid-auto-rows:auto; }
    #dashboardGrid.free-card-layout > [data-widget-id] { grid-column:1 !important; grid-row:auto !important; min-height:16rem; }
    #dashboardGrid.free-card-layout > [data-viz=kpi], #dashboardGrid.free-card-layout > [data-viz=text] { min-height:9rem; }
    #dashboardGrid.free-card-layout > [data-viz=table] { height:23rem; }
    .card-action { min-width:38px; min-height:36px; }
}
@media (prefers-reduced-motion:reduce) { .card-action[aria-busy=true] svg { animation:none; } }
.chart-with-scroll-legend { display:flex; flex-direction:column; height:100%; width:100%; min-height:0; }
.chart-scroll-legend { display:flex; align-items:center; overflow:auto hidden; white-space:nowrap; gap:.35rem; padding:.15rem .35rem; flex:0 0 auto; color:var(--card-muted,currentColor); }
.chart-scroll-legend button { flex:none; padding:.15rem .45rem; border-inline-start:4px solid #64748b; border-radius:.3rem; font-size:11px; background:#94a3b81c; }
.chart-scroll-legend button[aria-pressed=false] { opacity:.65; text-decoration:line-through; }
.chart-scroll-plot { position:relative; flex:1 1 auto; min-height:0; }
#pinQueryTools label { display:inline-flex; gap:.4rem; align-items:center; padding:.25rem; }
#pinQueryTools select { background:Canvas; color:CanvasText; border:1px solid #94a3b870; border-radius:.4rem; padding:.25rem; }
.card-grid-clear { align-self:start; padding:.15rem .4rem; font-size:.7rem; }
.table-pagination button[data-page-edge] { padding:.15rem .45rem; border-radius:.3rem; background:#94a3b825; }
.table-pagination button[data-page-edge]:disabled { opacity:.4; }
.widget-content:has(.data-grid-host) { padding:.45rem; }
.data-grid-host .table-pagination { padding-top:.25rem; margin-top:.25rem; row-gap:.2rem; }
.data-grid-host .table-pagination > div { gap:.25rem; }

@media (max-width: 750px) {
    #dashboardGrid:not(.free-card-layout) {
        grid-auto-rows: minmax(250px, auto);
    }
    /* Let the dashboard own vertical scrolling. Every layer above the
       horizontal scroller must be free to grow with the current page. */
    #dashboardGrid > [data-viz="table"]:not(:is(.widget-mobile-fullscreen, :fullscreen, :-webkit-full-screen)) {
        grid-row: auto !important;
        height: auto;
        min-height: 0;
        max-height: none;
    }
    #dashboardGrid > [data-viz="table"]:not(:is(.widget-mobile-fullscreen, :fullscreen, :-webkit-full-screen))
        :is(.widget-content, .data-grid-host, .data-grid-container) {
        flex: 0 0 auto;
        height: auto;
        max-height: none;
        overflow: visible;
    }
    #dashboardGrid > [data-viz="table"]:not(:is(.widget-mobile-fullscreen, :fullscreen, :-webkit-full-screen)) .data-grid-scroll {
        flex: 0 0 auto;
        height: auto;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
        overscroll-behavior-x: none;
        overscroll-behavior-y: auto;
        scrollbar-gutter: auto;
        scrollbar-width: none;
        direction: rtl;
    }
    #dashboardGrid > [data-viz="table"]:not(:is(.widget-mobile-fullscreen, :fullscreen, :-webkit-full-screen)) .data-grid-scroll::-webkit-scrollbar {
        display: none;
    }
}
