/* ============================================================
   TechMarket Discovery (TMD) — Hoja de estilos
   Diseño iPad-first, premium, con modo claro/oscuro.
   ============================================================ */

:root {
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-3: #06b6d4;
  --grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #06b6d4 130%);
  --grad-soft: linear-gradient(135deg, rgba(79,70,229,.12), rgba(124,58,237,.10));

  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --info: #0ea5e9;

  --bg: #eef1f7;
  --bg-2: #f7f8fc;
  --surface: #ffffff;
  --surface-2: #f4f6fb;
  --text: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;
  --border: #e4e8f0;
  --border-strong: #d4dae6;
  --ring: rgba(79, 70, 229, .35);

  --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.08);
  --shadow: 0 4px 12px rgba(15,23,42,.07), 0 2px 4px rgba(15,23,42,.05);
  --shadow-lg: 0 18px 40px rgba(15,23,42,.16), 0 4px 12px rgba(15,23,42,.08);

  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --r-xl: 28px;

  --sidebar-w: 268px;
  --topbar-h: 62px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", sans-serif;
}

[data-theme="dark"] {
  --bg: #070b18;
  --bg-2: #0b1124;
  --surface: #111a31;
  --surface-2: #0d1529;
  --text: #e7ecf6;
  --muted: #94a3b8;
  --faint: #64748b;
  --border: #1e2a44;
  --border-strong: #2a3a5c;
  --ring: rgba(124, 58, 237, .45);
  --grad-soft: linear-gradient(135deg, rgba(79,70,229,.22), rgba(6,182,212,.12));
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 6px 18px rgba(0,0,0,.45);
  --shadow-lg: 0 24px 50px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); text-decoration: none; }
h1,h2,h3,h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }
::selection { background: rgba(124,58,237,.25); }

/* ---------- Boot splash ---------- */
.boot { position: fixed; inset: 0; display: grid; place-content: center; gap: 22px; justify-items: center; background: var(--bg); z-index: 50; }
.boot-logo { font-weight: 800; font-size: 40px; letter-spacing: 2px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.boot-spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Layout principal
   ============================================================ */
.app { min-height: 100%; }
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding-top: var(--safe-top);
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 18px 14px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  background: var(--grad); color: #fff; display: grid; place-content: center;
  font-weight: 800; font-size: 16px; letter-spacing: .5px; box-shadow: var(--shadow-sm);
}
.brand-name { font-weight: 800; font-size: 16px; line-height: 1.05; }
.brand-name span { display: block; font-weight: 500; font-size: 11px; color: var(--muted); letter-spacing: .3px; }

