* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #151d24;
    background: #f7f9fb;
}

button,
input {
    font: inherit;
}

code {
    color: #3f4c56;
    font-size: 0.86rem;
}

.tool-page {
    width: min(1480px, 100%);
    margin: 0 auto;
    padding: 18px 20px 28px;
}

.app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 58px;
    margin: -18px -20px 14px;
    padding: 12px 20px;
    border-bottom: 1px solid #e3e9ee;
    background: #ffffff;
}

.brand-lockup {
    display: flex;
    align-items: center;
    min-width: 0;
}

.app-topbar h1 {
    margin: 0;
    color: #101820;
    font-size: 1.55rem;
    font-weight: 760;
    line-height: 1.18;
}

.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.account-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.account-status {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #f1f4f6;
    color: #536370;
    font-size: 0.82rem;
    font-weight: 720;
    white-space: nowrap;
}

.account-status.connected {
    background: #edf9ed;
    color: #208a3c;
}

.account-name {
    max-width: 180px;
    overflow: hidden;
    color: #33434f;
    font-size: 0.88rem;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.experimental-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding: 10px 14px;
    border: 1px solid #f0dc92;
    border-radius: 8px;
    background: #fffaf0;
    color: #654b00;
    font-size: 0.9rem;
    line-height: 1.4;
}

.experimental-banner strong {
    color: #151d24;
    font-weight: 760;
    white-space: nowrap;
}

.workspace-grid {
    display: grid;
    grid-template-columns: minmax(500px, 1.05fr) minmax(360px, 0.9fr) minmax(450px, 1.15fr);
    gap: 14px;
    align-items: start;
}

.left-stack,
.center-stack {
    display: grid;
    gap: 14px;
    min-width: 0;
}

.left-stack > *,
.center-stack > * {
    width: 100%;
    min-width: 0;
}

.panel,
.loading-panel {
    background: #ffffff;
    border: 1px solid #dfe6eb;
    border-radius: 8px;
    box-shadow: 0 10px 26px rgba(18, 32, 41, 0.05);
}

.panel {
    padding: 18px;
    min-width: 0;
}

.loading-panel {
    padding: 24px;
    color: #5d6c78;
}

.panel-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.panel-title h2 {
    margin: 0;
    color: #151d24;
    font-size: 1.05rem;
    font-weight: 760;
    line-height: 1.25;
}

.panel-title span {
    display: block;
    margin-top: 4px;
    color: #657482;
    font-size: 0.86rem;
    line-height: 1.35;
}

.count-pill,
.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 4px 12px;
    border-radius: 999px;
    background: #eef8f6;
    color: #008f83;
    font-size: 0.86rem;
    font-weight: 740;
    white-space: nowrap;
}

.status-pill {
    background: #f1f4f6;
    color: #657482;
}

.status-good {
    background: #edf9ed;
    color: #208a3c;
}

.status-pending {
    background: #fff7dc;
    color: #9a6a00;
}

