:root {
    --footer-height: 42px;
    --gap: 16px;
    --pc-right-margin: 144px; /* base:48px */
    --pc-left-margin: 144px;
    --header-height: 42px;
    --row-height: 36px;
    --border-color: #d0d7de;
    --bg: #f6f8fa;
    --pane-bg: #ffffff;
    --accent: #2563eb;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    background: var(--bg);
    color: #1f2937;
    overflow: hidden;
}

body {
    display: grid;
    grid-template-rows: 1fr var(--footer-height);
}

.app {
    min-height: 0;
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    grid-template-areas: "table chart";
    gap: var(--gap);

    /* PC表示時：左ペインの左側と右ペインの右側に同じ余白を設ける */
    padding: var(--gap) var(--pc-right-margin) var(--gap) var(--pc-left-margin);

    overflow: hidden;
}

.pane {
    min-height: 0;
    background: var(--pane-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgb(0 0 0 / 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pane-header {
    flex: 0 0 auto;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 700;
    background: #ffffff; /*#e4ecfd;*/
}

.table-pane {
    grid-area: table;
    width: max-content;
}

.table-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

table {
    width: max-content;
    min-width: 280px;
    border-collapse: collapse;
    table-layout: auto;
    font-size: 14px;
}

thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    height: var(--header-height);
    background: #eef4ff;
    color: #111827;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

#data-table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    table-layout: auto;
    font-size: 14px;
}

.col-dt {
    width: 150px;
    text-align: center;
}

.col-val {
    width: 90px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

th,
td {
    height: var(--row-height);
    padding: 0 8px;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

td.value {
    text-align: center;
    font-variant-numeric: tabular-nums;
}

tbody tr:nth-child(even) {
    background: #fafafa;
}

.chart-pane {
    grid-area: chart;
    min-height: 0;
}

.chart-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
}

.chart-title {
    flex: 0 0 auto;
    font-size: 0.875rem;
    font-weight: 700;
    margin: 0 0 6px 0;
}

.chart-item {
    flex: 1 0 400px;
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

.chart-canvas-wrap {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
}

.chart-canvas-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

.fixed-footer {
    display: flex;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--footer-height);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #111827;
    color: #ffffff;
    font-size: 14px;
    z-index: 100;
}

#modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(236, 236, 236, 0.5)
}

#spinner {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    width: 8rem;
    height: 8rem;
    z-index: 9999;

    border: 0.3rem solid rgba(37, 99, 235, 0.15);
    border-top-color: #2563eb;
    border-radius: 50%;

    transform: translate(-50%, -50%);
    animation: spinner-rotate 0.9s linear infinite;
}

@keyframes spinner-rotate {
    from {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

@media (max-width: 768px) {
    .app {
        display: block;
        padding: 16px 0 16px 0;
        gap: 16px;
        overflow-y: auto;
        overflow-x: hidden;
        align-content: start;
    }

    .chart-pane {
        width: auto;
        height: auto;
        min-height: 0;
        overflow: visible;
        margin-bottom: var(--gap);
    }

    .chart-list {
        display: flex;
        flex-direction: column;
        gap: 16px;
        padding: 16px;
        flex: none;
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    .chart-item {
        flex: 0 0 auto;
        height: 360px;
        min-height: 360px;
        display: flex;
        flex-direction: column;
    }

    .chart-title {
        flex: 1 1 auto;
        min-height: 0;
        position: relative;
    }

    .chart-canvas-wrap {
        flex: 1 1 auto;
        min-height: 0;
        position: relative;
    }

    .table-pane {
        width: auto;
        height: auto;
        min-height: 0;
    }

    .table-scroll {
        flex: none;
        width: 100%;
        height: 400px;
        max-height: 400px;
        min-height: 0;
        overflow: auto;
    }

    .table-scroll table {
        width: 100%;
        min-width: 0;
        table-layout: fixed;
    }

    #data-table {
        width: max-content;
        min-width: 100%;
        table-layout: auto;
    }

    .col-dt {
        width: 60%;
    }

    .col-val {
        width: 40%;
    }
}

@media (max-width: 480px) {
    :root {
        --gap: 10px;
        --row-height: 34px;
        --header-height: 40px;
    }

    .pane-header {
        padding: 10px 12px;
    }

    th,
    td {
        padding: 0 8px;
        font-size: 13px;
    }
}