:root { --moss: #2f5d3a; --moss-d: #1f3d27; --sage: #e7eee3; --line: #dde3d8; --ink: #1d2a21; --muted: #637166; --water: #2a7f80; --bg: #f4f6f2; --err: #a3322b; --warn: #8a520c; --ok: #2f6b3a; }
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.5; }
a { color: var(--moss); }
h1 { font-size: 1.6rem; margin: 0 0 16px; color: var(--moss-d); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 1.1rem; margin: 0 0 12px; color: var(--moss-d); }
h3 { font-size: .95rem; margin: 12px 0 4px; }
code, .mono { font-family: ui-monospace, Menlo, monospace; font-size: .85em; }
.muted { color: var(--muted); }
.page { max-width: 1240px; margin: 0 auto; padding: 22px 18px 60px; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { display: inline-block; background: var(--moss); color: #fff; border: 0; border-radius: 8px; padding: 9px 16px; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--moss-d); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: .9rem; }
.btn-ghost { background: #fff; color: var(--moss); box-shadow: inset 0 0 0 1.5px var(--moss); }
.btn-ghost:hover { background: var(--sage); color: var(--moss-d); }
.btn-danger { background: var(--err); }
.btn-block { display: block; width: 100%; text-align: center; }
.flash { padding: 10px 14px; border-radius: 8px; margin: 0 0 12px; font-weight: 600; }
.flash-ok { background: #dcefdc; color: var(--ok); }
.flash-aviso { background: #fbeccd; color: var(--warn); }
.flash-error { background: #f8dcd9; color: var(--err); }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin: 0 0 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; }
.kpi span { color: var(--muted); font-size: .9rem; }
.kpi b { font-size: 1.6rem; color: var(--moss-d); }
.cols { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }
table.t { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 14px; }
.panel table.t { border: 0; }
table.t th, table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.t th { background: var(--sage); font-size: .85rem; color: #3b4a3f; }
table.t tr.dim td { opacity: .55; }
table.t tfoot td { font-weight: 600; }
.strong td, td.strong { font-weight: 800; }
.num { text-align: right !important; white-space: nowrap; }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
.in-num { width: 80px; }
.in-money { width: 110px; }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid #c9d2c4; border-radius: 7px; background: #fff; max-width: 100%; }
textarea { width: 100%; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .92rem; margin-bottom: 12px; }
label small { font-weight: 400; color: var(--muted); }
label.check, label.radio { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.err { color: var(--err); font-size: .85rem; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input[type=search] { min-width: 260px; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0 0 10px; }
.form-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }
.form-grid input:not([type=checkbox]):not([type=file]), .form-grid select, .form-stack input:not([type=checkbox]):not([type=radio]), .form-stack select, .settings input:not([type=checkbox]), .settings select { width: 100%; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.preview { border-radius: 8px; margin-bottom: 8px; }
.pill { display: inline-block; font-size: .72rem; font-weight: 800; padding: 1px 8px; border-radius: 999px; }
.pill-live { background: #d7ecec; color: var(--water); }
.st { font-size: .8rem; font-weight: 800; padding: 3px 10px; border-radius: 999px; background: #eee; white-space: nowrap; }
.st-pendiente_pago { background: #fbeccd; color: var(--warn); }
.st-pagado { background: #d9ecf7; color: #1f5f86; }
.st-preparando { background: #e5dcf5; color: #563c8a; }
.st-enviado { background: #d7ecec; color: var(--water); }
.st-entregado { background: #dcefdc; color: var(--ok); }
.st-cancelado { background: #eee; color: #666; }
.events { list-style: none; padding: 0; margin: 0; font-size: .92rem; }
.events li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.events time { color: var(--muted); margin-right: 8px; }
.cat-head, .cat-form { display: grid; grid-template-columns: 1.4fr 1.2fr 1.1fr 80px 90px 70px 90px; gap: 8px; align-items: center; }
.cat-head { font-size: .85rem; color: var(--muted); font-weight: 700; padding: 0 10px 6px; }
.cat-list { background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 16px; }
.cat-form { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.cat-form label { margin: 0; }
.cat-form input[name=name], .cat-form select { width: 100%; }
.nowrap { display: flex; gap: 6px; align-items: center; }
.nowrap select { flex: 1; }
.nowrap input[type=color] { width: 40px; height: 34px; padding: 2px; }
.lines input[name="desc[]"] { width: 100%; }
body.is-login { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(160deg, #e7eee3, #cfe0d6); }
.login-box { background: #fff; padding: 30px; border-radius: 16px; width: min(380px, 92vw); box-shadow: 0 10px 30px rgba(0,0,0,.08); text-align: center; }
.login-box form { text-align: left; margin-top: 12px; }
.login-box input { width: 100%; }
.login-box h1 { justify-content: center; font-size: 1.3rem; }
.login-box img { margin: 0 auto 8px; display: block; }
@media (max-width: 900px) {
  .cols, .form-grid, .row2, .row3 { grid-template-columns: 1fr; }
  .cat-head { display: none; }
  .cat-form { grid-template-columns: 1fr 1fr; }
  table.t { display: block; overflow-x: auto; }
}
.steps { display: flex; gap: 6px; margin: 0 0 16px; flex-wrap: wrap; }
.steps span { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 4px 14px; color: var(--muted); font-weight: 600; font-size: .9rem; }
.steps span.on { background: var(--moss); border-color: var(--moss); color: #fff; }
.map-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table.t.map { margin: 0; border: 0; min-width: 100%; }
table.t.map th { vertical-align: top; min-width: 170px; background: #f1f5ef; }
table.t.map td { font-size: .85rem; white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.col-name { font-weight: 800; margin-bottom: 6px; white-space: nowrap; }
table.t.map select { width: 100%; font-size: .85rem; }
table.t.map select.set { border-color: var(--moss); background: #e6f1e3; font-weight: 700; }
.pill-bo { background: #fbeccd; color: var(--warn); }
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { display: grid; grid-template-columns: 1.6fr 2fr auto; gap: 10px; align-items: center; padding: 5px 0; font-size: .92rem; }
.bars .bar { background: var(--sage); border-radius: 6px; height: 14px; overflow: hidden; }
.bars .bar i { display: block; height: 100%; background: var(--moss); border-radius: 6px; }
.bars .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs a { padding: 4px 12px; border-radius: 999px; text-decoration: none; border: 1px solid var(--line); font-size: .88rem; font-weight: 600; background: #fff; }
.tabs a.on { background: var(--moss); color: #fff; border-color: var(--moss); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.panel-head h2 { margin: 0; }
.chart svg { width: 100%; height: auto; display: block; }
.bo-group { border-top: 1px solid var(--line); padding: 10px 0; }
.bo-group:first-of-type { border-top: 0; }
.st-po-borrador { background: #fbeccd; color: var(--warn); }
.st-po-enviado { background: #d7ecec; color: var(--water); }
.st-po-recibido { background: #dcefdc; color: var(--ok); }
.st-po-cancelado { background: #eee; color: #666; }
details.help { margin-top: 8px; font-size: .9rem; color: var(--muted); }
details.help summary { cursor: pointer; font-weight: 600; color: var(--moss); }
details.help code { background: #f0f3ee; padding: 1px 5px; border-radius: 4px; }
.cat-child td:first-child { padding-left: 28px; }
.cat-form.cat-sub > input[name="name"] { margin-left: 22px; width: calc(100% - 22px); }
.cat-form.cat-top > input[name="name"] { font-weight: 700; }
.export-btns { display: inline-flex; gap: 6px; vertical-align: middle; }
h2 .export-btns { margin-left: 10px; font-size: .9rem; font-weight: 400; }
label.check, label.radio { justify-content: flex-start; } label.check input, label.radio input { width: auto; flex: none; }

.chip-mini{display:inline-block;background:#eef2ee;border-radius:10px;padding:1px 8px;margin:2px 2px 0 0;font-size:.85em}
.gal-item{display:inline-flex;align-items:center;gap:6px;margin:0 10px 6px 0}
.gal-item img{border-radius:6px;object-fit:cover}

/* Panel en el móvil */
@media (max-width: 900px) {
  .page { padding: 14px 12px 50px; }
  h1 { font-size: 1.3rem; }
  .head .actions { width: 100%; }
  .head .actions .btn { flex: 1 1 auto; text-align: center; }
  input, select, textarea { max-width: 100%; font-size: 16px; }
  .panel { padding: 14px 12px; }
  .panel { overflow-x: auto; }
}

/* Menú lateral agrupado */
:root { --side-w: 236px; }
body.has-side { padding-left: var(--side-w); }
.side { position: fixed; inset: 0 auto 0 0; width: var(--side-w); background: var(--moss-d); color: #fff; display: flex; flex-direction: column; z-index: 30; overflow-y: auto; overscroll-behavior: contain; }
.side .brand { color: #fff; text-decoration: none; display: flex; gap: 12px; align-items: center; padding: 16px 16px 14px; font-weight: 800; font-size: 1.2rem; letter-spacing: .02em; border-bottom: 1px solid rgba(255,255,255,.08); }
.side .brand small { display: block; font-weight: 500; font-size: .75rem; color: #a9c2a7; letter-spacing: .06em; text-transform: uppercase; }
.side nav { flex: 1; padding: 8px 8px 12px; }
.side-group { margin-top: 6px; }
.side-group summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; padding: 8px 10px 4px; font-size: .72rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: #9fbb9c; user-select: none; }
.side-group summary::-webkit-details-marker { display: none; }
.side-group summary::after { content: "▸"; margin-left: auto; font-size: .8rem; transition: transform .15s; }
.side-group[open] summary::after { transform: rotate(90deg); }
.side-group summary:hover { color: #d6e3d1; }
.side-link { display: flex; align-items: center; gap: 10px; color: #d6e3d1; text-decoration: none; padding: 8px 10px; border-radius: 8px; font-weight: 600; font-size: .94rem; }
.side-link .ico { width: 20px; text-align: center; font-size: .95rem; filter: grayscale(.2); }
.side-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.side-link.on { background: rgba(143,201,143,.22); color: #fff; box-shadow: inset 3px 0 0 #8fc98f; }
.side .badge { margin-left: auto; background: #e0a43a; color: #2b1d05; border-radius: 10px; font-size: .72rem; padding: 0 7px; line-height: 1.5; font-weight: 800; }
.side-group summary .badge { margin-left: 4px; }
.side-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08); }
.side-foot a { color: #d6e3d1; font-size: .9rem; }
.side-foot button { background: none; border: 1px solid #7d9a80; color: #fff; border-radius: 6px; padding: 4px 10px; cursor: pointer; font: inherit; font-size: .9rem; }
.mtop { display: none; }
.side-shade { position: fixed; inset: 0; background: rgba(15,25,18,.45); z-index: 25; }
@media (max-width: 900px) {
  body.has-side { padding-left: 0; }
  .side { transform: translateX(-100%); transition: transform .2s ease; width: min(84vw, 300px); box-shadow: 4px 0 24px rgba(0,0,0,.25); }
  body.side-open .side { transform: none; }
  body.side-open { overflow: hidden; }
  .mtop { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20; background: var(--moss-d); color: #fff; padding: 8px 12px; }
  .mtop .brand { display: flex; }
  .mtop-cur { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #e6efe3; }
  .nav-toggle { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.1); color: #fff; border: 1px solid #5d7d62; border-radius: 8px; padding: 6px 10px; font: inherit; font-weight: 700; cursor: pointer; }
  .side-link { padding: 11px 12px; font-size: 1rem; }
}
@media print { .side, .mtop { display: none !important; } body.has-side { padding-left: 0; } }

/* Gastos y banco */
.warn-txt { color: var(--warn); }
.ok-txt { color: var(--ok); }
.small { font-size: .88rem; }
.kpi small { margin-top: 2px; }
td.neg { color: var(--err); }
td.pos { color: var(--ok); }
.linkish { background: none; border: 0; padding: 0; color: var(--moss); text-decoration: underline; cursor: pointer; font: inherit; font-size: .88rem; }
.inline-form { display: inline; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 4px 0; border-bottom: 1px solid var(--line); }
.nowrap-cell { white-space: nowrap; }
.bank-t td { vertical-align: top; }
.bank-what { min-width: 320px; }
.bank-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.bank-form .bank-choice { flex: 1 1 260px; max-width: 420px; }
.bank-form .bank-supplier { flex: 1 1 140px; }
.bank-form .bank-pattern { width: 130px; }
.bank-form .check { margin: 0; }
.bank-form:not(.is-new) .bank-supplier { display: none; }
.bank-form:not(.can-remember) .check, .bank-form:not(.can-remember) .bank-pattern { display: none; }
.bank-form:not(.remembering) .bank-pattern { display: none; }
.bank-import .inline { margin: 0 0 6px; }
.money-row input { max-width: 100%; }
@media (max-width: 900px) {
  .bank-t, .bank-t tbody, .bank-t tr, .bank-t td { display: block; width: 100%; }
  .bank-t thead { display: none; }
  .bank-t tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  .bank-t td { border: 0; padding: 2px 10px; text-align: left !important; }
  .bank-what { min-width: 0; }
}

/* Fotos de portada y de la ficha */
.photo-admin { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 12px; }
.photo-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: #fff; }
.photo-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; display: block; margin-bottom: 8px; }
.photo-card label { font-size: .88rem; }
