:root {
    --bg: #f5f7f4;
    --panel: #ffffff;
    --ink: #20231f;
    --muted: #687064;
    --line: #dfe4da;
    --green: #2f7d4f;
    --blue: #276b8f;
    --red: #b63e35;
    --amber: #b98322;
    --shadow: 0 10px 28px rgba(31, 38, 29, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", Arial, sans-serif;
}

.app-shell {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 18px 14px 88px;
}

.topbar,
.quick-links,
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.topbar {
    align-items: flex-start;
    margin-bottom: 16px;
}

.quick-links {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.quick-links a,
.btn {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: 900;
    text-decoration: none;
}

.quick-links a {
    padding: 8px 11px;
    border: 1px solid var(--line);
    color: var(--green);
    background: var(--panel);
}

.eyebrow,
p {
    margin-top: 0;
}

.eyebrow {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 13px;
}

h1,
h2,
h3 {
    margin: 0;
}

h1 {
    font-size: 30px;
    line-height: 1.1;
}

h2 {
    font-size: 21px;
}

.toolbar,
.summary-card,
.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.toolbar {
    display: grid;
    gap: 12px;
    margin-bottom: 14px;
    padding: 14px;
}

.filter-row {
    display: grid;
    gap: 10px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

input,
button {
    font: inherit;
}

input {
    width: 100%;
    min-height: 44px;
    padding: 10px 11px;
    border: 1px solid #cbd4c4;
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
}

.btn {
    border: 0;
    padding: 10px 12px;
    color: #ffffff;
    background: var(--green);
    cursor: pointer;
}

.summary-grid,
.dashboard-grid,
.chart-list,
.rank-list,
.status-list,
.anomaly-list {
    display: grid;
    gap: 10px;
}

.summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 14px;
}

.summary-card {
    min-height: 92px;
    padding: 14px;
    border-left: 5px solid var(--green);
}

.summary-card.warning {
    border-left-color: var(--amber);
}

.summary-card span {
    display: block;
    margin-bottom: 6px;
    font-size: 26px;
    font-weight: 900;
    line-height: 1;
}

.summary-card p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.panel {
    display: grid;
    gap: 12px;
    margin-bottom: 14px;
    padding: 14px;
}

.chart-row,
.column-day,
.rank-row,
.status-row,
.anomaly-card {
    display: grid;
    gap: 9px;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfa;
}

.chart-label,
.status-row,
.anomaly-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.chart-label small,
.rank-row small,
.anomaly-card small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.bar-stack {
    display: grid;
    gap: 6px;
}

.bar-line {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 44px;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.bar-line i,
.rank-meter {
    height: 10px;
    border-radius: 999px;
    background: #edf1ea;
}

.bar-line i {
    display: block;
    background: var(--green);
}

.bar-line.muted i {
    background: var(--amber);
}

.column-day {
    gap: 12px;
}

.column-day-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.column-day-head small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.column-chart {
    display: flex;
    align-items: end;
    gap: 10px;
    min-height: 190px;
    overflow-x: auto;
    padding: 8px 2px 2px;
}

.column-item {
    width: 92px;
    min-width: 92px;
    display: grid;
    grid-template-rows: 150px auto auto;
    gap: 5px;
    text-align: center;
}

.column-bar-wrap {
    display: flex;
    align-items: end;
    justify-content: center;
    border-radius: 8px;
    background: #edf1ea;
}

.column-bar-wrap i {
    display: block;
    width: 30px;
    min-height: 4px;
    border-radius: 8px 8px 0 0;
    background: var(--green);
}

.column-bar-wrap .series-1 {
    background: var(--blue);
}

.column-bar-wrap .series-2 {
    background: var(--amber);
}

.column-bar-wrap .series-3 {
    background: #6f7f49;
}

.column-bar-wrap .series-4 {
    background: #8c5f3f;
}

.column-bar-wrap .series-5 {
    background: var(--red);
}

.column-item b {
    font-size: 18px;
    line-height: 1;
    white-space: nowrap;
}

.column-item span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
}

.chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.chart-legend i,
.grouped-bar i {
    background: var(--green);
}

.chart-legend i {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.chart-legend .series-1,
.grouped-bar .series-1 {
    background: var(--blue);
}

.chart-legend .series-2,
.grouped-bar .series-2 {
    background: var(--amber);
}

.chart-legend .series-3,
.grouped-bar .series-3 {
    background: #6f7f49;
}

.chart-legend .series-4,
.grouped-bar .series-4 {
    background: #8c5f3f;
}

.chart-legend .series-5,
.grouped-bar .series-5 {
    background: var(--red);
}

.chart-canvas-panel {
    min-height: 380px;
    height: clamp(380px, 48vw, 520px);
    overflow-x: auto;
}

.chart-canvas-panel canvas {
    min-width: 720px;
}

.chart-note {
    margin: -4px 0 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    line-height: 1.5;
}

.grouped-chart-scroll {
    overflow-x: auto;
    padding-bottom: 4px;
}

.grouped-chart {
    position: relative;
    min-width: 720px;
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    min-height: 330px;
    padding-top: 18px;
    overflow: visible;
}

.y-axis {
    grid-row: 1;
    display: grid;
    grid-template-rows: 1fr 1fr 1fr;
    align-items: start;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    justify-items: end;
    padding-right: 16px;
    overflow: visible;
}

.y-axis span {
    min-width: 3ch;
    text-align: right;
    white-space: nowrap;
    overflow: visible;
}

.plot-grid {
    position: absolute;
    left: 64px;
    right: 0;
    top: 28px;
    height: 220px;
    display: grid;
    grid-template-rows: 1fr 1fr 1fr;
    pointer-events: none;
}

.plot-grid i {
    border-top: 1px dashed #d9ded3;
}

.date-groups {
    position: relative;
    z-index: 1;
    grid-column: 2;
    display: flex;
    align-items: end;
    gap: 18px;
    min-height: 300px;
}

.date-group {
    min-width: 116px;
    display: grid;
    grid-template-rows: 230px auto auto;
    gap: 5px;
    justify-items: center;
}

.bar-group {
    display: flex;
    align-items: end;
    justify-content: center;
    gap: 5px;
    width: 100%;
    height: 220px;
    padding-top: 24px;
}

.grouped-bar {
    position: relative;
    width: 24px;
    height: 196px;
    display: flex;
    align-items: end;
    justify-content: center;
    overflow: visible;
}

.grouped-bar i {
    display: block;
    width: 18px;
    min-height: 0;
    border-radius: 5px 5px 0 0;
}

.grouped-bar em {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    color: var(--ink);
    font-size: 13px;
    font-style: normal;
    font-weight: 900;
    line-height: 1;
    min-width: 3ch;
    text-align: center;
    white-space: nowrap;
    overflow: visible;
    z-index: 2;
}

.grouped-bar.is-zero em {
    display: none;
}

.svg-chart-wrap {
    overflow-x: auto;
    padding-bottom: 4px;
}

.species-svg {
    display: block;
    max-width: none;
}

.species-svg .grid-line {
    stroke: #d9ded3;
    stroke-dasharray: 5 5;
    stroke-width: 1;
}

.species-svg .axis-label,
.species-svg .date-label,
.species-svg .total-label {
    fill: var(--muted);
    font-weight: 900;
}

.species-svg .axis-label {
    font-size: 13px;
}

.species-svg .date-label {
    font-size: 13px;
}

.species-svg .total-label {
    font-size: 12px;
}

.species-svg .bar-value {
    fill: var(--ink);
    font-size: 14px;
    font-weight: 900;
}

.species-svg .bar-rect {
    fill: var(--green);
}

.species-svg .series-1 {
    fill: var(--blue);
}

.species-svg .series-2 {
    fill: var(--amber);
}

.species-svg .series-3 {
    fill: #6f7f49;
}

.species-svg .series-4 {
    fill: #8c5f3f;
}

.species-svg .series-5 {
    fill: var(--red);
}

.date-group strong {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.date-group small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.rank-row {
    grid-template-columns: minmax(0, 1fr);
}

.rank-row strong,
.rank-row small {
    display: block;
}

.rank-meter {
    overflow: hidden;
}

.rank-meter i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--green);
}

.rank-row b {
    font-size: 18px;
}

.status-row span {
    color: var(--muted);
    font-weight: 900;
}

.status-row strong {
    font-size: 24px;
}

.anomaly-card {
    align-items: flex-start;
}

.anomaly-card p {
    margin: 0;
    color: var(--red);
    font-weight: 900;
}

.empty-state {
    padding: 14px;
    border: 1px dashed #c8d1c0;
    border-radius: 8px;
    color: var(--muted);
    background: #fbfcfa;
    text-align: center;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 18px;
    z-index: 30;
    transform: translate(-50%, 16px);
    max-width: min(460px, calc(100% - 28px));
    padding: 12px 14px;
    border-radius: 8px;
    background: #1f2a22;
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

@media (min-width: 760px) {
    .app-shell {
        padding: 26px 24px 96px;
    }

    .toolbar {
        grid-template-columns: minmax(0, 1fr) minmax(520px, auto);
        align-items: end;
    }

    .filter-row {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        align-items: end;
    }

    .summary-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .dashboard-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
    }

    .trend-panel {
        grid-column: span 2;
    }

    .rank-row {
        grid-template-columns: minmax(0, 1fr) minmax(120px, 0.8fr) auto;
        align-items: center;
    }
}
