*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh;
  background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(215,32,42,.18), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgba(215,32,42,.10), transparent 60%);
}
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .07; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
a { color: var(--white); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-color: var(--red); text-underline-offset: 3px; }
h1, h2, h3, .display {
  font-family: var(--font-display); font-weight: 800; font-style: italic; text-transform: uppercase;
  letter-spacing: .01em; line-height: .95; margin: 0; color: var(--white);
}
h1 { font-size: clamp(30px, 6vw, 44px); }
h2 { font-size: clamp(22px, 4.5vw, 28px); }
h3 { font-size: 18px; font-style: normal; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
p { margin: 0 0 var(--s3); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; }
.red { color: var(--red); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.danger { color: var(--danger); }
.wrap { position: relative; z-index: 1; max-width: var(--maxw); margin: 0 auto; padding: var(--s4); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s3); margin: var(--s3) 0 var(--s5); flex-wrap: wrap; }
.page-head h1 { position: relative; padding-bottom: 8px; }
.page-head h1::after {
  content: ""; position: absolute; left: -4px; right: -8px; bottom: 0; height: 7px;
  background: url("/img/brush.svg") no-repeat left center / 100% 100%; opacity: .95;
}
.brush-title { position: relative; display: inline-block; padding-bottom: 8px; }
.brush-title::after { content: ""; position: absolute; left: -4px; right: -8px; bottom: 0; height: 7px; background: url("/img/brush.svg") no-repeat left center / 100% 100%; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: var(--radius);
  font-family: var(--font-display); font-weight: 800; font-style: italic; text-transform: uppercase; letter-spacing: .04em; font-size: 18px;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--white); cursor: pointer;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease; text-decoration: none !important; white-space: nowrap;
}
.btn:hover { background: #26262b; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--red); border-color: var(--red); box-shadow: 0 6px 20px var(--red-glow); }
.btn-primary:hover { background: #E42F39; }
.btn-wa { background: var(--wa); border-color: var(--wa); color: #06270F; }
.btn-wa:hover { background: #33E074; }
.btn-ok { background: var(--ok-deep); border-color: var(--ok-deep); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-sm { min-height: 38px; padding: 0 12px; font-size: 15px; }
.btn-xl { min-height: 72px; font-size: 26px; width: 100%; }
.btn-block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-icon { min-width: var(--tap); padding: 0; }

/* Formularios */
.field { margin-bottom: var(--s4); }
.field label, .label { display: block; font-family: var(--font-display); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.field label.req::after { content: " *"; color: var(--red); }
.field .hint { font-size: 13px; color: var(--muted-2); margin-top: 4px; }
.field .error { font-size: 13px; color: var(--danger); margin-top: 4px; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=date], input[type=time], input[type=number], input[type=search], input[type=month], select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--bg-2); color: var(--white); border: 1px solid var(--line-2); font: inherit; font-size: 16px;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--red); outline-offset: 1px; border-color: var(--red); }
input.is-invalid, select.is-invalid { border-color: var(--danger); }
textarea { min-height: 90px; resize: vertical; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%239A9AA3' stroke-width='2' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
input[type=date] { color-scheme: dark; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.check input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--red); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--s3); }
@media (max-width: 480px) { .grid-2 { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: var(--s3); flex-wrap: wrap; margin-top: var(--s4); }
.form-actions .btn { flex: 1; }
.alert-error { background: rgba(255,77,87,.12); border: 1px solid var(--danger); color: #FFB3B8; border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: var(--s4); font-size: 15px; }
.segmented { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; }
.segmented span { display: flex; align-items: center; justify-content: center; min-height: var(--tap); padding: 0 14px; font-family: var(--font-display); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); cursor: pointer; }
.segmented input:checked + span { background: var(--red); color: #fff; }

/* Tarjetas y listas */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4); margin-bottom: var(--s3); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); margin-bottom: var(--s3); }
.list { display: flex; flex-direction: column; gap: var(--s2); }
.row { display: flex; align-items: center; gap: var(--s3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; min-height: 64px; }
.row:hover { border-color: var(--line-2); }
a.row { text-decoration: none; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 600; color: var(--white); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { font-size: 13px; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .amount { font-family: var(--font-display); font-weight: 800; font-size: 22px; white-space: nowrap; }
.row .actions { display: flex; gap: 6px; }
.row.dim { opacity: .55; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap; }
.badge-ok { color: var(--ok); border-color: rgba(61,214,140,.4); background: rgba(61,214,140,.08); }
.badge-warn { color: var(--warn); border-color: rgba(245,181,43,.4); background: rgba(245,181,43,.08); }
.badge-red { color: #FF8A90; border-color: rgba(215,32,42,.5); background: rgba(215,32,42,.12); }
.badge-muted { color: var(--muted-2); }
.empty { text-align: center; padding: var(--s6) var(--s4); color: var(--muted); border: 1px dashed var(--line-2); border-radius: var(--radius); }
.empty .kanji { font-size: 40px; opacity: .25; margin-bottom: var(--s2); }
.empty .btn { margin-top: var(--s3); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: var(--s3); }
.chip { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); font-size: 14px; font-weight: 600; text-decoration: none !important; }
.chip.active { background: var(--white); color: var(--bg); border-color: var(--white); }
.toolbar { display: flex; gap: var(--s2); align-items: center; margin-bottom: var(--s3); flex-wrap: wrap; }
.toolbar form { display: flex; gap: 8px; flex: 1; }
.toolbar input[type=search] { flex: 1; }
.totals { display: flex; gap: var(--s3); flex-wrap: wrap; margin: var(--s3) 0; }
.totals div { flex: 1; min-width: 120px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.totals .label { margin: 0; font-size: 12px; }
.totals .val { font-family: var(--font-display); font-size: 24px; font-weight: 800; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 15px; }
.kv dt { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .05em; font-family: var(--font-display); font-weight: 700; padding-top: 2px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.divider { height: 1px; background: var(--line); margin: var(--s4) 0; }
.stack { display: flex; flex-direction: column; gap: var(--s3); }
.inline { display: inline; }
.hidden { display: none !important; }

/* Flash */
.flash { position: relative; z-index: 2; display: flex; flex-direction: column; gap: 8px; margin-bottom: var(--s3); }
.flash div { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 15px; border: 1px solid; animation: flashin .35s ease both; }
.flash .ok { background: rgba(61,214,140,.1); border-color: rgba(61,214,140,.45); color: #BFF3D8; }
.flash .warn { background: rgba(245,181,43,.1); border-color: rgba(245,181,43,.5); color: #FFE2A0; }
.flash .info { background: rgba(244,242,238,.06); border-color: var(--line-2); color: var(--ink); }
@keyframes flashin { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* Month picker */
.month { display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: var(--s4); }
.month a { display: flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap); border-radius: var(--radius); border: 1px solid var(--line-2); font-size: 20px; text-decoration: none !important; }
.month .label { margin: 0; flex: 1; text-align: center; font-family: var(--font-display); font-weight: 800; font-style: italic; text-transform: uppercase; font-size: 24px; color: var(--white); letter-spacing: .02em; }
.month .label.past { color: var(--muted); }

/* Logo */
.logo { display: inline-flex; align-items: center; gap: 12px; text-decoration: none !important; }
.logo svg { display: block; }
.logo .name { font-family: var(--font-display); font-weight: 800; font-style: italic; text-transform: uppercase; line-height: .9; font-size: 22px; color: var(--white); }
.logo .name small { display: block; font-size: 11px; letter-spacing: .28em; font-style: normal; font-weight: 700; color: var(--muted); margin-top: 4px; }
.kanji { font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", "MS Mincho", serif; }
@media (max-width: 1023px) { .kanji-side { display: none; } }
.kanji-side { position: fixed; right: 10px; top: 50%; transform: translateY(-50%); writing-mode: vertical-rl; font-size: 34px; letter-spacing: .3em; color: rgba(244,242,238,.06); pointer-events: none; z-index: 0; user-select: none; }

/* Minimal layout */
.minimal { min-height: 100dvh; display: flex; flex-direction: column; }
.minimal .wrap { width: 100%; max-width: 520px; flex: 1; display: flex; flex-direction: column; justify-content: center; padding: var(--s5) var(--s4); }
.minimal .top { display: flex; justify-content: center; margin-bottom: var(--s5); }
.hero-line { font-family: var(--font-display); font-weight: 800; font-style: italic; text-transform: uppercase; font-size: 15px; letter-spacing: .12em; color: var(--muted); text-align: center; margin-bottom: var(--s4); }
.hero-line b { color: var(--red); }
.foot { text-align: center; color: var(--muted-2); font-size: 12px; padding: var(--s4); letter-spacing: .08em; text-transform: uppercase; }
.steps { display: flex; gap: 6px; margin-bottom: var(--s4); }
.steps span { flex: 1; height: 4px; border-radius: 2px; background: var(--line-2); }
.steps span.done { background: var(--red); }
.big-time { font-family: var(--font-display); font-weight: 800; font-style: italic; font-size: clamp(56px, 18vw, 96px); line-height: 1; color: var(--white); text-align: center; letter-spacing: -.01em; }
.big-date { text-align: center; color: var(--muted); font-size: 16px; margin-bottom: var(--s5); }
.success { text-align: center; padding: var(--s5); border: 1px solid rgba(61,214,140,.5); background: rgba(61,214,140,.08); border-radius: var(--radius); margin-bottom: var(--s4); }
.success .check { display: block; width: 72px; height: 72px; margin: 0 auto var(--s3); border-radius: 50%; background: var(--ok); color: #05301A; font-size: 44px; line-height: 72px; text-align: center; font-weight: 800; }
.copy-box { display: flex; gap: 6px; }
.copy-box input { font-size: 13px; color: var(--muted); }
.qr-box { background: #fff; border-radius: var(--radius); padding: 16px; max-width: 360px; margin: 0 auto var(--s4); }
.qr-box svg { width: 100%; height: auto; display: block; }

/* Print */
@media print {
  body::before, body::after, .kanji-side, .bottomnav, .sidebar, .no-print, .flash { display: none !important; }
  body { background: #fff; color: #000; }
  .wrap { max-width: none; padding: 0; }
}
