/* HOPE ON LINE — misma apariencia que MY HOPE (logo, banderas, colores 藍).
   Una columna para celular (máx. 560px); la oficina usa un poco más de ancho. */
:root {
  --bg: #f7f7f7;   /* mismo gris claro del fondo del logo */
  --surface: #ffffff;
  --ink: #18202b;
  --muted: #5d6877;
  --line: #dde2e8;
  --accent: #24477a;
  --accent-ink: #ffffff;
  --accent-soft: #e5ebf4;
  --ok: #1f7a4d;   --ok-soft: #e2f2e9;
  --warn: #9a5b00; --warn-soft: #fbefd9;
  --bad: #b3261e;  --bad-soft: #fbe4e2;
  --orange: #c2410c; --orange-soft: #ffedd5;
  --font-body: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  --font-display: "Zen Maru Gothic", "Noto Sans JP", "Hiragino Maru Gothic ProN", system-ui, sans-serif;
  --r: 14px;
}
/* Siempre claro (igual que MY HOPE), para que el fondo sea igual al del logo. */
:root { color-scheme: light; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 15px; line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: 560px; margin: 0 auto; padding-inline: 16px; padding-block: 0 48px; }
.wrap.wide { max-width: 860px; }

/* ---------- Encabezado (igual que MY HOPE) ---------- */
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  background: var(--bg); padding-block: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; row-gap: 6px;
}
.brand { font-family: var(--font-display); font-weight: 700; font-size: 17px; min-width: 0; display: flex; align-items: center; gap: 8px; }
.brand span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand .logo { height: 60px; width: auto; max-width: 200px; object-fit: contain; flex-shrink: 0; }
.brand .logo + span { display: none; }
.langs { display: flex; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; flex-shrink: 0; flex-wrap: wrap; justify-content: center; margin-left: auto; }
.langs button { border: 0; background: none; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--muted); }
.langs button.flag-btn { padding: 4px 6px; line-height: 0; }
.langs .flag { width: 26px; height: 17px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .18); display: block; }
.langs button.flag-btn[aria-pressed="true"] { background: var(--accent); }
.langs button.flag-btn[aria-pressed="true"] .flag { box-shadow: 0 0 0 2px #fff; }
@media (max-width: 420px) {
  .top { flex-wrap: nowrap; gap: 8px; }
  .top .brand .logo { max-width: 32vw; height: auto; max-height: 44px; }
  .top .langs { gap: 1px; padding: 2px; flex-wrap: nowrap; }
  .top .langs button.flag-btn { padding: 3px 3px; }
  .top .langs .flag { width: 21px; height: 14px; }
}
.demo-bar { background: var(--warn-soft); color: var(--warn); font-size: 13px; padding: 8px 12px; border-radius: 10px; margin-block-end: 8px; }
.adm-bar { display: flex; align-items: center; gap: 8px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 10px; margin-block-end: 8px; }

h1, h2 { font-family: var(--font-display); font-weight: 700; line-height: 1.3; text-wrap: balance; margin: 0; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
.sub { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.grow { flex: 1; min-width: 0; }
.title { font-weight: 700; display: block; }
.meta { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; display: block; margin: 0; }
.muted { color: var(--muted); }
.info { background: var(--accent-soft); color: var(--ink); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin: 0; }
.blocked { background: var(--bad-soft); color: var(--bad); border-radius: 10px; padding: 12px; font-weight: 500; margin: 0; }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r); }
.pie { text-align: center; margin: 8px 0 0; }
.ok-txt { color: var(--ok); font-weight: 700; font-size: 13px; }
.bad-txt { color: var(--bad) !important; }

/* ---------- Tarjetas ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card.row { flex-direction: row; align-items: center; }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill.est-0 { background: var(--warn-soft); color: var(--warn); }
.pill.est-1 { background: var(--accent-soft); color: var(--accent); }
.pill.est-2 { background: var(--ok-soft); color: var(--ok); }
.pill.est-3 { background: var(--bad-soft); color: var(--bad); }
.pill-nuevo { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .5px; background: var(--bad); color: #fff; border-radius: 999px; padding: 2px 8px; vertical-align: middle; }

/* ---------- Formularios ---------- */
.form-sec h2 { color: var(--accent); }
.form-sec.oficina { border: 2px dashed var(--accent); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field .label { font-weight: 500; font-size: 14px; }
.field .hint { color: var(--muted); font-size: 12px; margin-top: -2px; }
.req { color: var(--bad); }
.opt { color: var(--muted); font-weight: 400; font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=search], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); min-height: 46px;
}
textarea { min-height: 80px; resize: vertical; }
input.upper { text-transform: uppercase; }
input.num { text-align: right; font-variant-numeric: tabular-nums; }
input.postal { max-width: 200px; font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.field.bad input, .field.bad select, .field.bad textarea, .field.bad .filebox, .field.bad .yn-opts { border-color: var(--bad); box-shadow: 0 0 0 2px var(--bad-soft); border-radius: 10px; }
.err-msg { color: var(--bad); font-size: 13px; font-weight: 700; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.three { display: grid; grid-template-columns: 2fr 1.3fr .8fr; gap: 8px; }
@media (max-width: 380px) { .two { grid-template-columns: 1fr; } .three { grid-template-columns: 1fr 1fr; } .three .field:first-child { grid-column: 1 / -1; } }
.yn-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.yn-opts.col { grid-template-columns: 1fr; }
.yn-opt { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-height: 48px; cursor: pointer; font-weight: 500; font-size: 14px; line-height: 1.4; }
.yn-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.yn-opt input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; flex-shrink: 0; }
.yn-opt .nv { font-size: 18px; color: var(--accent); }
.chk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.yn-opt.small { min-height: 42px; padding: 8px 10px; font-size: 13px; gap: 8px; }
.yn-opt.small input { width: 18px; height: 18px; }
.field.bad .chk-grid { border: 1px solid var(--bad); box-shadow: 0 0 0 2px var(--bad-soft); border-radius: 10px; padding: 4px; }
.yn-opt.consent { font-weight: 700; }
.rowbox { border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.rowbox-h { display: flex; align-items: center; justify-content: space-between; }
.pick-tiempo { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pick-tiempo span { display: flex; align-items: center; gap: 6px; }
.pick-tiempo input, .pick-tiempo select { width: 84px; }
.consent-txt { background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.6; max-height: 220px; overflow: auto; }
.consent-txt hr { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }
/* Campo trampa (anti-spam): oculto para personas */
.trampa { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
/* Elegir archivo: recuadro grande (igual que MY HOPE) */
.filebox { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; cursor: pointer; padding: 14px; background: var(--surface); border: 2px dashed var(--accent); border-radius: var(--r); }
.filebox-btn { display: block; width: 100%; padding: 14px 12px; text-align: center; font-size: 17px; font-weight: 700; background: var(--accent); color: var(--accent-ink); border-radius: 10px; }
.filebox:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.file-hidden { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.foto-prev { width: 150px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px; box-shadow: 0 0 0 1px var(--line); }
.doc-prev { max-width: 100%; max-height: 200px; border-radius: 8px; box-shadow: 0 0 0 1px var(--line); }
.pdf-prev { font-weight: 700; word-break: break-all; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 12px; padding: 12px 16px; min-height: 48px; font-weight: 700; cursor: pointer; background: var(--accent); color: var(--accent-ink); text-decoration: none; }
.btn.block { width: 100%; }
.btn.big { font-size: 18px; min-height: 56px; }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.bad { background: var(--surface); color: var(--bad); border-color: var(--bad); }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.file-btn { position: relative; overflow: hidden; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions .btn { flex: 1 1 auto; }
.actions.small .btn { flex: 1 1 140px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding-block: 10px; }
.back { background: none; border: 0; color: var(--accent); font-weight: 500; padding: 4px 0; cursor: pointer; align-self: flex-start; }
.link { background: none; border: 0; padding: 4px 2px; color: var(--accent); font-weight: 500; text-decoration: underline; cursor: pointer; font-size: 13px; }
.link.center { align-self: center; }

/* ---------- Envío correcto ---------- */
.ok-box { text-align: center; align-items: center; padding-block: 32px; }
.ok-ico { width: 72px; height: 72px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; font-size: 40px; font-weight: 700; }
.ok-nro { font-size: 17px; margin: 0; }

/* ---------- Login ---------- */
.login { min-height: 75vh; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.is-login .brand .logo { display: none; }
.login-logo { display: block; width: min(320px, 90%); height: auto; margin: 0 auto 8px; }

/* ---------- Oficina: lista ---------- */
.filtros { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filtros input[type=search] { flex: 2 1 220px; }
.filtros select { flex: 1 1 150px; min-width: 0; width: auto; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.chk input { width: 18px; height: 18px; accent-color: var(--accent); }
.ficha-row { flex-direction: row; align-items: center; text-align: left; cursor: pointer; width: 100%; font: inherit; color: inherit; }
.ficha-row:hover { border-color: var(--accent); }
.ficha-row.arch { opacity: .6; }
.thumb { width: 54px; height: 72px; border-radius: 8px; background: var(--accent-soft); flex-shrink: 0; display: grid; place-items: center; font-size: 26px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.uso { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }
.uso-h { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; flex-wrap: wrap; }
.uso-bar { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.uso-bar i { display: block; height: 100%; background: var(--ok); border-radius: 999px; }
.uso.warn { border-color: var(--warn); background: var(--warn-soft); } .uso.warn .uso-bar i { background: var(--warn); }
.uso.naranja { border-color: var(--orange); background: var(--orange-soft); } .uso.naranja .uso-bar i { background: var(--orange); }
.uso.bad { border-color: var(--bad); background: var(--bad-soft); } .uso.bad .uso-bar i { background: var(--bad); }
.uso-msg { margin: 0; font-size: 13px; font-weight: 700; }
.lib-row { cursor: pointer; }
.lib-row.off { opacity: .55; cursor: not-allowed; }
.lib-row input { width: 22px; height: 22px; accent-color: var(--bad); flex-shrink: 0; }
.vac-row .title { font-weight: 500; }
.vac-row .vac-rom { margin-top: 6px; min-height: 38px; padding: 6px 10px; font-size: 13px; }
.vac-add { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
@media (max-width: 520px) { .vac-add { grid-template-columns: 1fr; } }
.pick { display: flex; gap: 8px; }
.pick input { flex: 1; min-width: 0; }

/* ---------- Oficina: ficha ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; }
.toolbar .nro { font-family: var(--font-display); font-size: 18px; min-width: 80px; text-align: center; }
.lbl-in { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
.lbl-in select { min-height: 38px; padding: 6px 10px; width: auto; }
.doc-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.trad-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.flag-mini { border: 0; background: none; padding: 3px; border-radius: 6px; cursor: pointer; line-height: 0; }
.flag-mini .flag { width: 28px; height: 19px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .18); display: block; }
.flag-mini[aria-pressed="true"] { background: var(--accent); }
.flag-mini.suya { box-shadow: 0 0 0 2px var(--ok); }
.msg { display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--line); padding-top: 8px; }
.msg-txt { white-space: pre-wrap; word-break: break-word; font-size: 15px; line-height: 1.5; }
.msg-orig summary { cursor: pointer; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.msg-orig .flag { width: 20px; height: 13px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .18); }
.msg-orig .msg-txt { color: var(--muted); font-size: 14px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table.kv { border-collapse: collapse; width: 100%; font-size: 13px; }
table.kv th, table.kv td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.kv th { color: var(--muted); font-weight: 500; white-space: nowrap; width: 1%; }

/* ---------- 身上書 (A4, igual que la hoja del Excel) ---------- */
.hoja-wrap { overflow: hidden; }
.hoja { width: 186mm; background: #fff; color: #000; padding: 6mm; transform-origin: top left; font-family: "Noto Sans JP", "Yu Gothic", "MS PGothic", sans-serif; box-shadow: 0 1px 6px rgba(0, 0, 0, .15); }
.h-top { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 3mm; }
.h-title { font-size: 26px; font-weight: 700; letter-spacing: 6px; flex: 1; text-align: center; padding-left: 30mm; }
.h-no { font-size: 12px; border: 1px solid #000; padding: 1mm 3mm; white-space: nowrap; }
.h-no b { font-size: 15px; }
.h-t { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 12px; }
.h-t th, .h-t td { border: 1px solid #000; padding: 1.2mm 1.5mm; height: 8.5mm; vertical-align: middle; overflow: hidden; word-break: break-all; line-height: 1.35; }
.h-t th { background: #eef2f7; font-weight: 700; text-align: center; font-size: 11px; }
.h-t .c { text-align: center; }
.h-t tr.alto td, .h-t tr.alto th { height: 16mm; }
.h-nombre { font-size: 19px; font-weight: 700; }
.h-foto { padding: 0 !important; text-align: center; background: #fafafa; }
.h-foto img { display: block; width: 100%; height: 41.5mm; object-fit: cover; }
.h-foto span { color: #999; }
.h-t tr.sep td { border-left: 0; border-right: 0; height: 2.5mm; padding: 0; }
.h-t tr.nv td { height: 7mm; font-size: 11px; }
.h-t tr.nv.on td:not(.nv-mark) { background: #fff3c4; font-weight: 700; }
.h-t tr.nv td.nv-mark { font-size: 44px; text-align: center; font-weight: 700; background: #fff !important; }
.h-t .h-sec { background: #dfe7f2; font-size: 13px; text-align: left; padding-left: 3mm; }
.h-t tr.exp td { height: 10mm; }
.h-t tr.exp td.ijo { text-align: right; padding-right: 8mm; }
.yn-opt.fin-exp { border-style: dashed; }
.h-t tr.biko td { height: 26mm; vertical-align: top; }
.h-pie { display: flex; justify-content: space-between; align-items: center; gap: 6mm; margin-top: 4mm; font-size: 11px; line-height: 1.5; }
.h-cont { font-weight: 700; font-size: 12px; }
.h-logo { height: 22mm; width: auto; }

/* ---------- Visor de documentos ---------- */
#visor { width: min(960px, 96vw); max-height: 92vh; border: 0; border-radius: var(--r); padding: 12px; background: var(--surface); }
#visor::backdrop { background: rgba(0, 0, 0, .55); }
.visor-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
#visor img { display: block; max-width: 100%; max-height: 78vh; margin: 0 auto; }
#visor iframe { width: 100%; height: 78vh; border: 0; }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 20;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px;
  max-width: calc(100% - 32px);
}
#toast.error { background: var(--bad); color: var(--surface); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ---------- Impresión: solo el 身上書, en A4 ---------- */
@page { size: A4 portrait; margin: 10mm; }
@media print {
  body { background: #fff; }
  .no-print, #toast, #visor { display: none !important; }
  .wrap, .wrap.wide { max-width: none; padding: 0; }
  .stack { gap: 0; }
  .hoja-wrap { overflow: visible; height: auto !important; }
  .hoja { transform: none !important; box-shadow: none; padding: 0; width: 190mm; }
  .h-t th, .h-t tr.nv.on td, .h-t .h-sec { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
