/* SOSFIX Impuestos — estilos (mobile-first) */
:root {
  --primary: #0066cc;
  --accent: #00aaff;
  --brand: #67e8f9;
  --bg: #0a1628;
  --card: #132337;
  --field: #0d1b2e;
  --line: #2a4a7a;
  --text: #e8f0fe;
  --muted: #8aa4c8;
  --success: #00c853;
  --warning: #ffab00;
  --danger: #ef5350;
  --radius: 14px;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --nav-h: 76px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg) linear-gradient(160deg, #0a1628 0%, #14254a 100%) fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.45;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app { max-width: 760px; margin: 0 auto; padding: 12px 12px calc(var(--nav-h) + 80px); }
.app.wide { max-width: 1000px; padding-bottom: 32px; }

/* Header */
.header {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); padding: 10px 14px; border-radius: var(--radius);
  border: 1px solid rgba(0,170,255,.2); margin-bottom: 12px;
}
.logo { width: 38px; height: auto; flex-shrink: 0; }
.header h1 { font-size: 1.15rem; font-weight: 800; letter-spacing: .02em; color: var(--brand); }
.header .sub { font-size: .8rem; color: var(--muted); }
.badge { display: inline-block; background: var(--warning); color: #000; padding: 2px 10px; border-radius: 99px; font-size: .72rem; font-weight: 700; margin-left: auto; }
.header a.badge { text-decoration: none; }

/* Progress (transform-only, no layout) */
.progress { display: flex; align-items: center; gap: 12px; background: var(--card); padding: 12px 14px; border-radius: var(--radius); margin-bottom: 12px; }
.progress-track { flex: 1; height: 10px; background: #1e3a5f; border-radius: 99px; overflow: hidden; }
.progress-fill {
  height: 100%; width: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--primary));
  transform-origin: left center; transform: scaleX(0);
  transition: transform .45s var(--ease-out);
}
.progress-text { font-size: .85rem; color: var(--muted); min-width: 7.5em; text-align: right; font-variant-numeric: tabular-nums; }

/* Steps */
.step { display: none; background: var(--card); padding: 20px 16px; border-radius: var(--radius); }
.step.active { display: block; }
.step.enter { animation: stepIn .28s var(--ease-out) both; }
.step.enter.back { animation-name: stepInBack; }
@keyframes stepIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes stepInBack { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }

.step-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.step-head h2 { font-size: 1.2rem; color: var(--accent); display: flex; align-items: center; gap: 8px; outline: none; }
.step-head .help-btn { margin-left: auto; }
.step-count { font-size: .78rem; color: var(--muted); margin-bottom: 4px; }
.icon { width: 1.15em; height: 1.15em; flex-shrink: 0; }
.lead { color: var(--muted); margin-bottom: 12px; font-size: .95rem; }

