body {
    margin: 0;
    padding-top: 10px;
    overflow: hidden;
}
h3 {
    margin: 0.5em;
}

.icon {
    border-radius: 0.4em;
    width: 1.5rem;
    height: 1.5rem;
    font-size: 1.3rem;
    display: inline-block;
    text-align: center;
    align-content: center;
}

header {
    display: flex;
    white-space: nowrap;
    font-variant: small-caps;

    > * {
        text-decoration: none;
        margin: 0 0.25em;
        flex-shrink: 1;
    }

    textarea {
        height: 3rem;
    }

    /* current price box */
    .current {
        border: 1px dotted cadetblue;
        padding: 0.2em;
        max-width: 10em;
        margin-left: 2.2em;
        border-radius: 0.4em;
        background: palegreen;
        overflow: hidden;
        flex-shrink: 0;

        .unit {
            font-variant: all-small-caps;
            font-size: 0.75em;
        }
    }

    .popup {
        label {
            display: block;
            text-align: left;
            display: flex;
        }
        label > * {
            flex: 1;
        }
        label input {
            width: 6em;
            flex: none;

            &[type="checkbox"] {
                width: auto;
            }
        }
        .content {
            background: white;
            border-radius: 0 0.4em 0.4em 0.4em;
            display: none;
            position: absolute;
            flex-direction: column;
            gap: 1rem;
            padding: 0.5em;
            z-index: 1;
            border: 1px dotted;
        }
        .icon:hover {
            border-radius: 0.4em 0.4em 0 0;
        }
        .icon:hover ~ .content,
        .content:hover {
            display: flex;
            border-top: hidden;
        }
        .icon:has(~ .content:hover) {
            border-radius: 0.4em 0.4em 0 0;
        }

        &.queries {
            width: 100%;
            position: relative;
            .icon {
                border: 1px dotted darkkhaki;
                background: khaki;
            }
            .content {
                left: 0;
                right: 0;
                background: khaki;
                border-color: darkkhaki;
            }
            &:hover {
                .icon {
                    border-bottom-color: darkkhaki;
                }
            }
        }

        &.prices {
            .icon {
                border: 1px dotted cadetblue;
                background: skyblue;
            }
            .content {
                background: skyblue;
                border-color: cadetblue;
            }
            &:hover {
                .icon {
                    border-bottom-color: skyblue;
                }
            }
        }

        &.consumption {
            .icon {
                border: 1px dotted purple;
                background: plum;
            }
            .content {
                background: plum;
                border-color: purple;
            }
            &:hover {
                .icon {
                    border-bottom-color: plum;
                }
            }
            table {
                border: 1px solid purple;
                button {
                    float: right;
                }
                input[type="text"] {
                    max-width: 8em;
                    width: fit-content;
                }
            }
        }

        &.api {
            .content {
                right: 0;
            }
        }

    }

    #querypresets,
    #query {
        font-size: 0.65rem;
    }
    #query:hover,
    #query:focus {
        flex-shrink: 0;
    }
    
    .repo img {
        width: 1.25em;
        height: 1.25em;
    }
}

main {
    height: 80vh;
    height: calc(99dvh - 32px);

    /* show chart or tabular view */
    .mode {
        position: absolute;
        left: 5px;
        top: 9px;
        text-decoration: none;
    }

    #chart {
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    #price-chart,
    #consumption-chart,
    #cost-chart {
        flex: 1 1 auto;
        min-height: 0;
        display: none;
    }
    #price-chart,
    #consumption-chart:has(*),
    #cost-chart:has(*) {
        display: block;
    }

    #import-status {
        font-size: 0.75rem;
        color: cadetblue;
    }

    /* Tabular view */
    #table {
        display: none;
        overflow: scroll;
        height: 100%;

        &:target {
            display: flex;
        }
        &:target + #chart {
            display: none;
        }

        table {
            border: 1px solid lightgray;
            border-spacing: 2em 0.2em;
            margin: 1em;

            display: none;
            &:has(tbody tr) {
                display: table;
            }
        }
        th {
            text-align: left;
            border-bottom: 1px solid black;
            white-space: nowrap;
        }
    }
}

body:has(#consumptions-visible:not(:checked)) {
    #consumption-chart,
    #consumption-query {
        display: none;
    }
}
body:has(#costs-visible:not(:checked)) {
    #cost-chart,
    #costs-query {
        display: none;
    }
}

object {
    position:absolute;
    left: -99999px;
}