:root{
  --bg:#f3f4f6;
  --paper:#ffffff;
  --ink:#0f172a;
  --muted:#64748b;
  --line:#e5e7eb;
  --accent:#111827;
  --danger:#b91c1c;
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,sans-serif;
  background:var(--bg);
  color:var(--ink);
}
.sheet{
  max-width:980px;
  margin:24px auto;
  padding:18px;
}
.header{
  background:var(--paper);
  border:1px solid var(--line);
  border-radius:14px;
  padding:18px 18px 14px;
  margin-bottom:14px;
}
h1{margin:0;font-size:22px;letter-spacing:-0.02em}
.sub{margin:6px 0 0;color:var(--muted);font-size:14px}

.box{
  background:var(--paper);
  border:1px solid var(--line);
  border-radius:14px;
  padding:16px;
  margin-bottom:14px;
}

.grid{
  display:grid;
  grid-template-columns:1fr 1fr 1fr;
  gap:12px;
  align-items:end;
}
@media (max-width:860px){
  .grid{grid-template-columns:1fr}
}

.field span{
  display:block;
  color:var(--muted);
  font-size:12px;
  margin-bottom:6px;
}
.field input{
  width:100%;
  padding:10px 12px;
  border:1px solid var(--line);
  border-radius:10px;
  font-size:15px;
  outline:none;
  background:#fff;
}
.field input:focus{
  border-color:#cbd5e1;
  box-shadow:0 0 0 3px rgba(148,163,184,.25);
}

.actions{
  display:flex;
  gap:10px;
  justify-content:flex-end;
}
@media (max-width:860px){
  .actions{justify-content:stretch}
  .actions button{flex:1}
}

button{
  padding:10px 14px;
  border-radius:10px;
  border:1px solid var(--accent);
  background:var(--accent);
  color:#fff;
  font-weight:600;
  cursor:pointer;
}
button.ghost{
  background:#fff;
  color:var(--accent);
  border-color:var(--line);
}
button:hover{filter:brightness(.98)}
button:active{transform:translateY(1px)}

.err{
  margin:10px 0 0;
  color:var(--danger);
  font-size:13px;
  min-height:1.2em;
}

.hidden{display:none}

.out h2{margin:0 0 12px;font-size:16px}
.kpi{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:10px;
  margin-bottom:14px;
}
@media (max-width:860px){
  .kpi{grid-template-columns:1fr 1fr}
}
.kpi-item{
  border:1px solid var(--line);
  border-radius:12px;
  padding:12px;
  background:#fff;
}
.kpi-item.total{
  border-color:#cbd5e1;
}
.kpi-label{color:var(--muted);font-size:12px}
.kpi-value{font-size:18px;font-weight:750;margin-top:6px}

.detail{
  border-top:1px solid var(--line);
  padding-top:12px;
  margin-top:10px;
  display:grid;
  gap:8px;
}
.row{font-size:14px}
.lbl{color:var(--muted)}
h3{margin:14px 0 8px;font-size:14px}

.table-wrap{
  overflow:auto;
  border:1px solid var(--line);
  border-radius:12px;
}
.tbl{
  width:100%;
  border-collapse:collapse;
  min-width:720px;
  background:#fff;
}
.tbl th,.tbl td{
  padding:10px 10px;
  border-bottom:1px solid var(--line);
  font-size:13px;
  text-align:left;
  white-space:nowrap;
}
.tbl th{
  background:#f8fafc;
  color:#334155;
  font-weight:700;
}
.tbl tfoot td{
  background:#fbfbfb;
  border-bottom:none;
}
.num{text-align:right}

.note{
  margin-top:10px;
  padding:10px 12px;
  border-radius:12px;
  border:1px dashed #cbd5e1;
  color:#334155;
  background:#f8fafc;
  font-size:13px;
}

.foot{
  text-align:center;
  color:var(--muted);
  font-size:12px;
  margin-top:6px;
}


/* Date picker wrapper (calendario) */
.datewrap{
  display:flex;
  gap:10px;
  align-items:center;
  position:relative;
}
.datewrap > input:not(.calpick){
  flex:1;
}
.calbtn{
  width:42px;
  height:42px;
  border-radius:12px;
  border:1px solid var(--line);
  background:#fff;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  user-select:none;
}
.calbtn:active{ transform: translateY(1px); }
.calpick{
  position:absolute;
  right:0;
  top:50%;
  transform: translateY(-50%);
  width:42px;
  height:42px;
  opacity:0;
  cursor:pointer;
  z-index:2;
}
.calbtn{ position:relative; z-index:1; }
