@font-face {
    font-family: "Geist";
    src: url("fonts/Geist-Regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Geist";
    src: url("fonts/Geist-Medium.woff2") format("woff2");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Monaspace Neon";
    src: url("fonts/MonaspaceNeon-Regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Monaspace Neon";
    src: url("fonts/MonaspaceNeon-Medium.woff2") format("woff2");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

:root {
    color-scheme: light;

    --font-ui:
        "Geist",
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    --font-value:
        "Monaspace Neon",
        ui-monospace,
        SFMono-Regular,
        "SF Mono",
        Menlo,
        Consolas,
        "Liberation Mono",
        monospace;

    --bg: #f6f8fa;
    --panel: rgba(255, 255, 255, 0.82);
    --panel-strong: rgba(255, 255, 255, 0.94);
    --border: rgba(100, 116, 139, 0.20);
    --border-strong: rgba(100, 116, 139, 0.34);
    --text: #1e293b;
    --muted: #64748b;
    --focus: #94a3b8;
    --soft: #eef2f3;
    --danger-bg: #fff4f3;
    --danger-line: #e5c0bc;
    --danger-text: #8b4a44;
}

* {
    box-sizing: border-box;
}

html {
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-ui);
    color: var(--text);
    background:
        radial-gradient(circle at 8% 0%, rgba(214, 226, 229, 0.74), transparent 28rem),
        radial-gradient(circle at 100% 20%, rgba(238, 227, 218, 0.62), transparent 30rem),
        linear-gradient(180deg, #f8fafb 0%, #f2f5f5 58%, #f8f7f4 100%);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button,
select,
textarea {
    font-family: var(--font-ui);
}

button,
input {
    font: inherit;
}

.app-shell {
    width: min(100% - 16px, 760px);
    margin: 0 auto;
    padding: 10px 0 12px;
}

.panel {
    border: 1px solid var(--border);
    border-radius: 0.3rem;
    background: var(--panel);
    box-shadow: 0 12px 36px rgba(54, 68, 75, 0.07);
    backdrop-filter: blur(18px) saturate(112%);
    -webkit-backdrop-filter: blur(18px) saturate(112%);
    padding: 11px;
}

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

/* .btn sets no display, but be explicit so the hidden attribute cannot be
   defeated by a later rule. */
#install-button[hidden],
.install-hint[hidden] {
    display: none;
}

.install-hint {
    margin: -4px 0 10px;
    font-size: 0.78rem;
    color: var(--muted, inherit);
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: clamp(1.15rem, 5.6vw, 1.35rem);
    font-weight: 500;
    line-height: 1.18;
    letter-spacing: -0.035em;
}

.subtitle {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.76rem;
    line-height: 1.45;
}

.rate-grid,
.results {
    display: grid;
    gap: 10px;
}

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

.results {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 6px;
}

/* Mobile result composition: two aligned columns, wide detail cards full width. */
.result-card-wide {
    grid-column: 1 / -1;
}

.field-rate {
    grid-column: 1 / -1;
}

.field,
.field-network {
    min-width: 0;
}

.field {
    display: grid;
    gap: 4px;
}

.field label,
.field > span {
    display: block;
    margin: 0;
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 500;
    line-height: 1.25;
    color: var(--muted);
}

.field-network > span,
.field-network > small {
    min-width: 0;
}

.optional-tag {
    color: var(--muted);
    font-size: 0.62rem;
    font-style: normal;
    font-weight: 500;
}

.numeric-input,
.field input {
    display: block;
    width: 100%;
    min-width: 0;
    height: 40px;
    padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: 0.3rem;
    background: var(--panel);
    color: var(--text);
    font-family: var(--font-value);
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    font-feature-settings:
        "tnum" 1,
        "zero" 1;
    letter-spacing: -0.025em;
    outline: none;
    transition:
        border-color 120ms ease,
        box-shadow 120ms ease,
        background 120ms ease;
}

.numeric-input::placeholder,
.field input::placeholder {
    color: #94a3b8;
    font-weight: 400;
    opacity: 1;
}

.numeric-input:focus,
.field input:focus {
    border-color: var(--focus);
    box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.12);
    background: #ffffff;
}

.field small,
.result-card small,
.note {
    color: var(--muted);
    font-size: 0.65rem;
    line-height: 1.4;
}

.field-network small {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rate-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
}

.actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
    margin-top: 8px;
}

.btn {
    min-height: 40px;
    border-radius: 0.3rem;
    border: 1px solid transparent;
    cursor: pointer;
    padding: 0 11px;
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-weight: 500;
    transition: transform 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
}

.btn-primary {
    background: #34444b;
    border-color: #34444b;
    color: #ffffff;
}

.btn-secondary {
    background: rgba(250, 252, 252, 0.88);
    border-color: var(--border-strong);
    color: #536169;
}

.btn-compact {
    min-height: 40px;
    white-space: nowrap;
    padding-inline: 10px;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.56;
}

.result-card {
    min-height: 82px;
    border: 1px solid var(--border);
    border-radius: 0.3rem;
    background: rgba(255, 255, 255, 0.66);
    padding: 11px;
    display: grid;
    align-content: center;
    gap: 6px;
}

.result-card > span {
    color: #697880;
    font-size: 0.68rem;
    font-weight: 500;
}

.result-value,
.result-card strong {
    font-family: var(--font-value);
    font-variant-numeric: tabular-nums;
    font-feature-settings:
        "tnum" 1,
        "zero" 1;
    letter-spacing: -0.025em;
}

.form-error {
    margin-top: 9px;
    border: 1px solid var(--danger-line);
    border-radius: 0.3rem;
    background: var(--danger-bg);
    color: var(--danger-text);
    padding: 8px 10px;
    font-size: 0.7rem;
}

.note {
    margin: 12px 0 0;
}

.note code {
    color: #536169;
}

.rate-status {
    min-height: 1.15em;
}

.rate-status[data-state="success"] {
    color: #55766a;
}

.rate-status[data-state="error"] {
    color: #9c615b;
}

.rate-status[data-state="loading"],
.rate-status[data-state="manual"] {
    color: var(--muted);
}

.entry-section {
    margin-top: 8px;
    border: 1px solid var(--border);
    border-radius: 0.3rem;
    background: rgba(255, 255, 255, 0.48);
    padding: 10px;
}

.entry-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.entry-heading > div {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.section-label {
    color: #52616a;
    font-size: 0.72rem;
    font-weight: 500;
}

.entry-heading small {
    color: var(--muted);
    font-size: 0.65rem;
    line-height: 1.35;
}

.entry-list {
    display: grid;
    gap: 5px;
    margin-top: 6px;
}

.entry-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    align-items: center;
}

.entry-field {
    grid-template-columns: 64px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
}

.entry-field > span {
    white-space: nowrap;
}

.entry-field input {
    height: 36px;
}

.btn-remove-entry {
    min-height: 36px;
    border: 1px solid var(--border-strong);
    background: rgba(255, 255, 255, 0.7);
    color: #7d5b57;
    padding: 0 9px;
    font-size: 0.66rem;
}

.entry-breakdown {
    display: grid;
    gap: 6px;
    margin-top: 3px;
}

.breakdown-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    border-top: 1px dashed var(--border);
    padding-top: 5px;
}

.breakdown-row:first-child {
    border-top: 0;
    padding-top: 0;
}

.breakdown-row span {
    color: #697880;
    font-size: 0.62rem;
    font-weight: 500;
}

.breakdown-row code {
    color: #43525a;
    font-family: var(--font-value);
    font-size: 0.66rem;
    line-height: 1.45;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.empty-breakdown {
    color: var(--muted);
}

/* Detail rundown: full width, grouped by calculation stage. */
.result-card-detail {
    grid-column: 1 / -1;
    align-content: start;
}

.detail-list {
    display: grid;
    gap: 9px;
    margin-top: 3px;
}

.detail-group {
    display: grid;
    gap: 6px;
    border-top: 1px solid var(--border);
    padding-top: 9px;
}

.detail-group:first-child {
    border-top: 0;
    padding-top: 0;
}

/* Mobile-first: Network 1 and Network 2 stay aligned in two columns. */
@media (max-width: 540px) {
    .rate-grid {
        gap: 6px;
    }

    .results {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 5px;
    }

    .result-card {
        min-height: 64px;
        padding: 8px;
        align-content: start;
    }

    .result-card-wide {
        grid-column: 1 / -1;
    }

    .result-card > span {
        font-size: 0.64rem;
        line-height: 1.3;
    }

    .result-card small {
        font-size: 0.6rem;
    }

    .numeric-input,
    .field input {
        height: 38px;
        padding-inline: 9px;
        font-size: 12.5px;
    }

    .field label,
    .field > span {
        font-size: 10.5px;
    }

    .btn,
    .btn-compact {
        min-height: 38px;
    }
}

@media (max-width: 320px) {
    .entry-heading,
    .entry-row {
        grid-template-columns: 1fr;
    }

    .entry-heading .btn,
    .btn-remove-entry {
        width: 100%;
    }

    .entry-field {
        grid-template-columns: 1fr;
        gap: 4px;
    }

}

@media (min-width: 560px) {
    .app-shell {
        padding: 22px 0 30px;
    }

    .panel {
        padding: 18px;
    }

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

    .result-card-wide {
        grid-column: 1 / -1;
    }
}
