:root {
  --bg: #EEF1F5;
  --surface: #FFFFFF;
  --ink: #141C26;
  --muted: #5B6776;
  --line: #D6DCE4;
  --chip: #E1E7EF;
  --accent: #2340D9;
  --accent-ink: #FFFFFF;
  --accent-soft: #E3E8FF;
  --fav: #D6285B;
  --ok: #1F7A4A;
  --ok-soft: #DDF3E6;
  --warn: #B3261E;
  --pending: #8A5A00;
  --pending-soft: #FFF1D1;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1319; --surface: #171E27; --ink: #E9EEF4; --muted: #97A4B4; --line: #2A3441; --chip: #212A35;
    --accent: #8CA2FF; --accent-ink: #0E1319; --accent-soft: #1E2748; --fav: #FF6F98;
    --ok: #6CD69B; --ok-soft: #173325; --warn: #FF8A80; --pending: #F2C35B; --pending-soft: #3A2E12;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1319; --surface: #171E27; --ink: #E9EEF4; --muted: #97A4B4; --line: #2A3441; --chip: #212A35;
  --accent: #8CA2FF; --accent-ink: #0E1319; --accent-soft: #1E2748; --fav: #FF6F98;
  --ok: #6CD69B; --ok-soft: #173325; --warn: #FF8A80; --pending: #F2C35B; --pending-soft: #3A2E12;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 17px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--warn); font-weight: 600; min-height: 1em; margin: 6px 0; }
svg { stroke-linecap: round; stroke-linejoin: round; }

/* ── Login ── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-in { width: 100%; max-width: 360px; text-align: center; }
.login form { text-align: left; margin-top: 24px; }
.logo { width: 72px; height: 72px; margin: 0 auto 12px; border-radius: 18px; background: url(/app/icon-192.png) center / cover; }

/* ── Encabezado ── */
.top {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 6px;
}
.title-row { display: flex; align-items: center; gap: 8px; min-height: 44px; max-width: 720px; margin: 0 auto; }
.top h1 { margin: 0; flex: 1; min-width: 0; font-size: 28px; line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { color: var(--muted); font-size: 15px; flex: none; }
.sync { font-size: 13px; color: var(--pending); background: var(--pending-soft); padding: 2px 8px; border-radius: 10px; }
#topExtra { max-width: 720px; margin: 0 auto; }
.icon-btn {
  flex: none; width: 44px; height: 44px; margin-left: -10px; border: 0; background: none; border-radius: 22px;
  display: grid; place-items: center; color: var(--ink);
}
.icon-btn svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.4; }

.search {
  width: 100%; height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
}
.search::placeholder { color: var(--muted); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 44px; padding: 0 16px; border-radius: 22px; border: 0; background: var(--chip); font-weight: 600; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

main { padding: 6px 16px calc(150px + env(safe-area-inset-bottom, 0px)); max-width: 720px; margin: 0 auto; }
.group-title { margin: 20px 2px 8px; font-size: 19px; font-weight: 700; display: flex; justify-content: space-between; align-items: baseline; }
.group-title small { font-size: 14px; color: var(--muted); font-weight: 400; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

/* ── Tarjetas con esquinas de visor ── */
.card {
  position: relative; display: block; width: 100%; text-align: left; color: inherit; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin: 0 0 12px; padding: 16px 18px;
  --frame: var(--accent);
}
.card.vf::before, .card.vf::after {
  content: ""; position: absolute; width: 12px; height: 12px; border: 2px solid var(--frame); pointer-events: none; opacity: .75;
}
.card.vf::before { top: 7px; left: 7px; border-right: 0; border-bottom: 0; border-top-left-radius: 3px; }
.card.vf::after { bottom: 7px; right: 7px; border-left: 0; border-top: 0; border-bottom-right-radius: 3px; }
.card.new { --frame: var(--fav); }
.card h3 { margin: 0; font-size: 20px; line-height: 1.25; }
.card .sub { color: var(--muted); font-size: 15px; margin-top: 2px; }
.card-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 12px; }
.pill.pendiente { background: var(--pending-soft); color: var(--pending); }
.pill.enviado { background: var(--ok-soft); color: var(--ok); }
.pill.oculta { background: var(--chip); color: var(--muted); }
.bar { flex: 1; min-width: 100px; height: 6px; background: var(--chip); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }

/* ── Lista de poses del catálogo ── */
.pose-row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px; margin: 0 0 10px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
}
.thumb {
  flex: none; width: 64px; height: 80px; border-radius: 10px; background: var(--chip) center / cover no-repeat;
  display: grid; place-items: center; color: var(--muted);
}
.thumb svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.pose-row .txt { flex: 1; min-width: 0; }
.pose-row .name { display: block; font-size: 18px; font-weight: 600; line-height: 1.25; }
.pose-row .cat { display: block; font-size: 14px; color: var(--muted); }

/* ── Detalle de cliente ── */
.section-title { margin: 26px 2px 10px; font-size: 20px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--muted); font-size: 15px; }
.kv dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.link-box {
  display: flex; gap: 8px; align-items: center; background: var(--bg); border: 1px dashed var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; overflow-wrap: anywhere; margin: 10px 0; -webkit-user-select: all; user-select: all;
}
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }
.btn {
  min-height: 50px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; color: var(--ink);
}
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--warn); }
.btn.small { min-height: 40px; font-size: 15px; padding: 0 12px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; }
.btn.copied { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.btn.copied svg { stroke-width: 3; }

.item {
  display: flex; align-items: stretch; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin: 0 0 8px;
}
.item.done { opacity: .6; }
.item.done .it-name { text-decoration: line-through; }
.item .it-main { flex: 1; min-width: 0; padding: 12px 6px 12px 14px; border: 0; background: none; text-align: left; display: flex; gap: 10px; align-items: center; }
.item .thumb { width: 44px; height: 54px; border-radius: 8px; }
.it-name { display: block; font-weight: 600; line-height: 1.25; }
.it-meta { display: block; font-size: 14px; color: var(--muted); }
.it-note { display: block; font-size: 14px; color: var(--accent); margin-top: 2px; white-space: pre-wrap; }
.check {
  flex: none; width: 60px; border: 0; background: none; display: grid; place-items: center; color: var(--muted);
}
.check span {
  width: 30px; height: 30px; border-radius: 15px; border: 2px solid currentColor; display: grid; place-items: center;
}
.check svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 3; opacity: 0; }
.check[aria-pressed="true"] { color: var(--ok); }
.check[aria-pressed="true"] span { background: var(--ok); border-color: var(--ok); }
.check[aria-pressed="true"] svg { opacity: 1; stroke: var(--surface); }
.order { display: flex; flex-direction: column; border-left: 1px solid var(--line); }
.order button { flex: 1; width: 48px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; min-height: 36px; }
.order svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; }
.src { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--chip); padding: 1px 6px; border-radius: 6px; margin-left: 4px; }

