/* Relevo — mundo "Lámina de mensura".
   Hoja de plano: papel, tinta fina, cotas y un rótulo fijo abajo. Color solo en el sello. */
:root {
  --paper: #FBFAF6;
  --paper-2: #F3F0E8;
  --ink: #1C1A17;
  --ink-2: #5E5A54;
  --ink-3: #8E8A82;
  --rule: #CFC9BE;      /* filete 0.25 */
  --rule-2: #A8A196;    /* filete 0.5 */
  --grid: rgba(28, 26, 23, .06);
  --seal: #C8694A;      /* tinta del sello */
  --seal-soft: #F5E3DA;
  --seal-deep: #9E4A2F;
  --ok: #3C6F4A; --ok-soft: #E1EBE2;
  --warn: #8A6410; --warn-soft: #F3E9CF;
  --bad: #9E3A2E; --bad-soft: #F3DBD6;
  --info: #3B5A80; --info-soft: #E0E8F1;
  --shadow: 0 10px 24px -14px rgba(28, 26, 23, .35);
  --tap: 48px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Sometype Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* cianotipo: la misma lámina copiada en azul */
    --paper: #12283D; --paper-2: #0E2033; --ink: #EAF0F6; --ink-2: #B7C6D6; --ink-3: #7E93A8;
    --rule: #2B4560; --rule-2: #3E5C7A; --grid: rgba(234, 240, 246, .07);
    --seal: #E28F6E; --seal-soft: #3A2A25; --seal-deep: #F0A98C;
    --ok: #8FCC9E; --ok-soft: #1B3527; --warn: #E6BE5C; --warn-soft: #3A3016;
    --bad: #EE8E7F; --bad-soft: #43231F; --info: #9CBEE6; --info-soft: #1B2F47;
    --shadow: 0 10px 24px -14px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #12283D; --paper-2: #0E2033; --ink: #EAF0F6; --ink-2: #B7C6D6; --ink-3: #7E93A8;
  --rule: #2B4560; --rule-2: #3E5C7A; --grid: rgba(234, 240, 246, .07);
  --seal: #E28F6E; --seal-soft: #3A2A25; --seal-deep: #F0A98C;
  --ok: #8FCC9E; --ok-soft: #1B3527; --warn: #E6BE5C; --warn-soft: #3A3016;
  --bad: #EE8E7F; --bad-soft: #43231F; --info: #9CBEE6; --info-soft: #1B2F47;
  --shadow: 0 10px 24px -14px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(var(--grid) 1px, transparent 1px);
  background-size: 24px 24px; background-position: 12px 12px;
  font: 16px/1.45 var(--font); font-feature-settings: "tnum" 1, "cv11" 1;
  -webkit-tap-highlight-color: transparent; overflow-x: hidden; min-height: 100dvh;
}
::selection { background: var(--seal-soft); color: var(--ink); }
:focus-visible { outline: 2px solid var(--seal); outline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--seal-deep); text-decoration: underline; text-underline-offset: .18em; text-decoration-thickness: 1px; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: 1.375rem; font-weight: 700; }
h2 { font-size: .8125rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
h3 { font-size: .9375rem; font-weight: 600; }
p { margin: 0; }
small, .muted { color: var(--ink-2); }
.mono { font-family: var(--mono); font-weight: 500; letter-spacing: .01em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- lámina ---------- */
#app { max-width: 720px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--paper);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; border-bottom: 1px solid var(--ink);
  display: flex; align-items: center; gap: 6px; min-height: 58px;
}
.topbar h1 { flex: 1; font-size: 1.125rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { display: block; font-family: var(--mono); font-size: .75rem; font-weight: 500; color: var(--ink-2); letter-spacing: .02em; margin-top: 2px; }
.wordmark { font-weight: 800; letter-spacing: -0.03em; font-size: 1.25rem; color: var(--ink); }
.wordmark::after { content: "."; color: var(--seal); }
main { flex: 1; padding: 12px 16px calc(128px + env(safe-area-inset-bottom)); }
main.narrow { padding-bottom: 24px; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: 4px;
  border: 1px solid var(--ink); font-weight: 600; font-size: .9375rem;
  background: var(--ink); color: var(--paper); text-decoration: none;
  transition: transform .12s ease, background-color .15s ease, color .15s ease;
}
.btn:hover { background: var(--ink-2); border-color: var(--ink-2); color: var(--paper); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.btn.sec { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn.sec:hover { background: var(--paper-2); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--seal-deep); border-color: transparent; }
.btn.ghost:hover { background: var(--seal-soft); color: var(--seal-deep); border-color: transparent; }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: var(--bad); color: #fff; }
.btn.wide { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: .875rem; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.sm svg { width: 16px; height: 16px; }
.iconbtn {
  width: var(--tap); height: var(--tap); border-radius: 50%; border: 0; background: transparent; color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.iconbtn:hover { background: var(--paper-2); }
.iconbtn svg { width: 24px; height: 24px; }
.icon { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; }
.field > label, .label { font-family: var(--mono); font-size: .6875rem; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.input, textarea.input, select.input {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border-radius: 3px;
  border: 1px solid var(--rule-2); background: var(--paper); color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder { color: var(--ink-3); }
.input:focus { outline: none; border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
textarea.input { min-height: 88px; resize: vertical; line-height: 1.4; }
.input[aria-invalid="true"] { border-color: var(--bad); }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.seg { display: flex; border: 1px solid var(--ink); border-radius: 4px; overflow: hidden; }
.seg button {
  flex: 1; min-height: 42px; border: 0; border-left: 1px solid var(--ink); background: transparent; color: var(--ink-2);
  font-family: var(--mono); font-weight: 500; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase;
  transition: background-color .15s ease, color .15s ease;
}
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* tabs: pestañas de la lámina */
.tabs {
  display: flex; gap: 0; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px;
  position: sticky; top: 58px; z-index: 15; background: var(--paper); border-bottom: 1px solid var(--rule-2);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: 0; background: transparent; color: var(--ink-2); font-family: var(--mono); font-weight: 500; font-size: .75rem;
  letter-spacing: .08em; text-transform: uppercase; padding: 14px 12px; position: relative; white-space: nowrap; min-height: 44px;
}
.tabs button[aria-selected="true"] { color: var(--ink); }
.tabs button[aria-selected="true"]::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; background: var(--ink);
}
.tabs .badge { margin-left: 6px; }

/* ---------- bloques: sin cajas, filetes ---------- */
.block { padding: 12px 0 14px; margin: 0; border-bottom: 1px solid var(--rule); }
.block > h2 { margin-bottom: 12px; }
.block.plain { border-bottom: 0; }
.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule-2); border-bottom: 1px solid var(--rule-2); }
.list > li { border-top: 1px solid var(--rule); }
.list > li:first-child { border-top: 0; }
.rowitem {
  display: flex; align-items: center; gap: 12px; padding: 12px 2px; min-height: 60px; width: 100%;
  background: transparent; border: 0; text-align: left; color: inherit; text-decoration: none;
}
.rowitem:hover { background: var(--paper-2); }
.rowitem .main { flex: 1; min-width: 0; }
.rowitem .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rowitem .meta { font-size: .8125rem; color: var(--ink-2); display: flex; gap: 10px; flex-wrap: wrap; }
.rowitem .meta .mono { font-size: .75rem; }
.rowitem .chev { color: var(--ink-3); }

/* sello de estado */
.badge {
  display: inline-flex; align-items: center; font-family: var(--mono); font-size: .6875rem; font-weight: 500;
  letter-spacing: .1em; text-transform: uppercase; padding: 3px 7px; border: 1.5px solid currentColor; border-radius: 3px;
  color: var(--ink-2); line-height: 1.3; white-space: nowrap; transform: rotate(-2deg); transform-origin: center;
}
.badge.nuevo { color: var(--info); }
.badge.coordinado { color: var(--warn); }
.badge.visitado { color: var(--seal); }
.badge.cargado { color: var(--ok); }
.badge.plain { transform: none; border-color: var(--rule-2); color: var(--ink-2); letter-spacing: .04em; }

.kv { display: grid; grid-template-columns: minmax(90px, auto) 1fr; gap: 8px 14px; font-size: .9375rem; }
.kv dt { font-family: var(--mono); color: var(--ink-2); font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase; padding-top: 4px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.notice { padding: 10px 12px; border: 1px solid currentColor; border-radius: 3px; font-size: .9375rem; display: flex; gap: 10px; align-items: flex-start; background: var(--paper); }
.notice svg { flex: none; margin-top: 2px; }
.notice.warn { color: var(--warn); background: var(--warn-soft); }
.notice.bad { color: var(--bad); background: var(--bad-soft); }
.notice.ok { color: var(--ok); background: var(--ok-soft); }
.notice.info { color: var(--info); background: var(--info-soft); }
.notice b { color: inherit; }

.empty { text-align: center; padding: 40px 20px; color: var(--ink-2); }
.empty svg { width: 44px; height: 44px; margin: 0 auto 12px; color: var(--ink-3); }
.empty h2 { color: var(--ink); margin-bottom: 6px; font-size: 1.0625rem; text-transform: none; letter-spacing: -0.01em; }
.empty p { max-width: 34ch; margin: 0 auto 16px; }

/* ---------- rótulo (barra fija inferior) ---------- */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  background: var(--paper); border-top: 1px solid var(--ink);
  padding-bottom: env(safe-area-inset-bottom);
}
.actionbar .frame { max-width: 720px; margin: 0 auto; }
.rotulo { display: grid; grid-template-columns: 1fr auto auto; border-bottom: 1px solid var(--ink); }
.rotulo .cell { padding: 6px 12px; border-left: 1px solid var(--ink); min-width: 0; }
.rotulo .cell:first-child { border-left: 0; }
.rotulo small { display: block; font-family: var(--mono); font-size: .5625rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); }
.rotulo b { display: block; font-family: var(--mono); font-weight: 500; font-size: .8125rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rotulo .badge { margin-top: 3px; }
.actionbar .inner { display: flex; gap: 10px; padding: 10px 16px; }
.actionbar .inner > * { flex: 1; }

/* ---------- checklist con líneas de puntos ---------- */
.check { list-style: none; margin: 0; padding: 0; }
.check li { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 4px 0; border-top: 1px solid var(--rule); }
.check li:first-child { border-top: 0; }
.check .name { flex: 1; font-weight: 500; display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.check .name::after { content: ""; flex: 1; border-bottom: 1px dotted var(--rule-2); margin: 0 4px; transform: translateY(-4px); }
.check .name small { display: block; color: var(--ink-3); font-size: .75rem; font-weight: 500; }
.check .name .txt { min-width: 0; }
.check .req-tag { font-family: var(--mono); font-size: .625rem; color: var(--seal); font-weight: 500; letter-spacing: .1em; text-transform: uppercase; }
.check li.done .name { color: var(--ink-2); }
.count { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; padding: 0 6px; font-family: var(--mono); font-weight: 500; font-size: .9375rem; color: var(--ink-3); }
.count.has { color: var(--ink); }
.check li.req:not(.done) .count { color: var(--seal); }
.camera {
  display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap);
  border-radius: 50%; background: transparent; color: var(--ink); border: 1px solid var(--ink); position: relative; overflow: hidden;
}
.camera:hover { background: var(--ink); color: var(--paper); }
.camera input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.camera svg { width: 22px; height: 22px; }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-top: 12px; }
.thumb { position: relative; aspect-ratio: 4/3; overflow: hidden; background: var(--paper-2); border: 1px solid var(--ink); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .tag { position: absolute; left: 0; bottom: 0; right: 0; font-family: var(--mono); font-size: .625rem; letter-spacing: .06em; text-transform: uppercase; color: var(--paper); background: var(--ink); padding: 2px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb button.x { position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(28,26,23,.75); color: #fff; display: flex; align-items: center; justify-content: center; }
.thumb button.x svg { width: 16px; height: 16px; }
.thumb.off img { opacity: .3; }
.thumb .pick { position: absolute; top: 4px; left: 4px; width: 28px; height: 28px; border-radius: 3px; border: 1.5px solid #fff; background: rgba(28,26,23,.55); display: flex; align-items: center; justify-content: center; color: #fff; }
.thumb .pick svg { width: 16px; height: 16px; }
.thumb.on .pick { background: var(--ok); border-color: var(--ok); }

/* cota */
.cota { display: flex; align-items: center; gap: 0; font-family: var(--mono); font-size: .8125rem; color: var(--ink); margin: 6px 0 2px; }
.cota::before, .cota::after { content: ""; flex: 1; height: 1px; background: var(--ink); position: relative; }
.cota span { padding: 0 10px; white-space: nowrap; }
.cota i { width: 1px; height: 12px; background: var(--ink); display: block; }
.cota.muted { color: var(--ink-3); }
.cota.muted::before, .cota.muted::after, .cota.muted i { background: var(--rule-2); }

/* ---------- progreso ---------- */
.progress { height: 6px; border: 1px solid var(--ink); overflow: hidden; }
.progress > div { height: 100%; width: 100%; background: var(--ink); transform-origin: left; transition: transform .6s cubic-bezier(.2,.7,.2,1); }

/* ---------- comparables ---------- */
.comp { display: flex; gap: 12px; padding: 12px 2px; border-top: 1px solid var(--rule); align-items: flex-start; }
.comp:first-child { border-top: 0; }
.comp .pic { width: 84px; height: 64px; background: var(--paper-2); object-fit: cover; flex: none; border: 1px solid var(--ink); }
.comp .body { flex: 1; min-width: 0; }
.comp .t { font-weight: 600; font-size: .9375rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.comp .price { font-weight: 700; font-size: 1.0625rem; margin-top: 2px; }
.comp .price small { font-family: var(--mono); font-weight: 500; color: var(--ink-2); font-size: .75rem; margin-left: 8px; }
.comp .facts { font-size: .8125rem; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px; }
.comp .facts .src { font-family: var(--mono); font-size: .6875rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.comp .nota { font-size: .75rem; color: var(--warn); margin-top: 4px; }
.comp .acts { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.comp.sel { background: var(--seal-soft); margin: 0 -8px; padding-left: 10px; padding-right: 10px; }
.pickbtn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--ink); background: transparent; color: transparent; display: flex; align-items: center; justify-content: center; flex: none; }
.pickbtn svg { width: 20px; height: 20px; }
.pickbtn[aria-pressed="true"] { background: var(--seal); border-color: var(--seal); color: #fff; }
.stat { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--ink); border: 1px solid var(--ink); }
.stat div { padding: 10px 12px; background: var(--paper); }
.stat b { display: block; font-family: var(--mono); font-size: 1.125rem; font-weight: 500; letter-spacing: -0.01em; }
.stat span { font-size: .75rem; color: var(--ink-2); }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login form { width: 100%; max-width: 360px; border: 1px solid var(--ink); padding: 28px 24px; background: var(--paper); }
.login .wordmark { font-size: 2.25rem; display: block; margin-bottom: 4px; }
.login p { color: var(--ink-2); margin-bottom: 24px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(120px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(8px);
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 3px; font-size: .9375rem; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; z-index: 40; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { background: var(--bad); color: #fff; }

/* ---------- motion ---------- */
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.enter { animation: enter .2s cubic-bezier(.2,.7,.2,1) both; }
@keyframes stamp { from { opacity: 0; transform: rotate(-2deg) scale(1.25); } to { opacity: 1; transform: rotate(-2deg) scale(1); } }
.badge.stamped { animation: stamp .28s cubic-bezier(.2,.8,.2,1) both; }
.skeleton { background: linear-gradient(90deg, var(--paper-2) 25%, var(--paper) 50%, var(--paper-2) 75%); background-size: 200% 100%; animation: sk 1.2s ease-in-out infinite; height: 60px; margin-bottom: 8px; border-bottom: 1px solid var(--rule); }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .enter, .skeleton, .progress > div, .badge.stamped { animation: none; transition: none; } }

pre.copy { white-space: pre-wrap; font: .875rem/1.5 var(--font); border: 1px solid var(--rule-2); padding: 12px 14px; margin: 0 0 10px; color: var(--ink); overflow-wrap: anywhere; background: var(--paper); }
dialog { border: 1px solid var(--ink); border-radius: 3px; background: var(--paper); color: var(--ink); padding: 20px; width: min(92vw, 420px); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(28, 26, 23, .45); }
details summary { list-style: none; }
details summary::-webkit-details-marker { display: none; }
