:root {
  color-scheme: light;
  --green-950: #063a26;
  --green-900: #075333;
  --green-800: #0b6b43;
  --green-700: #108654;
  --green-500: #29aa70;
  --lime: #d8f46b;
  --mint: #e9f8ef;
  --surface: #ffffff;
  --canvas: #f3f7f4;
  --line: #dce7e0;
  --text: #173329;
  --muted: #6b7f76;
  --danger: #b33d48;
  --shadow: 0 12px 32px rgba(10, 65, 42, .09);
  --radius: 20px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--canvas); scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--text); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 78px;
  padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--green-900), var(--green-700));
  box-shadow: 0 6px 22px rgba(6, 58, 38, .22);
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark { width: 48px; height: 48px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 15px; background: rgba(255,255,255,.13); }
.brand-mark svg { width: 41px; height: 41px; fill: #fff; overflow: visible; }
.brand-mark .leaf-line, .brand-mark .plus-line { fill: none; stroke-linecap: round; }
.brand-mark .leaf-line { stroke: var(--green-800); stroke-width: 5; }
.brand-mark .plus-line { stroke: var(--lime); stroke-width: 5; }
.brand strong { display: block; font-size: 1.27rem; line-height: 1.05; letter-spacing: -.02em; }
.brand small { display: block; margin-top: 3px; color: rgba(255,255,255,.8); font-size: .72rem; }
.offline-badge { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; padding: 7px 9px; border: 1px solid rgba(255,255,255,.2); border-radius: 999px; background: rgba(0,0,0,.11); font-size: .69rem; font-weight: 700; }
.offline-badge i { width: 7px; height: 7px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 3px rgba(216,244,107,.18); }

.app-main { width: min(100%, 860px); margin: 0 auto; padding: 25px 16px calc(112px + env(safe-area-inset-bottom)); }
.welcome { margin: 0 2px 26px; }
.eyebrow { margin: 0 0 7px; color: var(--green-700); font-size: .76rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.welcome h1 { max-width: 680px; margin: 0; font-size: clamp(1.55rem, 6vw, 2.35rem); line-height: 1.12; letter-spacing: -.04em; }
.welcome > p:last-child { max-width: 600px; margin: 10px 0 0; color: var(--muted); line-height: 1.5; }

.license-banner { margin: -5px 0 24px; padding: 14px 15px; display: flex; align-items: center; gap: 12px; border: 1px solid #b7ddc7; border-radius: 16px; background: #edf9f1; box-shadow: 0 8px 20px rgba(10,65,42,.06); }
.license-banner__mark { width: 36px; height: 36px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 12px; color: #fff; background: var(--green-700); font-weight: 900; }
.license-banner__content { min-width: 0; flex: 1; }
.license-banner strong { display: block; color: var(--green-900); font-size: .84rem; }
.license-banner p { margin: 3px 0 0; color: #587067; font-size: .73rem; line-height: 1.35; }
.license-banner a { flex: 0 0 auto; padding: 9px 12px; border-radius: 10px; color: #fff; background: var(--green-800); font-size: .72rem; font-weight: 800; text-decoration: none; }
.license-banner.is-checking { border-color: #d7e2dc; background: #f8faf9; }
.license-banner.is-checking .license-banner__mark { background: #8a9a92; }
.license-banner.is-warning { border-color: #efd19c; background: #fff8e9; }
.license-banner.is-warning .license-banner__mark { background: #d68936; }
.license-banner.is-error { border-color: #efc2c6; background: #fff3f4; }
.license-banner.is-error .license-banner__mark { background: var(--danger); }
.license-banner.is-error strong { color: #8c2d37; }
.is-license-locked .form-card, .is-license-locked .compare-card { opacity: .72; }
button:disabled { cursor: not-allowed; filter: grayscale(.25); opacity: .58; box-shadow: none; }

.view { display: none; animation: enter .22s ease; }
.view.is-active { display: block; }
@keyframes enter { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.section-heading { display: flex; align-items: center; gap: 12px; margin: 0 2px 15px; }
.section-heading h2 { margin: 0; font-size: 1.22rem; letter-spacing: -.02em; }
.section-heading p { margin: 3px 0 0; color: var(--muted); font-size: .84rem; line-height: 1.35; }
.section-icon { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 13px; color: #fff; background: var(--green-800); font-size: 1.25rem; font-weight: 800; box-shadow: 0 7px 16px rgba(11,107,67,.18); }

.form-card, .result-panel, .compare-card, .install-card { border: 1px solid rgba(15, 99, 64, .1); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.form-card { padding: 18px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field > span, .mini-form label span { color: #345146; font-size: .78rem; font-weight: 800; }
.field small { margin-top: -2px; color: var(--muted); font-size: .7rem; line-height: 1.35; }
.field input, .field select, .mini-form input {
  width: 100%;
  height: 48px;
  min-width: 0;
  padding: 0 13px;
  border: 1px solid #cadbd1;
  border-radius: 13px;
  outline: 0;
  color: var(--text);
  background: #fbfdfb;
  transition: border .16s ease, box-shadow .16s ease, background .16s ease;
}
.field input:focus, .field select:focus, .mini-form input:focus { border-color: var(--green-500); background: #fff; box-shadow: 0 0 0 4px rgba(41,170,112,.12); }
.input-prefix, .input-suffix { position: relative; display: flex; align-items: center; }
.input-prefix b, .input-suffix b { position: absolute; z-index: 1; color: var(--green-800); font-size: .82rem; pointer-events: none; }
.input-prefix b { left: 13px; }
.input-suffix b { right: 13px; }
.input-prefix input { padding-left: 40px; }
.input-suffix input { padding-right: 37px; }

.primary-button, .secondary-button, .danger-button { width: 100%; min-height: 50px; border-radius: 14px; font-weight: 800; cursor: pointer; }
.primary-button { margin-top: 17px; border: 0; color: #fff; background: linear-gradient(135deg, var(--green-800), var(--green-700)); box-shadow: 0 8px 18px rgba(11,107,67,.2); }
.primary-button:active { transform: translateY(1px); }
.secondary-button { margin-top: 15px; border: 1px solid #b9d4c4; color: var(--green-800); background: #fff; }
.danger-button { border: 1px solid #efc2c6; color: var(--danger); background: #fff7f8; }

.result-panel { margin-top: 18px; padding: 18px; }
.hero-result { padding: 20px; border-radius: 17px; color: #fff; background: radial-gradient(circle at 90% 5%, rgba(216,244,107,.28), transparent 35%), linear-gradient(135deg, var(--green-950), var(--green-700)); }
.hero-result span, .hero-result small { display: block; color: rgba(255,255,255,.76); }
.hero-result span { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.hero-result strong { display: block; margin: 8px 0 5px; font-size: clamp(1.8rem, 8vw, 2.8rem); line-height: 1; letter-spacing: -.05em; }
.hero-result small { font-size: .75rem; line-height: 1.35; }
.result-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.result-grid article { min-height: 90px; padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: #fbfdfb; }
.result-grid span, .rate-cards span { display: block; margin-bottom: 8px; color: var(--muted); font-size: .73rem; }
.result-grid strong { display: block; font-size: 1.05rem; overflow-wrap: anywhere; }
.positive strong, strong.positive, .comparison-result .positive strong { color: var(--green-700); }
.negative strong { color: var(--danger); }

.chart-card, .schedule-card { margin-top: 13px; border: 1px solid var(--line); border-radius: 16px; background: #fff; overflow: hidden; }
.chart-card { padding: 14px; }
.chart-card h3 { margin: 0 0 10px; font-size: .88rem; }
.chart-card canvas { width: 100%; height: 190px; display: block; }
.schedule-card summary { padding: 15px; color: var(--green-800); font-size: .83rem; font-weight: 800; cursor: pointer; }
.table-scroll { max-height: 360px; overflow: auto; border-top: 1px solid var(--line); }
table { width: 100%; min-width: 520px; border-collapse: collapse; font-size: .75rem; }
th { position: sticky; top: 0; z-index: 1; padding: 10px; text-align: right; color: #fff; background: var(--green-800); }
th:first-child, td:first-child { text-align: center; }
td { padding: 9px 10px; text-align: right; border-bottom: 1px solid #edf2ef; white-space: nowrap; }
tbody tr:nth-child(even) { background: #f8fbf9; }
.disclaimer { margin: 13px 2px 0; color: var(--muted); font-size: .7rem; line-height: 1.45; }

.rate-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.rate-cards article { min-height: 118px; padding: 15px; border-radius: 15px; background: var(--mint); }
.rate-cards strong { display: block; color: var(--green-900); font-size: 1.22rem; overflow-wrap: anywhere; }
.rate-cards small { display: block; margin-top: 6px; color: var(--muted); font-size: .68rem; }
.info-box { margin-top: 13px; padding: 14px; border-left: 4px solid var(--lime); border-radius: 10px; background: #f7fbdc; }
.info-box strong { color: var(--green-900); }
.info-box p { margin: 4px 0 0; color: #506258; font-size: .76rem; line-height: 1.45; }
.compare-card { margin-top: 18px; padding: 18px; }
.compare-card h3 { margin: 0; }
.compare-card > p { margin: 4px 0 14px; color: var(--muted); font-size: .8rem; }
.mini-form { display: grid; grid-template-columns: 1.4fr 1fr .7fr auto; align-items: end; gap: 9px; }
.mini-form label { display: flex; flex-direction: column; gap: 6px; }
.mini-form input { height: 43px; }
.mini-form button { height: 43px; padding: 0 15px; border: 0; border-radius: 11px; color: #fff; background: var(--green-800); font-weight: 800; }
.comparison-result { display: grid; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.comparison-result span { display: flex; justify-content: space-between; gap: 14px; color: var(--muted); font-size: .79rem; }
.comparison-result strong { color: var(--text); }

.history-list { display: grid; gap: 11px; margin-bottom: 14px; }
.history-item { padding: 15px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: 0 7px 20px rgba(10,65,42,.05); }
.history-item header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.history-item header strong { font-size: .88rem; }
.history-item time { color: var(--muted); font-size: .67rem; white-space: nowrap; }
.history-item p { margin: 8px 0 0; color: #3c574c; font-size: .8rem; line-height: 1.4; }
.empty-state { padding: 35px 20px; border: 1px dashed #b9cec2; border-radius: 18px; text-align: center; color: var(--muted); background: rgba(255,255,255,.55); }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--text); }

.install-card { margin-top: 24px; padding: 16px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.install-card strong { display: block; }
.install-card p { margin: 4px 0 0; color: var(--muted); font-size: .75rem; line-height: 1.4; }
.install-card button { flex: 0 0 auto; min-height: 40px; padding: 0 13px; border: 0; border-radius: 11px; color: #fff; background: var(--green-800); font-size: .75rem; font-weight: 800; }

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 30;
  width: min(100%, 860px);
  min-height: 70px;
  padding: 7px 7px calc(7px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  transform: translateX(-50%);
  border: 1px solid rgba(11,107,67,.12);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  background: rgba(255,255,255,.97);
  box-shadow: 0 -10px 35px rgba(10,65,42,.12);
  backdrop-filter: blur(14px);
}
.bottom-nav button { min-width: 0; padding: 5px 2px; border: 0; border-radius: 13px; color: #74847c; background: transparent; font-size: .61rem; font-weight: 750; cursor: pointer; }
.bottom-nav button span { display: block; margin-bottom: 2px; font-size: 1.25rem; line-height: 1.1; }
.bottom-nav button.is-active { color: var(--green-800); background: var(--mint); }

dialog { width: min(calc(100% - 28px), 460px); padding: 20px; border: 0; border-radius: 20px; color: var(--text); box-shadow: 0 25px 80px rgba(0,0,0,.24); }
dialog::backdrop { background: rgba(4,29,19,.58); backdrop-filter: blur(4px); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.dialog-head strong { font-size: 1.1rem; }
.dialog-head button { width: 36px; height: 36px; border: 0; border-radius: 50%; color: var(--muted); background: var(--canvas); font-size: 1.4rem; }
#install-instructions { color: #486057; font-size: .87rem; line-height: 1.55; }
#install-instructions ol { padding-left: 21px; }
#install-instructions li + li { margin-top: 8px; }
.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 60; max-width: calc(100% - 32px); padding: 10px 15px; border-radius: 999px; color: #fff; background: #173329; box-shadow: 0 8px 24px rgba(0,0,0,.22); font-size: .78rem; font-weight: 700; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: .2s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

[hidden] { display: none !important; }

@media (max-width: 600px) {
  .app-header { padding-left: 14px; padding-right: 14px; }
  .offline-badge { padding: 6px 8px; font-size: .61rem; }
  .brand-mark { width: 43px; height: 43px; border-radius: 13px; }
  .brand-mark svg { width: 37px; height: 37px; }
  .brand strong { font-size: 1.13rem; }
  .brand small { font-size: .64rem; }
  .app-main { padding-left: 12px; padding-right: 12px; }
  .field-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .rate-cards { grid-template-columns: 1fr; }
  .rate-cards article { min-height: 92px; }
  .mini-form { grid-template-columns: 1fr 1fr; }
  .mini-form button { grid-column: 1 / -1; }
  .install-card { align-items: flex-start; flex-direction: column; }
  .install-card button { width: 100%; }
  .license-banner { align-items: flex-start; flex-wrap: wrap; }
  .license-banner a { width: 100%; text-align: center; }
}

@media (max-width: 370px) {
  .offline-badge { display: none; }
  .result-grid { grid-template-columns: 1fr; }
  .bottom-nav button { font-size: .56rem; }
}

@media (min-width: 780px) {
  .app-main { padding-top: 34px; }
  .form-card, .result-panel, .compare-card { padding: 24px; }
}

@media (display-mode: standalone) {
  .install-card { display: none; }
}
