/* Demo prototype styles - extracted from demo/prototype.html */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Nunito:wght@400;700&family=Poppins:wght@400;500;600&display=swap');

:root {
    --c-primary:    #124559;
    --c-primary-mid:#1e4d5c;
    --c-accent:     #70a9a1;
    --c-darkest:    #01161e;
    --c-bg:         #f3f6ff;
    --c-sidebar:    #fbfbfd;
    --c-body-bg:    linear-gradient(135deg, #f8fbfb 0%, #e4f0f0 50%, #dce9ea 100%);
    --c-text:       #323232;
    --c-text-label: #313131;
    --font-ui:      'Inter', sans-serif;
    --font-display: 'Nunito', sans-serif;
    --c-primary-dk: #3d4f6e;
    --c-border:     #d8ddf0;
    --c-green:      #27ae60;
    --c-red:        #e74c3c;
    --c-yellow:     #f1c40f;
}

/* Responsive wrapper for embedding */
.demo-prototype-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
}

/* CSS isolation */
.frame {
    all: initial;
    display: block;
    width: 1280px;
    height: 720px;
    position: relative;
    margin: 0;
    font-family: var(--font-ui);
    font-size: 16px;
    line-height: 1.5;
    color: #333;
    -webkit-text-size-adjust: 100%;
    transform-origin: top left;
}
.frame *, .frame *::before, .frame *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: inherit;
    line-height: inherit;
    color: inherit;
    text-decoration: none;
    outline: none;
    letter-spacing: normal;
    word-spacing: normal;
    text-transform: none;
    text-indent: 0;
    text-shadow: none;
    float: none;
    clear: none;
    vertical-align: baseline;
}
.frame h1, .frame h2, .frame h3, .frame h4, .frame h5, .frame h6 {
    font-size: inherit;
    font-weight: inherit;
}
.frame button {
    cursor: pointer;
}
.frame table {
    border-collapse: collapse;
    border-spacing: 0;
}
.frame img, .frame svg {
    display: inline-block;
    max-width: 100%;
}

/* Sections */
.page { display: none; width: 1280px; height: 720px; }
.page.active { display: block; }

/* INICIO */
#inicio {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 1280px;
    height: 720px;
    background: var(--c-bg);
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.16);
    text-align: center;
    padding: 20px 80px 36px;
    position: relative;
}
#inicio.active { display: flex; }

.logo-container { margin-bottom: 20px; flex-shrink: 0; margin-top: auto; }
.logo-container img { max-width: 150px; height: auto; }
.company-name {
    font-size: 1.25rem;
    font-weight: 400;
    color: #000;
    margin-bottom: 40px;
    flex-shrink: 0;
    font-family: 'Inter', sans-serif;
}
.dashboard-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2b3143;
    margin-bottom: 45px;
    flex-shrink: 0;
    font-family: 'Nunito', sans-serif;
}

.nav-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    width: 100%;
    align-content: flex-start;
    flex-shrink: 0;
}
.nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    width: 100%;
    max-width: 350px;
    height: 70px;
    padding: 14px 20px;
    border: none;
    border-radius: 8px;
    background: var(--c-primary);
    color: white;
    font-size: 1.35rem;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Nunito', sans-serif;
    box-shadow: 0 4px 4px rgba(0,0,0,0.25);
}
.nav-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.nav-btn:focus, .nav-btn:active { background: var(--c-primary) !important; }
.nav-btn.active-btn {
    background: var(--c-darkest) !important;
    font-weight: 600;
}
.nav-btn.active-btn:focus, .nav-btn.active-btn:active { background: var(--c-darkest) !important; }
.nav-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.inicio-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    width: 100%;
    color: #000;
    font-size: 0.875rem;
    font-weight: 300;
    margin-top: auto;
    flex-shrink: 0;
}
.inicio-footer .update-info { text-align: center; }

/* INNER PAGES LAYOUT */
.inner-page-wrapper {
    display: none;
    width: 1280px;
    height: 720px;
}
.inner-page-wrapper.active { display: block; }

.inner-page {
    display: grid;
    grid-template-columns: 180px 1fr;
    grid-template-rows: 78px 1fr;
    width: 1280px;
    height: 720px;
    background: var(--c-bg);
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.16);
    overflow: hidden;
}

