:root{
  --bg:#f6f7fb;
  --card:#ffffff;
  --ink:#101827;
  --muted:#667085;
  --line:#e5e7eb;
  --soft:#f9fafb;
  --brand:#b42323;
  --brand2:#7f1d1d;
  --good:#15803d;
  --bad:#dc2626;
  --warn:#b45309;
  --shadow:0 18px 50px rgba(16,24,40,.09);
  --radius:20px;
  color-scheme:light;
}

html[data-theme="dark"]{
  --bg:#080f1f;
  --card:#0f172a;
  --ink:#e5e7eb;
  --muted:#98a2b3;
  --line:#263247;
  --soft:#0b1326;
  --brand:#ef4444;
  --brand2:#991b1b;
  --good:#22c55e;
  --bad:#fb7185;
  --warn:#f59e0b;
  --shadow:0 18px 55px rgba(0,0,0,.45);
  color-scheme:dark;
}

*{box-sizing:border-box}

body{
  margin:0;
  font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;
  background:
    radial-gradient(900px 420px at 20% -10%, rgba(180,35,35,.18), transparent 60%),
    radial-gradient(600px 350px at 90% 5%, rgba(127,29,29,.12), transparent 60%),
    var(--bg);
  color:var(--ink);
  line-height:1.45;
}

.app{
  width:min(1180px,92vw);
  margin:0 auto;
  padding:28px 0 50px;
}

.hero{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:22px;
  margin-bottom:22px;
}

.eyebrow{
  margin:0 0 6px;
  color:var(--brand);
  font-weight:800;
  letter-spacing:.06em;
  text-transform:uppercase;
  font-size:.78rem;
}

h1,h2,h3,p{margin-top:0}

h1{
  margin-bottom:8px;
  font-size:clamp(2rem,4vw,3.25rem);
  letter-spacing:-.05em;
  line-height:1;
}

.lead{
  margin:0;
  color:var(--muted);
  max-width:680px;
}

.heroActions{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.themeSwitch{
  display:flex;
  align-items:center;
  gap:8px;
  padding:9px 11px;
  border:1px solid var(--line);
  border-radius:999px;
  background:rgba(255,255,255,.55);
  color:var(--muted);
  font-size:.9rem;
}

html[data-theme="dark"] .themeSwitch{
  background:rgba(15,23,42,.65);
}

.themeSwitch input{
  appearance:none;
  width:44px;
  height:24px;
  border-radius:999px;
  border:1px solid var(--line);
  background:#cbd5e1;
  position:relative;
  cursor:pointer;
}

.themeSwitch input:before{
  content:"";
  width:18px;
  height:18px;
  border-radius:50%;
  position:absolute;
  left:2px;
  top:2px;
  background:#fff;
  transition:.18s ease;
  box-shadow:0 2px 7px rgba(0,0,0,.2);
}

.themeSwitch input:checked{
  background:rgba(239,68,68,.65);
}

.themeSwitch input:checked:before{
  transform:translateX(20px);
}

button,
select,
input{
  font:inherit;
}

.ghostBtn{
  border:1px solid var(--line);
  background:var(--card);
  color:var(--ink);
  border-radius:999px;
  padding:10px 14px;
  cursor:pointer;
  font-weight:750;
}

.layout{
  display:grid;
  grid-template-columns:minmax(0,1.08fr) minmax(360px,.92fr);
  gap:18px;
  align-items:start;
}

.card{
  background:rgba(255,255,255,.86);
  border:1px solid rgba(229,231,235,.82);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  overflow:hidden;
  backdrop-filter:blur(12px);
}

html[data-theme="dark"] .card{
  background:rgba(15,23,42,.9);
  border-color:rgba(38,50,71,.95);
}

.cardHeader{
  padding:18px 20px;
  border-bottom:1px solid var(--line);
  display:flex;
  justify-content:space-between;
  gap:12px;
}

.cardHeader h2{
  margin:0 0 4px;
  font-size:1.15rem;
  letter-spacing:-.02em;
}

.cardHeader p{
  margin:0;
  color:var(--muted);
  font-size:.92rem;
}

.saveStatus{
  color:var(--muted);
  font-size:.85rem;
  white-space:nowrap;
}

.form{
  padding:20px;
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:14px;
}

.field{
  display:flex;
  flex-direction:column;
  gap:7px;
}

.field.full,
.full{
  grid-column:1 / -1;
}

label{
  font-weight:750;
  font-size:.92rem;
}

input,
select{
  width:100%;
  border:1px solid var(--line);
  background:var(--soft);
  color:var(--ink);
  border-radius:14px;
  padding:12px 13px;
  min-height:48px;
  outline:none;
}

input:focus,
select:focus{
  border-color:rgba(239,68,68,.6);
  box-shadow:0 0 0 4px rgba(239,68,68,.13);
}

.moneyInput{
  display:flex;
  align-items:center;
  gap:8px;
  border:1px solid var(--line);
  background:var(--soft);
  border-radius:14px;
  padding:0 12px;
}

.moneyInput:focus-within{
  border-color:rgba(239,68,68,.6);
  box-shadow:0 0 0 4px rgba(239,68,68,.13);
}

.moneyInput span{
  color:var(--muted);
  font-weight:800;
}

.moneyInput input{
  border:0;
  background:transparent;
  padding-left:0;
  padding-right:0;
  box-shadow:none !important;
}

.inlineCheck{
  display:flex;
  flex-direction:row;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  padding:13px;
  border:1px solid var(--line);
  border-radius:16px;
  background:var(--soft);
}

.inlineCheck > label{
  display:flex;
  align-items:center;
  gap:10px;
}

.inlineCheck input[type="checkbox"]{
  width:18px;
  height:18px;
  min-height:auto;
}

.miniField{
  display:flex;
  align-items:center;
  gap:10px;
}

.miniField input{
  width:130px;
  min-height:40px;
  background:var(--card);
}

.advanced{
  border:1px solid var(--line);
  border-radius:16px;
  padding:14px;
  background:rgba(180,35,35,.035);
}

.advanced summary{
  cursor:pointer;
  font-weight:850;
}

.advancedGrid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:14px;
  margin-top:14px;
}

