/* Facturas MDE — colores de la plantilla de Maderas de Espino. Móvil primero. */
[hidden] { display: none !important; }
:root {
  --text: #46281d; --label: #5f453b; --muted: #7a6a62; --brown: #6b4936; --beige: #efe6db; --cream: #f6f2ef;
  --line: #e3d2c4; --green: #80932f; --white: #fff; --danger: #a3352b; --ok: #2e6b3f; --warn: #8a5a00;
  --radius: 12px; --nav-h: 64px; --top-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--cream); color: var(--text); }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
h2 { font-size: 1.15rem; margin: 4px 2px 12px; }
h3 { font-size: .95rem; margin: 18px 2px 8px; color: var(--label); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 6px; min-height: calc(var(--top-h) + var(--safe-t));
  padding: var(--safe-t) 10px 0 14px; background: var(--brown); color: #fff; }
.top h1 { flex: 1; font-size: 1.1rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; background: transparent; color: inherit; border-radius: 10px; }
#topActions { display: flex; gap: 6px; }
#view { padding: 14px 14px calc(var(--nav-h) + var(--safe-b) + 28px); max-width: 760px; margin: 0 auto; outline: none; }
body.kb #view { padding-bottom: 28px; }

.bottomnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: #fff; border-top: 1px solid var(--line); }
.bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .74rem; color: var(--muted); text-decoration: none; }
.bottomnav a.active { color: var(--brown); font-weight: 700; }
body.kb .bottomnav { display: none; } /* teclado abierto: la barra no tapa los campos */

.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card-title { display: block; background: var(--beige); margin: -14px -14px 12px; padding: 10px 14px; border-radius: var(--radius) var(--radius) 0 0;
  font-weight: 700; font-size: .9rem; letter-spacing: .03em; text-transform: uppercase; }
.list { list-style: none; padding: 0; margin: 0; }
.list a, .list button.item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 12px; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 8px; color: var(--text); text-decoration: none; text-align: left; font: inherit; }
.list .grow { flex: 1; min-width: 0; }
.list small { display: block; color: var(--muted); }
.list .chev { color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--text); font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--brown); border-color: var(--brown); color: #fff; }
.btn-light { background: #fff; color: var(--brown); border-color: #fff; min-height: 38px; padding: 6px 14px; }
.btn-danger { color: var(--danger); }
.btn-small { min-height: 36px; padding: 5px 12px; font-size: .9rem; }
.btn[disabled] { opacity: .5; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > .btn { flex: 1; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: .85rem; font-weight: 700; color: var(--label); }
.field input, .field textarea, .field select { font: inherit; font-size: 16px; color: var(--text); background: var(--cream); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 12px; min-height: 48px; width: 100%; }
.field textarea { min-height: 72px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--green); border-color: transparent; background: #fff; }
.field .hint { font-size: .8rem; color: var(--muted); }
.field .hint.bad { color: var(--warn); }
.field .hint.good { color: var(--ok); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 48px; font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--brown); }

.alert { padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; font-size: .92rem; background: #fff4df; color: #6b4300; border: 1px solid #f0d9a8; }
.alert.ok { background: #e7f3ea; color: #1e5b35; border-color: #c4e2cc; }
.alert.bad { background: #fbe8e5; color: #8c1d18; border-color: #f0c4be; }
.alert .row { margin-top: 8px; }
.search { width: 100%; font: inherit; font-size: 16px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; margin-bottom: 10px; min-height: 48px; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: .92rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: #2b1d14; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .92rem; transition: all .2s; z-index: 90; max-width: 92vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--danger); } .toast.ok { background: var(--ok); }
body.kb .toast { bottom: 16px; }
.update { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 8px 12px; background: var(--green); color: #fff; font-size: .9rem; }
.update[hidden] { display: none; }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--beige); color: var(--label); }
.dialog { position: fixed; inset: 0; z-index: 95; background: rgba(30, 15, 8, .45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog .box { background: #fff; border-radius: 14px; padding: 18px; width: min(420px, 100%); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