.page-header {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 14px;
    border-bottom: 1px solid rgba(43,49,67,0.2);
    background: var(--c-bg);
}
.page-header h1 {
    flex: 1;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--c-darkest);
    font-family: 'Nunito', sans-serif;
}
.back-btn {
    width: 30px; height: 30px;
    border-radius: 4px;
    background: var(--c-primary);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.back-btn:hover { background: #0d3344; }
.back-btn:focus, .back-btn:active { background: var(--c-primary) !important; }
.back-btn svg { width: 16px; height: 16px; }

/* Sidebar */
.sidebar {
    grid-column: 1;
    grid-row: 1 / -1;
    background: var(--c-sidebar);
    padding: 0 15px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
}
.sidebar-logo {
    display: flex;
    justify-content: center;
    padding: 16px 0 12px;
    flex-shrink: 0;
}
.sidebar-logo img { max-width: 130px; height: auto; }
.sidebar h3 {
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--c-text-label);
    font-family: 'Inter', sans-serif;
    margin-bottom: 4px;
    text-align: center;
}
.sidebar h3 svg { width: 16px; height: 16px; }
.filter-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--c-text-label);
    margin-bottom: 2px;
    font-family: 'Inter', sans-serif;
}
.filter-group select {
    width: 100%;
    padding: 2px 8px;
    border: 1px solid #8c8c8c;
    border-radius: 6px;
    font-family: 'Nunito', sans-serif;
    font-size: 0.6875rem;
    background: white;
    cursor: pointer;
    color: #373737;
    height: 24px;
}
.filter-group input[type="date"] {
    width: 100%;
    padding: 2px 8px;
    border: 1px solid #8c8c8c;
    border-radius: 6px;
    font-family: 'Nunito', sans-serif;
    font-size: 0.6875rem;
    background: white;
    height: 24px;
}

.variable-selector { margin-top: 4px; }
.variable-selector h4 { font-size: 0.75rem; color: var(--c-text-label); margin-bottom: 4px; font-weight: 600; }
.frame .var-btn {
    display: block;
    width: 100%;
    padding: 7px 10px;
    margin-bottom: 4px;
    border: 1px solid #8c8c8c !important;
    border-radius: 6px;
    background: white;
    font-family: 'Nunito', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: #373737;
}
.frame .var-btn.active {
    background: var(--c-primary) !important;
    color: white;
    border-color: var(--c-primary) !important;
}
.frame .var-btn:focus, .frame .var-btn:active { background: white !important; }
.frame .var-btn.active:focus, .frame .var-btn.active:active { background: var(--c-primary) !important; }

/* Main content */
.main-content {
    padding: 10px 16px 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
    min-height: 0;
}

/* Update badge */
.update-badge {
    background: var(--c-primary);
    color: white;
    padding: 0;
    height: 45px;
    font-size: 0.75rem;
    line-height: 1.4;
    text-align: center;
    margin-top: auto;
    margin-left: -15px;
    margin-right: -15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: 'Nunito', sans-serif;
    letter-spacing: -0.24px;
}

/* CARDS */
.kpi-row {
    display: grid;
    gap: 10px;
    flex-shrink: 0;
}
.kpi-row.cols-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-row.cols-5 { grid-template-columns: repeat(5, 1fr); }
.kpi-row.cols-8 { grid-template-columns: repeat(4, 1fr); }

.kpi-card {
    background: white;
    border-radius: 8px;
    padding: 4px 6px;
    text-align: center;
    box-shadow: 0px 4px 4px rgba(0,0,0,0.25);
    height: 70px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.kpi-card .kpi-icon {
    width: 26px;
    height: 26px;
    opacity: 0.7;
    flex-shrink: 0;
}
.kpi-card .kpi-label {
    font-size: 0.95rem;
    color: var(--c-text);
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    text-align: center;
    line-height: 1.2;
}
.kpi-card .kpi-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--c-text);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-family: 'Inter', sans-serif;
}
.kpi-card .kpi-value svg { width: 18px; height: 18px; }
.kpi-card .kpi-sub {
    font-size: 0.6rem;
    color: #888;
}
.kpi-card:has(.kpi-sub) {
    gap: 1px;
    padding: 2px 6px;
}
.kpi-card:has(.kpi-sub) .kpi-label { font-size: 0.82rem; }
.kpi-card:has(.kpi-sub) .kpi-value { font-size: 1.3rem; }