.swatch,
.mini-swatch {
    display: inline-block;
    flex: 0 0 auto;
    background: var(--swatch-color);
    border: 1px solid rgba(21, 29, 36, 0.18);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.swatch {
    width: 34px;
    height: 34px;
    border-radius: 7px;
}

.large-swatch {
    width: 48px;
    height: 48px;
}

.mini-swatch {
    width: 14px;
    height: 14px;
    border-radius: 4px;
}

.base-summary {
    display: grid;
    gap: 4px;
    padding: 12px;
    border: 1px solid #e1e8ed;
    border-radius: 8px;
    background: #fafcfd;
}

.base-summary strong {
    color: #151d24;
    font-size: 0.95rem;
}

.base-summary span {
    color: #657482;
    font-size: 0.86rem;
}

.pellet-fields {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.text-input,
.number-input {
    width: 100%;
    min-width: 0;
    min-height: 38px;
    border: 1px solid #ccd8df;
    border-radius: 6px;
    background: #ffffff;
    color: #151d24;
    padding: 8px 10px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.text-input:focus,
.number-input:focus {
    border-color: #00998f;
    box-shadow: 0 0 0 3px rgba(0, 153, 143, 0.13);
}

.color-line,
.quantity-row,
.range-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-input {
    width: 44px;
    height: 34px;
    padding: 2px;
    border: 1px solid #ccd8df;
    border-radius: 6px;
    background: #ffffff;
    cursor: pointer;
}

.field-label {
    display: block;
    margin: 14px 0 6px;
    color: #33434f;
    font-size: 0.84rem;
    font-weight: 700;
}

.range-row {
    min-width: 0;
}

.range-row > input[type="range"] {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    accent-color: #00998f;
}

.percent-control {
    display: grid;
    grid-template-columns: 54px 24px;
    align-items: center;
    flex: 0 0 78px;
    width: 78px;
    overflow: hidden;
    border: 1px solid #ccd8df;
    border-radius: 6px;
    background: #ffffff;
}

.percent-control input {
    width: 100%;
    min-width: 0;
    min-height: 34px;
    border: 0;
    color: #008f83;
    font-size: 0.9rem;
    font-weight: 740;
    text-align: right;
    outline: none;
}

.percent-control span {
    display: grid;
    place-items: center;
    min-height: 34px;
    border-left: 1px solid #e1e8ed;
    color: #008f83;
    font-size: 0.86rem;
    font-weight: 740;
    background: #f7f9fb;
}

.model-note,
.empty-state,
.pending-note {
    margin-top: 14px;
    padding: 12px;
    border-radius: 8px;
    background: #f3f7f8;
    color: #5d6c78;
    font-size: 0.9rem;
    line-height: 1.45;
}

.pending-note {
    margin-bottom: 14px;
    border: 1px solid #f0dc92;
    background: #fffaf0;
    color: #7a5a00;
}

.add-wide-button {
    width: 100%;
    margin-bottom: 12px;
}

.pellet-table-head,
.pellet-row {
    display: grid;
    grid-template-columns: 58px 58px minmax(120px, 1fr) minmax(82px, 0.65fr) auto;
    gap: 10px;
    align-items: center;
}

.pellet-table-head {
    min-height: 36px;
    padding: 0 8px;
    border: 1px solid #e1e8ed;
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    background: #fafcfd;
    color: #536370;
    font-size: 0.82rem;
    font-weight: 700;
}

.pellet-list {
    border: 1px solid #e1e8ed;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

.pellet-row {
    min-height: 56px;
    padding: 8px;
    border-bottom: 1px solid #e8eef2;
    background: #ffffff;
}

.pellet-row:last-child {
    border-bottom: 0;
}

.toggle-line {
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-line input {
    width: 18px;
    height: 18px;
    accent-color: #00998f;
}

.mode-tabs {
    display: flex;
    gap: 30px;
    margin: 2px 0 18px;
    border-bottom: 1px solid #e1e8ed;
}

.mode-tabs button {
    appearance: none;
    border: 0;
    background: transparent;
    padding: 0 0 10px;
    color: #536370;
    font-size: 0.9rem;
    font-weight: 650;
    cursor: pointer;
}

.mode-tabs .active {
    color: #008f83;
    border-bottom: 2px solid #00998f;
}

.target-form-panel {
    display: grid;
    gap: 14px;
}

.wide-chip {
    height: 128px;
}

.rgb-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.rgb-grid label {
    display: grid;
    gap: 6px;
}

.rgb-grid span {
    color: #33434f;
    font-size: 0.84rem;
    font-weight: 700;
}

.target-picker-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 118px;
    gap: 18px;
    align-items: start;
}

.target-preview {
    display: grid;
    place-items: center;
    min-height: 238px;
    border-radius: 8px;
    border: 1px solid rgba(21, 29, 36, 0.12);
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.06)),
        var(--preview-color);
}

.target-preview input {
    width: 88px;
    height: 58px;
    padding: 4px;
    border: 1px solid rgba(21, 29, 36, 0.22);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.82);
    cursor: pointer;
}

.target-side {
    display: grid;
    gap: 14px;
}

.target-chip {
    width: 100%;
    height: 94px;
    border: 1px solid rgba(21, 29, 36, 0.12);
    border-radius: 8px;
    background: var(--preview-color);
}

.target-history {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #e1e8ed;
}

.target-history h3 {
    margin: 0 0 10px;
    color: #33434f;
    font-size: 0.9rem;
    font-weight: 760;
}

.target-history > div {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.target-history button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    max-width: 126px;
    border: 1px solid #d7e1e7;
    border-radius: 999px;
    background: #ffffff;
    color: #33434f;
    padding: 4px 10px 4px 6px;
    cursor: pointer;
}

.target-history button::before {
    content: "";
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    border: 1px solid rgba(21, 29, 36, 0.18);
    border-radius: 50%;
    background: var(--history-color);
}

.target-history span {
    overflow: hidden;
    font-size: 0.82rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quantity-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 28px;
    overflow: hidden;
    border: 1px solid #ccd8df;
    border-radius: 8px;
}

.quantity-row .number-input {
    min-height: 52px;
    border: 0;
    border-radius: 0;
    font-size: 1.16rem;
}

.quantity-row span {
    display: grid;
    place-items: center;
    border-left: 1px solid #e1e8ed;
    color: #536370;
    background: #f7f9fb;
}

.calculate-button {
    width: 100%;
    min-height: 52px;
    margin-top: 18px;
    font-size: 1rem;
    font-weight: 760;
}

.calculate-button.ant-btn-primary {
    background: #00998f;
    border-color: #00998f;
}

.result-preview {
    display: grid;
    grid-template-columns: minmax(180px, 0.95fr) minmax(160px, 0.75fr);
    gap: 22px;
    align-items: start;
    margin-bottom: 22px;
}

.result-color {
    width: 100%;
    min-height: 245px;
    border: 1px solid rgba(21, 29, 36, 0.12);
    border-radius: 8px;
    background: var(--swatch-color);
}

.result-metrics {
    display: grid;
    gap: 20px;
}

.result-metrics span {
    display: block;
    color: #657482;
    font-size: 0.86rem;
}

.result-metrics strong {
    display: block;
    margin-top: 4px;
    color: #151d24;
    font-size: 1.02rem;
}

.subsection-title {
    margin: 0 0 12px;
    color: #151d24;
    font-size: 1rem;
    font-weight: 760;
}

.ingredient-table {
    border: 1px solid #e1e8ed;
    border-radius: 8px;
    overflow: hidden;
}

.ingredient-table-head,
.ingredient-row {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) minmax(130px, 0.9fr) 72px 70px;
    gap: 12px;
    align-items: center;
}