.hint{
  color:var(--muted);
  font-size:.82rem;
  margin:0;
}

.resultCard{
  position:sticky;
  top:18px;
}

.resultTone{
  margin:20px;
  padding:20px;
  border-radius:20px;
  border:1px solid var(--line);
  background:var(--soft);
}

.resultTone p{
  margin:0 0 8px;
  color:var(--muted);
  font-weight:750;
}

.resultTone strong{
  display:block;
  font-size:clamp(1.8rem,4vw,2.55rem);
  letter-spacing:-.04em;
  line-height:1;
}

.resultTone span{
  display:block;
  margin-top:10px;
  color:var(--muted);
  font-size:.92rem;
}

.resultTone.good{
  border-color:rgba(21,128,61,.35);
  background:rgba(21,128,61,.08);
}

.resultTone.bad{
  border-color:rgba(220,38,38,.35);
  background:rgba(220,38,38,.08);
}

.metricGrid{
  padding:0 20px 20px;
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
}

.metric{
  border:1px solid var(--line);
  background:var(--soft);
  border-radius:16px;
  padding:14px;
  min-height:94px;
}

.metric span{
  display:block;
  color:var(--muted);
  font-size:.84rem;
  margin-bottom:8px;
}

.metric strong{
  font-size:1.05rem;
  font-variant-numeric:tabular-nums;
  word-break:break-word;
}

.detailsBlock{
  padding:0 20px 20px;
}

.detailsBlock h3{
  margin:2px 0 10px;
  font-size:1rem;
}

.detailRows{
  display:grid;
  gap:8px;
}

.detailRow{
  display:flex;
  justify-content:space-between;
  gap:12px;
  border:1px solid var(--line);
  border-radius:13px;
  padding:10px 12px;
  background:rgba(255,255,255,.35);
  font-variant-numeric:tabular-nums;
}

html[data-theme="dark"] .detailRow{
  background:rgba(255,255,255,.025);
}

.detailRow span:first-child{
  color:var(--muted);
}

.detailRow strong{
  text-align:right;
}

.footer{
  margin-top:18px;
  color:var(--muted);
  font-size:.88rem;
}

@media (max-width:900px){
  .hero{
    flex-direction:column;
    align-items:flex-start;
  }

  .heroActions{
    justify-content:flex-start;
  }

  .layout{
    grid-template-columns:1fr;
  }

  .resultCard{
    position:static;
    order:-1;
  }
}

@media (max-width:560px){
  .app{
    width:min(94vw,1180px);
    padding-top:18px;
  }

  .form,
  .advancedGrid,
  .metricGrid{
    grid-template-columns:1fr;
  }

  .inlineCheck{
    flex-direction:column;
    align-items:flex-start;
  }

  .miniField{
    width:100%;
    justify-content:space-between;
  }

  .miniField input{
    width:150px;
  }

  .detailRow{
    flex-direction:column;
    gap:4px;
  }

  .detailRow strong{
    text-align:left;
  }
}