/* ── Botón flotante ── */
.fab {
  position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); z-index: 6;
  min-height: 56px; padding: 0 20px 0 16px; border-radius: 28px; border: 0; background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; gap: 8px; font-weight: 700; box-shadow: 0 4px 14px rgba(20, 28, 38, .25);
}
.fab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.6; }

/* ── Barra inferior ── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab {
  position: relative; min-height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-weight: 600; font-size: 12px; color: var(--muted); text-decoration: none;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; }
.tab[aria-current="page"] { color: var(--accent); }
.dot { position: absolute; top: 8px; left: calc(50% + 8px); width: 10px; height: 10px; border-radius: 5px; background: var(--fav); }

/* ── Hojas / formularios ── */
dialog.sheet {
  border: 0; padding: 0; background: var(--surface); color: var(--ink);
  width: 100%; max-width: 560px; max-height: 94vh; border-radius: 18px; margin: auto;
}
@media (max-width: 600px) {
  dialog.sheet { margin: auto 0 0; max-width: 100%; border-radius: 18px 18px 0 0; max-height: 94vh; }
}
dialog::backdrop { background: rgba(0, 0, 0, .5); }
.sheet-in { padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px)); overflow-y: auto; max-height: 94vh; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; font-size: 22px; }
.form label { display: block; font-weight: 600; margin: 12px 0 6px; font-size: 15px; }
.field {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg);
}
textarea.field { min-height: 90px; resize: vertical; }
select.field { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 21px, calc(100% - 14px) 21px; background-size: 6px 6px; background-repeat: no-repeat; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0 4px; font-weight: 600; }
.switch input { width: 24px; height: 24px; accent-color: var(--accent); }
.photo-pick { display: flex; gap: 12px; align-items: center; }
.photo-pick .thumb { width: 96px; height: 120px; }
.photo-pick .btn-row { flex-direction: column; flex: 1; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.form-actions .btn { flex: 1; }
.hint { font-size: 14px; color: var(--muted); margin: 4px 0 0; }
.form-sub { margin: 24px 0 0; padding-top: 16px; border-top: 1px solid var(--line); font-size: 17px; }

.picker-item { display: flex; align-items: center; gap: 12px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.picker-item input { width: 24px; height: 24px; accent-color: var(--accent); flex: none; }
.picker-item label { flex: 1; margin: 0; font-weight: 500; display: flex; gap: 10px; align-items: center; }
.picker-item .thumb { width: 40px; height: 50px; border-radius: 8px; }

/* ── Ideas ── */
.search-sites { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.link-row { display: flex; align-items: center; gap: 8px; }
.link-row a { flex: 1; min-width: 0; padding: 14px 4px; text-decoration: none; color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-row small { display: block; color: var(--muted); font-weight: 400; overflow: hidden; text-overflow: ellipsis; }

/* ── Modo boda ── */
.session {
  position: fixed; inset: 0; z-index: 10; background: var(--bg); overflow-y: auto;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px calc(24px + env(safe-area-inset-bottom, 0px));
}
.session-in { max-width: 720px; margin: 0 auto; }
.session-top { position: sticky; top: calc(-10px - env(safe-area-inset-top, 0px)); z-index: 2; background: var(--bg); padding: 10px 0 8px; }
.session-top .title-row h1 { font-size: 24px; }
.big-progress { display: flex; align-items: baseline; gap: 8px; margin: 4px 0 6px; }
.big-progress b { font-size: 34px; line-height: 1; }
.session .bar { height: 10px; border-radius: 5px; }
.session .item { min-height: 72px; }
.session .it-name { font-size: 19px; }
.session .check { width: 76px; }
.session .check span { width: 40px; height: 40px; border-radius: 20px; }
.session .check svg { width: 24px; height: 24px; }
.expand { padding: 0 14px 14px; font-size: 16px; }
.expand p { margin: 0 0 8px; }
.big-photo { position: relative; display: block; width: 100%; padding: 0; margin: 0 0 12px; border: 0; background: var(--chip); border-radius: 12px; overflow: hidden; cursor: zoom-in; }
.big-photo img { display: block; width: 100%; max-height: 65vh; object-fit: contain; }
.zoom-hint { position: absolute; right: 8px; bottom: 8px; padding: 4px 10px; border-radius: 12px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 13px; font-weight: 600; }
button.thumb { border: 0; padding: 0; cursor: zoom-in; }
.item-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin: 0 0 8px; }
.item-wrap .item { border: 0; margin: 0; background: none; }
.item-wrap.done { opacity: .6; }
.item-wrap.done .it-name { text-decoration: line-through; }

.viewer { background: #000; border: 0; padding: 0; max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; }
.viewer img { width: 100%; height: 100%; object-fit: contain; touch-action: pinch-zoom; }
.viewer .close {
  position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px; width: 48px; height: 48px;
  border-radius: 24px; border: 0; background: rgba(255, 255, 255, .2); color: #fff; font-size: 26px;
}

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(146px + env(safe-area-inset-bottom, 0px)); z-index: 30;
  max-width: 420px; margin: 0 auto; padding: 14px 16px; border-radius: 12px; background: var(--ink); color: var(--bg);
  text-align: center; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .15s;
}
.toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