.ingredient-table-head {
    min-height: 42px;
    padding: 0 12px;
    background: #fafcfd;
    color: #536370;
    font-size: 0.82rem;
    font-weight: 760;
}

.ingredient-table-head span:nth-child(2) {
    grid-column: 3;
}

.ingredient-table-head span:nth-child(3) {
    grid-column: 4;
}

.ingredient-row {
    min-height: 58px;
    padding: 10px 12px;
    border-top: 1px solid #e8eef2;
    background: #ffffff;
}

.ingredient-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.ingredient-heading strong {
    min-width: 0;
    overflow-wrap: anywhere;
    color: #22313b;
    font-size: 0.94rem;
}

.mix-bar {
    height: 9px;
    overflow: hidden;
    border-radius: 999px;
    background: #e6edf1;
}

.mix-bar span {
    display: block;
    width: var(--mix-width);
    height: 100%;
    background: var(--mix-color);
    box-shadow: inset 0 0 0 1px rgba(21, 29, 36, 0.16);
}

.percent-value {
    color: #008f83;
    font-weight: 760;
    text-align: right;
}

.grams-value {
    color: #536370;
    text-align: right;
}

.ant-alert {
    margin-bottom: 14px;
    border-radius: 8px;
}

#blazor-error-ui {
    color-scheme: light only;
    display: none;
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1000;
    max-width: 460px;
    padding: 12px 42px 12px 14px;
    border: 1px solid #f0c36b;
    border-radius: 8px;
    background: #fff8e1;
    color: #4d3a05;
    box-shadow: 0 12px 30px rgba(18, 32, 41, 0.16);
}

#blazor-error-ui .reload {
    color: #8a6100;
    font-weight: 700;
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: 10px;
    right: 12px;
    cursor: pointer;
}

.loading-progress {
    position: relative;
    display: block;
    width: 88px;
    height: 88px;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: #dce5ea;
    stroke-width: 0.6rem;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
}

.loading-progress circle:last-child {
    stroke: #00998f;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    inset: calc(20vh + 34px) 0 auto 0;
    text-align: center;
    color: #5d6c78;
    font-weight: 700;
}

.loading-progress-text::after {
    content: var(--blazor-load-percentage-text, "Loading");
}

@media (max-width: 1420px) {
    .workspace-grid {
        grid-template-columns: 1fr 1fr;
    }

    .result-panel {
        grid-column: 1 / -1;
    }
}

@media (max-width: 820px) {
    .tool-page {
        padding: 14px;
    }

    .app-topbar {
        display: grid;
        margin: -14px -14px 14px;
        padding: 14px;
    }

    .app-topbar h1 {
        margin: 0;
        font-size: 1.9rem;
    }

    .header-actions {
        display: grid;
        justify-content: stretch;
    }

    .header-actions .ant-btn,
    .account-summary {
        width: 100%;
    }

    .account-summary {
        display: grid;
        grid-template-columns: 1fr;
    }

    .account-name {
        max-width: none;
    }

    .experimental-banner {
        display: grid;
    }

    .workspace-grid {
        grid-template-columns: 1fr;
    }

    .pellet-table-head {
        display: none;
    }

    .pellet-list {
        border-radius: 8px;
    }

    .pellet-row {
        grid-template-columns: 44px 58px minmax(0, 1fr);
        gap: 10px;
        padding: 12px;
    }

    .pellet-row code {
        grid-column: 2 / -1;
    }

    .pellet-row .ant-btn {
        grid-column: 1 / -1;
        justify-self: center;
    }

    .target-picker-grid,
    .result-preview,
    .ingredient-table-head,
    .ingredient-row {
        grid-template-columns: 1fr;
    }

    .target-preview,
    .result-color {
        min-height: 190px;
    }

    .ingredient-table-head {
        display: none;
    }

    .percent-value,
    .grams-value {
        text-align: left;
    }
}
