:root {
  --navy: #14233a;
  --navy-soft: #1e314e;
  --black: #10100b;
  --beige: #d5cfcc;
  --coffee: #968378;
  --white: #ffffff;
  --blue: #2fbcfb;
  --blue-deep: #217ee6;
  --bg: #f4f5f6;
  --line: #dfe3e8;
  --muted: #667085;
  --danger: #b42318;
  --shadow: 0 18px 60px rgba(20, 35, 58, 0.1);
}

* { box-sizing: border-box; }
html { font-family: "Montserrat", Arial, sans-serif; color: var(--navy); background: var(--bg); }
body { margin: 0; min-width: 320px; overflow-x: hidden; background: linear-gradient(180deg, #eef2f6 0, var(--bg) 320px); }
button, input, select { font: inherit; }
button { cursor: pointer; }

.site-header { background: var(--navy); color: var(--white); }
.header-inner { max-width: 1240px; min-height: 112px; margin: 0 auto; padding: 24px 32px; display: flex; align-items: center; justify-content: space-between; gap: 32px; }
.brand-logo { width: 252px; height: 54px; display: block; flex: 0 0 auto; object-fit: contain; object-position: left center; overflow: visible; }
.header-title { text-align: right; border-left: 1px solid rgba(255,255,255,.2); padding-left: 28px; }
.header-title span { display: block; font-weight: 700; font-size: 1.125rem; }
.header-title small { display: block; margin-top: 5px; color: rgba(255,255,255,.65); font-size: .78rem; }

.app-shell { max-width: 1240px; margin: 0 auto; padding: 28px 32px 72px; }
.main-tabs { width: fit-content; display: flex; gap: 6px; padding: 5px; background: rgba(255,255,255,.72); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 5px 18px rgba(20,35,58,.06); }
.main-tab { border: 0; background: transparent; color: var(--muted); padding: 11px 22px; border-radius: 10px; font-weight: 700; }
.main-tab.is-active { background: var(--navy); color: var(--white); }
.main-panel { display: none; }
.main-panel.is-active { display: block; }

.calc-switcher { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 28px 0 40px; }
.calc-switch { min-height: 78px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.78); color: var(--navy); padding: 16px 18px; display: flex; align-items: center; gap: 14px; text-align: left; font-weight: 700; line-height: 1.25; transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.calc-switch:hover { transform: translateY(-2px); border-color: #a9b7c8; }
.calc-switch.is-active { border-color: var(--navy); background: var(--white); box-shadow: var(--shadow); }
.calc-index { color: var(--coffee); font-size: .75rem; letter-spacing: .08em; }
.calc-switch.is-active .calc-index { color: var(--blue-deep); }

.calculator { display: none; }
.calculator.is-active { display: block; animation: panelIn .25s ease; }
@keyframes panelIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.calculator-copy { max-width: 780px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 8px; color: var(--blue-deep); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; }
h1 { margin: 0; color: var(--navy); font-size: clamp(1.8rem, 4vw, 2.75rem); line-height: 1.08; letter-spacing: -.035em; }
.calculator-copy > p:last-child, .settings-header > div > p:last-child { max-width: 690px; margin: 14px 0 0; color: var(--muted); font-size: 1rem; line-height: 1.65; }
.calculator-grid { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(340px, .92fr); gap: 22px; align-items: stretch; }
.input-card, .result-card { border-radius: 22px; padding: 28px; box-shadow: var(--shadow); }
.input-card { background: var(--white); border: 1px solid rgba(20,35,58,.08); }
.result-card { background: var(--navy); color: var(--white); position: relative; overflow: hidden; display: flex; flex-direction: column; }
.result-card::after { content: ""; position: absolute; width: 300px; height: 300px; right: -145px; top: -150px; border: 38px solid rgba(47,188,251,.08); border-radius: 42%; transform: rotate(45deg); }
.result-card-single { justify-content: flex-start; }
.card-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 24px; }
.card-heading h2 { margin: 0; font-size: 1.1rem; }
.card-heading span { padding: 6px 9px; border-radius: 999px; color: var(--muted); background: var(--bg); font-size: .72rem; font-weight: 600; }
.field { display: block; margin-bottom: 18px; }
.field > span:first-child { display: block; margin-bottom: 8px; font-size: .83rem; font-weight: 600; }
.input-wrap { display: grid; grid-template-columns: 1fr auto; align-items: center; border: 1px solid #cfd6de; border-radius: 12px; background: #fafbfc; transition: border-color .15s, box-shadow .15s; }
.input-wrap:focus-within { border-color: var(--blue-deep); box-shadow: 0 0 0 3px rgba(33,126,230,.12); background: var(--white); }
.input-wrap input, .input-wrap select { width: 100%; min-height: 50px; border: 0; outline: 0; background: transparent; color: var(--navy); padding: 12px 14px; font-size: 1rem; font-weight: 600; }
.input-wrap b { padding: 0 14px; color: var(--coffee); font-size: .82rem; }
.primary-button, .secondary-button, .danger-button { min-height: 48px; border-radius: 11px; padding: 11px 18px; font-weight: 700; border: 0; }
.primary-button { width: 100%; margin-top: 4px; color: var(--white); background: linear-gradient(135deg, var(--blue-deep), var(--blue)); box-shadow: 0 10px 25px rgba(33,126,230,.22); }
.primary-button:hover { filter: brightness(.97); }
.secondary-button { color: var(--navy); background: var(--white); border: 1px solid #cbd3dd; }
.danger-button { color: var(--white); background: var(--danger); }
.form-error { min-height: 18px; margin: 11px 0 0; color: var(--danger); font-size: .78rem; }
.result-heading { position: relative; z-index: 1; color: rgba(255,255,255,.58); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; }
.result-primary { position: relative; z-index: 1; margin: 34px 0 auto; padding-bottom: 30px; border-bottom: 1px solid rgba(255,255,255,.14); }
.result-primary span, .result-row span { display: block; color: rgba(255,255,255,.72); font-size: .82rem; line-height: 1.4; }
.result-primary strong { display: block; margin-top: 10px; color: var(--white); font-size: clamp(2rem, 5vw, 3.5rem); line-height: 1; letter-spacing: -.04em; }
.result-row { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 20px; }
.result-row strong { color: var(--white); font-size: 1.3rem; }

.settings-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin: 42px 0 30px; }
.settings-form { display: grid; gap: 18px; }
.settings-group { background: var(--white); border: 1px solid var(--line); border-radius: 20px; padding: 26px; }
.settings-group-title { display: grid; grid-template-columns: auto 1fr; gap: 15px; margin-bottom: 22px; }
.settings-group-title > span { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: var(--navy); color: var(--white); font-size: .72rem; font-weight: 700; }
.settings-group-title h2 { margin: 0; font-size: 1.08rem; }
.settings-group-title p { margin: 5px 0 0; color: var(--muted); font-size: .8rem; }
.settings-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.settings-field { margin: 0; }
.settings-field > span:first-child { min-height: 34px; display: flex; align-items: flex-end; }
.settings-field small { display: block; margin-top: 6px; color: var(--muted); font-size: .7rem; line-height: 1.4; }
.tariff-details { background: var(--white); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.tariff-details summary { list-style: none; padding: 22px 26px; display: flex; justify-content: space-between; align-items: center; gap: 15px; cursor: pointer; font-weight: 700; }
.tariff-details summary::-webkit-details-marker { display: none; }
.tariff-details summary small { color: var(--blue-deep); font-size: .76rem; }
.tariff-note { padding: 0 26px 18px; color: var(--muted); font-size: .8rem; }
.tariff-table-wrap { max-height: 460px; overflow: auto; border-top: 1px solid var(--line); }
.tariff-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.tariff-table th { position: sticky; top: 0; z-index: 1; background: #eef1f4; color: var(--navy); text-align: left; padding: 11px 16px; }
.tariff-table td { border-top: 1px solid #edf0f3; padding: 8px 16px; }
.tariff-table input { width: 100%; min-height: 38px; border: 1px solid #d6dce3; border-radius: 8px; padding: 7px 9px; color: var(--navy); background: #fafbfc; }
.save-status { justify-self: end; min-height: 22px; color: #31774d; font-size: .78rem; opacity: 0; transition: opacity .2s; }
.save-status.is-visible { opacity: 1; }

.site-footer { max-width: 1240px; margin: 0 auto; padding: 25px 32px 38px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; color: var(--muted); font-size: .75rem; }
.reset-dialog { width: min(440px, calc(100% - 30px)); border: 0; border-radius: 18px; padding: 0; color: var(--navy); box-shadow: 0 24px 80px rgba(20,35,58,.28); }
.reset-dialog::backdrop { background: rgba(20,35,58,.62); }
.reset-dialog form { padding: 28px; }
.reset-dialog h2 { margin: 0; font-size: 1.25rem; }
.reset-dialog p { color: var(--muted); line-height: 1.55; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

@media (max-width: 900px) {
  .calculator-grid { grid-template-columns: 1fr; }
  .result-card { min-height: 390px; }
  .settings-fields { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .calc-switcher { display: flex; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; scroll-snap-type: x proximity; }
  .calc-switcher::-webkit-scrollbar { display: none; }
  .calc-switch { flex: 0 0 min(300px, 78vw); scroll-snap-align: start; }
}

@media (max-width: 680px) {
  .header-inner { min-height: 82px; padding: 14px 16px; }
  .brand-logo { width: 218px; height: 46px; }
  .header-title { display: none; }
  .app-shell { padding: 16px 14px 44px; }
  .main-tabs { width: 100%; }
  .main-tab { flex: 1; padding: 10px 12px; }
  .calc-switcher { display: grid; grid-template-columns: 1fr; gap: 8px; overflow: visible; margin: 16px 0 24px; padding: 0; }
  .calc-switch { width: 100%; min-height: 54px; padding: 12px 14px; }
  .calculator-copy { margin-bottom: 20px; }
  h1 { font-size: clamp(1.7rem, 8.5vw, 2.2rem); overflow-wrap: anywhere; }
  .calculator-copy > p:last-child { font-size: .9rem; }
  .input-card, .result-card { padding: 20px; border-radius: 18px; }
  .result-card { min-height: 300px; }
  .result-primary { margin-top: 26px; padding-bottom: 24px; }
  .result-primary strong { font-size: clamp(2rem, 13vw, 3rem); }
  .result-row { gap: 12px; padding-top: 17px; }
  .result-row strong { white-space: nowrap; font-size: 1.15rem; }
  .field { margin-bottom: 15px; }
  .input-wrap input, .input-wrap select { font-size: 16px; }
  .settings-header { align-items: stretch; flex-direction: column; margin-top: 30px; }
  .settings-fields { grid-template-columns: 1fr; }
  .settings-group { padding: 18px; }
  .site-footer { padding: 22px 14px 30px; flex-direction: column; gap: 8px; }
  .tariff-details summary { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