.proj-switch {
  margin: 4px 14px 8px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--r-sm); background: var(--surface-2); display: flex; align-items: center; gap: 10px;
  text-align: left; width: calc(100% - 28px); transition: border-color .15s, background .15s;
}
.proj-switch:hover { border-color: var(--border-strong); }
.proj-switch .ps-info { min-width: 0; flex: 1; }
.proj-switch .ps-label { font-size: 10px; text-transform: uppercase; letter-spacing: .8px; color: var(--faint); }
.proj-switch .ps-name { font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-switch .ps-chevron { color: var(--faint); flex: none; }

.nav { flex: 1; overflow-y: auto; padding: 6px 10px 16px; }
.nav::-webkit-scrollbar { width: 8px; }
.nav::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
.nav-section { margin: 14px 8px 6px; font-size: 10.5px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--faint); }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px; margin: 2px 0; border-radius: var(--r-sm);
  color: var(--muted); font-weight: 600; font-size: 14px; border: none; background: none;
  transition: background .14s, color .14s; position: relative;
}
.nav-item .ni-icon { width: 22px; display: grid; place-items: center; flex: none; }
.nav-item .ni-step { margin-left: auto; font-size: 11px; color: var(--faint); font-weight: 700; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--grad-soft); color: var(--brand); }
.nav-item.active .ni-icon { color: var(--brand); }
[data-theme="dark"] .nav-item.active { color: #c7d2fe; }
.nav-item .ni-dot { width: 7px; height: 7px; border-radius: 50%; margin-left: auto; }
.nav-item .ni-dot.done { background: var(--ok); }
.nav-item .ni-dot.partial { background: var(--warn); }

.sidebar-foot { padding: 12px 14px calc(12px + var(--safe-bottom)); border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: center; }

/* ---------- Topbar ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
  padding-top: var(--safe-top);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar .hamburger { display: none; }
.topbar h1 { font-size: 18px; font-weight: 800; }
.topbar .crumb { color: var(--faint); font-size: 13px; font-weight: 600; }
.topbar .spacer { flex: 1; }
.save-pill { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.save-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.save-pill.saving .dot { background: var(--warn); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.content { padding: 24px clamp(16px, 4vw, 40px) 80px; max-width: 1180px; width: 100%; margin: 0 auto; }
.view-head { margin-bottom: 22px; }
.view-head .eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .5px; color: var(--brand); text-transform: uppercase; }
.view-head h2 { font-size: clamp(22px, 3.4vw, 30px); margin: 4px 0 6px; }
.view-head p { color: var(--muted); max-width: 70ch; line-height: 1.5; }

/* ============================================================
   Componentes
   ============================================================ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-sm); padding: 20px;
}
.card.pad-lg { padding: 26px; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.card-head h3 { font-size: 16px; }
.card-head .ch-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--grad-soft); color: var(--brand); flex: none; }
.card-head .spacer { flex: 1; }
.card-sub { color: var(--muted); font-size: 13px; margin-top: -8px; margin-bottom: 14px; line-height: 1.5; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 700; font-size: 14px;
  transition: transform .08s ease, box-shadow .15s, background .15s, border-color .15s;
  min-height: 44px; white-space: nowrap;
}
.btn:hover { border-color: var(--brand); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn.primary { background: var(--grad); color: #fff; border: none; box-shadow: 0 6px 18px rgba(79,70,229,.32); }
.btn.primary:hover { box-shadow: 0 10px 26px rgba(79,70,229,.42); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.subtle { background: var(--surface-2); border-color: transparent; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.btn.sm { padding: 7px 13px; min-height: 36px; font-size: 13px; }
.btn.icon { padding: 0; width: 44px; height: 44px; }
.btn.icon.sm { width: 36px; height: 36px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; pointer-events: none; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* Forms */
.field { margin-bottom: 16px; }
.field > label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 7px; color: var(--text); }
.field .hint { font-size: 12px; color: var(--faint); margin-top: 6px; line-height: 1.4; }
.input, .select, .textarea {
  width: 100%; padding: 12px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s; min-height: 46px;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--ring); background: var(--surface); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* Segmented / yes-no */
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 4px; gap: 4px; }
.segmented button { border: none; background: none; padding: 9px 16px; border-radius: 999px; font-weight: 700; font-size: 13px; color: var(--muted); min-height: 40px; transition: .12s; }
.segmented button.on { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }
.segmented.yn button.on.yes { background: var(--ok); color: #fff; }
.segmented.yn button.on.no { background: var(--danger); color: #fff; }

/* Chips / tags */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.chip.brand { background: var(--grad-soft); color: var(--brand); border-color: transparent; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 7px; font-size: 11.5px; font-weight: 700; }
.tag.alto, .tag.alta, .tag.high { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.tag.medio, .tag.media, .tag.med { background: color-mix(in srgb, var(--warn) 18%, transparent); color: #b45309; }
.tag.bajo, .tag.baja, .tag.low { background: color-mix(in srgb, var(--ok) 16%, transparent); color: #047857; }
[data-theme="dark"] .tag.medio, [data-theme="dark"] .tag.media { color: #fbbf24; }
[data-theme="dark"] .tag.bajo, [data-theme="dark"] .tag.baja { color: #34d399; }
.tag.neutral { background: var(--surface-2); color: var(--muted); }
.tag.info { background: color-mix(in srgb, var(--info) 15%, transparent); color: var(--info); }

/* Stat tiles */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 18px; position: relative; overflow: hidden; }
.stat .s-ico { position: absolute; right: 14px; top: 14px; opacity: .16; }
.stat .s-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat .s-value { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; }
.stat .s-sub { font-size: 12px; color: var(--faint); margin-top: 2px; }
.stat.accent { background: var(--grad); color: #fff; border: none; }
.stat.accent .s-label, .stat.accent .s-sub { color: rgba(255,255,255,.85); }

/* Progress */
.progress { height: 9px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.progress > i { display: block; height: 100%; background: var(--grad); border-radius: 999px; transition: width .5s cubic-bezier(.2,.8,.2,1); }
.progress.thin { height: 6px; }

/* Lists / tables */
.list { display: flex; flex-direction: column; gap: 10px; }
.row-item {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); transition: border-color .15s, box-shadow .15s;
}
.row-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.row-item .ri-body { flex: 1; min-width: 0; }
.row-item .ri-title { font-weight: 700; font-size: 14.5px; }
.row-item .ri-sub { color: var(--muted); font-size: 13px; margin-top: 3px; line-height: 1.45; }
.row-item .ri-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; font-weight: 700; color: var(--faint); }

table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--faint); padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.tbl td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: top; }
table.tbl tr:last-child td { border-bottom: none; }

/* Empty state */
.empty { text-align: center; padding: 46px 24px; color: var(--muted); }
.empty .e-ico { width: 64px; height: 64px; border-radius: 18px; background: var(--grad-soft); color: var(--brand); display: grid; place-items: center; margin: 0 auto 16px; }
.empty h3 { font-size: 17px; color: var(--text); margin-bottom: 6px; }
.empty p { max-width: 42ch; margin: 0 auto 18px; line-height: 1.5; }

/* Stepper banner (next action) */
.next-step { display: flex; align-items: center; gap: 16px; padding: 16px 20px; border-radius: var(--r); background: var(--grad); color: #fff; box-shadow: 0 12px 30px rgba(79,70,229,.3); }
.next-step .ns-ico { width: 44px; height: 44px; border-radius: 12px; background: rgba(255,255,255,.18); display: grid; place-items: center; flex: none; }
.next-step .ns-body { flex: 1; }
.next-step .ns-label { font-size: 12px; opacity: .85; font-weight: 600; }
.next-step .ns-title { font-weight: 800; font-size: 16px; }
.next-step .btn { background: #fff; color: var(--brand); border: none; }

/* Maturity / area cards */
.area-card { display: flex; flex-direction: column; gap: 12px; cursor: pointer; }
.area-card .ac-top { display: flex; align-items: center; gap: 12px; }
.area-card .ac-emoji { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; background: var(--surface-2); flex: none; }
.area-card .ac-name { font-weight: 700; font-size: 15px; }
.area-card .ac-meta { font-size: 12px; color: var(--muted); }
.ring { --p: 0; width: 46px; height: 46px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 12px; font-weight: 800;
  background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--surface-2) 0); }
.ring > span { width: 36px; height: 36px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(7,11,24,.55); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; z-index: 60; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(620px, 100%); max-height: 88vh; overflow-y: auto; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); border: 1px solid var(--border); animation: pop .18s cubic-bezier(.2,.9,.3,1); }
@keyframes pop { from { transform: translateY(12px) scale(.98); opacity: 0; } }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 20px 22px 0; }
.modal-head h3 { font-size: 18px; flex: 1; }
.modal-body { padding: 18px 22px; }
.modal-foot { padding: 14px 22px 20px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--border); margin-top: 6px; }
.modal.wide { width: min(920px, 100%); }

/* Toast */
.toast-root { position: fixed; left: 50%; bottom: calc(20px + var(--safe-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 10px; z-index: 80; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; background: #0f172a; color: #fff; padding: 12px 18px; border-radius: 999px; box-shadow: var(--shadow-lg); font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 10px; animation: pop .2s ease; }
[data-theme="dark"] .toast { background: #e7ecf6; color: #0f172a; }
.toast.ok .t-dot { color: var(--ok); }
.toast.err .t-dot { color: var(--danger); }

/* Misc helpers */
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.flex { display: flex; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Sortable handle */
.drag-handle { cursor: grab; color: var(--faint); touch-action: none; }
.dragging { opacity: .5; }

/* ============================================================
   Procesos (flujo)
   ============================================================ */
.flow { display: flex; flex-direction: column; align-items: center; gap: 0; padding: 8px 0; }
.flow-node { width: min(320px, 100%); background: var(--surface); border: 2px solid var(--brand); border-radius: var(--r); padding: 14px 16px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow-sm); position: relative; }
.flow-node .fn-num { width: 26px; height: 26px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 12px; flex: none; }
.flow-node .fn-label { flex: 1; font-weight: 600; }
.flow-arrow { width: 2px; height: 26px; background: var(--border-strong); position: relative; }
.flow-arrow::after { content: ""; position: absolute; bottom: -2px; left: 50%; transform: translateX(-50%); border: 5px solid transparent; border-top-color: var(--border-strong); }

/* ============================================================
   Roadmap timeline
   ============================================================ */
.roadmap { display: flex; flex-direction: column; gap: 18px; }
.phase { border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.phase-head { display: flex; align-items: center; gap: 14px; padding: 18px 20px; color: #fff; }
.phase-head .ph-num { width: 38px; height: 38px; border-radius: 12px; background: rgba(255,255,255,.2); display: grid; place-items: center; font-weight: 800; }
.phase-head .ph-title { font-size: 17px; font-weight: 800; }
.phase-head .ph-sub { font-size: 12.5px; opacity: .9; }
.phase-body { padding: 18px 20px; }
.phase.f1 .phase-head { background: linear-gradient(135deg,#0ea5e9,#06b6d4); }
.phase.f2 .phase-head { background: linear-gradient(135deg,#6366f1,#4f46e5); }
.phase.f3 .phase-head { background: linear-gradient(135deg,#7c3aed,#a855f7); }
.phase.f4 .phase-head { background: linear-gradient(135deg,#db2777,#f43f5e); }
.deliverable { display: flex; gap: 10px; padding: 7px 0; align-items: flex-start; font-size: 14px; }
.deliverable .dv-check { color: var(--ok); flex: none; margin-top: 1px; }

/* ============================================================
   Documentos generados
   ============================================================ */
.doc-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.doc-tab { padding: 9px 15px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-weight: 700; font-size: 13px; color: var(--muted); min-height: 40px; }
.doc-tab.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.doc-paper {
  background: #fff; color: #1e293b; border-radius: var(--r); border: 1px solid var(--border);
  padding: clamp(24px, 5vw, 56px); box-shadow: var(--shadow); line-height: 1.6;
}
.doc-paper h1 { font-size: 26px; margin-bottom: 4px; color: #0f172a; }
.doc-paper h2 { font-size: 18px; margin: 28px 0 10px; padding-bottom: 6px; border-bottom: 2px solid #e2e8f0; color: var(--brand); }
.doc-paper h3 { font-size: 15px; margin: 16px 0 6px; color: #0f172a; }
.doc-paper p, .doc-paper li { font-size: 14px; color: #334155; }
.doc-paper ul { margin: 8px 0; padding-left: 22px; }
.doc-paper table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px; }
.doc-paper th, .doc-paper td { border: 1px solid #e2e8f0; padding: 9px 11px; text-align: left; }
.doc-paper th { background: #f1f5f9; }
.doc-paper .doc-brand { display: flex; align-items: center; gap: 14px; padding-bottom: 18px; border-bottom: 3px solid var(--brand); margin-bottom: 8px; }
.doc-paper .doc-brand .db-mark { width: 48px; height: 48px; border-radius: 12px; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 800; }
.doc-paper .doc-meta { color: #64748b; font-size: 12.5px; }
/* Las tablas se desplazan solas en pantallas angostas en vez de
   empujar la página entera de lado. */
.doc-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 12px 0; }
.doc-scroll > table { margin: 0; }
.doc-paper .doc-total { font-size: 20px; font-weight: 800; color: var(--brand); }
.doc-paper .tcell-r { text-align: right; }
.doc-watermark { color: #94a3b8; font-size: 11px; font-style: italic; }

/* ============================================================
   Observaciones ancladas (bandeja del consultor y portal)
   ============================================================ */
.ann-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }

.obs-figure { position: relative; display: block; border-radius: var(--r); overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.obs-figure > img { display: block; width: 100%; height: auto; }

.obs-thumb {
  position: relative; width: 76px; height: 58px; flex: none; border-radius: 9px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center;
}
.obs-thumb > img { width: 100%; height: 100%; object-fit: cover; }
.obs-thumb.glyph { color: var(--brand); background: var(--grad-soft); border-color: transparent; }

.obs-quote { border-left: 3px solid var(--brand); background: var(--surface-2); border-radius: 0 var(--r-sm) var(--r-sm) 0; padding: 12px 16px; }
.obs-quote p { font-size: 14px; line-height: 1.6; font-style: italic; color: var(--text); }

.obs-msg { border-radius: var(--r); padding: 12px 15px; margin-top: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.obs-msg.me { background: var(--grad-soft); border-color: transparent; }
.obs-msg .om-who { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
.obs-msg p { font-size: 14px; line-height: 1.6; white-space: pre-wrap; }

/* ============================================================
   Responsive — iPad y móvil
   ============================================================ */
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w);
    transform: translateX(-104%); transition: transform .25s cubic-bezier(.2,.8,.2,1);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .scrim { position: fixed; inset: 0; background: rgba(7,11,24,.5); z-index: 25; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .scrim.show { opacity: 1; pointer-events: auto; }
  .topbar .hamburger { display: inline-grid; }
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .field-row { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .content { padding: 18px 16px 90px; }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
}

/* ============================================================
   Impresión (exportar a PDF de documentos)
   ============================================================ */
@media print {
  .sidebar, .topbar, .scrim, .doc-tabs, .no-print { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; max-width: none; }
  .doc-paper { box-shadow: none; border: none; border-radius: 0; padding: 0; }
  body { background: #fff; }
  .doc-paper h2 { break-after: avoid; }
  .phase, .row-item, table { break-inside: avoid; }
}
