/* dAIvid — estilos base. Paleta tomada de brunayasociados.cl */
:root {
  --bg: #F5F6F8; --card: #FFFFFF; --ink: #1A2131; --muted: #5A6478; --line: #DCE0E7;
  --head: #1B263B; --head-ink: #FFFFFF; --head-muted: #A9B3C6; --head-line: #1B263B; --search: #2A3753;
  --gold: #A8844F; --gold-ink: #121A2A; --nav-active: #1B263B;
  --red-bg: #FBE9E7; --red-ink: #A3261B; --amber-bg: #FDF1DC; --amber-ink: #7A4A00;
  --green-bg: #E3F4EA; --green-ink: #17703F; --navy-bg: #E8ECF3; --navy-ink: #1B263B;
  --radius: 14px; --font: Figtree, "Segoe UI", system-ui, -apple-system, sans-serif;
  --display: "Cormorant Garamond", Garamond, Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121A2A; --card: #1B263B; --ink: #E8ECF3; --muted: #A9B3C6; --line: #2A3753;
    --head: #121A2A; --head-ink: #E8ECF3; --head-muted: #A9B3C6; --head-line: #2A3753; --search: #1B263B;
    --gold: #C9A46C; --gold-ink: #121A2A; --nav-active: #C9A46C;
    --red-bg: #3A1F24; --red-ink: #F4A9A0; --amber-bg: #3A2E1A; --amber-ink: #F2C27A;
    --green-bg: #173326; --green-ink: #7FD6A2; --navy-bg: #2A3753; --navy-ink: #E8ECF3;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121A2A; --card: #1B263B; --ink: #E8ECF3; --muted: #A9B3C6; --line: #2A3753;
  --head: #121A2A; --head-ink: #E8ECF3; --head-muted: #A9B3C6; --head-line: #2A3753; --search: #1B263B;
  --gold: #C9A46C; --gold-ink: #121A2A; --nav-active: #C9A46C;
  --red-bg: #3A1F24; --red-ink: #F4A9A0; --amber-bg: #3A2E1A; --amber-ink: #F2C27A;
  --green-bg: #173326; --green-ink: #7FD6A2; --navy-bg: #2A3753; --navy-ink: #E8ECF3;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 16px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--gold); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--card); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }

.shell { max-width: 640px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
.main { flex: 1; padding: 16px 16px 112px; display: flex; flex-direction: column; gap: 18px; outline: none; }

/* Encabezado */
.header { background: var(--head); color: var(--head-ink); padding: calc(16px + env(safe-area-inset-top)) 20px 16px; display: flex; flex-direction: column; gap: 12px; border-bottom: 1px solid var(--head-line); }
.header-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.header-sub { font-size: 13px; color: var(--head-muted); }
.header-title { font-family: var(--display); font-size: 28px; font-weight: 600; line-height: 1.1; margin: 0; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--gold); background: transparent; color: var(--head-ink); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.search { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 14px; border-radius: 12px; background: var(--search); }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--head-muted); stroke-width: 2; stroke-linecap: round; flex-shrink: 0; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--head-ink); font-size: 16px; }
.search input::placeholder { color: var(--head-muted); }

/* Chips y filtros */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; min-height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--head-muted); background: transparent; color: var(--head-ink); font-size: 14px; font-weight: 600; }
.chip[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.filtro { flex-shrink: 0; min-height: 36px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 14px; font-weight: 500; }
.filtro[aria-pressed="true"] { background: var(--navy-bg); border-color: var(--navy-bg); color: var(--navy-ink); font-weight: 600; }

/* Bloques */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 2px; text-decoration: none; }
.tile b { font-size: 22px; line-height: 1.2; }
.tile span { font-size: 12px; font-weight: 500; }
.t-red { background: var(--red-bg); color: var(--red-ink); }
.t-amber { background: var(--amber-bg); color: var(--amber-ink); }
.t-green { background: var(--green-bg); color: var(--green-ink); }
.t-navy { background: var(--navy-bg); color: var(--navy-ink); }
.section { display: flex; flex-direction: column; gap: 8px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; }
.section-head h2 { margin: 0; font-size: 17px; }
.section-head a { font-size: 14px; font-weight: 600; text-decoration: none; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.list { display: flex; flex-direction: column; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.strong { font-weight: 600; }
.muted { color: var(--muted); font-size: 13px; }
.amount { font-weight: 700; white-space: nowrap; }
.plazo { display: flex; gap: 12px; align-items: center; padding: 12px; }
.badge-dias { width: 58px; flex-shrink: 0; border-radius: 10px; padding: 8px 0; text-align: center; display: flex; flex-direction: column; }
.badge-dias b { font-size: 17px; }
.badge-dias span { font-size: 11px; font-weight: 600; }
.pill { display: inline-block; font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 12px; }
.tag { flex-shrink: 0; font-size: 12px; font-weight: 600; padding: 4px 8px; border-radius: 6px; background: var(--navy-bg); color: var(--navy-ink); }
.causa { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.causa-foot { display: flex; justify-content: space-between; align-items: center; padding-top: 8px; border-top: 1px solid var(--line); }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; }
.demo-note { font-size: 12px; color: var(--muted); text-align: center; }

/* Asistente */
.chat { display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 82%; padding: 12px 14px; font-size: 15px; border-radius: 16px; }
.msg-bot { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-top-left-radius: 4px; }
.msg-yo { align-self: flex-end; background: var(--head); color: var(--head-ink); border-top-right-radius: 4px; }
.composer { position: fixed; left: 0; right: 0; bottom: calc(76px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; max-width: 640px; margin: 0 auto; }
.composer form { display: flex; gap: 8px; align-items: center; }
.composer input { flex: 1; min-width: 0; height: 48px; padding: 0 16px; border-radius: 24px; border: 1px solid var(--line); background: var(--bg); }
.composer .chip { border-color: var(--line); color: var(--ink); font-weight: 500; }
.round-btn { width: 48px; height: 48px; border-radius: 24px; border: 0; background: var(--gold); color: var(--gold-ink); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.round-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.main.con-composer { padding-bottom: 260px; }

/* Barra inferior */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; max-width: 640px; margin: 0 auto; height: calc(76px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center; background: var(--card); border-top: 1px solid var(--line); z-index: 10; }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); text-decoration: none; min-height: 56px; justify-content: center; }
.tabbar a svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a[aria-current="page"] { color: var(--nav-active); font-weight: 600; }
.fab-slot { display: flex; justify-content: center; }
.fab { width: 58px; height: 58px; margin-top: -28px; border-radius: 29px; border: 0; background: var(--gold); color: var(--gold-ink); display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(18, 26, 42, .25); }
.fab svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }

/* Hoja inferior y avisos */
.sheet { border: 0; border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); width: 100%; max-width: 640px; margin: auto auto 0; background: var(--card); color: var(--ink); }
.sheet::backdrop { background: rgba(18, 26, 42, .5); }
.sheet h2 { margin: 0 0 12px; font-size: 18px; }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.sheet-actions button { min-height: 52px; text-align: left; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-weight: 600; }
.btn-ghost { width: 100%; min-height: 48px; border: 0; background: transparent; color: var(--muted); font-weight: 600; }
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--head); color: var(--head-ink); padding: 12px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); z-index: 30; }
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
