:root {
  --bg: #f3efe8;
  --card: #fbf9f5;
  --ink: #1c2422;
  --muted: #5c6764;
  --line: #e0d8cc;
  --line-strong: #8fbfb8;
  --accent: #14656c;
  --accent-ink: #f4fbfb;
  --accent-press: #0f5359;
  --good: #0f6b4c;
  --bad: #9f2d24;
  --field: #ffffff;
  --tint: #f3faf8;
  --formula: #eef5f6;
  --formula-hover: #e3f2f1;
  --ok-bg: #e5f4ed;
  --bad-bg: #f8e8e6;
  --bot: #e7eef1;
  --user: #d7ebe9;
  --tab-bg: #efe8dc;
  --wash-a: #d7ece8;
  --wash-b: #f3e4cf;
  --focus: #c5e4e6;
  --shadow: 0 1px 2px rgba(28, 36, 34, 0.05);
  --lift: 0 16px 36px rgba(20, 101, 108, 0.12);
  --sheen: rgba(255, 255, 255, 0.72);
  color-scheme: light;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(820px 380px at 8% -8%, var(--wash-a) 0%, transparent 62%),
    radial-gradient(640px 320px at 100% 0%, var(--wash-b) 0%, transparent 58%),
    var(--bg);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121816;
    --card: #1b2422;
    --ink: #e7eeeb;
    --muted: #a8b5b0;
    --line: #2e3b38;
    --line-strong: #3d9ea6;
    --accent: #3d9ea6;
    --accent-ink: #062426;
    --accent-press: #8fd4d4;
    --good: #8ddec0;
    --bad: #f0a8a2;
    --field: #141c1b;
    --tint: #1e3332;
    --formula: #1a3030;
    --formula-hover: #234241;
    --ok-bg: #163028;
    --bad-bg: #3a2220;
    --bot: #24302e;
    --user: #1e3a36;
    --tab-bg: #24302e;
    --wash-a: #1a3330;
    --wash-b: #24302a;
    --focus: #1e5558;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
    --lift: 0 16px 36px rgba(0, 0, 0, 0.35);
    --sheen: rgba(255, 255, 255, 0.08);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, .money, .kpi { font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }

.app { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 80px; }
.top {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  margin-bottom: 16px;
  padding: 18px 18px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  transition: transform 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
}
.top:hover { box-shadow: var(--lift); border-color: var(--line-strong); }
.tools { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
#reset { height: 36px; background: var(--field); }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px; background: var(--tab-bg); border-radius: 12px; }
.brand { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.brand img { width: 28px; height: 28px; display: block; }
h1 { margin: 2px 0 0; font-size: 36px; font-weight: 600; }
.hello { max-width: 46rem; margin: 8px 0 0; color: var(--muted); line-height: 1.5; }
.guides { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.guides button {
  position: relative;
  overflow: hidden;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
  transition: transform 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
}
.guides button::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 28%, var(--sheen) 48%, transparent 68%);
  transform: translateX(-130%);
  pointer-events: none;
}
.guides button:hover { box-shadow: var(--lift); border-color: var(--line-strong); }
.guides button:hover::after { transform: translateX(130%); transition: transform 0.7s ease; }
.guides button[aria-pressed="true"] { border-color: var(--accent); background: var(--tint); }
.guides span { display: block; font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.guides em { display: block; margin-top: 4px; font-style: normal; font-size: 13px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--ink); }
.guides strong { display: block; margin-top: 8px; font-size: 15px; font-weight: 500; line-height: 1.4; color: var(--ink); }
.tabs button {
  border: 0;
  background: transparent;
  border-radius: 9px;
  padding: 8px 12px;
  font-weight: 500;
  color: var(--muted);
  transition: transform 0.25s ease, background 0.25s ease, color 0.25s ease;
}
.tabs button:hover { color: var(--ink); background: var(--field); }
.tabs button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.tabs button:active { transform: scale(0.98); }

.layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr); gap: 16px; align-items: start; }
.layout > * { min-width: 0; }
.panel, .result, .card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  transition: transform 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
}
.panel { padding: 18px; }
.panel:hover, .result:hover { box-shadow: var(--lift); border-color: var(--line-strong); }
.result:hover { transform: translateY(-6px); }
.result { padding: 18px; position: sticky; top: 16px; }
.lead { margin: 0 0 16px; color: var(--muted); line-height: 1.45; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 8px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  transition: transform 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
}
label:hover { background: var(--field); box-shadow: var(--shadow); }
input {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  padding: 0 12px;
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
}
input:hover { border-color: var(--line-strong); }
input:focus { outline: 2px solid var(--focus); border-color: var(--accent); }
label input, label select { width: 100%; min-width: 0; }
select {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  padding: 0 12px;
}

