/* ============================================================================
 * WellForms — estilos. Estética limpia inspirada en apple.com:
 * clara, aireada y premium. Sin emojis en la UI: solo iconos SVG inline.
 * ========================================================================== */

:root {
  --bg: #f5f5f7;
  --panel: #ffffff;
  --ink: #1d1d1f;
  --ink-soft: #515154;
  --ink-faint: #86868b;
  --line: #d2d2d7;
  --line-soft: #e8e8ed;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-soft: #e9f2fd;
  --ok: #1d8127;
  --ok-soft: #e6f4ea;
  --warn: #b25000;
  --warn-soft: #fef3e2;
  --bad: #d70015;
  --bad-soft: #fdeeee;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 14px rgba(0, 0, 0, .05);
  --shadow-md: 0 12px 40px rgba(0, 0, 0, .10);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: rgba(0, 113, 227, .18); }

.ic { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.ic-lg { width: 26px; height: 26px; }

/* ------------------------------- demo banner ------------------------------ */
.demo-banner {
  background: #fff4d6; color: #7a4d00; text-align: center;
  font-size: 13px; font-weight: 600; letter-spacing: .04em;
  padding: 9px 12px; position: sticky; top: 0; z-index: 200;
  border-bottom: 1px solid #f0dfae;
}

/* --------------------------------- login ---------------------------------- */
.login-wrap {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(600px 400px at 20% 10%, rgba(0, 113, 227, .07), transparent 60%),
    radial-gradient(700px 500px at 85% 90%, rgba(0, 113, 227, .05), transparent 60%),
    var(--bg);
}
.login-card {
  background: var(--panel); border-radius: 20px; padding: 40px 38px;
  width: 100%; max-width: 400px; box-shadow: var(--shadow-md);
  border: 1px solid var(--line-soft);
}
/* Selector de idioma centrado arriba del cuadro de login */
.login-lang {
  width: 100%; max-width: 400px; display: flex; justify-content: center;
  margin-bottom: 16px;
}
.login-card h1 { margin: 0 0 6px; font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.login-card p.sub { margin: 0 0 24px; color: var(--ink-soft); font-size: 14px; }
.demo-hint {
  background: var(--warn-soft); border: 1px solid #f0d9a8; border-radius: var(--radius);
  padding: 10px 14px; font-size: 13px; margin-bottom: 16px; color: #7c4a12;
}

/* --------------------------------- layout --------------------------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 252px; background: rgba(255, 255, 255, .85); color: var(--ink);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex: none;
  border-right: 1px solid var(--line-soft);
  -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
}
.brand { padding: 22px 20px 16px; }
.brand .name { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.brand .who {
  font-size: 15px; font-weight: 700; color: #0071e3; margin-top: 6px; letter-spacing: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", sans-serif;
}
.nav { padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px; color: var(--ink-soft);
  text-decoration: none; padding: 10px 12px; border-radius: 10px; font-size: 14px; font-weight: 500;
}
.nav a:hover { background: #f0f0f2; color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-foot { padding: 16px 20px; border-top: 1px solid var(--line-soft); font-size: 12px; color: var(--ink-faint); }
.side-foot button { margin-top: 10px; }

.main { flex: 1; min-width: 0; padding: 32px 36px 70px; max-width: 1560px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.page-head .crumb { font-size: 13px; color: var(--ink-faint); margin-bottom: 4px; font-weight: 500; }
.page-head .crumb a { color: var(--accent); text-decoration: none; }
/* Nombre del cliente en el breadcrumb: destacado para identificar el expediente */
.page-head .crumb .crumb-client {
  font-weight: 800; font-size: 15px; color: var(--accent);
  background: rgba(0,113,227,.12); padding: 4px 12px; border-radius: 980px;
  border: 1px solid rgba(0,113,227,.25); white-space: nowrap;
}
.page-head .crumb .crumb-client:hover { background: rgba(0,113,227,.2); }

/* --------------------------------- cards ---------------------------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card {
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius-lg);
  padding: 20px 22px; box-shadow: var(--shadow-sm);
}
.card h3 { margin: 0 0 14px; font-size: 13px; font-weight: 600; letter-spacing: .02em; color: var(--ink-soft); display: flex; align-items: center; gap: 8px; }
.stat { font-size: 36px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.stat small { font-size: 14px; font-weight: 400; color: var(--ink-soft); }
.rowline { display: flex; justify-content: space-between; gap: 6px 12px; padding: 9px 0; border-top: 1px solid var(--line-soft); font-size: 14px; flex-wrap: wrap; min-width: 0; }
.rowline > * { min-width: 0; }
.rowline:first-of-type { border-top: 0; }
.muted { color: var(--ink-soft); } .faint { color: var(--ink-faint); } .small { font-size: 13px; }

/* --------------------------------- tablas --------------------------------- */
.table-wrap { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius-lg); overflow-x: auto; box-shadow: var(--shadow-sm); }
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th {
  text-align: left; padding: 12px 16px; color: var(--ink-faint);
  font-size: 12px; font-weight: 600; letter-spacing: .04em; border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
table.grid td { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tr.clickable { cursor: pointer; }
table.grid tr.clickable:hover td { background: #f9f9fb; }

/* --------------------------------- botones --------------------------------- */
/* --------------------- botones: liquid glass ------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid rgba(210,210,215,.9); border-radius: 980px; padding: 10px 20px;
  font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none;
  color: var(--accent);
  font-family: inherit; white-space: nowrap;
  background: linear-gradient(180deg, rgba(255,255,255,.85), rgba(245,245,247,.55));
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  backdrop-filter: blur(18px) saturate(180%);
  box-shadow:
    inset 0 1px 1px rgba(255,255,255,.9),
    inset 0 -1px 2px rgba(0,0,0,.04),
    0 4px 14px rgba(0,0,0,.08);
  transition: transform .05s, box-shadow .15s, background .15s;
}
.btn:hover {
  background: linear-gradient(180deg, rgba(255,255,255,.95), rgba(245,245,247,.7));
  box-shadow:
    inset 0 1px 1px rgba(255,255,255,1),
    inset 0 -1px 2px rgba(0,0,0,.04),
    0 6px 20px rgba(0,0,0,.12);
}
.btn:active { transform: scale(.98); }
.btn-primary {
  color: #fff; border: 1px solid rgba(255,255,255,.35);
  background: linear-gradient(180deg, rgba(10,132,255,.88), rgba(0,113,227,.78));
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  backdrop-filter: blur(18px) saturate(180%);
  box-shadow:
    inset 0 1px 1px rgba(255,255,255,.5),
    inset 0 -1px 3px rgba(0,40,90,.35),
    0 8px 24px rgba(0,113,227,.35);
  text-shadow: 0 1px 2px rgba(0,40,90,.25);
}
.btn-primary:hover {
  background: linear-gradient(180deg, rgba(20,140,255,.94), rgba(0,122,240,.85));
  box-shadow:
    inset 0 1px 1px rgba(255,255,255,.6),
    inset 0 -1px 3px rgba(0,40,90,.35),
    0 10px 28px rgba(0,113,227,.45);
}
.btn-danger {
  color: #fff; border: 1px solid rgba(255,255,255,.35);
  background: linear-gradient(180deg, rgba(255,99,88,.88), rgba(215,0,21,.78));
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  backdrop-filter: blur(18px) saturate(180%);
  box-shadow:
    inset 0 1px 1px rgba(255,255,255,.5),
    inset 0 -1px 3px rgba(90,0,10,.35),
    0 8px 24px rgba(215,0,21,.3);
  text-shadow: 0 1px 2px rgba(90,0,10,.25);
}
.btn-danger:hover {
  background: linear-gradient(180deg, rgba(255,110,100,.94), rgba(230,10,30,.85));
}
.btn-beige {
  color: #6d5f42; border: 1px solid rgba(255,255,255,.55);
  background: linear-gradient(180deg, rgba(252,248,238,.88), rgba(240,232,210,.6));
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  backdrop-filter: blur(18px) saturate(180%);
  box-shadow:
    inset 0 1px 1px rgba(255,255,255,.9),
    inset 0 -1px 2px rgba(120,100,60,.08),
    0 4px 14px rgba(120,100,60,.12);
}
.btn-beige:hover {
  background: linear-gradient(180deg, rgba(253,250,242,.95), rgba(244,236,216,.72));
}
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); padding: 8px 10px; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* --------------------------------- forms ---------------------------------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 14px; font-size: 15px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--ink); font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0, 113, 227, .15);
}
.field textarea { min-height: 90px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.form-panel { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius-lg); padding: 22px 24px; margin-bottom: 20px; box-shadow: var(--shadow-sm); }
.form-panel h3 { margin: 0 0 16px; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }

.yesno { display: flex; gap: 12px; }
.yesno button {
  flex: 1; padding: 14px; border: 1.5px solid var(--line); border-radius: 14px;
  background: #fff; font-size: 15px; font-weight: 600; cursor: pointer; color: var(--ink-soft);
  font-family: inherit; transition: border-color .15s, background .15s;
  min-width: 0;
}
.yesno button:hover { border-color: var(--ink-faint); }
.yesno button.sel-yes { border-color: #22a355; border-width: 2px; }
.yesno button.sel-no { border-color: #22a355; border-width: 2px; }

/* --------------------------------- badges --------------------------------- */
.badge {
  display: inline-block; padding: 4px 12px; border-radius: 980px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.b-amber { background: #fdf0dc; color: #92600a; }
.b-blue { background: var(--accent-soft); color: #0a5fc2; }
.b-green { background: var(--ok-soft); color: #14663c; }
.b-teal { background: #e6f3ee; color: #14663c; }
.b-purple { background: #f0e9fd; color: #5b21b6; }
.b-gold { background: #f7ecd4; color: #8a5f14; }
.b-gray { background: #ececf0; color: #515154; }
.b-red { background: var(--bad-soft); color: #a11f26; }

/* ---------------------------------- tabs ---------------------------------- */
.tabs {
  display: inline-flex; gap: 2px; margin-bottom: 20px; max-width: 100%;
  background: rgba(118, 118, 128, .12); border-radius: 12px; padding: 3px;
  overflow-x: auto;
}
.tabs button {
  background: none; border: 0; padding: 8px 16px; font-size: 14px; font-weight: 600;
  color: var(--ink-soft); cursor: pointer; border-radius: 9px;
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  font-family: inherit; flex: none;
}
.tabs button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }

/* -------------------------------- checklist ------------------------------- */
.check-item {
  display: flex; align-items: flex-start; gap: 14px; padding: 16px 18px;
  border: 1px solid var(--line-soft); border-radius: 16px; margin-bottom: 12px; background: #fff;
  box-shadow: var(--shadow-sm);
}
.check-item .grow { flex: 1; min-width: 0; }
.check-item .t { font-weight: 600; font-size: 15px; overflow-wrap: break-word; line-height: 1.35; }
.check-item .small { overflow-wrap: break-word; }
.check-item .h { font-size: 13px; color: var(--ink-faint); margin-top: 2px; line-height: 1.4; }
.check-dot {
  width: 30px; height: 30px; border-radius: 50%; flex: none; margin-top: 2px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--line); color: transparent; background: #fff;
}
.sample-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 0; border: 0; background: none; color: var(--accent); font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; white-space: nowrap; }
.sample-link:hover { color: var(--accent-hover); text-decoration: underline; }
.sample-link svg { width: 15px; height: 15px; flex: none; }
.sample-img { width: 100%; height: auto; display: block; border-radius: 12px; border: 1px solid var(--line-soft); background: #fff; }
.file-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; padding: 8px 10px; background: var(--bg); border-radius: 10px; font-size: 13px; }
.file-row svg { width: 16px; height: 16px; flex: none; color: var(--ink-soft); }
.file-row .file-name { font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.file-row .faint { font-size: 12px; color: var(--ink-faint); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; flex: none; border-radius: 9px; border: 1px solid var(--line-soft); background: #fff; cursor: pointer; color: var(--ink-soft); margin-left: auto; }
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn.danger { color: #d92d20; }
.icon-btn.danger:hover { background: #fef3f2; border-color: #fecdca; }
.check-act { flex: none; padding-top: 2px; }
.check-item.done { border-color: #bfe3cd; background: #f4faf6; }
.check-item.done .check-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.check-item .meta { font-size: 12px; color: var(--ink-soft); text-align: right; flex: none; }

/* ---------------------------------- chat ---------------------------------- */
.chat { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; max-height: 420px; overflow-y: auto; padding: 4px; }
.msg { max-width: 78%; padding: 10px 14px; border-radius: 18px; font-size: 14px; overflow-wrap: break-word; }
.msg .who { font-size: 11px; font-weight: 700; margin-bottom: 3px; opacity: .75; }
.msg .when { font-size: 11px; opacity: .6; margin-top: 4px; }
.msg.me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.them { align-self: flex-start; background: #e9e9eb; color: var(--ink); border-bottom-left-radius: 4px; }
.chat-input { display: flex; gap: 8px; }
.chat-input input { flex: 1; min-width: 0; padding: 11px 14px; border: 1px solid var(--line); border-radius: 980px; font-size: 15px; font-family: inherit; }
.chat-input input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0, 113, 227, .15); }

/* --------------------------------- modal ---------------------------------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 18px;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.modal {
  background: rgba(255, 255, 255, .96); border-radius: 20px; width: 100%; max-width: 560px;
  max-height: 92vh; overflow-y: auto; padding: 28px; box-shadow: var(--shadow-md);
  border: 1px solid var(--line-soft); position: relative;
}
.modal-x {
  position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.06); cursor: pointer; display: flex; align-items: center;
  justify-content: center; color: #333; z-index: 2;
}
.modal-x:hover { background: rgba(0,0,0,.12); }
.modal-x svg { width: 18px; height: 18px; }
.modal h3 { margin: 0 0 18px; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* ------------------------------ firma (canvas) ----------------------------- */
.sig-pad { border: 1.5px dashed var(--line); border-radius: var(--radius); background: #fbfbfd; touch-action: none; }
.sig-pad canvas { display: block; width: 100%; height: 180px; cursor: crosshair; border-radius: var(--radius); }
.sig-preview { max-width: 320px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }

/* ------------------------------ portal cliente ----------------------------- */
.portal-wrap { max-width: 680px; margin: 0 auto; padding: 20px 16px 70px; min-height: 100vh; }
.portal-top {
  background: var(--panel); border: 1px solid var(--line-soft); color: var(--ink);
  border-radius: var(--radius-lg); padding: 22px 24px; margin-bottom: 18px; box-shadow: var(--shadow-sm);
}
.portal-top .t { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; overflow-wrap: break-word; display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }
.portal-top .t-sep { color: var(--ink-faint); font-weight: 400; }
.portal-top .t-name { font-weight: 800; }
.top-logo { height: 46px; width: auto; display: inline-block; vertical-align: middle; border-radius: 6px; }
.brand-logo { height: 76px; width: auto; display: block; border-radius: 10px; }
.brand-logo-sm { height: 44px; width: auto; display: block; border-radius: 6px; }
.login-logo { height: 88px; width: auto; display: block; margin: 0 auto 12px; border-radius: 10px; }
.portal-top .s { font-size: 13px; color: var(--ink-faint); margin-top: 6px; overflow-wrap: break-word; }
.portal-card { background: #fff; border: 1px solid var(--line-soft); border-radius: var(--radius-lg); padding: 24px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.portal-card h3 { margin-top: 0; letter-spacing: -0.01em; }
.steps-bar { display: flex; gap: 6px; margin-bottom: 20px; }
.steps-bar span { flex: 1; height: 6px; border-radius: 3px; background: #e3e3e8; }
.steps-bar span.on { background: var(--accent); }
.pin-input {
  font-size: 30px !important; letter-spacing: .5em; text-align: center;
  padding: 14px !important; font-weight: 700;
}
.doc-upload { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.legal-text {
  white-space: pre-wrap; font-size: 13px; background: #f9f9fb; border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 16px 18px; max-height: 260px; overflow-y: auto; margin-bottom: 16px;
  font-family: Georgia, serif; line-height: 1.6;
}

/* ------------------------------- impresión -------------------------------- */
.print-toolbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .8); color: var(--ink);
  -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--line-soft);
  padding: 12px 18px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.print-doc { background: #fff; color: #111; max-width: 820px; margin: 24px auto; padding: 48px 52px; box-shadow: var(--shadow-md); border-radius: 4px; font-size: 14px; }
.print-doc h1 { font-size: 24px; margin: 0; letter-spacing: -0.01em; }
.print-doc h2 { font-size: 16px; border-bottom: 2px solid #111; padding-bottom: 6px; margin: 28px 0 12px; text-transform: uppercase; letter-spacing: .04em; }
.print-doc table { width: 100%; border-collapse: collapse; margin: 8px 0 4px; }
.print-doc table td, .print-doc table th { border: 1px solid #999; padding: 6px 9px; font-size: 13px; text-align: left; vertical-align: top; overflow-wrap: break-word; }
.print-doc table th { background: #f2f2f4; }
.print-doc .kv { display: grid; grid-template-columns: 220px 1fr; gap: 4px 12px; margin: 6px 0; }
.print-doc .kv dt { font-weight: 700; } .print-doc .kv dd { margin: 0; overflow-wrap: break-word; }
.print-doc .sigimg { max-width: 300px; border: 1px solid #999; border-radius: 4px; }
.print-doc .foot { margin-top: 34px; font-size: 12px; color: #444; border-top: 1px solid #999; padding-top: 10px; }

@media print {
  body { background: #fff; }
  .print-toolbar, .demo-banner, .no-print { display: none !important; }
  .print-doc { box-shadow: none; margin: 0; padding: 0; max-width: none; border-radius: 0; }
}

/* --------------------------------- varios --------------------------------- */
.alert {
  border-radius: var(--radius); padding: 13px 16px; font-size: 14px; margin-bottom: 16px;
  display: flex; gap: 10px; align-items: flex-start; overflow-wrap: break-word;
}
.alert > div, .alert > span { min-width: 0; }
.alert-err { background: var(--bad-soft); border: 1px solid #f3c2c6; color: #8f1d23; }
.alert-ok { background: var(--ok-soft); border: 1px solid #bfe3cd; color: #14663c; }
.alert-info { background: var(--accent-soft); border: 1px solid #c3d9f5; color: #0a5fc2; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar .searchbox { margin: 0; }
.toolbar .searchbox input { height: 46px; }
.toolbar select {
  height: 46px; padding: 0 14px; font-size: 15px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); margin: 0;
}
.searchbox { position: relative; }
.searchbox .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-faint); }
.searchbox input { padding-left: 36px; width: 260px; max-width: 100%; }
.empty { text-align: center; padding: 48px 20px; color: var(--ink-faint); }
.empty .ic-lg { opacity: .4; margin-bottom: 8px; }
.pin-display {
  font-size: 40px; font-weight: 700; letter-spacing: .35em; text-align: center;
  background: #f9f9fb; border: 1.5px dashed var(--accent); border-radius: 14px; padding: 16px; margin: 12px 0;
  overflow-wrap: break-word;
}
.link-box {
  font-family: ui-monospace, SFMono-Regular, monospace; font-size: 12px; word-break: break-all;
  background: #f9f9fb; border: 1px solid var(--line-soft); border-radius: 10px; padding: 10px 14px;
}
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); margin: 24px 0 12px; font-weight: 700; }

/* Barra móvil: oculta en escritorio, visible solo en teléfono (ver @media abajo) */
.mobilebar { display: none; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { padding: 20px 16px 70px; max-width: none; }
  .print-doc { padding: 24px 20px; }
  .print-doc .kv { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr 1fr; gap: 12px; }
  .card { padding: 16px; }
  .stat { font-size: 30px; }
  /* Barra superior móvil con efecto cristal: reemplaza al sidebar oculto */
  .mobilebar {
    display: flex; align-items: center; gap: 8px;
    position: sticky; top: 0; z-index: 40;
    background: rgba(255, 255, 255, .72); color: var(--ink);
    -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--line-soft);
    padding: 10px 12px;
  }
  .app { flex-direction: column; }

  /* Panel: encabezado apilado y botones a todo ancho en móvil */
  .page-head { flex-direction: column; align-items: stretch; margin-bottom: 18px; }
  .page-head h2 { font-size: 24px; }
  .page-head .toolbar { display: grid; grid-template-columns: 1fr; width: 100%; }
  .page-head .toolbar .btn { justify-content: center; width: 100%; }

  /* ---- Optimización móvil del portal del cliente ---- */
  .check-item { flex-wrap: wrap; gap: 10px; padding: 16px; }
  .check-item .check-dot { width: 26px; height: 26px; }
  .check-item .grow { flex: 1 1 calc(100% - 40px); min-width: 0; }
  .check-item .t { font-size: 15px; }
  .check-item > div:last-child { flex: 1 1 100%; min-width: 0; }
  .check-item > div:last-child .btn { width: 100%; justify-content: center; min-height: 48px; font-size: 15px; }
  /* Botones con tamaño táctil cómodo */
  .btn { min-height: 46px; }
  .btn-sm { min-height: 42px; }
  /* Pestañas estilo control segmentado: 4 caben a 360px; scroll si el texto es largo */
  .portal-wrap .tabs { display: flex; width: 100%; }
  .portal-wrap .tabs button { flex: 1 1 0; justify-content: center; padding: 9px 2px; font-size: 12px; gap: 5px; min-width: 0; }
  .portal-wrap .tabs button .ic { width: 15px; height: 15px; }
  /* Inputs a 16px para que iOS no haga zoom al enfocarlos */
  .field input, .field select, .field textarea { font-size: 16px; padding: 13px 14px; }
  .searchbox input { font-size: 16px !important; }
  /* Encabezado y tarjetas del portal */
  .portal-top { padding: 18px; }
  .portal-top .t { font-size: 20px; }
  .portal-card { padding: 20px 18px; }
  .section-title { font-size: 13px; margin: 20px 0 10px; }
  /* PIN: tamaño que cabe bien en pantallas angostas */
  .pin-input { font-size: 26px !important; letter-spacing: .35em; }
  /* Login más compacto */
  .login-card { padding: 32px 26px; }
  .login-card h1 { font-size: 26px; }
  /* Quiz: botones sí/no apilados si no caben */
  .yesno { flex-wrap: wrap; }
  .yesno button { flex: 1 1 140px; }
  .modal { padding: 22px 20px; }
}
.mb-brand { font-weight: 700; letter-spacing: -0.02em; font-size: 17px; color: var(--ink); flex: none; }
.mb-nav { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; }
.mb-nav a {
  display: flex; align-items: center; gap: 6px; color: var(--ink-soft);
  text-decoration: none; padding: 8px 12px; border-radius: 8px; font-size: 14px; font-weight: 600;
  white-space: nowrap; flex: none;
}
.mb-nav a.active { background: var(--accent-soft); color: var(--accent); }
.mb-lang { flex: none; }

/* Selector de idioma ES | EN — control segmentado */
.lang-toggle {
  display: inline-flex; align-items: center; vertical-align: middle;
  border-radius: 980px; padding: 3px;
  background: linear-gradient(180deg, rgba(255,255,255,.8), rgba(245,245,247,.55));
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  backdrop-filter: blur(18px) saturate(180%);
  border: 1px solid rgba(210,210,215,.85);
  box-shadow: inset 0 1px 1px rgba(255,255,255,.9), 0 2px 8px rgba(0,0,0,.07);
}
.lang-toggle button {
  background: none; border: 0; padding: 7px 18px; cursor: pointer;
  font-weight: 700; font-size: 12.5px; letter-spacing: .05em;
  color: var(--ink-soft); border-radius: 980px; font-family: inherit;
  line-height: 1; transition: all .15s;
}
.lang-toggle button.on {
  background: linear-gradient(180deg, rgba(10,132,255,.95), rgba(0,113,227,.88));
  color: #fff;
  box-shadow: inset 0 1px 1px rgba(255,255,255,.45), 0 2px 10px rgba(0,113,227,.4);
  text-shadow: 0 1px 2px rgba(0,40,90,.3);
}
.portal-topbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.copy-ok { margin-top: 10px; }
.link-box.selectable { user-select: all; cursor: text; }

/* Checklist "qué me debe cada cliente" */
.gap-row { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.gap-row:last-child { border-bottom: 0; padding-bottom: 0; }
.gap-row:first-of-type { padding-top: 4px; }
.gap-link { color: var(--accent); text-decoration: none; font-weight: 600; }
.gap-link:hover { text-decoration: underline; }
.gap-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.gap-tags .badge { white-space: nowrap; }

/* Portal del cliente: subsecciones en paralelo (desktop), apiladas en teléfono */
.doc-cols { display: grid; grid-template-columns: 1fr; gap: 4px 24px; }
.doc-col { min-width: 0; }
@media (min-width: 1024px) {
  .doc-cols { grid-template-columns: 1fr 1fr; align-items: start; }
}

/* Asistente del cuestionario: una pregunta por pantalla */
.quiz-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 4px 12px; min-width: 0; }
.quiz-top > * { min-width: 0; }
.quiz-count { font-weight: 700; color: var(--accent); white-space: nowrap; }
.quiz-qnum { font-weight: 600; color: var(--ink-soft); overflow-wrap: break-word; }
.quiz-bar { height: 8px; background: #e3e3e8; border-radius: 99px; margin-top: 10px; overflow: hidden; }
.quiz-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #4da3ff); border-radius: 99px; transition: width .25s; }
.quiz-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.quiz-nav .btn { min-height: 50px; flex: 1; }
/* Asistente guiado (primer acceso): X arriba a la derecha, nav de documentos */
.guided-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.guided-nav { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.guided-nav .btn { flex: 1 1 0; min-height: 50px; white-space: normal; }
/* Botones grandes Sí/No (p. ej. pregunta de viaje DS-160) */
.lang-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
.lang-btn {
  min-height: 56px; border-radius: 10px; font-size: 17px; font-weight: 700;
  border: 2px solid transparent; cursor: pointer; color: #fff;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.quiz-card { text-align: left; }
.quiz-q { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; margin: 6px 0 18px; overflow-wrap: break-word; }

/* Hijos en el cuestionario: una línea por hijo — nombre | fecha nac. | edad | quitar */
#q-children { display: flex; flex-direction: column; gap: 10px; }
.child-row { display: grid; grid-template-columns: 1fr 136px 86px 44px; gap: 8px; align-items: stretch; }
.child-row input {
  width: 100%; box-sizing: border-box; font-size: 16px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); min-height: 50px;
}
.child-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.child-age {
  display: flex; align-items: center; justify-content: center; text-align: center;
  background: var(--accent-soft); border: 1px solid var(--line); border-radius: 10px;
  font-weight: 700; font-size: 14px; color: var(--ink-soft); min-height: 50px; padding: 0 6px;
}
.child-del {
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  font-size: 22px; line-height: 1; color: var(--ink-faint); cursor: pointer; min-height: 50px;
}
.child-del:hover { color: #c00; border-color: #c00; }
.q-add-child { margin-top: 10px; display: inline-flex; align-items: center; gap: 8px; }
.q-add-child .ic { width: 18px; height: 18px; }
@media (max-width: 560px) {
  .child-row { grid-template-columns: 1fr 44px; grid-template-areas: "name del" "dob age"; }
  .child-name { grid-area: name; }
  .child-dob { grid-area: dob; }
  .child-age { grid-area: age; }
  .child-del { grid-area: del; }
}

/* Botón copiar en ficha: feedback visual */
.kv-copy.copied { border-color: #22a355; color: #22a355; }

/* ============ Optimización smartphone ============ */
@media (max-width: 640px) {
  /* Tablas → tarjetas apiladas */
  .table-wrap { overflow-x: visible; border: none; background: transparent; box-shadow: none; }
  .table-wrap table, .table-wrap thead, .table-wrap tbody, .table-wrap tr, .table-wrap td {
    display: block; width: 100%;
  }
  .table-wrap thead { display: none; }
  .table-wrap tr {
    background: var(--panel); border: 1px solid var(--line-soft);
    border-radius: var(--radius-lg); margin-bottom: 10px; padding: 6px 0;
  }
  .table-wrap td { border: none; padding: 6px 14px; }
  .table-wrap td:last-child { text-align: right; }

  /* Formularios a una columna */
  .form-grid { grid-template-columns: 1fr; }

  /* Toolbar: botones envuelven */
  .toolbar { flex-wrap: wrap; gap: 8px; }
  .toolbar .btn { flex: 1 1 auto; min-height: 44px; justify-content: center; }

  /* Modal a pantalla completa */
  .modal-box { width: 100%; max-width: 100%; margin: 0; border-radius: 0; max-height: 100dvh; }

  /* Ficha: filas más compactas */
  .rowline { flex-wrap: wrap; gap: 4px; }
  .rowline b { word-break: break-word; }

  /* Quiz nav: botones grandes táctiles */
  .quiz-nav { gap: 8px; }
  .quiz-nav .btn { min-height: 52px; font-size: 16px; }

  /* Yes/No lado a lado */
  .yesno { grid-template-columns: 1fr 1fr; gap: 8px; }

  /* Dashboard cards a una columna */
  .cards { grid-template-columns: 1fr; }

  /* Encabezados más compactos */
  h2 { font-size: 20px; }
  .page-head { flex-direction: column; align-items: stretch; gap: 10px; }
}

/* Indicador de extracción en curso */
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(0,0,0,.25); border-top-color: currentColor; border-radius: 50%; animation: spinrot .7s linear infinite; vertical-align: -2px; }
@keyframes spinrot { to { transform: rotate(360deg); } }

/* Badges de casos en la ficha del cliente (estilo WellTAX) */
.case-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.case-badge { cursor: pointer; border: 1px solid transparent; font-size: 13px; padding: 5px 12px; }
.case-badge:hover { filter: brightness(0.94); }

/* Documentos en tarjetas uniformes (como WellTAX) */
.doc-items { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .doc-items { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .doc-items { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1500px) { .doc-items { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.doc-items .check-item {
  flex-direction: column; align-items: stretch; gap: 10px;
  height: 100%; margin-bottom: 0; padding: 14px;
}
.doc-items .check-item .check-dot { margin-top: 0; }
.doc-items .check-item .t { font-weight: 700; }
.doc-items .file-row .file-name {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.doc-items .check-act { padding-top: 6px; margin-top: auto; }
.doc-items .check-act .btn { width: 100%; justify-content: center; }

/* Tarjeta de documento: punto de estado arriba a la derecha */
.doc-items .check-item { position: relative; padding-top: 14px; }
.doc-items .check-item .check-dot {
  position: absolute; top: 12px; right: 12px;
  width: 24px; height: 24px; margin: 0;
}
.doc-items .check-item .grow { padding-right: 28px; }

/* Filas de datos con botón Copiar (como WellTAX) */
.kv-row { padding: 10px 0; border-top: 1px solid #eef1f4; }
.kv-row:first-of-type { border-top: 0; }
.kv-label { display: block; font-size: 12px; margin-bottom: 4px; }
.kv-val { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.kv-val b { word-break: break-word; }
.kv-copy { flex-shrink: 0; }
.kv-copy.copied { border-color: #22a355; color: #22a355; }
