/* =========================================================================
   CakeHut Sales Trend Report - standalone stylesheet.
   This is the full stylesheet for this report (no separate style.css to
   load) - the brand variables and base/header/button rules below are
   copied from the main Kitchen Order Dashboard's stylesheet so this page
   looks identical whether it's opened from the dashboard or hosted on
   its own subdomain.
   ========================================================================= */

:root {
    --ch-orange: #F36B21;
    --ch-orange-dark: #D84A12;
    --ch-cream: #FFF4EA;
    --ch-brown: #4B2C20;
    --ch-white: #FFFFFF;
    --ch-border: #F0DCC9;
    --ch-shadow: 0 2px 10px rgba(75, 44, 32, 0.08);
    --ch-radius: 14px;
    --ch-red: #D64545;
    --ch-gray: #8A7B6F;
    --ch-header-h: 68px;

    --viz-surface: #fcfcfb;
    --viz-text-primary: #0b0b0b;
    --viz-text-secondary: #52514e;
    --viz-text-muted: #898781;
    --viz-grid: #e1e0d9;
    --viz-baseline: #c3c2b7;
    --viz-good: #006300;
    --viz-bad: #c0392b;

    --viz-series-1: #2a78d6; /* blue */
    --viz-series-2: #eb6834; /* orange */
    --viz-series-3: #1baf7a; /* aqua */
    --viz-series-4: #eda100; /* yellow */
    --viz-series-5: #e87ba4; /* magenta */
    --viz-series-6: #008300; /* green */
    --viz-series-7: #4a3aa7; /* violet */
    --viz-series-8: #e34948; /* red */
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--ch-cream);
    color: var(--ch-brown);
    font-family: 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 15px;
}

a { color: inherit; }

/* ---------------------------------------------------------------------
   Header (copied from the dashboard's style.css so this page matches)
   --------------------------------------------------------------------- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: var(--ch-header-h);
    background: var(--ch-white);
    border-bottom: 3px solid var(--ch-orange);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 20px;
    box-shadow: var(--ch-shadow);
}
.app-header__brand {
    display: flex;
    align-items: center;
    gap: 14px;
}
.app-header__logo {
    height: 44px;
    width: auto;
}
.app-header h1 {
    margin: 0;
    font-size: 18px;
    color: var(--ch-orange-dark);
}
.app-header__subtitle {
    margin: 0;
    font-size: 12px;
    color: var(--ch-gray);
}
.app-header__actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.db-error-banner {
    background: var(--ch-red);
    color: #fff;
    padding: 10px 16px;
    text-align: center;
    font-size: 14px;
}

.btn {
    border: none;
    border-radius: 30px;
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: transform .08s ease, box-shadow .08s ease;
}
.btn:active { transform: scale(0.97); }
.btn-ghost {
    background: var(--ch-cream);
    color: var(--ch-orange-dark);
    border: 1px solid var(--ch-orange);
}

.no-orders {
    text-align: center;
    color: var(--ch-gray);
    padding: 40px 0;
    font-size: 14px;
}

/* ---------------------------------------------------------------------
   Report content
   Categorical line colors below are the dataviz skill's validated
   8-hue default order (see references/palette.md) - CVD-checked, kept
   distinct from the single brand orange used for the yearly bar chart.
   --------------------------------------------------------------------- */
.analytics-content {
    max-width: 1180px;
    margin: 0 auto;
    padding: 22px 16px 60px;
}

/* KPI row */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.kpi-tile {
    background: var(--ch-white);
    border: 1px solid var(--ch-border);
    border-radius: var(--ch-radius);
    box-shadow: var(--ch-shadow);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.kpi-tile__label {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ch-gray);
    font-weight: 700;
}
.kpi-tile__value {
    font-size: 26px;
    font-weight: 700;
    color: var(--ch-brown);
    line-height: 1.15;
}
.kpi-tile__sub {
    font-size: 12.5px;
    color: var(--ch-gray);
}
.kpi-tile__delta {
    font-size: 12.5px;
    font-weight: 700;
}
.kpi-tile__delta.is-up { color: var(--viz-good); }
.kpi-tile__delta.is-down { color: var(--viz-bad); }

/* Chart cards */
.chart-card {
    background: var(--ch-white);
    border: 1px solid var(--ch-border);
    border-radius: var(--ch-radius);
    box-shadow: var(--ch-shadow);
    padding: 18px 20px 20px;
    margin-bottom: 20px;
}
.chart-card__head h2 {
    font-size: 16.5px;
    color: var(--ch-orange-dark);
    margin: 0 0 2px;
}
.chart-card__subtitle {
    font-size: 12.5px;
    color: var(--ch-gray);
    margin: 0 0 12px;
}

.trend-chart, .year-chart, .category-chart {
    position: relative;
    width: 100%;
    margin-top: 14px;
}
.trend-chart svg, .year-chart svg, .category-chart svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.viz-axis-label {
    font-size: 11px;
    fill: var(--viz-text-muted);
    font-family: 'Segoe UI', Roboto, Arial, sans-serif;
}
.viz-gridline { stroke: var(--viz-grid); stroke-width: 1; }
.viz-baseline { stroke: var(--viz-baseline); stroke-width: 1; }

