:root{
  --bg:#f5f7fa;
  --text:#111827;
  --muted:#6b7280;
  --line:#e5e7eb;
  --green:#059669;
  --red:#dc2626;
}

*{ box-sizing:border-box; }

body{
  margin:0;
  font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  background:linear-gradient(180deg,#fff,var(--bg));
  color:var(--text);
  min-height:100vh;
}

.hidden{ display:none !important; }

.login-page{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
}

.login-card{
  width:min(520px,100%);
  background:rgba(255,255,255,.9);
  border:1px solid white;
  border-radius:34px;
  padding:34px;
  box-shadow:0 30px 100px rgba(0,0,0,.09);
}

.login-card h1{
  font-size:56px;
  line-height:.95;
  margin:0;
  letter-spacing:-.06em;
}

.login-copy{
  color:var(--muted);
  font-size:17px;
  line-height:1.6;
  margin:18px 0 24px;
}

.login-form{
  display:grid;
  gap:12px;
}

.form-error{
  margin:4px 0 0;
  color:var(--red);
  font-weight:700;
}

.app{
  max-width:1200px;
  margin:auto;
  padding:48px 20px;
}

.hero{
  display:flex;
  justify-content:space-between;
  align-items:end;
  gap:24px;
  margin-bottom:28px;
}

.hero-actions{
  display:flex;
  align-items:center;
  gap:14px;
}

.eyebrow{
  margin:0 0 8px;
  text-transform:uppercase;
  font-size:12px;
  letter-spacing:.12em;
  color:var(--muted);
  font-weight:700;
}

h1{
  margin:0;
  font-size:72px;
  line-height:.9;
  letter-spacing:-.06em;
}

h2{ margin:0; }

.budget-stack{
  background:#111827;
  color:white;
  padding:18px 24px;
  border-radius:26px;
  font-size:20px;
  font-weight:800;
  line-height:1.5;
  white-space:nowrap;
}

.cards{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:18px;
  margin-bottom:18px;
}

.card,.panel{
  background:rgba(255,255,255,.85);
  border-radius:28px;
  border:1px solid white;
  box-shadow:0 20px 60px rgba(0,0,0,.06);
}

.card{ padding:24px; }

.card span{
  display:block;
  margin-bottom:12px;
  color:var(--muted);
  font-weight:600;
}

.card strong{ font-size:28px; }

.panel{
  padding:26px;
  margin-bottom:18px;
}

.progress-head,.section-head,.estimate-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:16px;
}

.progress{
  margin-top:14px;
  height:20px;
  background:#e5e7eb;
  border-radius:999px;
  overflow:hidden;
}

.progress-fill{
  height:100%;
  width:0%;
  background:linear-gradient(90deg,#111827,#4b5563);
}

.secondary-fill{
  background:linear-gradient(90deg,#374151,#9ca3af);
}

button{
  border:0;
  background:#111827;
  color:white;
  padding:13px 18px;
  border-radius:999px;
  font-weight:700;
  cursor:pointer;
  font-size:15px;
}

button.secondary{
  background:#f3f4f6;
  color:#111827;
}

button.danger{
  background:#fee2e2;
  color:#991b1b;
}

.logout-btn{
  white-space:nowrap;
}

.plus-btn{
  width:52px;
  height:52px;
  padding:0;
  font-size:32px;
  line-height:1;
}

.add-wrap{
  position:relative;
}

.add-tooltip{
  position:absolute;
  right:0;
  top:64px;
  z-index:10;
  width:min(360px,90vw);
  background:white;
  border:1px solid var(--line);
  border-radius:24px;
  padding:18px;
  box-shadow:0 24px 80px rgba(0,0,0,.18);
}

.add-tooltip::before{
  content:"";
  position:absolute;
  right:20px;
  top:-9px;
  width:18px;
  height:18px;
  background:white;
  border-left:1px solid var(--line);
  border-top:1px solid var(--line);
  transform:rotate(45deg);
}

.add-tooltip input,
.add-tooltip select,
.add-tooltip button{
  width:100%;
  margin-top:12px;
}

input,select{
  border:1px solid var(--line);
  padding:14px 16px;
  border-radius:16px;
  font-size:16px;
  outline:none;
  background:white;
  width:100%;
}

.estimate{
  border:1px solid var(--line);
  border-radius:24px;
  padding:24px;
  margin-top:18px;
  background:white;
}

.estimate-title{
  font-size:26px;
  font-weight:800;
}

.legend{
  color:var(--muted);
  line-height:1.7;
}

.metrics{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:14px;
  margin:22px 0;
}

.metric{
  background:#f9fafb;
  border-radius:18px;
  padding:16px;
}

.metric span{
  display:block;
  color:var(--muted);
  margin-bottom:6px;
  font-size:13px;
}

.metric strong{ font-size:18px; }

.chart-wrap{
  display:flex;
  align-items:center;
  gap:24px;
  margin-top:20px;
}

.pie{
  width:120px;
  height:120px;
  border-radius:50%;
  background:conic-gradient(#111827 var(--deg), #e5e7eb 0deg);
  flex:0 0 auto;
}

.payments{ margin-top:18px; }

.payment{
  padding:12px 0;
  border-top:1px solid var(--line);
  color:var(--muted);
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:center;
}

.payment-main{ flex:1; }

.small-inline{
  padding:8px 12px;
  font-size:13px;
}

.item-actions{
  display:flex;
  gap:10px;
  margin-top:18px;
  flex-wrap:wrap;
}

.over{ color:var(--red); }
.under{ color:var(--green); }

.checkbox-row{
  display:flex;
  align-items:center;
  gap:10px;
  margin-top:14px;
  color:var(--muted);
}

.checkbox-row input{
  width:auto;
  margin:0;
}

dialog{
  border:0;
  border-radius:26px;
  padding:28px;
  width:min(420px,90vw);
  box-shadow:0 30px 100px rgba(0,0,0,.25);
}

dialog::backdrop{
  background:rgba(17,24,39,.45);
}

dialog input,dialog button{
  width:100%;
  margin-top:12px;
}

@media(max-width:1000px){
  .hero{
    align-items:flex-start;
    flex-direction:column;
  }

  .hero-actions{
    width:100%;
    justify-content:space-between;
  }

  .cards,.metrics{
    grid-template-columns:repeat(2,1fr);
  }
}

@media(max-width:700px){
  .app{
    padding:28px 14px;
  }

  h1,
  .login-card h1{
    font-size:44px;
  }

  .login-card{
    padding:24px;
    border-radius:28px;
  }

  .cards,.metrics,.chart-wrap,.section-head,.estimate-head{
    display:block;
  }

  .card,.metric{
    width:100%;
    margin-top:12px;
  }

  .hero-actions{
    display:block;
  }

  .budget-stack{
    width:100%;
    white-space:normal;
    font-size:18px;
  }

  .logout-btn{
    width:100%;
    margin-top:12px;
  }

  .plus-btn{
    width:100%;
    margin-top:16px;
  }

  .add-tooltip{
    position:static;
    width:100%;
    margin-top:16px;
  }

  .add-tooltip::before{
    display:none;
  }

  .payment{
    display:block;
  }

  .small-inline{
    width:100%;
    margin-top:10px;
  }
}