:root {
  --ink: #132931;
  --ink-soft: #1b3841;
  --muted: #66787e;
  --line: #dce5e5;
  --canvas: #eef3f2;
  --paper: #ffffff;
  --teal: #42c7a5;
  --teal-strong: #2ab792;
  --teal-dark: #11785f;
  --green: #dff6ed;
  --yellow: #fff0bc;
  --red: #ffe0dc;
  --danger: #c9483e;
  --shadow: 0 18px 50px rgba(19, 41, 49, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  font-size: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--canvas); min-height: 100vh; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

.app-shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--ink); color: white; padding: 25px 18px 20px; display: flex; flex-direction: column; gap: 18px; }
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 7px 7px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.12rem; font-weight: 850; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--teal); color: var(--ink); }
.language-switch { display: flex; align-items: center; gap: 5px; color: #82989e; font-size: 0.72rem; font-weight: 800; }
.language-switch button { border: 0; background: none; color: #82989e; padding: 4px 2px; font: inherit; }
.language-switch button:hover, .language-switch button.active { color: white; }
.language-switch button.active { text-decoration: underline; text-decoration-color: var(--teal); text-decoration-thickness: 2px; text-underline-offset: 4px; }

.primary, .secondary, .ghost, .icon-button { border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 780; }
.primary { background: var(--teal); color: #092a24; box-shadow: 0 6px 16px rgba(42, 183, 146, 0.2); }
.primary:hover { background: #61d1b5; }
.secondary { background: white; border: 1px solid #c9d7d6; color: var(--ink); }
.secondary:hover { border-color: #91aaa7; background: #f8fbfa; }
.ghost { background: transparent; border: 1px solid rgba(255, 255, 255, 0.18); color: inherit; }
.full { width: 100%; }
.section-label, .eyebrow { font-size: 0.73rem; text-transform: uppercase; letter-spacing: 0.115em; font-weight: 850; color: var(--muted); }
.sidebar > .section-label { color: #87a0a6; padding: 4px 9px 0; }

#project-list { min-height: 0; overflow-y: auto; margin: -5px -4px 0; padding: 5px 4px; }
.project-link { width: 100%; border: 0; color: #c6d3d5; background: transparent; border-radius: 12px; text-align: left; padding: 11px 12px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.project-link:hover, .project-link.active { background: rgba(255, 255, 255, 0.08); color: white; }
.project-link.active { box-shadow: inset 3px 0 var(--teal); }
.project-link > span { min-width: 0; display: flex; align-items: center; gap: 6px; }
.project-link b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.88rem; }
.project-link em { flex: 0 0 auto; border: 1px solid rgba(66, 199, 165, 0.45); color: #84e2c9; border-radius: 999px; padding: 2px 5px; font-size: 0.56rem; font-style: normal; text-transform: uppercase; letter-spacing: 0.06em; }
.project-link small { color: #adc0c3; font-size: 0.72rem; font-weight: 720; white-space: nowrap; }
.project-list-empty { color: #789097; font-size: 0.83rem; padding: 10px 9px; }
.sidebar-bottom { margin-top: auto; display: grid; gap: 12px; }
.local-note { border-top: 1px solid rgba(255, 255, 255, 0.1); padding: 15px 8px 0; }
.local-note strong { color: #c9d8da; font-size: 0.75rem; }
.local-note p { color: #82989e; font-size: 0.69rem; line-height: 1.45; margin: 5px 0 0; }
.sidebar-footer { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sidebar-footer .ghost { padding-inline: 8px; font-size: 0.76rem; }

main { padding: 34px 44px 70px; max-width: 1440px; width: 100%; margin: 0 auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.project-heading { min-width: 0; flex: 1; }
.eyebrow-line { display: flex; align-items: center; gap: 9px; }
.sample-badge { background: #dff6ed; color: var(--teal-dark); border-radius: 999px; padding: 3px 7px; font-size: 0.62rem; font-weight: 850; text-transform: uppercase; letter-spacing: 0.08em; }
.topbar h1, .section-heading h2 { margin: 4px 0 0; }
.topbar h1 { overflow: hidden; text-overflow: ellipsis; font-size: clamp(1.6rem, 3vw, 2.35rem); letter-spacing: -0.035em; }

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.metric { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 20px; box-shadow: 0 4px 16px rgba(19, 41, 49, 0.035); }
.metric > span { display: block; color: var(--muted); font-size: 0.86rem; font-weight: 700; margin-bottom: 9px; }
.metric strong { font-size: 1.65rem; letter-spacing: -0.03em; }
.metric.accent { background: var(--ink); border-color: var(--ink); color: white; }
.metric.accent > span { color: #a9bbbf; }
.meter { height: 5px; background: #e9efef; border-radius: 10px; margin-top: 14px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--teal-strong); border-radius: inherit; transition: width 0.25s ease, background 0.25s ease; }
.metric.exhausted { border-color: #efb9b3; background: #fff9f8; }
.metric.exhausted .remaining { color: var(--danger); }
.metric.exhausted .meter i { background: var(--danger); }
.remaining { display: block; color: var(--muted); font-weight: 700; margin-top: 5px; }

.scope-card { margin: 14px 0 32px; background: #f8fbfa; border: 1px solid var(--line); border-radius: 16px; padding: 20px; display: flex; justify-content: space-between; align-items: center; gap: 28px; }
.scope-card p { margin: 7px 0 0; line-height: 1.55; }
.scope-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.rate { white-space: nowrap; background: white; border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; font-weight: 800; }
.danger-button, .delete-change-button { background: white; border: 1px solid #e8bdb7; color: #9b413a; border-radius: 8px; font-weight: 750; }
.danger-button { padding: 8px 11px; white-space: nowrap; }
.delete-change-button { padding: 5px 8px; font-size: 0.7rem; }
.danger-button:hover, .delete-change-button:hover { border-color: #cf746b; background: #fff5f3; color: #7f2e28; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.section-heading h2 { font-size: 1.25rem; }
.legend { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.78rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-left: 8px; }
.dot.green { background: #24a77f; }
.dot.yellow { background: #d49716; }
.dot.red { background: #d35247; }

.change-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: start; background: white; border: 1px solid var(--line); border-radius: 15px; padding: 17px 18px; margin-bottom: 10px; }
.status-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-weight: 900; }
.status-icon.included { background: var(--green); color: var(--teal-dark); }
.status-icon.last { background: var(--yellow); color: #9a6500; }
.status-icon.extra { background: var(--red); color: var(--danger); }
.change-card h3 { font-size: 0.98rem; margin: 2px 0 6px; overflow-wrap: anywhere; }
.change-card p { color: var(--muted); font-size: 0.85rem; margin: 0; }
.change-side { min-width: 95px; display: flex; flex-direction: column; align-items: flex-end; gap: 7px; }
.change-amount { text-align: right; min-width: 95px; }
.change-amount strong { display: block; }
.change-amount small { color: var(--muted); }
.message-box { grid-column: 2 / -1; background: #fff8f6; border: 1px solid #f0cac5; border-radius: 11px; padding: 12px 14px; margin-top: 2px; display: flex; gap: 12px; align-items: flex-start; }
.message-box p { color: #6a4945; line-height: 1.5; flex: 1; }
.copy-button { border: 1px solid #e8bdb7; background: white; color: #8e3a33; border-radius: 8px; padding: 7px 10px; font-weight: 750; white-space: nowrap; }
.copy-button.copied { border-color: #73cbb2; color: var(--teal-dark); background: #edf9f5; }
.empty-state { padding: 36px; text-align: center; background: white; border: 1px dashed #c9d6d6; border-radius: 15px; color: var(--muted); }

.welcome-view { max-width: 1080px; margin: 4vh auto 0; }
.welcome-panel { min-height: 370px; display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(320px, 0.88fr); align-items: center; gap: clamp(35px, 7vw, 92px); background: var(--ink); border-radius: 28px; padding: clamp(32px, 6vw, 70px); color: white; overflow: hidden; position: relative; }
.welcome-panel::after { content: ""; position: absolute; right: -100px; top: -170px; width: 370px; height: 370px; border: 90px solid rgba(66, 199, 165, 0.07); border-radius: 50%; }
.welcome-copy { position: relative; z-index: 1; }
.welcome-copy .eyebrow { color: #75d9c0; }
.welcome-copy h1 { font-size: clamp(2.4rem, 5.3vw, 4.75rem); max-width: 720px; letter-spacing: -0.055em; line-height: 0.98; margin: 14px 0 20px; }
.welcome-lead { color: #c3d1d3; font-size: clamp(1rem, 1.5vw, 1.18rem); line-height: 1.6; max-width: 610px; }
.welcome-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 27px; }
.welcome-actions .secondary { color: white; border-color: rgba(255,255,255,0.25); background: rgba(255,255,255,0.05); }
.welcome-actions .secondary:hover { background: rgba(255,255,255,0.1); }
.value-preview { position: relative; z-index: 1; background: #f8fbfa; border-radius: 18px; padding: 17px; transform: rotate(1.5deg); box-shadow: 0 28px 70px rgba(0,0,0,0.2); }
.preview-top { color: var(--ink); display: flex; justify-content: space-between; align-items: center; font-size: 0.76rem; font-weight: 850; padding: 2px 2px 13px; }
.preview-pill { background: #e6efed; border-radius: 999px; padding: 5px 9px; }
.preview-item { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 9px; background: white; border: 1px solid var(--line); padding: 11px; margin-top: 7px; border-radius: 10px; }
.preview-item i { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 8px; font-style: normal; font-weight: 900; }
.preview-item span { height: 7px; background: #dce5e5; border-radius: 9px; }
.preview-item b { color: var(--danger); font-size: 0.7rem; }
.preview-item.included i { background: var(--green); color: var(--teal-dark); }
.preview-item.last i { background: var(--yellow); color: #9a6500; }
.preview-item.extra i { background: var(--red); color: var(--danger); }
.welcome-points { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; padding: 35px 10px 26px; }
.welcome-points article { display: grid; grid-template-columns: auto 1fr; gap: 12px; }
.welcome-points article > span { color: var(--teal-dark); font-size: 0.7rem; font-weight: 900; padding-top: 4px; }
.welcome-points h2 { font-size: 0.98rem; margin: 0 0 6px; }
.welcome-points p { color: var(--muted); font-size: 0.82rem; line-height: 1.5; margin: 0; }
.privacy-card { border-top: 1px solid #d3dfde; padding: 18px 10px 0; display: flex; gap: 12px; align-items: flex-start; color: var(--muted); }
.privacy-card > span { color: var(--teal-dark); background: #dff6ed; border-radius: 8px; padding: 4px 7px; }
.privacy-card strong { color: #3c555c; font-size: 0.78rem; }
.privacy-card p { font-size: 0.75rem; margin: 3px 0 0; }

.mobile-only { display: none; }
.icon-button { padding: 7px 10px; background: #e8eeee; color: var(--ink); font-size: 1.15rem; }
dialog { width: min(570px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; overscroll-behavior: contain; border: 0; border-radius: 20px; padding: 0; box-shadow: var(--shadow); color: var(--ink); }
dialog::backdrop { background: rgba(8, 24, 29, 0.6); backdrop-filter: blur(3px); }
dialog form { padding: 24px; }
.dialog-head { display: flex; align-items: start; justify-content: space-between; margin-bottom: 20px; }
.dialog-head h2 { margin: 4px 0; }
.dialog-head .icon-button { font-size: 1.5rem; line-height: 1; }
label, fieldset { display: block; font-weight: 750; font-size: 0.9rem; margin-top: 16px; }
fieldset { border: 0; padding: 0; }
legend { padding: 0; }
input, textarea { width: 100%; border: 1px solid #cbd7d7; border-radius: 10px; padding: 11px 12px; margin-top: 7px; color: var(--ink); background: #fbfcfc; }
textarea { resize: vertical; }
.scope-reference { margin-top: 14px; padding: 11px 13px; background: #f1f6f5; border: 1px solid #d2dfdd; border-left: 3px solid var(--teal-strong); border-radius: 10px; }
.scope-reference .section-label { color: #4f6a70; font-size: 0.66rem; }
.scope-reference p { max-height: 105px; overflow-y: auto; overflow-wrap: anywhere; white-space: pre-wrap; color: #425a60; font-size: 0.82rem; font-weight: 500; line-height: 1.48; margin: 5px 0 0; padding-right: 3px; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { display: flex; align-items: flex-start; gap: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-top: 8px; }
.choice:has(input:checked) { border-color: var(--teal-strong); background: #eefaf7; }
.choice input { width: auto; margin: 3px 0; }
.choice span { display: grid; gap: 3px; }
.choice small { font-weight: 500; color: var(--muted); line-height: 1.35; }
.choice .warning { color: var(--danger); font-weight: 750; }
.inline-warning { display: flex; gap: 9px; align-items: center; background: #fff2d2; border: 1px solid #efd181; color: #704b00; border-radius: 10px; padding: 10px 12px; margin-top: 13px; font-size: 0.82rem; font-weight: 750; }
.inline-warning > span:first-child { display: grid; place-items: center; min-width: 22px; height: 22px; border-radius: 50%; background: #e6b842; color: white; }
.form-error { display: flex; gap: 9px; align-items: center; background: #fff2f0; border: 1px solid #e8afa8; color: #8f312a; border-radius: 10px; padding: 11px 12px; margin: -5px 0 4px; font-size: 0.84rem; font-weight: 750; }
.form-error > span:first-child { display: grid; place-items: center; min-width: 22px; height: 22px; border-radius: 50%; background: var(--danger); color: white; }
.form-error:focus { outline: 3px solid rgba(201, 72, 62, 0.18); outline-offset: 2px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.dialog-actions .ghost { color: var(--ink); border-color: var(--line); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: white; border-radius: 999px; padding: 11px 17px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: 0.2s; z-index: 20; font-weight: 700; font-size: 0.88rem; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
input:focus, textarea:focus, button:focus-visible { outline: 3px solid rgba(42, 183, 146, 0.3); outline-offset: 2px; }

@media (max-width: 950px) {
  main { padding-inline: 28px; }
  .welcome-panel { grid-template-columns: 1fr; }
  .value-preview { display: none; }
}

@media (max-width: 800px) {
  .app-shell { grid-template-columns: 1fr; }
  body.menu-open { overflow: hidden; }
  body.menu-open::before { content: ""; position: fixed; inset: 0; z-index: 4; background: rgba(8, 24, 29, 0.42); }
  .sidebar { position: fixed; z-index: 5; transform: translateX(-105%); transition: transform 0.2s ease; width: 280px; box-shadow: var(--shadow); }
  body.menu-open .sidebar { transform: translateX(0); }
  body.welcome-mode .sidebar { position: static; transform: none; width: auto; height: auto; padding: 15px 18px; box-shadow: none; }
  body.welcome-mode .sidebar > .full, body.welcome-mode .sidebar > .section-label, body.welcome-mode #project-list, body.welcome-mode .sidebar-bottom { display: none; }
  body.welcome-mode .brand-row { padding: 0; }
  main { padding: 22px 18px 50px; }
  body.welcome-mode main { padding-top: 18px; }
  .mobile-only { display: block; }
  .topbar { align-items: flex-start; }
  .topbar .primary { padding: 10px; font-size: 0.84rem; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .metric.accent { grid-column: 1 / -1; }
  .scope-card { align-items: flex-start; flex-direction: column; gap: 12px; }
  .scope-actions { justify-content: flex-start; }
  .section-heading { align-items: flex-start; }
  .legend { display: none; }
  .change-card { grid-template-columns: auto minmax(0, 1fr); }
  .change-side { grid-column: 2; align-items: flex-start; min-width: 0; }
  .change-amount { text-align: left; min-width: 0; }
  .message-box { grid-column: 1 / -1; }
  .welcome-view { margin-top: 0; }
  .welcome-panel { border-radius: 22px; }
  .welcome-points { grid-template-columns: 1fr; gap: 18px; }
}

@media (max-width: 500px) {
  .summary-grid { grid-template-columns: 1fr; }
  .metric.accent { grid-column: auto; }
  .topbar h1 { font-size: 1.4rem; }
  .topbar .primary { max-width: 112px; }
  .change-card { padding: 14px; gap: 12px; }
  .form-grid, .choice-grid { grid-template-columns: 1fr; }
  .message-box { flex-direction: column; }
  .copy-button { width: 100%; }
  .welcome-panel { padding: 31px 22px; min-height: 470px; }
  .welcome-copy h1 { font-size: 2.65rem; }
  .welcome-actions { display: grid; }
  .toast { width: calc(100vw - 32px); text-align: center; }
}
