:root {
  --page: #e8ebe8;
  --bg: #0b0d0c;
  --panel: #161816;
  --panel-2: #1c1f1d;
  --line: #2a2e2b;
  --line-soft: #222623;
  --text: #f1f3f1;
  --muted: #9aa29c;
  --faint: #6c746e;
  --green: #5fd068;
  --green-ink: #0c1a0e;
  --green-soft: rgba(95, 208, 104, 0.12);
  --red: #f06a6a;
  --amber: #f2b84b;
  --radius: 14px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding: 40px;
  min-height: 100vh;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8;
        stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ------------------------------------------------------------------ shell */
.shell {
  max-width: 1360px;
  margin: 0 auto;
  border-radius: 40px;
  background:
    radial-gradient(1200px 380px at 50% -120px, rgba(95, 208, 104, 0.10), transparent 70%),
    linear-gradient(180deg, #121613 0%, var(--bg) 360px);
  box-shadow: 0 30px 80px rgba(10, 20, 12, 0.25);
  padding: 0 46px 46px;
  min-height: calc(100vh - 80px);
}
.nav {
  display: flex; align-items: center; gap: 28px;
  height: 78px; border-bottom: 1px solid var(--line-soft);
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text);
        font-weight: 600; font-size: 19px; letter-spacing: 0.01em; margin-right: 18px; }
.logo b { color: var(--green); font-weight: 600; }
.logo-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--green); color: var(--green-ink);
             display: grid; place-items: center; }
.logo-mark svg.i { width: 20px; height: 20px; stroke-width: 2.4; }
.nav-links { display: flex; gap: 6px; flex: 1; }
.nav-link { background: none; border: 0; padding: 9px 16px; border-radius: 9px; font-weight: 600;
            font-size: 13px; color: var(--text); text-decoration: none; }
.nav-link:hover { background: var(--panel-2); }
.nav-link.active { background: #262a27; }
.currency { display: flex; align-items: center; gap: 10px; background: #fff; color: #111; border-radius: 9px;
            padding: 0 6px 0 14px; height: 36px; font-weight: 600; font-size: 13px; }
.currency select { background: transparent; border: 0; color: #111; font-weight: 700; padding: 6px 4px;
                   outline: none; cursor: pointer; }

.hero { text-align: center; padding: 52px 0 40px; }
.hero h1 { margin: 0; font-size: 40px; font-weight: 700; letter-spacing: -0.01em; }
.hero p { margin: 10px 0 0; color: var(--muted); font-size: 15px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); background: none; border: 0;
        font-weight: 600; font-size: 13px; padding: 6px 10px; border-radius: 8px; margin-bottom: 14px; }
.back:hover { color: var(--text); background: var(--panel-2); }

/* ------------------------------------------------------------------ home */
.search { display: flex; align-items: center; gap: 10px; max-width: 440px; margin: 26px auto 0;
          background: var(--panel); border: 1px solid var(--line); border-radius: 11px; padding: 0 14px;
          color: var(--muted); }