.kpi-card.green-border { border: 2px solid #27ae60; }
.kpi-card.red-border { border: 2px solid #e74c3c; }
.kpi-card .kpi-value.green { color: #27ae60; }
.kpi-card .kpi-value.red { color: #e74c3c; }

/* CHART CARDS */
.chart-grid {
    display: grid;
    gap: 10px;
    flex: 1;
    min-height: 0;
    align-items: stretch;
}
.chart-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.chart-grid.cols-3 { grid-template-columns: 2fr 1fr; }

.chart-card {
    background: white;
    border-radius: 12px;
    padding: 6px 10px;
    box-shadow: 0px 4px 4px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}
.chart-card h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--c-text);
    margin-bottom: 4px;
    flex-shrink: 0;
    font-family: 'Inter', sans-serif;
    text-align: left;
}
.chart-card canvas { flex: 1; min-height: 0; width: 100% !important; display: block; }

/* TABLES */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.7rem;
}
.data-table th {
    background: #f5f7f8;
    padding: 6px 8px;
    text-align: right;
    font-weight: 600;
    color: #444;
    border-bottom: 2px solid #e0e0e0;
    white-space: nowrap;
}
.data-table th:first-child { text-align: left; }
.data-table td {
    padding: 8px 8px;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
    text-align: right;
}
.data-table td:first-child { text-align: left; }
.data-table tr:hover { background: #f8fafa; }
.data-table .total-row { font-weight: 700; background: #f5f7f8; }

.semaphore {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    vertical-align: middle;
    line-height: 1;
}
.semaphore.red    { background: #fde8e8; color: #c0392b; }
.semaphore.yellow { background: #fef9e7; color: #b7770d; }
.semaphore.green  { background: #e8f8f0; color: #1e8449; }
.semaphore.red::before    { content: '▼'; font-size: 0.6rem; }
.semaphore.yellow::before { content: '▶'; font-size: 0.6rem; }
.semaphore.green::before  { content: '▲'; font-size: 0.6rem; }

.cell-green { background: #d4edda; color: #155724; font-weight: 600; }
.cell-red { background: #f8d7da; color: #721c24; font-weight: 600; }
.cell-yellow { background: #fff3cd; color: #856404; font-weight: 600; }

/* Expandable rows */
.expand-btn {
    background: none; border: none; cursor: pointer;
    display: inline-flex; align-items: center; gap: 5px;
    font-family: var(--font-ui); font-size: 0.7rem; font-weight: 600;
    color: var(--c-text); padding: 0; text-align: left;
}
.expand-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 13px; height: 13px; border: 1px solid rgba(0,0,0,0.5);
    border-radius: 3px; font-size: 0.65rem; font-weight: 700; flex-shrink: 0;
    line-height: 1; color: #444;
}
.sub-row { display: none; }
.sub-row td { background: #edeff0; font-size: 0.68rem; }
.sub-row td:first-child { padding-left: 22px; font-style: italic; color: #555; }

.value-bar {
    display: inline-block;
    height: 22px;
    border-radius: 4px;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    line-height: 18px;
}

/* TABS */
.tabs {
    display: flex;
    justify-content: center;
    gap: 0;
    margin-bottom: 8px;
    border-bottom: 2px solid #e0e0e0;
}
.tab-btn {
    padding: 6px 18px;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}
.tab-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.tab-btn.active {
    color: var(--c-primary-mid);
    border-bottom-color: var(--c-primary-mid);
    font-weight: 600;
}
.tab-btn:hover { color: var(--c-primary-mid); }
.tab-content { display: none; }
.tab-content.active { display: block; flex: 1; min-height: 0; overflow: auto; }

/* MAP */
#salesMap { flex: 1; min-height: 0; border-radius: 8px; }

/* LEGEND */
.chart-legend {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    margin-bottom: 4px;
    flex-wrap: wrap;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    color: #555;
}
.legend-dot {
    width: 10px; height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* Sort arrows */
.sort-arrows {
    display: inline-flex;
    flex-direction: column;
    gap: 0;
    margin-left: 4px;
    opacity: 0.4;
}
.sort-arrows svg { width: 10px; height: 10px; }
