:root{
  --bg:#f4f6f9;
  --card:#ffffff;
  --border:#d9dde3;
  --text:#1f2933;
  --muted:#6b7280;
  --primary:#0f62fe;
  --primary-hover:#0b53d0;
  --danger:#d93025;
  --danger-hover:#b1271b;
}

*,
*::before,
*::after{
  box-sizing:border-box;
}

html,body{
  margin:0;
  padding:0;
  font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  background:var(--bg);
  color:var(--text);
}

.app{
  min-height:100vh;
  display:flex;
  flex-direction:column;
}

.topbar{
  background:#ffffff;
  border-bottom:1px solid var(--border);
  position:sticky;
  top:0;
  z-index:50;
}

.topbar__inner{
  max-width:1100px;
  margin:0 auto;
  padding:12px 16px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
}

.brand__title{
  font-size:18px;
  font-weight:600;
}

.brand__sub{
  font-size:12px;
  color:var(--muted);
}

.topbar__nav .link{
  text-decoration:none;
  color:var(--primary);
  margin-left:16px;
  font-size:14px;
}

.main{
  flex:1;
  padding:24px 12px;
}

.card{
  max-width:1100px;
  margin:0 auto 24px auto;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:10px;
  padding:20px;
}

.h1{
  margin:0 0 18px 0;
  font-size:24px;
}

.h2{
  margin:0;
  font-size:18px;
}

.form{
  display:flex;
  flex-direction:column;
  gap:18px;
}

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

.label{
  font-size:13px;
  color:var(--muted);
}

.input,
.select,
.textarea{
  border:1px solid var(--border);
  border-radius:6px;
  padding:10px;
  font-size:15px;
  background:#fff;
}

.textarea{
  resize:vertical;
}

.grid{
  display:grid;
  gap:16px;
}

.grid--2{
  grid-template-columns:repeat(2,1fr);
}

.grid--4{
  grid-template-columns:repeat(4,1fr);
}

.grid__full{
  grid-column:1/-1;
}

.section-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-top:12px;
}

.section-head__actions{
  display:flex;
  gap:8px;
}

.btn{
  border:none;
  border-radius:6px;
  padding:10px 14px;
  font-size:14px;
  cursor:pointer;
  background:#e5e7eb;
}

.btn--primary{
  background:var(--primary);
  color:#fff;
}

.btn--primary:hover{
  background:var(--primary-hover);
}

.btn--danger{
  background:var(--danger);
  color:#fff;
}

.btn--danger:hover{
  background:var(--danger-hover);
}

.btn--ghost{
  background:#eef2f7;
}

.btn--small{
  padding:6px 10px;
  font-size:12px;
}

.btn--wide{
  width:100%;
}

.entries{
  display:flex;
  flex-direction:column;
  gap:18px;
}

.entry{
  border:1px solid var(--border);
  border-radius:10px;
  padding:14px;
  background:#fff;
}

.entry__header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:12px;
}

.entry__title{
  font-weight:600;
}

.entry__calc{
  display:flex;
  gap:20px;
  margin-top:12px;
  flex-wrap:wrap;
}

.calc__label{
  font-size:12px;
  color:var(--muted);
}

.calc__value{
  font-size:15px;
  font-weight:600;
}

.actions{
  margin-top:10px;
}

.alert{
  border:1px solid var(--border);
  border-radius:8px;
  padding:12px;
  font-size:14px;
  background:#f8fafc;
}

.alert--error{
  border-color:#f1b5b2;
  background:#fde8e7;
}

.alert--success{
  border-color:#b7e4c7;
  background:#e6f7ec;
}

.sticky-summary{
  position:sticky;
  top:64px;
  background:#ffffff;
  border:1px solid var(--border);
  border-radius:10px;
  padding:10px 14px;
  margin:10px 0 18px 0;
  z-index:20;
}

.sticky-summary__row{
  display:flex;
  justify-content:space-between;
  font-size:14px;
  gap:10px;
}

.paper{
  border:1px solid var(--border);
  border-radius:10px;
  padding:16px;
  margin-top:10px;
}

.paper--compact{
  padding:12px 16px;
}

.paper__section{
  margin-bottom:18px;
}

.paper__title{
  font-weight:600;
  margin-bottom:10px;
}

.kv__row{
  display:flex;
  justify-content:space-between;
  padding:4px 0;
  gap:12px;
}

.kv__k{
  color:var(--muted);
}

.table{
  display:flex;
  flex-direction:column;
  border:1px solid var(--border);
  border-radius:8px;
  overflow:hidden;
}

.table__head,
.table__row{
  display:grid;
  grid-template-columns:repeat(6,1fr);
}

.table__head{
  background:#f3f4f6;
  font-weight:600;
  font-size:13px;
}

.table__row{
  font-size:14px;
}

.table__head > div,
.table__row > div{
  padding:8px;
  border-bottom:1px solid var(--border);
}

.note-block__item{
  border:1px solid var(--border);
  padding:10px;
  border-radius:6px;
  margin-bottom:8px;
  background:#fff;
}

.toggle{
  display:flex;
  align-items:center;
  gap:10px;
  user-select:none;
  font-size:14px;
}

.toggle input{
  width:20px;
  height:20px;
}

.sig{
  margin-top:10px;
  border:1px solid var(--border);
  border-radius:10px;
  background:#ffffff;
  padding:10px;
}

.sig__canvas{
  width:100%;
  height:200px;
  background:#ffffff;
  display:block;
  touch-action:none;
}

@media (max-width:900px){
  .grid--4{
    grid-template-columns:repeat(2,1fr);
  }
}

@media (max-width:640px){
  .grid--2{
    grid-template-columns:1fr;
  }
  .grid--4{
    grid-template-columns:1fr;
  }
  .kv__row{
    flex-direction:column;
    align-items:flex-start;
  }
  .table__head{
    display:none;
  }
  .table__row{
    grid-template-columns:1fr;
    gap:6px;
    padding:10px 8px;
  }
  .table__row > div{
    border-bottom:none;
    padding:0;
  }
  .table__row > div::before{
    content:attr(data-label) ": ";
    color:var(--muted);
    font-size:13px;
  }
}