:root{
  --bg:#f4f6fb;
  --card:#ffffff;
  --text:#101828;
  --muted:#667085;
  --line:#e6e8ef;

  --primary:#2563eb;
  --danger:#dc2626;
  --green:#16a34a;

  --radius:16px;
  --shadow: 0 8px 22px rgba(16,24,40,.08);
}

:root.dark{
  --bg:#0b1220;
  --card:#111a2e;
  --text:#f3f4f6;
  --muted:#a7b0c0;
  --line:#22304a;

  --shadow: 0 10px 26px rgba(0,0,0,.35);
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  color:var(--text);
  background:var(--bg);
}

.bg{ padding-bottom: 84px; } /* espacio para bottom bar */

.appbar{
  position: sticky;
  top:0;
  z-index: 50;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 12px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

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

.brand-title{ font-weight: 800; letter-spacing: .2px; }
.brand-sub{ font-size: 12px; color: var(--muted); margin-top:2px; }

.container{
  max-width: 980px;
  margin: 14px auto;
  padding: 0 12px;
  display:flex;
  flex-direction:column;
  gap:12px;
}

.card{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.card.subtle{
  box-shadow:none;
}

.h1{ margin:0 0 6px 0; font-size: 22px; }
.h2{ margin:0; font-size: 16px; }

.p{ margin: 6px 0 0 0; color: var(--muted); }

.grid{
  display:grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap:10px;
}
@media (max-width: 820px){
  .grid{ grid-template-columns: 1fr; }
}

.field label{
  display:block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.field input, .field select{
  width:100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  outline: none;
}
.field input:focus, .field select:focus{
  border-color: rgba(37,99,235,.55);
  box-shadow: 0 0 0 4px rgba(37,99,235,.12);
}

.stack{ display:flex; flex-direction:column; gap:10px; margin-top:12px; }
.row-between{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.small{ font-size: 12px; color: var(--muted); }
.mono{ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

.note{
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px dashed var(--line);
  color: var(--muted);
}
.hidden{ display:none; }

.btn{
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 12px;
  background: transparent;
  color: var(--text);
  cursor:pointer;
  font-weight: 650;
  white-space: nowrap;
}
.btn.big{ padding: 12px 14px; font-size: 15px; }
.btn.icon{ padding: 10px 12px; }

.btn.primary{ background: var(--primary); color:#fff; }
.btn.green{ background: var(--green); color:#fff; }
.btn.danger{ background: var(--danger); color:#fff; }
.btn.outline{ border-color: var(--line); background: transparent; }
.btn.ghost{ border-color: var(--line); background: transparent; color: var(--text); }

.btn:active{ transform: translateY(1px); }

.footer{
  padding: 18px 12px;
  text-align:center;
  color: var(--muted);
  font-size: 12px;
}

/* Chapters */
.chapters{ display:flex; flex-direction:column; gap:12px; margin-top:12px; }

.chapter{
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}
.chapter-head{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:space-between;
  margin-bottom: 10px;
}
.chapter-title{
  flex:1;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-weight: 750;
}

.items{ display:flex; flex-direction:column; gap:10px; }

.item{
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
}
.item-grid{
  display:grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap:10px;
}
@media (max-width: 820px){
  .item-grid{ grid-template-columns: 1fr 1fr; }
}
.subrow{
  display:flex;
  justify-content:space-between;
  margin-top:8px;
  color: var(--muted);
  font-size: 13px;
}
.actions-row{
  display:flex;
  gap:10px;
  justify-content:flex-end;
  margin-top:10px;
}

.summary{
  margin-top: 10px;
  display:flex;
  flex-direction:column;
  gap:8px;
}
.divider{ height:1px; background: var(--line); margin: 6px 0; }
.total{ font-size: 16px; }

/* Bottom bar */
.bottom-bar{
  position: fixed;
  left:0; right:0; bottom:0;
  z-index: 60;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 10px 10px;
  display:flex;
  gap:8px;
  justify-content: space-between;
  overflow:auto;
}
.bottom-bar .btn{ flex: 0 0 auto; }