
:root {
    --base-yellow: #F3A800;
    --base-yellow-dark: #D99500;
    --base-gold: #B4A269;
    --base-gray: #6F7271;
    --base-dark: #343837;
    --green: #15803D;
    --background: #F5F5F3;
    --white: #FFFFFF;
    --text: #343837;
    --muted: #6F7271;
    --border: #DEDFDC;
    --danger: #B91C1C;
    --danger-light: #FEF2F2;
    --radius: 14px;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont,
        "Segoe UI", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
    touch-action: manipulation;
}

.app {
    max-width: 1120px;
    margin: 0 auto;
    padding: 24px;
}

/* HEADER */

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 3px solid var(--base-yellow);
}

.brand-group {
    display: flex;
    align-items: center;
    gap: 24px;
    min-width: 0;
}

.brand-logo {
    display: block;
    width: 160px;
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

.brand-divider {
    width: 1px;
    height: 44px;
    background: var(--border);
    flex-shrink: 0;
}

.app-header h1 {
    margin: 0;
    font-size: 30px;
    font-weight: 750;
    letter-spacing: -1px;
    color: var(--base-dark);
}

.app-header p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.version {
    background: #EAEAE6;
    color: var(--muted);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

/* MAIN LAYOUT */

.workspace {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: stretch;
}

.panel {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: 0 2px 8px rgba(52, 56, 55, 0.04);
}

.panel h2 {
    margin: 0 0 18px;
    font-size: 17px;
    font-weight: 700;
    color: var(--base-dark);
}

/* INPUTS */

.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px 14px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.full-width {
    grid-column: 1 / -1;
}

label {
    font-size: 12px;
    font-weight: 650;
    color: var(--muted);
}

input,
select {
    width: 100%;
    min-width: 0;
    height: 50px;
    padding: 10px 13px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--base-dark);
    font-size: 20px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    outline: none;
}

select {
    font-size: 16px;
    cursor: pointer;
}

input::placeholder {
    color: #B5B8B5;
    font-weight: 400;
}

input:focus,
select:focus {
    border-color: var(--base-yellow);
    box-shadow: 0 0 0 3px rgba(243, 168, 0, 0.15);
}

button:focus-visible {
    outline: 3px solid var(--base-yellow);
    outline-offset: 3px;
}

/* MARKET WARNINGS */

input.market-warning,
input[aria-invalid="true"] {
    border-color: var(--danger);
    background: var(--danger-light);
    color: var(--danger);
}

input.market-warning:focus,
input[aria-invalid="true"]:focus {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.10);
}

.market-warning-message {
    margin: 0;
    color: var(--danger);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

/* CALCULATED CROSS RATE */

.cross-rate-field {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 14px;
    background: #FAF8F0;
    border: 1px solid #E6DFC8;
    border-left: 3px solid var(--base-gold);
    border-radius: 9px;
}

.cross-rate-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.cross-rate-value {
    color: var(--base-dark);
    font-size: 20px;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

/* SEGMENTED BUTTONS */

.segmented {
    display: flex;
    align-items: stretch;
    min-height: 50px;
    padding: 4px;
    gap: 3px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #F1F1EE;
}

.segmented button {
    flex: 1;
    min-width: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    padding: 9px 10px;
}

.segmented button.active {
    background: var(--base-yellow);
    color: var(--base-dark);
    box-shadow: 0 1px 4px rgba(52, 56, 55, 0.12);
}

.segmented button:hover:not(.active) {
    background: #E8E8E3;
}

.amount-group {
    display: flex;
    gap: 8px;
}

.amount-group input {
    flex: 1;
    min-width: 0;
}

.amount-group .segmented {
    flex-shrink: 0;
    width: 132px;
}

/* RESULTS */

.results-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.rate-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 165px;
    padding: 24px 16px;
    background: var(--base-yellow);
    color: var(--base-dark);
    border-radius: var(--radius);
}

.rate-card .metric-label {
    color: #4D3C12;
    font-size: 12px;
    letter-spacing: 1.2px;
    font-weight: 700;
}

.main-rate {
    font-size: clamp(42px, 5vw, 60px);
    font-weight: 750;
    letter-spacing: -2px;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    margin: 8px 0;
    overflow-wrap: anywhere;
}

#rateDescription {
    color: #4D3C12;
    font-size: 13px;
    font-weight: 600;
}

/* METRIC WIDGETS */

.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    flex: 1;
}

.metric-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    min-height: 105px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.metric-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.metric-card strong {
    color: var(--base-dark);
    font-size: clamp(19px, 2.2vw, 27px);
    font-weight: 750;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.6px;
    overflow-wrap: anywhere;
}

.profit-card strong {
    color: var(--green);
}

.metric-unit {
    font-size: 12px;
    color: var(--muted);
}

/* COMMERCIAL QUOTE */

.quote-panel {
    margin-top: 16px;
}

.quote-preview {
    margin: 0 0 14px;
    padding: 16px;
    background: #F7F7F4;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.65;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: var(--text);
}

.copy-button {
    width: 100%;
    min-height: 48px;
    border: none;
    border-radius: 9px;
    background: var(--base-yellow);
    color: var(--base-dark);
    font-size: 15px;
    font-weight: 750;
}

.copy-button:hover:not(:disabled) {
    background: var(--base-yellow-dark);
}

.copy-button:disabled {
    background: #E4E5E1;
    color: #858984;
    cursor: not-allowed;
}

.copy-status {
    margin: 0;
    color: var(--green);
    font-size: 13px;
    text-align: center;
}

.copy-status:not(:empty) {
    margin-top: 10px;
}

.copy-status.error {
    color: var(--danger);
}

.validation-message {
    margin: 0;
    color: var(--danger);
    font-size: 12px;
    line-height: 1.5;
}

.validation-message:not(:empty) {
    margin-top: 12px;
}

/* FOOTER */

footer {
    padding: 18px 0 4px;
    text-align: center;
    color: var(--muted);
    font-size: 11px;
}

/* MOBILE */

@media (max-width: 760px) {

    .app {
        padding: 14px;
    }

    .app-header {
        margin-bottom: 16px;
        padding-bottom: 16px;
    }

    .brand-group {
        gap: 12px;
    }

    .brand-logo {
        width: 110px;
    }

    .brand-divider {
        height: 36px;
    }

    .app-header h1 {
        font-size: 23px;
    }

    .app-header p {
        font-size: 11px;
    }

    .version {
        font-size: 10px;
        padding: 5px 8px;
    }

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

    .panel {
        padding: 16px;
    }

    .input-grid {
        gap: 16px 10px;
    }

    input {
        font-size: 19px;
    }

    select {
        font-size: 16px;
    }

    .segmented button {
        font-size: 12px;
        padding: 9px 6px;
    }

    .rate-card {
        min-height: 150px;
    }

    .main-rate {
        font-size: 52px;
    }

    .metric-card {
        padding: 13px;
        min-height: 100px;
    }

    .metric-card strong {
        font-size: 22px;
    }

    .metric-label {
        font-size: 11px;
    }

    .amount-group .segmented {
        width: 120px;
    }

    .quote-panel {
        margin-top: 14px;
    }

    .copy-button {
        min-height: 52px;
        font-size: 16px;
    }
}

@media (max-width: 360px) {

    .app {
        padding: 10px;
    }

    .brand-group {
        gap: 8px;
    }

    .brand-logo {
        width: 90px;
    }

    .app-header h1 {
        font-size: 20px;
    }

    .brand-divider {
        display: none;
    }

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

    .metric-card strong {
        font-size: 19px;
    }

    .main-rate {
        font-size: 44px;
    }
}
