:root {
  color-scheme: light;
  --page: var(--tg-theme-bg-color, #ffffff);
  --surface: var(--tg-theme-secondary-bg-color, #f3f5f7);
  --text: var(--tg-theme-text-color, #17212b);
  --muted: var(--tg-theme-subtitle-text-color, var(--tg-theme-hint-color, #576676));
  --accent: var(--tg-theme-button-color, #2175b5);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --line: #dce2e7;
  --error: #bb3344;
  --error-surface: #fff0f1;
  --focus: #2286cf;
  --selection: #d8eaf8;
  --radius: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--text); background: var(--page); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
body.dark { color-scheme: dark; --muted: var(--tg-theme-subtitle-text-color, var(--tg-theme-hint-color, #a8b5c2)); --line: #394651; --error: #ff9ba6; --error-surface: #482c33; --selection: #285379; }
::selection { background: var(--selection); color: var(--text); }
button, input { font: inherit; }
button, label, input { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
input { min-width: 0; accent-color: var(--accent); caret-color: var(--accent); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
button:disabled { cursor: wait; }
[hidden] { display: none !important; }
.app { width: min(100%, 520px); margin: 0 auto; padding: max(20px, env(safe-area-inset-top)) 22px 0; }
.header { margin-bottom: 18px; }
h1 { font-size: 27px; line-height: 1.15; letter-spacing: -.025em; font-weight: 700; margin: 0 0 7px; }
.header p { margin: 0; color: var(--muted); font-size: 14px; }
.order-reference { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin-top: 10px; font-size: 14px; font-variant-numeric: tabular-nums; }
.order-reference .copy-button { padding-inline: 0; }
.header #edit-load-status { margin-top: 12px; }
.form-body { padding-bottom: 18px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.customer-row { margin-bottom: 16px; }
.amount-row { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
.field { min-width: 0; }
.field > label, legend { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.field input { display: block; width: 100%; height: 49px; padding: 12px 13px; color: var(--text); background: var(--surface); border: 1px solid transparent; border-radius: var(--radius); font-size: 16px; line-height: 24px; transition: border-color .15s; }
.field input:hover { border-color: var(--line); }
.field input:focus { border-color: var(--accent); outline: none; }
.field input[aria-invalid="true"] { border-color: var(--error); }
.field input::placeholder { color: var(--muted); opacity: 1; font-size: 14px; }
.field-error { display: block; font-size: 12px; color: var(--error); line-height: 1.4; }
.field-error:not(:empty) { margin-top: 6px; }
.input-wrap { position: relative; }
.input-wrap input { padding-right: 51px; font-variant-numeric: tabular-nums; }
#tariff { padding-right: 34px; }
.input-unit { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--muted); pointer-events: none; }
.currency-field { margin: 0 0 16px; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; }
.currency-options { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.currency-options label { min-width: 0; cursor: pointer; position: relative; }
.currency-options input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.currency-options span { min-height: 43px; padding: 9px 3px; background: var(--surface); border-radius: 10px; font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 5px; border: 1px solid transparent; transition: background .15s, color .15s; }
.currency-options b { font-size: 16px; font-weight: 500; }
.currency-options input:checked + span { background: var(--accent); color: var(--accent-text); }
.currency-options input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 3px; }
.currency-options label:hover input:not(:checked) + span { border-color: var(--line); }
.rate-source-field { margin: 0 0 18px; padding: 0; border: 0; min-width: 0; }
.rate-options { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
.rate-options label { min-width: 0; cursor: pointer; position: relative; }
.rate-options input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.rate-options span { min-height: 43px; padding: 10px 12px; background: var(--surface); border-radius: 10px; border: 1px solid transparent; display: flex; align-items: center; justify-content: center; color: var(--text); font-size: 13px; font-weight: 600; }
.rate-options input:checked + span { background: var(--accent); color: var(--accent-text); }
.rate-options input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 3px; }
.rate-options label:hover input:not(:checked) + span { border-color: var(--line); }
.rate-options input:disabled + span { cursor: default; }
.manual-rate-field { margin-top: 12px; }
.manual-rate-equation { display: flex; align-items: center; gap: 10px; }
.manual-rate-equation > span { flex: 0 0 auto; font-size: 14px; font-variant-numeric: tabular-nums; }
.manual-rate-equation .input-wrap { min-width: 0; flex: 1; }
#quote-status { color: var(--error); overflow-wrap: anywhere; }
#rate-value { white-space: normal; overflow-wrap: anywhere; min-width: 0; }
.hint { font-size: 12px; line-height: 1.5; color: var(--muted); margin: 8px 0 0; }
.tariff-hint { text-align: right; margin-bottom: 17px; }
.delivery-section { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.delivery-toggle { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 70px; cursor: pointer; }
.delivery-label { display: flex; align-items: center; gap: 11px; }
.delivery-label strong { display: block; font-size: 14px; font-weight: 600; }
.delivery-label small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.delivery-icon { color: var(--muted); width: 25px; height: 25px; flex: 0 0 auto; }
.delivery-icon svg { width: 100%; height: 100%; }
.delivery-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch { display: block; width: 45px; height: 27px; flex: 0 0 45px; border-radius: 20px; background: #8b98a6; padding: 3px; transition: background .15s; }
.switch::before { content: ""; display: block; width: 21px; height: 21px; border-radius: 50%; background: #fff; transition: transform .18s cubic-bezier(.16,1,.3,1); }
.delivery-toggle input:checked + .switch { background: var(--accent); }
.delivery-toggle input:checked + .switch::before { transform: translateX(18px); }
.delivery-toggle input:focus-visible + .switch { outline: 2px solid var(--focus); outline-offset: 4px; }
.delivery-fields { padding: 0 0 17px 36px; display: grid; grid-template-columns: minmax(130px, 1fr) 1fr; gap: 12px; align-items: center; }
.delivery-fields .hint { margin: 24px 0 0; }
.calculation { padding-top: 12px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.calculation-row { display: flex; justify-content: space-between; gap: 12px; }
.calculation-row > :last-child { text-align: right; white-space: nowrap; }
#breakdown { margin-top: 10px; display: grid; gap: 5px; }
.edit-comparison { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 6px; color: var(--text); font-size: 14px; }
.edit-comparison .calculation-row > :last-child { white-space: normal; overflow-wrap: anywhere; }
.edit-comparison .rounding-note { margin-top: 6px; }
.rounding-note { margin: 3px 0 0; font-size: 12px; line-height: 1.4; color: var(--muted); }
.submit-bar { position: sticky; bottom: 0; z-index: 2; background: var(--page); padding: 15px 0 max(18px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.total-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 15px; }
.total-label { margin: 0 0 2px; font-size: 14px; font-weight: 600; }
.total-note { margin: 0; font-size: 12px; color: var(--muted); }
.payment-warning { margin: -4px 0 12px; color: var(--text); font-size: 13px; font-weight: 600; }
.total { text-align: right; font-size: clamp(22px, 6vw, 29px); font-weight: 700; letter-spacing: -.025em; font-variant-numeric: tabular-nums; line-height: 1.2; overflow-wrap: anywhere; }
.total span { font-size: 13px; letter-spacing: 0; font-weight: 500; margin-left: 2px; }
.primary-button { display: flex; align-items: center; justify-content: center; gap: 10px; position: relative; border: 0; width: 100%; min-height: 51px; padding: 13px 18px; border-radius: var(--radius); background: var(--accent); color: var(--accent-text); font-size: 15px; font-weight: 600; line-height: 1.4; }
.primary-button:hover { filter: brightness(.94); }
.primary-button:active { filter: brightness(.88); }
.primary-button:disabled { filter: none; }
.button-arrow { width: 19px; height: 19px; position: absolute; right: 16px; }
.primary-button:disabled .button-arrow { display: none; }
.spinner { height: 16px; width: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { padding: 12px 14px; border-radius: 9px; margin-bottom: 18px; font-size: 13px; }
.notice-error { color: var(--error); background: var(--error-surface); }
.preview-result { padding: 36px 0 24px; text-align: center; }
.result-icon { width: 54px; height: 54px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; color: var(--accent); margin: 0 auto 17px; }
.result-icon svg { width: 29px; height: 29px; }
.preview-result h2 { font-size: 23px; margin: 0 0 13px; letter-spacing: -.02em; }
.preview-result > p { overflow-wrap: anywhere; }
.result-total { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin: 20px 0 8px; font-variant-numeric: tabular-nums; }
.result-receipt { white-space: pre-wrap; overflow-wrap: anywhere; text-align: left; font: inherit; font-size: 14px; line-height: 1.65; background: var(--surface); padding: 16px; border-radius: var(--radius); margin: 20px 0 10px; }
.copy-button { color: var(--accent); background: transparent; border: 0; font-size: 14px; font-weight: 600; padding: 10px; }
.preview-result .primary-button { margin-top: 29px; }
.edit-result { padding: 16px 0 28px; }
.edit-result h2 { font-size: 23px; margin: 0 0 12px; letter-spacing: -.02em; }
.edit-result p { overflow-wrap: anywhere; }
.edit-result .primary-button { margin-top: 24px; }
@media (min-width: 600px) { body { background: var(--surface); } .app { background: var(--page); margin: 30px auto; padding: 29px 27px 0; border-radius: 20px; } .submit-bar { padding-bottom: 25px; } }
@media (max-width: 359px) { .app { padding-left: 16px; padding-right: 16px; } .field-row { gap: 9px; } .currency-options { gap: 4px; } .currency-options span { gap: 3px; font-size: 12px; } .currency-options b { font-size: 14px; } .button-arrow { display: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before { transition: none !important; animation: none !important; } }
