/* Layout: una columna para celular (máx. 560px), barra de navegación fija abajo.
   Color: 藍 (índigo de ropa de trabajo) como acento; grises con un toque azul. */
: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;
  --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 (aunque el celular esté en modo oscuro), para que el fondo
   sea igual al del logo. El tema oscuro queda solo si se pide con data-theme="dark". */
:root { color-scheme: light; }
:root[data-theme="dark"] {
  --bg: #0f141a; --surface: #182029; --ink: #e7ebf0; --muted: #9ba7b5; --line: #29333f;
  --accent: #8fb0e6; --accent-ink: #0f1a2c; --accent-soft: #1f2c40;
  --ok: #6fcf9d; --ok-soft: #173326; --warn: #f0b85a; --warn-soft: #3a2c12; --bad: #f28b82; --bad-soft: #3d1c1a;
  color-scheme: dark;
}

* { 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 calc(96px + env(safe-area-inset-bottom, 0px)); }

/* ---------- Encabezado ---------- */
.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;
}
.brand { font-family: var(--font-display); font-weight: 700; font-size: 17px; min-width: 0; display: flex; align-items: center; gap: 8px; }
.brand[data-a] { cursor: pointer; border-radius: 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; }
.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[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.demo-bar { background: var(--warn-soft); color: var(--warn); font-size: 13px; padding: 8px 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; }
.section { display: flex; flex-direction: column; gap: 12px; padding-block-start: 8px; }

/* ---------- Resumen ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.stat b { display: block; font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat span { color: var(--muted); font-size: 13px; }

/* ---------- Trámites ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px; cursor: pointer; min-height: 116px;
}
.tile:active { transform: scale(.98); }
.tile .name { font-weight: 700; font-size: 15px; line-height: 1.3; }
.tile .jp { color: var(--muted); font-size: 12px; }
.kanji {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font-family: var(--font-display); font-size: 20px; font-weight: 700;
}

/* ---------- Tarjetas / listas ---------- */
.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: 10px; min-width: 0; }
.row { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.grow { flex: 1; min-width: 0; }
.title { font-weight: 700; }
.meta { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.note { background: var(--bg); border-radius: 10px; padding: 8px 10px; font-size: 14px; overflow-wrap: anywhere; }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r); }

.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill.pendiente { background: var(--warn-soft); color: var(--warn); }
.pill.aprobado  { background: var(--ok-soft);   color: var(--ok); }
.pill.rechazado { background: var(--bad-soft);  color: var(--bad); }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 500; font-size: 14px; }
.field .hint { color: var(--muted); font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=month], 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[type=file] { width: 100%; font-size: 14px; }
.pick { display: flex; gap: 8px; }
.pick input { flex: 1; min-width: 0; }
.chip.day { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.card.notice { text-align: left; cursor: pointer; width: 100%; }
.card.notice.rechazado { border-color: var(--bad); }
.blocked { background: var(--bad-soft); color: var(--bad); border-radius: 10px; padding: 12px; font-weight: 500; }
.warn-text { color: var(--bad); font-weight: 500; }
.num-in { width: 130px; min-height: 38px !important; padding: 6px 10px !important; text-align: right; font-variant-numeric: tabular-nums; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.info { background: var(--accent-soft); color: var(--ink); border-radius: 10px; padding: 10px 12px; font-size: 13px; }

.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);
}
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.ok { background: var(--ok); color: var(--surface); }
.btn.bad { background: var(--surface); color: var(--bad); border-color: var(--bad); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn[disabled] { opacity: .5; cursor: wait; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions .btn { flex: 1; }
.back { background: none; border: 0; color: var(--accent); font-weight: 500; padding: 4px 0; cursor: pointer; align-self: flex-start; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 14px; font-size: 13px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- Login ---------- */
.login { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; gap: 20px; }
.fab-current { background: var(--surface); border: 2px solid var(--accent); border-radius: var(--r); padding: 18px 16px; text-align: center; font-family: var(--font-display); font-size: 22px; font-weight: 700; color: var(--accent); }
.is-login .brand .logo { display: none; } /* en la entrada ya está el logo grande */
.login-logo { display: block; width: min(320px, 90%); height: auto; margin: 0 auto 8px; }
.login .mark { width: 64px; height: 64px; border-radius: 18px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-family: var(--font-display); font-size: 34px; }

/* ---------- Navegación inferior ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
}
.nav-in { max-width: 560px; margin: 0 auto; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.nav button { background: none; border: 0; padding: 6px 2px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); cursor: pointer; }
.nav button svg { width: 24px; height: 24px; }
.nav button[aria-current="page"] { color: var(--accent); font-weight: 700; }
.badge { background: var(--bad); color: var(--surface); border-radius: 999px; font-size: 10px; padding: 0 6px; margin-inline-start: 2px; }

/* ---------- Tablas (oficina) ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; }
td.num { font-variant-numeric: tabular-nums; text-align: right; }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(84px + 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; } .tile:active { transform: none; } }

/* ---------- Fábrica y permiso del jefe ---------- */
.fab-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-block-start: 8px; }
.fab-tag { display: inline-block; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; padding: 4px 10px; border-radius: 8px; overflow-wrap: anywhere; }
.link { background: none; border: 0; padding: 4px 2px; color: var(--accent); font-weight: 500; text-decoration: underline; cursor: pointer; font-size: 13px; }
fieldset.yn { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.yn legend { font-weight: 500; font-size: 14px; padding: 0; margin-block-end: 6px; }
.yn-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.yn-opt { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-height: 48px; cursor: pointer; font-weight: 500; }
.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; }
#adm-fab { max-width: 100%; }