.kpi { margin: 4px 0 0; font-size: 44px; font-weight: 600; line-height: 1; }
.kpi.bad { color: var(--bad); }
.kpi.good { color: var(--good); }
.kicker { margin: 0; display: flex; flex-direction: column; gap: 2px; }
.kicker abbr { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); text-decoration: none; }
.kicker span { font-size: 15px; font-weight: 500; color: var(--ink); }
.formula { margin: 14px 0 0; padding: 10px 12px; background: var(--formula); border-radius: 10px; font-size: 14px; line-height: 1.4; transition: transform 0.3s ease, background 0.3s ease; }
.formula:hover { transform: translateY(-3px); background: var(--formula-hover); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.stats div { background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 10px; transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease; }
.stats div:hover { transform: translateY(-4px); box-shadow: var(--lift); border-color: var(--line-strong); }
.stats span { display: block; color: var(--muted); font-size: 12px; }
.stats strong { display: block; margin-top: 4px; font-size: 18px; }

table { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 14px; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 6px 0; }
td { padding: 8px 0; border-top: 1px solid var(--line); transition: background 0.25s ease, color 0.25s ease; }
tr:hover td { background: var(--tint); }
tr.active td { font-weight: 600; color: var(--accent); }
.comps { display: grid; gap: 8px; }
.comp {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 0.8fr) max-content;
  gap: 8px;
  align-items: end;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid transparent;
  transition: transform 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}
.comp:hover { background: var(--field); border-color: var(--line-strong); }
.comp .drop, .text-btn, .primary {
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--field);
  font-weight: 500;
}
.comp .drop { padding: 0 12px; width: auto; white-space: nowrap; }
.comp .drop:hover, .text-btn:hover { border-color: var(--accent); color: var(--accent); }
.actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); padding: 0 14px; }
.primary:hover, .ask:hover { background: var(--accent-press); }
.text-btn { padding: 0 14px; }
.note { margin: 12px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.lines { list-style: none; margin: 12px 0 0; padding: 0; }
.lines li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 6px; border-top: 1px solid var(--line); border-radius: 8px; font-size: 14px; transition: background 0.25s ease, transform 0.25s ease; }
.lines li:hover { background: var(--tint); transform: translateX(4px); }
.check { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--bad-bg); color: var(--bad); font-size: 14px; transition: transform 0.3s ease; }
.check:hover { transform: translateY(-3px); }
.check.ok { background: var(--ok-bg); color: var(--good); }

@media (max-width: 800px) {
  .top, .layout, .grid, .comp, .guides, .tools { display: grid; grid-template-columns: 1fr; }
  .tools { align-items: stretch; }
  .tabs { width: 100%; }
  .result { position: static; }
  h1 { font-size: 28px; }
}
.ask {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 4;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: var(--shadow);
}
.ask { transition: transform 0.3s ease, background 0.3s ease, box-shadow 0.3s ease; }
.ask:hover { background: var(--accent-press); transform: translateY(-4px); box-shadow: var(--lift); }
.chat {
  position: fixed;
  right: 20px;
  bottom: 72px;
  z-index: 5;
  width: min(360px, calc(100% - 24px));
  max-height: min(520px, calc(100% - 96px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--lift);
}
.chat[hidden] { display: none; }
.chat header { display: flex; justify-content: space-between; align-items: center; }
.chat header button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}
.log { display: flex; flex-direction: column; gap: 8px; overflow: auto; min-height: 120px; }
.log p { margin: 0; padding: 8px 10px; border-radius: 10px; font-size: 14px; line-height: 1.45; }
.log .bot { background: var(--bot); }
.log .user { background: var(--user); align-self: flex-end; }
.suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
.suggestions button {
  border: 1px solid var(--line);
  background: var(--field);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
}
.suggestions button { transition: transform 0.25s ease, border-color 0.25s ease, color 0.25s ease; }
.suggestions button:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }
.chat form { display: flex; gap: 8px; }
.chat input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--field);
}
.chat form button {
  border: 0;
  border-radius: 10px;
  padding: 0 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

@media (prefers-reduced-motion: no-preference) {
  .top, .guides {
    animation: rise 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
  }
  .guides { animation-delay: 0.08s; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .top, .guides button, .guides button::after, .panel, .result, label, .formula, .stats div, .comp, .lines li, .check, .ask, .suggestions button, .tabs button, td {
    transition: none;
  }
  .top:hover, .guides button:hover, .panel:hover, .result:hover, label:hover, .formula:hover, .stats div:hover, .comp:hover, .lines li:hover, .check:hover, .ask:hover, .suggestions button:hover, .tabs button:hover {
    transform: none;
  }
  .guides button:hover::after { transform: none; }
}