/* Forms */
.form-group { margin-bottom: 14px; }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.form-group label, .label-row label { font-weight: 500; color: var(--muted); font-size: .95rem; }
.form-group > label { display: block; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=number], input[type=password], select {
  width: 100%; padding: 12px 14px; background: var(--field);
  border: 1px solid var(--line); border-radius: 10px; font-size: 16px; /* 16px evita zoom en iOS */
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,170,255,.2); }
.invalid { border-color: var(--danger) !important; }
.err { color: #ff8a80; font-size: .82rem; margin-top: 4px; min-height: 0; }
.row2 { display: grid; gap: 0 12px; }
@media (min-width: 560px) { .row2 { grid-template-columns: 1fr 1fr; } }

.help-btn {
  background: rgba(0,170,255,.12); border: 1px solid rgba(0,170,255,.35); color: var(--accent);
  font-size: .78rem; padding: 3px 10px; border-radius: 99px; flex-shrink: 0;
}

.checks { display: grid; gap: 8px; }
@media (min-width: 560px) { .checks { grid-template-columns: 1fr 1fr; } }
.check {
  display: flex; align-items: center; gap: 10px; padding: 12px; background: var(--field);
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
}
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex-shrink: 0; }
.check:has(input:checked) { border-color: var(--accent); background: #10284a; }

/* Dependents as cards (works on phones) */
.dep-card { background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.dep-card .dep-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; color: var(--muted); font-size: .85rem; }
.dep-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dep-grid .full { grid-column: 1 / -1; }
.dep-grid input, .dep-grid select { padding: 10px 12px; background: var(--card); }
.dep-grid label { font-size: .75rem; color: var(--muted); display: block; margin-bottom: 3px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 20px; border: none; border-radius: 12px; font-weight: 600; font-size: 1rem; transition: transform .15s var(--ease-out), opacity .15s; text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; }
.btn-secondary { background: #1e3a5f; color: var(--text); }
.btn-ghost { background: transparent; color: var(--accent); border: 1px dashed var(--accent); }
.btn-danger { background: transparent; color: #ff8a80; border: 1px solid rgba(239,83,80,.5); padding: 6px 12px; font-size: .85rem; }
.btn-warn { background: var(--warning); color: #000; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: .9rem; }

/* Photos */
.cam-list { display: grid; gap: 8px; }
.cam-btn { position: relative; overflow: hidden; }
.cam-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 12px; }
.photo { position: relative; border-radius: 10px; overflow: hidden; background: var(--field); border: 1px solid var(--line); animation: pop .25s var(--ease-out) both; }
.photo img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.photo span { display: block; font-size: .7rem; padding: 4px 6px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo button { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: none; background: rgba(0,0,0,.65); color: #fff; }
@keyframes pop { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }

/* Signature */
.auth-label { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0; font-size: .92rem; }
.auth-label input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); flex-shrink: 0; }
.sig-box { background: var(--field); border: 2px dashed var(--accent); border-radius: 12px; padding: 10px; }
.sig-box canvas { display: block; width: 100%; height: 180px; background: #fff; border-radius: 8px; touch-action: none; cursor: crosshair; }
.sig-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 8px; }
.hint { font-size: .8rem; color: var(--muted); }
.summary { background: var(--field); border-radius: 10px; padding: 12px; font-size: .92rem; display: grid; gap: 4px; }
.summary b { color: var(--muted); font-weight: 500; }

/* Sticky bottom nav — chat FAB sits above it, never on top of buttons */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: rgba(10,22,40,.92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid rgba(0,170,255,.15);
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
}
.nav-inner { max-width: 760px; margin: 0 auto; display: flex; gap: 10px; }
.nav-inner .btn { flex: 1; }

/* Done screen */
.done { text-align: center; padding: 28px 16px; }
.done .tick { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 50%; background: rgba(0,200,83,.15); color: var(--success); display: grid; place-items: center; animation: pop .35s var(--ease-out) both; }
.done h2 { color: var(--success); margin-bottom: 8px; }
.done p { color: var(--muted); margin-bottom: 16px; }
.done .btn { margin: 4px; }

/* Modal (opacity/transform, closable) */
.modal {
  position: fixed; inset: 0; z-index: 1000; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0,0,0,.6); opacity: 0; visibility: hidden;
  transition: opacity .2s ease, visibility 0s linear .2s;
}
.modal.open { opacity: 1; visibility: visible; transition: opacity .2s ease, visibility 0s; }
.modal-card {
  background: var(--card); width: 100%; max-width: 480px; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  border-radius: 18px 18px 0 0; border: 1px solid rgba(0,170,255,.4); position: relative;
  transform: translateY(24px); transition: transform .28s var(--ease-out);
}
.modal.open .modal-card { transform: none; }
@media (min-width: 560px) {
  .modal { align-items: center; }
  .modal-card { border-radius: 18px; transform: translateY(12px) scale(.98); }
}
.modal-close { position: absolute; right: 10px; top: 8px; width: 40px; height: 40px; border: none; background: none; color: var(--text); font-size: 26px; line-height: 1; }
.modal-card h3 { margin-bottom: 8px; padding-right: 36px; }

/* Help demo — fixed height so nothing jumps while it animates */
.demo { margin-top: 14px; background: var(--field); border-radius: 12px; padding: 14px; min-height: 108px; display: grid; align-content: center; }
.demo-cap { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; }
.demo-input { background: var(--card); border: 1px solid var(--accent); border-radius: 8px; padding: 10px 12px; font-size: 1.05rem; white-space: nowrap; overflow: hidden; }
.demo-input .typed { color: var(--text); }
.caret { display: inline-block; width: 2px; height: 1.1em; background: var(--accent); vertical-align: -0.15em; margin-left: 1px; animation: caret 1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }
.demo-card { background: #1a3a6e; border-radius: 10px; padding: 10px 12px; opacity: 0; transform: translateY(8px); transition: opacity .3s ease, transform .3s var(--ease-out); }
.demo-card.in { opacity: 1; transform: none; }
.demo-check { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.demo-box { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--accent); display: grid; place-items: center; }
.demo-box svg { width: 14px; height: 14px; opacity: 0; transform: scale(.4); transition: opacity .2s, transform .25s var(--ease-out); }
.demo-check.on .demo-box { background: var(--accent); }
.demo-check.on .demo-box svg { opacity: 1; transform: none; }

/* Chat */
.chat-fab {
  position: fixed; right: 14px; bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom)); z-index: 60;
  display: flex; align-items: center; gap: 6px; border: none; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  padding: 10px 14px; border-radius: 99px; font-weight: 600; font-size: .9rem;
  box-shadow: 0 6px 18px rgba(0,102,204,.45);
}
.chat-win {
  position: fixed; right: 12px; left: 12px; bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom)); z-index: 70;
  height: min(420px, 60vh); background: var(--field); border: 1px solid var(--accent); border-radius: 16px;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 10px 40px rgba(0,0,0,.5);
  opacity: 0; visibility: hidden; transform: translateY(12px); transform-origin: bottom right;
  transition: opacity .2s ease, transform .25s var(--ease-out), visibility 0s linear .25s;
}
.chat-win.open { opacity: 1; visibility: visible; transform: none; transition: opacity .2s ease, transform .25s var(--ease-out), visibility 0s; }
@media (min-width: 560px) { .chat-win { left: auto; width: 360px; } }
.chat-head { background: linear-gradient(90deg, var(--primary), var(--accent)); padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.chat-head button { background: none; border: none; color: #fff; font-size: 24px; width: 36px; height: 36px; }
.chat-msgs { flex: 1; padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 82%; padding: 8px 12px; border-radius: 12px; font-size: .93rem; overflow-wrap: anywhere; animation: pop .2s var(--ease-out) both; }
.msg.client { background: #1a3a6e; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.agent { background: var(--card); align-self: flex-start; border-bottom-left-radius: 4px; border: 1px solid var(--line); }
.chat-form { display: flex; gap: 8px; padding: 10px; background: var(--card); }
.chat-form input { flex: 1; border-radius: 99px; }
.chat-form button { width: 44px; height: 44px; border-radius: 50%; border: none; background: var(--accent); color: #fff; flex-shrink: 0; display: grid; place-items: center; }

/* Agent / admin */
.card { background: var(--card); border-radius: var(--radius); padding: 18px 16px; margin-bottom: 12px; }
.login-box { max-width: 380px; margin: 24px auto; }
.login-box h2 { margin-bottom: 12px; }
.login-box input { margin-bottom: 10px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.list { display: grid; gap: 10px; }
.client-card { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--field); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 14px; border-radius: 12px; }
.client-card:hover { border-color: var(--accent); }
.client-card small { color: var(--muted); display: block; }
.pill { font-size: .75rem; padding: 3px 10px; border-radius: 99px; background: #1e3a5f; white-space: nowrap; }
.pill.ok { background: rgba(0,200,83,.18); color: #69f0ae; }
.pill.warn { background: rgba(255,171,0,.18); color: #ffd180; }
.detail h3 { margin-bottom: 10px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; font-size: .93rem; margin-bottom: 12px; }
.kv dt { color: var(--muted); }
.kv dd { overflow-wrap: anywhere; }
.sig-img { background: #fff; border-radius: 8px; max-width: 280px; width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.muted { color: var(--muted); }
.notice { background: rgba(255,171,0,.1); border: 1px solid rgba(255,171,0,.35); color: #ffd180; border-radius: 10px; padding: 10px 12px; font-size: .85rem; margin-bottom: 12px; }

/* Portal */
.portal { display: grid; gap: 12px; }
.portal a { display: block; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; transition: transform .15s var(--ease-out), border-color .15s; }
.portal a:hover { border-color: var(--accent); transform: translateY(-2px); }
.portal strong { display: block; color: var(--brand); font-size: 1.1rem; margin-bottom: 4px; }

@media (min-width: 720px) {
  .app { padding-top: 20px; }
  .header { padding: 14px 20px; }
  .logo { width: 46px; }
  .header h1 { font-size: 1.4rem; }
  .step { padding: 26px 24px; }
}

/* Accesibilidad: sin animaciones si el usuario lo pide */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
}
.chat-fab.has-new::after { content: ''; position: absolute; top: 4px; right: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 2px #0a1628; }
.docs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-bottom: 12px; }
.docs-grid a { display: block; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--field); color: var(--muted); font-size: .75rem; text-decoration: none; }
.docs-grid img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.docs-grid span { display: block; padding: 4px 6px; }
