/* Shared Forecasting Current + Historic styles */

.forecasting-page .forecasting-header {
    background: linear-gradient(135deg, #4c1d95 0%, #6366f1 55%, #2563eb 100%);
    color: #fff;
    padding: 0.9rem 1.5rem;
    border-radius: 16px;
    box-shadow: 0 18px 45px rgba(99, 102, 241, 0.28);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.forecasting-page .forecasting-header .header-content {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    min-width: 0;
}

.forecasting-page .forecasting-header .header-text h1 {
    margin: 0;
    font-size: 1.55rem;
    font-weight: 600;
    color: #fff;
}

.forecasting-page .forecasting-header .header-text p {
    margin: 0.15rem 0 0;
    font-size: 0.9rem;
    color: #eff6ff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.forecasting-page .header-icon .page-icon,
.forecasting-page .header-icon svg {
    width: 2rem;
    height: 2rem;
    max-width: 2rem;
    max-height: 2rem;
    color: #fff;
    opacity: 0.95;
    display: block;
    flex-shrink: 0;
}

.forecasting-source-meta {
    font-size: 0.78rem;
    color: rgba(239, 246, 255, 0.9);
    max-width: 28rem;
    text-align: right;
    line-height: 1.35;
}

.forecasting-header-meta {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.forecasting-header-link {
    color: #eff6ff;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
}

.forecasting-header-link:hover {
    text-decoration: underline;
    color: #fff;
}

.forecasting-subnav {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0 0 0.75rem;
    padding: 0.2rem;
    width: fit-content;
    border-radius: 10px;
    background: #0f172a;
    border: 1px solid #334155;
}

.forecasting-subnav-link {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.85rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #94a3b8;
    text-decoration: none;
}

.forecasting-subnav-link:hover {
    color: #e2e8f0;
    background: rgba(148, 163, 184, 0.18);
    text-decoration: none;
}

.forecasting-subnav-link.active,
.forecasting-subnav-link.active:hover {
    color: #f8fafc;
    background: #334155;
    text-decoration: none;
}

.forecasting-api-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.forecasting-api-badge.online {
    background: rgba(52, 211, 153, 0.2);
    color: #d1fae5;
}

.forecasting-api-badge.offline {
    background: rgba(248, 113, 113, 0.2);
    color: #fecaca;
}

.forecasting-live-card {
    padding: 0.85rem 1.1rem 1rem;
    height: auto !important;
    align-self: start;
}

.forecasting-live-hint {
    margin: 0 0 0.65rem;
    color: #94a3b8;
    font-size: 0.85rem;
}

.forecasting-live-form {
    display: grid;
    grid-template-columns: minmax(12rem, 2fr) repeat(3, minmax(7rem, 1fr)) auto;
    gap: 0.75rem;
    align-items: end;
}

.forecasting-accuracy-page .forecasting-live-form {
    grid-template-columns: repeat(3, minmax(10rem, 1fr));
}

.forecasting-field label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 0.3rem;
}

.forecasting-field .form-select {
    background: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
}

.forecasting-generate-btn {
    white-space: nowrap;
    min-height: 38px;
}

.forecasting-live-result {
    display: grid;
    grid-template-columns: repeat(3, minmax(10rem, 1fr)) minmax(14rem, 1fr);
    grid-template-rows: auto auto;
    gap: 0.75rem;
    align-items: stretch;
    margin-top: 0.75rem !important;
}

.forecasting-result-stat {
    margin: 0;
    height: auto !important;
}

.forecasting-result-details {
    display: grid;
    grid-template-columns: 1fr;
    grid-column: 4;
    grid-row: 1;
    gap: 0.35rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid #334155;
    border-radius: 10px;
    background: #0f172a;
    align-content: center;
    height: auto;
}

.forecasting-result-details div {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.forecasting-result-details span {
    font-size: 0.7rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.forecasting-result-details strong {
    font-size: 0.88rem;
    color: #e2e8f0;
    font-weight: 600;
    word-break: break-word;
}

.forecasting-history-panel {
    grid-column: 1 / 4;
    grid-row: 2;
    padding: 0.45rem 0.7rem 0.55rem;
    border: 1px solid #334155;
    border-radius: 10px;
    background: #0f172a;
}

.forecasting-seasonal-panel {
    grid-column: 4;
    grid-row: 2;
}

.forecasting-history-panel .chart-title {
    font-size: 0.78rem;
}

.forecasting-history-panel .forecasting-live-hint {
    font-size: 0.7rem;
}

.forecasting-history-chart {
    position: relative;
    height: 105px;
    margin-top: 0.2rem;
}

.forecasting-history-message {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    color: #64748b;
    font-size: 0.85rem;
}

.forecasting-tekion-card {
    height: auto !important;
    align-self: start;
}

.forecasting-tekion-panel {
    height: 100%;
    padding: 0.75rem 0.85rem 0.85rem;
    border: 1px solid #334155;
    border-radius: 10px;
    background: #0f172a;
}

.forecasting-tekion-panel > .chart-title {
    margin-bottom: 0.5rem;
}

.forecasting-mini-metric {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid #334155;
    border-radius: 10px;
    background: #0f172a;
    height: 100%;
}

.forecasting-mini-metric span {
    font-size: 0.72rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.forecasting-mini-metric strong {
    font-size: 0.95rem;
    color: #e2e8f0;
    font-weight: 600;
}

.forecasting-dealer-link {
    background: none;
    border: none;
    padding: 0;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: default;
    text-decoration: none;
}

.forecasting-dealer-link:hover {
    color: inherit;
    text-decoration: none;
}

.forecasting-legacy-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.35rem;
    min-width: 1.05rem;
    height: 1.05rem;
    padding: 0 0.25rem;
    border-radius: 4px;
    background: rgba(251, 191, 36, 0.18);
    border: 1px solid rgba(251, 191, 36, 0.45);
    color: #fcd34d;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    vertical-align: middle;
    letter-spacing: 0.02em;
}

.forecasting-page .forecasting-forecast-value {
    color: #818cf8;
    font-weight: 700;
}

.forecasting-page .forecasting-fcst-curr {
    color: #2dd4bf;
    font-weight: 700;
}

.forecasting-page .forecasting-fcst-next {
    color: #818cf8;
    font-weight: 700;
}

.forecasting-rankings-table thead th {
    vertical-align: bottom;
}

.forecasting-rankings-table thead .forecasting-pred-group {
    text-align: center;
    letter-spacing: 0.04em;
    border-bottom: 1px solid #475569;
}

.forecasting-rankings-table thead tr:nth-child(2) th {
    font-size: 0.68rem;
    padding-top: 0.35rem;
}

.forecast-up {
    color: #34d399 !important;
    font-weight: 600;
}

.forecast-down {
    color: #f472b6 !important;
    font-weight: 600;
}

.forecasting-change-reason {
    max-width: 22rem;
    font-size: 0.78rem;
    color: #94a3b8;
    white-space: normal;
    line-height: 1.35;
}

.forecasting-change-reason-empty {
    color: #475569;
}

/* Historic page header variant */
.forecasting-accuracy-page .forecasting-accuracy-header {
    background: linear-gradient(135deg, #0f766e 0%, #0d9488 50%, #2563eb 100%);
    box-shadow: 0 18px 45px rgba(13, 148, 136, 0.28);
}

/* Filters must not stretch to fill the scroll body (dialpad .chart-card uses height: 100%) */
.forecasting-accuracy-page .forecasting-filters-card {
    height: auto !important;
}

/* Keep filters + summary cards fixed; only the results table scrolls */
.forecasting-accuracy-page .forecasting-accuracy-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    padding-bottom: 0.75rem;
}

.forecasting-accuracy-page .forecasting-accuracy-static {
    flex-shrink: 0;
}

.forecasting-accuracy-page .forecasting-accuracy-results-card {
    flex: 1 1 auto;
    min-height: 0;
    height: auto !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 0;
}

.forecasting-accuracy-page .forecasting-accuracy-results-card .chart-title {
    flex-shrink: 0;
}

.forecasting-accuracy-page .forecasting-accuracy-results-card .dialpad-stats-table-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding-bottom: 0.5rem;
}

.forecasting-accuracy-page .forecasting-accuracy-table {
    border-collapse: separate;
    border-spacing: 0;
}

.forecasting-accuracy-page .forecasting-accuracy-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #1e293b;
    box-shadow: inset 0 -1px 0 #334155;
}

.forecasting-accuracy-table th,
.forecasting-accuracy-table td {
    white-space: nowrap;
}

.forecasting-accuracy-notes {
    white-space: normal;
    min-width: 4.5rem;
}

.forecasting-clamp-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 0.12rem 0.4rem;
    border-radius: 999px;
    background: rgba(251, 191, 36, 0.2);
    color: #b45309;
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.forecasting-accuracy-page .forecast-up {
    color: #059669 !important;
}

.forecasting-accuracy-page .forecast-down {
    color: #dc2626 !important;
}

@media (max-width: 992px) {
    .forecasting-live-form,
    .forecasting-accuracy-page .forecasting-live-form {
        grid-template-columns: 1fr 1fr;
    }

    .forecasting-field-action {
        grid-column: 1 / -1;
    }

    .forecasting-live-result {
        grid-template-columns: 1fr;
    }

    .forecasting-result-details,
    .forecasting-history-panel,
    .forecasting-seasonal-panel {
        grid-column: 1;
        grid-row: auto;
    }
}

@media (max-width: 768px) {
    .forecasting-header-meta,
    .forecasting-source-meta {
        align-items: flex-start;
        text-align: left;
        max-width: 100%;
    }

    .forecasting-live-form,
    .forecasting-accuracy-page .forecasting-live-form {
        grid-template-columns: 1fr;
    }
}