.viz-line {
    fill: none;
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}
.viz-dot {
    stroke: var(--viz-surface);
    stroke-width: 2;
}
.viz-hit {
    fill: transparent;
    cursor: pointer;
}
.viz-bar {
    cursor: pointer;
    transition: opacity .1s;
}
.viz-bar:hover {
    opacity: .85;
}
.viz-end-label {
    font-size: 12px;
    font-weight: 700;
    font-family: 'Segoe UI', Roboto, Arial, sans-serif;
    fill: var(--viz-text-secondary);
}
.viz-bar-label {
    font-size: 12px;
    font-weight: 700;
    fill: var(--viz-text-primary);
    font-family: 'Segoe UI', Roboto, Arial, sans-serif;
}
.viz-bar-growth {
    font-size: 11.5px;
    font-weight: 700;
    font-family: 'Segoe UI', Roboto, Arial, sans-serif;
}
.viz-bar-growth.is-up { fill: var(--viz-good); }
.viz-bar-growth.is-down { fill: var(--viz-bad); }

/* Legend */
.viz-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--ch-border);
}
.viz-legend__item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--ch-brown);
}
.viz-legend__swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* Tooltip */
.viz-tooltip {
    position: absolute;
    pointer-events: none;
    background: var(--ch-brown);
    color: #fff;
    font-size: 12.5px;
    padding: 7px 10px;
    border-radius: 8px;
    box-shadow: var(--ch-shadow);
    z-index: 20;
    white-space: nowrap;
    transform: translate(-50%, -110%);
    opacity: 0;
    transition: opacity .1s;
}
.viz-tooltip.is-visible { opacity: 1; }
.viz-tooltip__title { font-weight: 700; margin-bottom: 2px; }

/* Detail table */
.table-scroll { overflow-x: auto; }
.analytics-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.analytics-table th {
    text-align: left;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--ch-gray);
    padding: 8px;
    border-bottom: 2px solid var(--ch-border);
    white-space: nowrap;
}
.analytics-table td {
    padding: 7px 8px;
    border-bottom: 1px solid var(--ch-border);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.analytics-table td.is-up { color: var(--viz-good); font-weight: 600; }
.analytics-table td.is-down { color: var(--viz-bad); font-weight: 600; }
.analytics-table th[data-sort] {
    cursor: pointer;
    user-select: none;
}
.analytics-table th[data-sort]:hover { color: var(--ch-orange-dark); }
.analytics-table th.is-sorted-asc::after { content: ' \25B2'; font-size: 9px; }
.analytics-table th.is-sorted-desc::after { content: ' \25BC'; font-size: 9px; }

/* ---------------------------------------------------------------------
   Filter bar (Order Status / Payment Mode)
   --------------------------------------------------------------------- */
.filter-bar {
    max-width: 1180px;
    margin: 0 auto;
    padding: 14px 16px 0;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 18px;
}
.filter-bar__group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.filter-bar__group label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--ch-gray);
    font-weight: 700;
}
.filter-bar__group select {
    padding: 8px 12px;
    border: 1px solid var(--ch-border);
    border-radius: 8px;
    background: var(--ch-white);
    color: var(--ch-brown);
    font-size: 13.5px;
    min-width: 180px;
}
.filter-bar__clear {
    font-size: 12.5px;
    color: var(--ch-orange-dark);
    text-decoration: none;
    font-weight: 600;
    padding-bottom: 9px;
}
.filter-bar__clear:hover { text-decoration: underline; }

/* ---------------------------------------------------------------------
   Two-column chart grid (status/payment, top products)
   --------------------------------------------------------------------- */
.chart-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.chart-grid-2 .chart-card { margin-bottom: 0; }
@media (max-width: 800px) {
    .chart-grid-2 { grid-template-columns: 1fr; }
}
.chart-grid-2 + .chart-grid-2,
.chart-grid-2 + .chart-card,
.chart-card + .chart-grid-2 {
    margin-top: 20px;
}

/* ---------------------------------------------------------------------
   Horizontal bar list (top products)
   --------------------------------------------------------------------- */
.hbar-chart { display: flex; flex-direction: column; gap: 10px; }
.hbar-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.hbar-row__label {
    width: 42%;
    flex-shrink: 0;
    font-size: 13px;
    color: var(--ch-brown);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hbar-row__track {
    flex: 1;
    height: 18px;
    background: var(--viz-grid);
    border-radius: 4px;
    position: relative;
}
.hbar-row__fill {
    height: 100%;
    border-radius: 0 4px 4px 0;
    min-width: 3px;
}
.hbar-row__value {
    flex-shrink: 0;
    min-width: 78px;
    text-align: right;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--viz-text-primary);
    font-variant-numeric: tabular-nums;
}
.hbar-empty {
    text-align: center;
    color: var(--ch-gray);
    font-size: 13px;
    padding: 24px 0;
}

/* ---------------------------------------------------------------------
   Stacked bar (status / payment distribution)
   --------------------------------------------------------------------- */
.stacked-bar {
    display: flex;
    width: 100%;
    height: 32px;
    border-radius: 6px;
    overflow: hidden;
    gap: 2px;
    background: var(--viz-surface);
}
.stacked-bar__segment {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 11.5px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
}

@media (max-width: 640px) {
    .kpi-tile__value { font-size: 21px; }
    .hbar-row__label { width: 34%; }
}