.search input { flex: 1; background: none; border: 0; outline: none; height: 44px; color: var(--text); }
.category { margin-top: 34px; }
.category-head { display: flex; align-items: baseline; gap: 12px; margin: 0 0 14px 4px; }
.category-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.category-head span { color: var(--faint); font-size: 13px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.calc-btn {
  display: flex; gap: 14px; align-items: flex-start; text-align: left;
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: 12px; padding: 18px;
  transition: border-color .15s, background .15s, transform .15s;
}
.calc-btn:hover { border-color: var(--green); background: #181c19; transform: translateY(-1px); }
.calc-btn:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.calc-icon { width: 40px; height: 40px; border-radius: 9px; border: 1.5px solid var(--line);
             display: grid; place-items: center; color: var(--green); flex: none; }
.calc-btn:hover .calc-icon { border-color: var(--green); background: var(--green-soft); }
.calc-btn .t { font-weight: 600; font-size: 15px; display: flex; gap: 8px; align-items: center; }
.calc-btn .tag { font-size: 11px; font-weight: 700; color: var(--green); background: var(--green-soft);
                 border-radius: 5px; padding: 1px 6px; letter-spacing: 0.02em; }
.calc-btn .d { color: var(--muted); font-size: 13px; margin-top: 3px; }
.empty { color: var(--muted); text-align: center; padding: 40px; }

/* ------------------------------------------------------------------ calculator view */
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tab {
  display: flex; gap: 16px; align-items: center; min-width: 220px; text-align: left;
  background: #111311; border: 1px solid var(--line-soft); border-bottom: 0;
  border-radius: 12px 12px 0 0; padding: 18px 22px; color: var(--muted);
}
.tab .calc-icon { border-color: #3a3f3b; color: var(--muted); width: 32px; height: 32px; border-radius: 7px; }
.tab .t { font-weight: 600; font-size: 15px; color: #c9cec9; }
.tab .d { font-size: 12.5px; color: var(--faint); margin-top: 2px; }
.tab.active { background: var(--panel); }
.tab.active .t { color: var(--green); }
.tab.active .d { color: var(--muted); }
.tab.active .calc-icon { border-color: var(--green); color: var(--green); }
.tab:not(.active):hover .t { color: var(--text); }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 372px; column-gap: 24px; row-gap: 24px;
             align-items: start; }
.workspace > .panel:not(.results) { grid-column: 1; }
.workspace > .results { grid-column: 2; grid-row: 1 / span 3; }
.panel { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); }
.inputs { border-top-left-radius: 0; padding: 26px 32px 30px; }
.section { padding: 20px 0; border-bottom: 1px solid var(--line); }
.section:first-child { padding-top: 6px; }
.section:last-of-type { border-bottom: 0; }
.label { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; margin-bottom: 12px; }
.label .opt { color: var(--faint); font-weight: 500; font-size: 12px; }
.help { position: relative; color: var(--faint); display: inline-grid; place-items: center; }
.help svg.i { width: 16px; height: 16px; }
.help:hover { color: var(--text); }
.help .tip { display: none; position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
             width: 260px; background: #2a2e2b; color: var(--text); font-size: 12.5px; font-weight: 400;
             padding: 9px 11px; border-radius: 8px; line-height: 1.4; z-index: 10;
             box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.help:hover .tip, .help:focus .tip { display: block; }

.field { display: flex; align-items: center; background: #101210; border: 1px solid var(--line);
         border-radius: 10px; height: 44px; padding: 0 14px; max-width: 360px; transition: border-color .15s; }
.field:focus-within { border-color: var(--green); }
.field.invalid { border-color: var(--red); }
.field .affix { color: var(--faint); font-weight: 600; }
.field input { flex: 1; min-width: 0; background: none; border: 0; outline: none; height: 100%; padding: 0 8px;
               font-variant-numeric: tabular-nums; font-size: 15px; }
.field input[type="date"] { color-scheme: dark; }
.hint { color: var(--muted); font-size: 13px; margin-top: 10px; }

.pills { display: flex; flex-wrap: wrap; gap: 10px; }
.pill { display: inline-flex; align-items: center; gap: 9px; height: 40px; padding: 0 17px;
        background: #151715; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); }
.pill:hover { color: var(--text); }
.pill.active { border-color: var(--green); color: var(--text); background: #141a15; }
.pill.active svg.i { color: var(--green); }

.rows { display: flex; flex-direction: column; gap: 8px; max-width: 520px; }
.row { display: grid; grid-template-columns: 76px minmax(0, 1fr) 36px; gap: 10px; align-items: center; }
.row.dated { grid-template-columns: 30px minmax(0, 1fr) minmax(0, 1fr) 36px; }
.row-label { color: var(--muted); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.row .field { max-width: none; height: 40px; }
.icon-btn { width: 36px; height: 36px; border-radius: 9px; border: 1px solid transparent; background: none;
            color: var(--faint); display: grid; place-items: center; }
.icon-btn:hover { color: var(--red); border-color: var(--line); }
.icon-btn:disabled { opacity: .3; pointer-events: none; }
.add-btn { display: flex; align-items: center; justify-content: center; gap: 8px; height: 40px; margin-top: 4px;
           border: 1px dashed #3b413c; border-radius: 10px; background: none; color: var(--muted);
           font-weight: 600; max-width: 520px; width: 100%; }
.add-btn:hover { border-color: var(--green); color: var(--green); background: var(--green-soft); }
.add-btn .plus { width: 22px; height: 22px; border-radius: 6px; background: var(--green); color: var(--green-ink);
                 display: grid; place-items: center; }
.add-btn .plus svg.i { width: 15px; height: 15px; stroke-width: 2.6; }

.formula { margin-top: 6px; font-family: var(--mono); font-size: 13px; color: #cfe9d1; background: #101410;
           border: 1px solid #1f2b20; border-radius: 10px; padding: 12px 14px; overflow-x: auto; white-space: nowrap; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding-top: 22px; }
.ghost { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 9px;
         border: 1px solid var(--line); background: #131513; color: var(--muted); font-weight: 600; font-size: 13px; }
.ghost:hover { color: var(--text); border-color: #3b413c; }
.switch { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: 13px; color: var(--text);
          margin-left: auto; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track { width: 38px; height: 22px; border-radius: 999px; background: #2d322e; position: relative;
                 transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
                        border-radius: 50%; background: #cfd4cf; transition: transform .15s; }
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(16px); background: var(--green-ink); }

/* ------------------------------------------------------------------ results sidebar */
.results { padding: 26px 30px 30px; position: sticky; top: 20px; }
.results h3 { margin: 0 0 18px; font-size: 19px; font-weight: 600; display: flex; justify-content: space-between;
              align-items: center; }
.live { font-size: 11px; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green);
                box-shadow: 0 0 0 3px var(--green-soft); }
.live.busy::before { background: var(--amber); box-shadow: 0 0 0 3px rgba(242,184,75,.15); }
.headline { padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.headline .k { color: var(--muted); font-weight: 600; font-size: 13px; }
.headline .v { display: flex; align-items: center; gap: 10px; margin-top: 4px; font-size: 34px; font-weight: 700;
               color: var(--green); letter-spacing: -0.01em; font-variant-numeric: tabular-nums;
               background: none; border: 0; padding: 0; text-align: left; }
.headline .v svg.i { width: 16px; height: 16px; color: var(--faint); opacity: 0; transition: opacity .15s; }
.headline .v:hover svg.i { opacity: 1; }
.headline.negative .v { color: var(--red); }
.headline.neutral .v { color: var(--text); }
.line-item { display: flex; justify-content: space-between; gap: 16px; padding: 14px 0;
             border-bottom: 1px solid var(--line); }
.line-item .k { font-weight: 600; font-size: 14.5px; }
.line-item .s { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.line-item .v { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; text-align: right; }
.stats { display: grid; grid-template-columns: 1fr 1fr; margin: 20px 0 22px; border: 1px solid var(--line);
         border-radius: 10px; background: #121412; }
.stats > div { text-align: center; padding: 14px 8px; }
.stats > div + div { border-left: 1px solid var(--line); }
.stats .k { color: var(--muted); font-size: 12.5px; }
.stats .v { font-weight: 700; font-size: 17px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.notes { margin: 14px 0 0; padding: 12px 14px; border-radius: 10px; background: rgba(242,184,75,.08);
         border: 1px solid rgba(242,184,75,.25); color: #f4d9a2; font-size: 13px; }
.primary { width: 100%; height: 56px; border: 0; border-radius: 10px; background: var(--green); color: var(--green-ink);
           font-weight: 700; font-size: 15px; display: flex; align-items: center; justify-content: center; gap: 10px;
           transition: filter .15s; }
.primary:hover { filter: brightness(1.07); }
.secondary-row { display: flex; gap: 10px; margin-top: 10px; }
.secondary-row .ghost { flex: 1; justify-content: center; }
.error { color: #ffb4b4; background: rgba(240,106,106,.08); border: 1px solid rgba(240,106,106,.3);
         border-radius: 10px; padding: 14px; font-size: 13.5px; }

/* ------------------------------------------------------------------ chart + table */
.wide { padding: 22px 26px; }
.wide-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.wide-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.chart svg { width: 100%; height: auto; display: block; }
.chart.loading { opacity: .5; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 13.5px; }
th { text-align: right; color: var(--muted); font-weight: 600; font-size: 12.5px; padding: 10px 12px;
     border-bottom: 1px solid var(--line); white-space: nowrap; }
td { text-align: right; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
tbody tr:hover td { background: #1a1d1b; }

.toast { position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 20px); opacity: 0;
         background: #fff; color: #111; padding: 11px 18px; border-radius: 10px; font-weight: 600;
         display: flex; align-items: center; gap: 8px; box-shadow: 0 12px 30px rgba(0,0,0,.3);
         transition: opacity .2s, transform .2s; pointer-events: none; z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast svg.i { color: #1f9a2b; }

@media (max-width: 1040px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .workspace > .panel:not(.results), .workspace > .results { grid-column: 1; grid-row: auto; }
  .results { position: static; }
}
@media (max-width: 720px) {
  body { padding: 0; }
  .shell { border-radius: 0; padding: 0 16px 24px; }
  .nav { gap: 12px; }
  .nav-links { display: none; }
  .logo { margin-right: auto; font-size: 16px; }
  .hero h1 { font-size: 30px; }
  .inputs { padding: 20px 18px; border-top-right-radius: 0; }
  .tab { min-width: 180px; padding: 14px 16px; }
  .row { grid-template-columns: 56px minmax(0, 1fr) 36px; }
  .wide { padding: 18px 14px; }
}
