:root {
  --g900: #062e16; --g800: #0a5a27; --g700: #0e6e31; --g600: #13873b; --g500: #1f9d48; --g300: #7ccf3f; --g200: #b8f27a; --g50: #eef7ef;
  --ink: #12261a; --muted: #5b6f63; --line: #d9e5dc; --bg: #f4f7f3; --card: #ffffff;
  --warn: #d9480f; --warn-bg: #fff4e6; --gold: #ffd23f;
  --r: 14px; --shadow: 0 1px 2px rgba(6, 46, 22, .06), 0 4px 16px rgba(6, 46, 22, .06);
  --display: 'Archivo', system-ui, sans-serif; --body: 'IBM Plex Sans', system-ui, sans-serif; --mono: 'IBM Plex Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--body); }
a { color: var(--g700); }
button, input, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--display); margin: 0; letter-spacing: -.01em; }
[hidden] { display: none !important; }

.logo { display: inline-block; width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: var(--g200) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M9 7h14v4H9zM8 12h2v14H8zM22 12h2v14h-2zM10 16h12v1.5H10zM10 20h12v1.5H10zM8 26h16v-3H8z' fill='%230a5a27'/%3E%3C/svg%3E") center/80% no-repeat; }
.logo.big { width: 56px; height: 56px; border-radius: 14px; }

/* ---- barra superior ---- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--g800); color: #fff; }
.topbar .tt { flex: 1; min-width: 0; }
.topbar h1 { font-size: 18px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar p { margin: 0; font-size: 13px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iconbtn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 0; background: rgba(255, 255, 255, .12); color: #fff; cursor: pointer; flex: none; }
.iconbtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn.sm { width: 34px; height: 34px; background: var(--g50); color: var(--g800); }
.save { font-size: 12px; padding: 4px 9px; border-radius: 99px; background: rgba(255, 255, 255, .14); white-space: nowrap; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
.save.busy { background: var(--gold); color: var(--g900); }
.save.off { background: var(--warn); }

.page { max-width: 720px; margin: 0 auto; padding: 16px 16px 48px; }
.wide-page { max-width: 1100px; }

/* ---- botones ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: 12px; border: 1.5px solid var(--g600);
  background: #fff; color: var(--g800); font-weight: 600; text-decoration: none; cursor: pointer; transition: transform .12s ease, background .15s; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--g600); color: #fff; border-color: var(--g600); }
.btn.primary:disabled { background: #a9bfb0; border-color: #a9bfb0; cursor: not-allowed; }
.btn.ghost { border-color: transparent; background: var(--g50); }
.btn.danger { border-color: #c92a2a; color: #c92a2a; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.wide { width: 100%; margin-top: 12px; }

/* ---- login ---- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(120% 80% at 50% 0%, var(--g600), var(--g900)); }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 20px; padding: 28px 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.login-card h1 { font-size: 24px; margin-top: 14px; }
.muted { color: var(--muted); margin: 4px 0 18px; }
.err { color: #c92a2a; min-height: 1.4em; margin: 10px 0 0; }

/* ---- campos ---- */
.fld { display: block; margin-bottom: 12px; }
.fld > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.fld input, textarea, .search { width: 100%; border: 1.5px solid var(--line); border-radius: 11px; padding: 11px 12px; background: #fff; outline: none; }
.fld input:focus, textarea:focus, .search:focus { border-color: var(--g500); box-shadow: 0 0 0 3px rgba(31, 157, 72, .18); }
.fld.num { margin: 0; }
.inwrap { position: relative; }
.inwrap input { font-family: var(--mono); font-size: 18px; padding-right: 44px; }
.inwrap em { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 12px; color: var(--muted); pointer-events: none; }
.cm { display: block; font-size: 11.5px; color: var(--muted); margin-top: 3px; min-height: 1.2em; }
.cm b { color: var(--warn); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (max-width: 380px) { .grid3 { grid-template-columns: repeat(2, 1fr); } }
textarea { resize: vertical; }

.switch { display: flex; align-items: center; gap: 10px; margin: 10px 0; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--g600); flex: none; }

.stepper { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; background: var(--g50); border-radius: 12px; margin-bottom: 12px; }
.stepper > span { font-weight: 600; }
.stepper div { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 44px; height: 44px; border-radius: 10px; border: 0; background: var(--g600); color: #fff; font-size: 24px; cursor: pointer; }
.stepper output { min-width: 40px; text-align: center; font: 700 24px var(--mono); }

/* ---- inicio ---- */
.progress-card { background: var(--g800); color: #fff; border-radius: var(--r); padding: 16px; margin-bottom: 14px; }
.pc-top { display: flex; align-items: baseline; gap: 8px; }
.pc-top strong { font: 800 36px var(--display); }
.bar { position: relative; display: flex; height: 10px; border-radius: 99px; background: rgba(255, 255, 255, .18); overflow: hidden; margin: 10px 0; }
.bar i { background: var(--g200); }
.bar b { background: var(--gold); }
.card .bar { background: var(--g50); flex: 1; margin: 0; }
.card .bar i { background: var(--g500); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; opacity: .9; margin-bottom: 6px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.dot.completo { background: var(--g200); } .dot.proceso { background: var(--gold); } .dot.pendiente { background: rgba(255, 255, 255, .4); }
.progress-card .btn.ghost { background: rgba(255, 255, 255, .14); color: #fff; margin-top: 6px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chip { flex: none; border: 1.5px solid var(--line); background: #fff; padding: 7px 14px; border-radius: 99px; font-weight: 600; font-size: 14px; cursor: pointer; }
.chip[aria-selected="true"] { background: var(--g800); border-color: var(--g800); color: #fff; }
.chips.small .chip { padding: 5px 12px; font-size: 13px; }
.search { margin-bottom: 12px; }

.stores, .units { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.store, .unit { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); text-decoration: none; color: inherit; }
.store .num { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: var(--g50); color: var(--g800); font: 700 13px var(--mono); }
.store .info, .unit .info { flex: 1; min-width: 0; display: grid; gap: 1px; }
.store strong, .unit strong { font-family: var(--display); font-size: 16px; }
.store small, .unit small { color: var(--muted); font-size: 13px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.tag { background: var(--g50); color: var(--g800); border-radius: 6px; padding: 1px 7px; font-weight: 600; font-size: 11.5px; }
.tag.rev { background: #fff3bf; color: #6b5300; }
.who { font-size: 12px !important; color: var(--muted); margin-top: 2px; }
.badge { flex: none; font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 99px; }
.badge.completo { background: #d3f9d8; color: #1b6b2f; }
.badge.proceso { background: #fff3bf; color: #7a5c00; }
.badge.pendiente { background: #eef1ee; color: var(--muted); }
.unit .thumb { flex: none; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; background: var(--g50); display: grid; place-items: center; font-size: 11px; color: var(--muted); }
.unit .thumb img { width: 100%; height: 100%; object-fit: cover; }
.empty { text-align: center; color: var(--muted); padding: 24px; }
.empty.big { background: #fff; border-radius: var(--r); border: 2px dashed var(--line); }
.hint { font-size: 13px; color: var(--muted); text-align: center; }

/* ---- visor ---- */
.viewer-wrap { position: sticky; top: 60px; z-index: 20; background: linear-gradient(#e9f3ea, #f8fbf7); border-bottom: 1px solid var(--line); }
.viewer, .plano-box { position: relative; height: var(--vh, 42vh); touch-action: none; }
.viewer-wrap.tall { position: relative; top: 0; }
.plano-box { overflow: auto; padding: 8px; touch-action: auto; background: #fff; }
.plano-box svg { width: 100%; height: 100%; }
.vhandle { display: flex; align-items: center; justify-content: center; gap: 8px; height: 26px; cursor: ns-resize; touch-action: none; user-select: none; color: var(--muted); font-size: 11.5px; border-top: 1px solid var(--line); background: rgba(255, 255, 255, .6); }
.vhandle i { width: 44px; height: 5px; border-radius: 99px; background: #9fb3a6; }
.vhandle:active i { background: var(--g600); }
@media (min-width: 900px) { .viewer-wrap { max-width: 1100px; margin: 0 auto; border-radius: 0 0 var(--r) var(--r); } }
.viewer canvas { display: block; }
.labels { position: absolute; inset: 0; }
.dim { font: 600 11.5px var(--mono); color: var(--g900); background: rgba(255, 255, 255, .94); border: 1.5px solid var(--g700); border-radius: 6px; padding: 2px 6px; white-space: nowrap; cursor: pointer; }
.dim.small { font-size: 10.5px; padding: 1px 5px; }
.dim.sep { border-color: #b08900; background: #fff9db; }
.dim.missing { border-color: var(--warn); color: var(--warn); border-style: dashed; }
.vbar { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 6px 12px; }
.seg { display: flex; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 2px; }
.seg button { border: 0; background: none; padding: 6px 11px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg button[aria-selected="true"] { background: var(--g800); color: #fff; }
.warns:empty { display: none; }
.warns { padding: 0 12px 8px; }
.warns p { margin: 4px 0 0; background: var(--warn-bg); color: #8a3a0b; border-radius: 8px; padding: 6px 10px; font-size: 13px; }

/* ---- formulario ---- */
.card { background: var(--card); border-radius: var(--r); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card h3 { display: flex; align-items: center; gap: 10px; font-size: 17px; margin-bottom: 6px; }
.card h4 { font-size: 15px; margin: 16px 0 2px; }
.card .n { width: 26px; height: 26px; border-radius: 8px; background: var(--g800); color: #fff; display: grid; place-items: center; font: 700 13px var(--mono); flex: none; }
.help { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.sec:focus-within { outline: 2.5px solid var(--gold); outline-offset: 2px; }

.photo-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0; }
.photo-btns .btn { padding: 0 8px; font-size: 15px; white-space: nowrap; }
.uprow { display: grid; grid-template-columns: 1fr 80px auto; gap: 8px; align-items: center; font-size: 13px; padding: 6px 0; }
.uprow span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uprow i { height: 6px; background: var(--g50); border-radius: 99px; overflow: hidden; }
.uprow i b { display: block; height: 100%; width: 0; background: var(--g500); }
.uprow em { font-style: normal; color: var(--muted); }
.uprow.fail i b { background: var(--warn); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 10px; }
.gallery figure { position: relative; margin: 0; background: var(--g50); border-radius: 10px; overflow: hidden; }
.gallery img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.gallery figcaption { padding: 6px 8px; font-size: 12px; display: grid; }
.gallery figcaption span { color: var(--muted); font-size: 11px; }
.gallery .del { position: absolute; top: 6px; right: 6px; min-width: 30px; height: 30px; border-radius: 99px; border: 0; background: rgba(0, 0, 0, .6); color: #fff; font-size: 18px; cursor: pointer; padding: 0 8px; }
.gallery .del.confirm { background: #c92a2a; font-size: 12px; font-weight: 700; }

.reg dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 8px 0; font-size: 14px; }
.reg dt { color: var(--muted); }
.reg dd { margin: 0; font-weight: 600; }
.reg details { margin: 8px 0; font-size: 13px; }
.log { padding-left: 18px; margin: 6px 0; }
.log span { color: var(--muted); }
.missing-box { background: var(--warn-bg); border-radius: 12px; padding: 12px 14px; font-size: 14px; color: #8a3a0b; }
.missing-box ul { margin: 6px 0 0; padding-left: 18px; columns: 2; }
.btn.soft { opacity: .55; }
.invalid input, .invalid textarea { border-color: #e03131 !important; background: #fff5f5; box-shadow: 0 0 0 3px rgba(224, 49, 49, .15); }
.invalid > span { color: #c92a2a !important; }
.stepper.invalid, .card.invalid { outline: 2.5px solid #e03131; outline-offset: 2px; }
.missing-box small { color: #8a3a0b; opacity: .8; }
.missing-box button { border: 0; background: none; padding: 2px 0; color: #c92a2a; text-decoration: underline; text-align: left; cursor: pointer; font-size: 14px; }
.linkbtn { display: block; width: 100%; margin-top: 12px; border: 0; background: none; color: #8a3a0b; text-decoration: underline; font-size: 14px; cursor: pointer; padding: 6px; }
.force { margin-top: 8px; background: var(--warn-bg); border-radius: 12px; padding: 12px; }
.warnbtn { background: #e8590c; border-color: #e8590c; color: #fff; }
.done.partial { background: #fff4e6; color: #8a3a0b; }
.done p { margin: 6px 0 0; font-weight: 400; }
.partial-who { color: #c2410c !important; font-weight: 600; }
.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.loc-ok { background: #d3f9d8; color: #1b6b2f; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 8px; }
.map { width: 100%; height: 200px; border: 0; border-radius: 10px; display: block; margin-bottom: 8px; }
.done-who { color: #1b6b2f !important; font-weight: 600; }
.brand { height: 34px; width: auto; border-radius: 8px; flex: none; }
.brandmark img { width: 100%; max-width: 300px; border-radius: 12px; display: block; }
.sh-logo { height: 46px; border-radius: 8px; }
#toast.warn { background: var(--warn); }
.done { background: #d3f9d8; color: #1b6b2f; border-radius: 12px; padding: 12px 14px; font-weight: 600; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 40px); opacity: 0; background: var(--g900); color: #fff; padding: 10px 18px; border-radius: 99px; transition: .25s; z-index: 99; pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- panel ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpis div { background: #fff; border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); }
.kpis b { display: block; font: 800 30px var(--display); color: var(--g800); }
.kpis span { font-size: 13px; color: var(--muted); }
.admin-actions { margin-bottom: 14px; }
.zrow { display: flex; align-items: center; gap: 12px; padding: 6px 0; }
.zrow > span { width: 110px; font-weight: 600; }
.zrow em { font: 600 14px var(--mono); font-style: normal; margin-left: auto; }
.tablewrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }

/* ---- ficha ---- */
.ficha { max-width: 900px; margin: 0 auto; padding: 16px; }
.sheet { background: #fff; padding: 24px; border-radius: 6px; box-shadow: var(--shadow); margin-bottom: 20px; }
.sh-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 3px solid var(--g800); padding-bottom: 10px; }
.sh-head h2 { font-size: 20px; font-weight: 800; }
.sh-head p { margin: 2px 0 0; color: var(--muted); }
.sh-info { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 16px; margin: 14px 0 6px; }
.sh-info span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.units-note { font-size: 12px; color: var(--muted); margin: 6px 0; }
.sh-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
.mt { width: 100%; border-collapse: collapse; font-size: 14px; }
.mt th, .mt td { border: 1.5px solid #1b2a20; padding: 7px 9px; }
.mt thead th { background: #eef1ee; font-family: var(--display); }
.mt td { font-family: var(--mono); text-align: center; }
.mt tbody th { text-align: left; }
.sh-plano { margin: 16px 0; border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.sh-plano svg { width: 100%; height: auto; max-height: 520px; }
.warns.static { padding: 0; }
.sh-obs { border: 1.5px solid #1b2a20; padding: 10px; min-height: 80px; }
.sh-obs span { font-weight: 700; font-family: var(--display); }
.sh-obs p { margin: 4px 0 0; white-space: pre-wrap; }
.sh-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.sh-photos figure { margin: 0; }
.sh-photos img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 4px; }
.sh-photos figcaption { font-size: 11px; color: var(--muted); }
.sh-foot { margin-top: 10px; font-size: 11px; color: var(--muted); }
@media (max-width: 640px) { .sh-info { grid-template-columns: 1fr 1fr; } .sh-grid { grid-template-columns: 1fr; } .sh-photos { grid-template-columns: 1fr 1fr; } .sheet { padding: 14px; } }
@media print {
  body { background: #fff; }
  .topbar, #toast { display: none; }
  .ficha { padding: 0; max-width: none; }
  .sheet { box-shadow: none; padding: 0; break-after: page; }
  .sh-photos { break-inside: avoid; }
}
