:root {
    --ink: #0b0b0f;
    --muted: #6b6272;
    --paper: #f7f3fb;
    --surface: #ffffff;
    --line: #e7def2;
    --line-strong: #d2c3e4;
    --primary: #a634ed;
    --primary-strong: #7418b5;
    --primary-soft: #f2e6fc;
    --accent: #edab32;
    --danger: #9b2c2c;
    --danger-soft: #f8e7e4;
    --ok: #2f6f4f;
    --ok-soft: #e5f1e9;
    --warn: #8a5a12;
    --warn-soft: #fbf0da;
    --info: #5b3f7a;
    --info-soft: #f0e8f8;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(84, 28, 128, .08);
    --font-body: "Open Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --font-display: "Poppins", "Open Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
    padding-bottom: 88px;
}

h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; }
h1 { font-size: clamp(1.7rem, 5vw, 2.3rem); font-weight: 600; letter-spacing: -.015em; }
h2 { font-size: 1.2rem; font-weight: 600; }
p { margin: .4rem 0; }
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-strong); }
small { display: block; font-size: .8rem; color: var(--muted); margin-top: .2rem; }
strong { font-weight: 650; }

:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--primary);
    color: #fff;
    padding: .8rem 1.2rem;
    z-index: 100;
}
.skip-link:focus { left: .5rem; top: .5rem; }

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0);
    white-space: nowrap; border: 0;
}

.muted { color: var(--muted); }
.eyebrow {
    text-transform: uppercase;
    letter-spacing: .12em;
    font-size: .72rem;
    font-weight: 700;
    color: var(--muted);
    margin: 0 0 .3rem;
}

/* Header */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar__inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: .7rem 1rem;
    display: flex;
    align-items: center;
    gap: .8rem;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    text-decoration: none;
    color: var(--ink);
    min-width: 0;
}
.brand__mark {
    width: 38px; height: 38px;
    display: grid; place-items: center;
    background: var(--primary);
    color: #fff;
    border-radius: 11px;
    font-weight: 700;
    font-size: .8rem;
    letter-spacing: .05em;
    flex: none;
}
.company-switch { margin-left: auto; }
.company-switch select {
    max-width: 190px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    border-radius: 9px;
    padding: .45rem .6rem;
    font: inherit;
    font-size: .82rem;
}
.topbar__logout { margin-left: auto; }
.company-switch + .topbar__logout { margin-left: 0; }

.modules {
    max-width: 1080px;
    margin: 0 auto;
    display: flex;
    gap: .25rem;
    padding: 0 .6rem;
    overflow-x: auto;
    scrollbar-width: none;
}
.modules::-webkit-scrollbar { display: none; }
.modules__tab {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .65rem .8rem;
    font-size: .86rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--muted);
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    min-height: 44px;
}
.modules__tab.is-active { color: var(--primary); border-color: var(--primary); }
.modules__tab.is-locked { color: #8a8690; }
.modules__tab.is-locked:hover { color: var(--ink); }
.modules__lock { display: inline-flex; }

/* Layout */
.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 1.2rem 1rem 2rem;
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: .9rem;
    margin-bottom: 1.1rem;
}
.page-head__actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.page-head h1 { margin-bottom: .15rem; }

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}
.panel__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .7rem; align-items: center; }
.panel__title { font-size: 1.05rem; margin-bottom: .7rem; }
.panel__tools { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.panel__tools select { max-width: 240px; }

/* Alerts */
.alert {
    border-radius: 10px;
    padding: .8rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    font-size: .92rem;
}
.alert ul { margin: .35rem 0 0; padding-left: 1.1rem; }
.alert--success { background: var(--ok-soft); border-color: #cbe1d5; color: #1f523a; }
.alert--error { background: var(--danger-soft); border-color: #ecc9c4; color: #7a2222; }

/* Forms */
.form { display: flex; flex-direction: column; gap: .2rem; }
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .85rem; min-width: 0; }
.field--grow { flex: 1 1 220px; }
.field > label { font-size: .9rem; font-weight: 650; color: #3a3342; }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"],
input[type="url"], input[type="number"], input[type="search"], input[type="file"],
input[type="color"], select, textarea {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: .95rem;
    padding: .65rem .7rem;
    min-height: 50px;
}
textarea { resize: vertical; min-height: 84px; }
input[type="color"] { padding: .25rem; height: 46px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .9rem; margin: .2rem 0 .9rem; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 0 .9rem; }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: 0 .9rem; }
.form__actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .5rem; }

/* Buttons */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-height: 44px;
    padding: .65rem 1rem;
    border-radius: 10px;
    border: 1px solid transparent;
    font: inherit;
    font-size: .92rem;
    font-weight: 650;
    text-decoration: none;
    cursor: pointer;
    color: var(--ink);
    background: transparent;
}
.button--primary { background: var(--primary); color: #fff; }
.button--primary:hover { background: var(--primary-strong); color: #fff; }
.button--secondary { background: var(--primary-soft); color: var(--primary-strong); border-color: #dcc8ef; }
.button--secondary:hover { background: #e7d6f7; }
.button--ghost { border-color: var(--line-strong); color: var(--ink); background: #fff; }
.button--ghost:hover { border-color: var(--primary); }
.button--small { min-height: 38px; padding: .35rem .7rem; font-size: .82rem; }
.button--block { width: 100%; }
.button:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.link-button {
    border: 0; background: none; padding: 0; margin: 0;
    color: var(--primary); font: inherit; font-size: .85rem;
    text-decoration: underline; cursor: pointer;
}

/* Dashboard */
.stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .6rem;
    margin-bottom: 1rem;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: .8rem .9rem;
    display: flex;
    flex-direction: column;
}
.stat strong { font-family: var(--font-display); font-size: 1.7rem; line-height: 1; color: var(--primary); }
.stat span { font-size: .76rem; color: var(--muted); margin-top: .3rem; }

.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin-bottom: 0; }
.filters > .button { margin-bottom: 0; }

.list { display: flex; flex-direction: column; gap: .55rem; }
.budget-row {
    display: flex;
    gap: .8rem;
    justify-content: space-between;
    align-items: flex-start;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: .85rem .95rem;
    text-decoration: none;
    color: var(--ink);
    transition: border-color .15s ease, transform .15s ease;
}
.budget-row:hover { border-color: var(--primary); color: var(--ink); transform: translateY(-1px); }
.budget-row__main { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.budget-row__ref { font-size: .76rem; font-weight: 700; letter-spacing: .04em; color: var(--muted); }
.budget-row__main strong { font-size: .98rem; }
.budget-row__main .muted { font-size: .8rem; }
.budget-row__side { display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; flex: none; }
.budget-row__total { font-size: .98rem; white-space: nowrap; }

.badge {
    display: inline-flex;
    align-items: center;
    padding: .18rem .5rem;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .02em;
    white-space: nowrap;
}
.badge--neutral { background: #efecf5; color: #5a5262; }
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--bad { background: var(--danger-soft); color: var(--danger); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--info { background: var(--info-soft); color: var(--info); }

.quick-links { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-top: 1rem; }
.quick-link {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: .8rem .9rem;
    text-decoration: none;
    color: var(--ink);
    display: flex;
    flex-direction: column;
}
.quick-link strong { font-family: var(--font-display); font-size: 1.3rem; color: var(--primary); }
.quick-link span { font-size: .78rem; color: var(--muted); }

.empty {
    background: var(--surface);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    padding: 1.6rem 1rem;
    text-align: center;
}
.empty p { color: var(--muted); }

/* Lines editor */
.assistant { border-color: #e4d3f5; background: linear-gradient(180deg, #fcf9ff, #fff); }
.assistant__head { display: flex; justify-content: space-between; gap: .8rem; flex-wrap: wrap; align-items: flex-start; }
.assistant__head .badge { align-self: flex-start; }
.assistant__actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.assistant__status { min-height: 1.3rem; font-size: .85rem; color: var(--muted); margin-top: .5rem; }
.questions { margin: .4rem 0 0; padding-left: 1.2rem; color: var(--warn); font-size: .88rem; }
.questions:empty { display: none; }

.lines { display: flex; flex-direction: column; gap: .65rem; }
.lines__head { display: none; }
.line {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: .7rem;
    background: #fbf8fe;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .4rem;
}
.line .field { margin-bottom: 0; }
.line .field:first-child { grid-column: 1 / -1; }
.remove-line { justify-self: start; color: var(--danger); border-color: #ecc9c4; grid-column: 1 / -1; }

.sticky-actions {
    display: flex;
    gap: .6rem;
    justify-content: flex-end;
    padding: .6rem 0;
    border-top: 1px solid var(--line);
}

/* Preview */
.compare {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: .6rem;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}
.compare strong { display: block; font-family: var(--font-display); font-size: 1.6rem; }
.compare__new { color: var(--primary); }
.compare__arrow { color: var(--muted); font-size: 1.3rem; }
.compare__detail { grid-column: 1 / -1; display: flex; gap: .8rem; flex-wrap: wrap; font-size: .78rem; color: var(--muted); }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; min-width: 620px; font-size: .88rem; }
.table th {
    text-align: left;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    border-bottom: 1px solid var(--line-strong);
    padding: .55rem .5rem;
    white-space: nowrap;
}
.table td { border-bottom: 1px solid var(--line); padding: .65rem .5rem; vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table__actions { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; }
.table__actions form { margin: 0; }

.dl { display: grid; grid-template-columns: auto 1fr; gap: .3rem .8rem; margin: 0; font-size: .88rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

.totals { margin: 1rem 0 0 auto; width: min(100%, 340px); }
.totals > div { display: flex; justify-content: space-between; padding: .3rem 0; font-size: .9rem; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; }
.totals__grand { border-top: 2px solid var(--primary); margin-top: .3rem; padding-top: .5rem !important; font-size: 1.1rem !important; }
.totals__grand dt, .totals__grand dd { color: var(--primary); font-weight: 700; }

/* Share */
.share__actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.share textarea { background: #fbf8fe; }

.status-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.status-actions form { margin: 0; }

/* Upsell */
.upsell {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.6rem 1.2rem;
    text-align: center;
    max-width: 620px;
}
.upsell__icon { color: var(--primary); margin-bottom: .6rem; }
.upsell h2 { margin: .5rem 0; }
.upsell p { color: var(--muted); }
.upsell form { margin: 1rem 0 .6rem; }

.logo-preview {
    max-height: 80px;
    max-width: 220px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: .4rem;
    background: #fff;
    margin-bottom: .4rem;
}

/* Selector de plantilla */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: .7rem;
    margin-top: .8rem;
}
.template-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: .2rem;
    border: 2px solid var(--line);
    border-radius: 12px;
    padding: .65rem;
    background: #fff;
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.template-card:hover { border-color: var(--line-strong); }
.template-card:has(input:checked) {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.template-card:has(input:focus-visible) {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}
.template-card input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}
.template-card strong { font-size: .86rem; }
.template-card small { color: var(--muted); font-size: .72rem; line-height: 1.35; }
.template-card__preview {
    display: block;
    position: relative;
    height: 96px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    overflow: hidden;
    padding: 9px;
    margin-bottom: .35rem;
}
.template-card__preview span { display: block; background: #e9e1f2; border-radius: 2px; }
.tpl-top { width: 42%; height: 9px; margin-bottom: 7px; }
.tpl-title { width: 72%; height: 6px; margin-bottom: 4px; }
.tpl-rule { width: 100%; height: 2px; margin: 7px 0; background: var(--primary) !important; }
.tpl-row { width: 100%; height: 5px; margin-bottom: 4px; }
.tpl-row--short { width: 68%; }
.tpl-total { width: 36%; height: 12px; margin: 8px 0 0 auto; background: var(--primary) !important; }
.template-card--estudio .tpl-top { width: 100%; height: 28px; background: var(--primary) !important; }
.template-card--estudio .tpl-rule { background: var(--accent) !important; }
.template-card--editorial .template-card__preview { border-left: 4px solid var(--primary); }
.template-card--editorial .tpl-title { width: 58%; height: 9px; background: #cfc2dd; }
.template-card--editorial .tpl-rule { height: 1px; background: var(--line-strong) !important; }
.template-card--editorial .tpl-total { background: var(--primary-soft) !important; }

/* Pagination */
.pagination { display: flex; gap: .6rem; align-items: center; justify-content: center; margin: 1.2rem 0; font-size: .85rem; }
.pagination__link { padding: .45rem .7rem; border: 1px solid var(--line-strong); border-radius: 8px; text-decoration: none; }
.pagination__link.is-disabled { color: #a9aeab; border-color: var(--line); }
.pagination__info { color: var(--muted); }

/* Bottom nav */
.bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: rgba(255, 255, 255, .97);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
    backdrop-filter: blur(8px);
}
.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .15rem;
    padding: .5rem .2rem .45rem;
    font-size: .68rem;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    min-height: 56px;
}
.bottom-nav a.is-active { color: var(--primary); }
.bottom-nav svg {
    width: 22px; height: 22px;
    fill: none; stroke: currentColor;
    stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}

/* Chat por voz */
.chat-page {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    align-items: start;
}
.chat-main {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    min-height: 62vh;
    overflow: hidden;
}
.orb-wrap {
    display: grid;
    justify-items: center;
    gap: .5rem;
    padding: 1.1rem 1rem .8rem;
    background:
        radial-gradient(420px 180px at 50% 0%, #f2e7fc 0%, transparent 70%),
        #fcf9ff;
    border-bottom: 1px solid var(--line);
}
.orb-label {
    margin: 0;
    min-height: 1.2rem;
    font-size: .82rem;
    color: var(--muted);
    text-align: center;
}
.voice-orb {
    position: relative;
    width: 104px;
    height: 104px;
    display: grid;
    place-items: center;
}
.voice-orb__core,
.voice-orb__ring,
.voice-orb__glow {
    position: absolute;
    border-radius: 50%;
}
.voice-orb__core {
    width: 58px;
    height: 58px;
    background:
        radial-gradient(circle at 30% 25%, #ffffff 0%, #d9a6ff 18%, #7b2bb5 55%, var(--primary) 100%);
    box-shadow:
        0 0 22px rgba(166, 52, 237, .35),
        inset -6px -8px 16px rgba(0, 0, 0, .25),
        inset 6px 8px 18px rgba(255, 255, 255, .35);
    animation: orbBreathe 4.5s ease-in-out infinite;
}
.voice-orb__glow {
    width: 96px;
    height: 96px;
    background: radial-gradient(circle, rgba(201, 162, 39, .35), rgba(166, 52, 237, .08) 55%, transparent 70%);
    filter: blur(4px);
    animation: orbGlow 4.5s ease-in-out infinite;
}
.voice-orb__ring {
    width: 82px;
    height: 82px;
    border: 1px solid rgba(166, 52, 237, .16);
    animation: orbRing 4.5s ease-in-out infinite;
}
.voice-orb__ring--two {
    width: 100px;
    height: 100px;
    border-color: rgba(166, 52, 237, .08);
    animation-delay: .4s;
}
[data-state="listening"] .voice-orb__core {
    animation: orbListen .85s ease-in-out infinite;
    background:
        radial-gradient(circle at 30% 25%, #ffffff 0%, #ffd977 15%, var(--accent) 50%, #8a5a12 100%);
    box-shadow: 0 0 34px rgba(201, 162, 39, .55), inset -6px -8px 16px rgba(0, 0, 0, .2);
}
[data-state="listening"] .voice-orb__ring {
    animation: orbPulse 1.2s ease-out infinite;
    border-color: rgba(201, 162, 39, .5);
}
[data-state="listening"] .voice-orb__glow {
    background: radial-gradient(circle, rgba(201, 162, 39, .55), transparent 65%);
    animation: orbGlow 1.1s ease-in-out infinite;
}
[data-state="thinking"] .voice-orb__core {
    animation: orbSpin 1.6s linear infinite;
    background: conic-gradient(from 0deg, var(--primary), #d9a6ff, var(--accent), var(--primary));
}
[data-state="thinking"] .voice-orb__ring {
    animation: orbPulse 1.6s ease-out infinite;
}
[data-state="error"] .voice-orb__core {
    background: radial-gradient(circle at 30% 25%, #ffffff 0%, #e6a09a 15%, #9b2c2c 60%, #5c1717 100%);
}

@keyframes orbBreathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}
@keyframes orbGlow {
    0%, 100% { opacity: .55; transform: scale(1); }
    50% { opacity: .9; transform: scale(1.1); }
}
@keyframes orbRing {
    0%, 100% { transform: scale(1); opacity: .8; }
    50% { transform: scale(1.1); opacity: .35; }
}
@keyframes orbListen {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.22); }
}
@keyframes orbPulse {
    0% { transform: scale(.9); opacity: .9; }
    100% { transform: scale(1.35); opacity: 0; }
}
@keyframes orbSpin {
    to { transform: rotate(360deg); }
}

.chat-log {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: .55rem;
    padding: 1rem;
    overflow-y: auto;
    max-height: 46vh;
    min-height: 180px;
    scroll-behavior: smooth;
}
.bubble {
    max-width: 88%;
    padding: .65rem .8rem;
    border-radius: 14px;
    font-size: .92rem;
    line-height: 1.45;
}
.bubble p { margin: 0; }
.bubble--assistant {
    align-self: flex-start;
    background: #f4eefa;
    border-bottom-left-radius: 4px;
}
.bubble--user {
    align-self: flex-end;
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-composer {
    padding: .7rem;
    background: rgba(255, 255, 255, .97);
    border-top: 1px solid var(--line);
}
.chat-composer__box {
    display: flex;
    align-items: flex-end;
    gap: .45rem;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    padding: .35rem .35rem .35rem .7rem;
    background: #fff;
}
.chat-composer__box:focus-within { border-color: var(--primary); }
.chat-composer textarea {
    flex: 1;
    border: 0;
    padding: .55rem 0;
    min-height: 44px;
    max-height: 140px;
    resize: none;
    background: transparent;
    overflow-y: auto;
}
.chat-composer textarea:focus { outline: none; }
.mic-button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid #dcc8ef;
    background: var(--primary-soft);
    color: var(--primary-strong);
    display: grid;
    place-items: center;
    cursor: pointer;
    flex: none;
}
.mic-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.mic-button.is-recording {
    background: var(--accent);
    border-color: #b08a18;
    color: #2c2105;
    animation: micPulse 1.2s ease-in-out infinite;
}
@keyframes micPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(201, 162, 39, .45); }
    50% { box-shadow: 0 0 0 8px rgba(201, 162, 39, 0); }
}

.chat-side { min-width: 0; }
.chat-side__inner {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}
.chat-side__head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.chat-side__head h2 { font-size: 1.05rem; }
.chat-customer { font-size: .86rem; color: var(--muted); margin: .35rem 0 .7rem; }
.chat-side__hint { font-size: .74rem; margin-top: .6rem; }

.chat-lines { display: flex; flex-direction: column; gap: .45rem; }
.chat-line {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .1rem .5rem;
    padding: .5rem .6rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fbf8fe;
    font-size: .84rem;
}
.chat-line__head { grid-column: 1 / -1; display: flex; align-items: center; gap: .4rem; justify-content: space-between; }
.chat-line__detail { color: var(--muted); font-size: .78rem; }
.chat-line__total { text-align: right; white-space: nowrap; }

.chat-totals { margin: .8rem 0 0; }
.chat-totals > div { display: flex; justify-content: space-between; padding: .2rem 0; font-size: .85rem; }
.chat-totals dt { color: var(--muted); }
.chat-totals dd { margin: 0; }

.chat-alerts { display: flex; flex-direction: column; gap: .3rem; margin-top: .7rem; }
.chat-alert {
    margin: 0;
    padding: .45rem .6rem;
    border-radius: 8px;
    background: var(--warn-soft);
    color: var(--warn);
    font-size: .8rem;
}
.chat-pending { display: flex; flex-direction: column; gap: .5rem; margin-top: .7rem; }
.decision-card {
    border: 1px solid #e6d9b8;
    background: #fffdf6;
    border-radius: 10px;
    padding: .65rem;
    font-size: .84rem;
}
.decision-card p { margin: 0 0 .5rem; }
.decision-card__actions { display: flex; gap: .4rem; flex-wrap: wrap; }

@media (min-width: 900px) {
    .chat-page { grid-template-columns: minmax(0, 1.45fr) minmax(300px, .9fr); }
    .chat-main { min-height: 70vh; }
    .chat-side__inner { position: sticky; top: 92px; }
    .chat-log { max-height: 52vh; }
}

@media (prefers-reduced-motion: reduce) {
    .voice-orb__core,
    .voice-orb__ring,
    .voice-orb__glow,
    .mic-button.is-recording {
        animation: none !important;
    }
    .chat-log { scroll-behavior: auto; }
}

.has-chat { padding-bottom: 0; }
.has-chat .bottom-nav { display: none; }
.has-chat .chat-composer { padding-bottom: calc(.7rem + env(safe-area-inset-bottom)); }

/* Fin chat por voz */
.guest {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.2rem;
    background:
        radial-gradient(1000px 500px at 10% -10%, var(--primary-soft) 0%, transparent 60%),
        var(--paper);
    padding-bottom: 1.2rem;
}
.guest__card {
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 1.4rem;
    box-shadow: var(--shadow);
}
.brand--guest { margin-bottom: 1.3rem; }
.guest__title { font-size: 1.5rem; margin-bottom: .2rem; }
.guest__lead { color: var(--muted); font-size: .9rem; margin-bottom: 1rem; }
.guest__foot { margin-top: 1rem; font-size: .88rem; color: var(--muted); text-align: center; }

@media (min-width: 680px) {
    .grid-2 { grid-template-columns: 1fr 1fr; }
    .grid-3 { grid-template-columns: 1fr 1fr 1fr; }
    .stats { grid-template-columns: repeat(4, 1fr); }
    .line { grid-template-columns: 2fr .8fr 1fr .8fr .7fr auto; align-items: end; }
    .line .field:first-child { grid-column: auto; }
    .line .field > label { font-size: .72rem; }
    .remove-line { align-self: end; grid-column: auto; }
    .container { padding: 1.8rem 1.2rem 3rem; }
    .panel { padding: 1.3rem; }
    .compare { grid-template-columns: 1fr auto 1fr auto; }
    .compare__detail { grid-column: auto; flex-direction: column; align-items: flex-end; gap: .1rem; }
}

@media (min-width: 900px) {
    body { padding-bottom: 0; }
    .bottom-nav { display: none; }
    .sticky-actions { padding-top: .6rem; }
    .topbar__inner { padding: .8rem 1.2rem; }
    .modules { padding: 0 1.2rem; }
}

/* Inicio móvil y componentes de tarjetas */
:root {
    --ink: #0d1b3e;
    --muted: #666d83;
    --paper: #f3f4fa;
    --line: #e5e7f0;
    --line-strong: #d7dae7;
    --primary: #a634ed;
    --primary-strong: #7d23b5;
    --primary-soft: #f2e7fc;
    --accent: #ff7917;
    --danger: #a33c38;
    --danger-soft: #f9e8e6;
    --ok: #36745c;
    --ok-soft: #e3f2e9;
    --warn: #8a5a12;
    --warn-soft: #fbf0da;
    --info: #415c96;
    --info-soft: #e9eef9;
    --radius: 22px;
    --shadow: 0 12px 32px rgba(17, 25, 54, .06);
}

body { padding-bottom: 100px; }
.container { padding: 1.2rem 1rem 2rem; }
.topbar { background: rgba(255,255,255,.94); backdrop-filter: blur(12px); }
.brand__mark { border-radius: 50%; }
.panel, .stat, .budget-row, .quick-link, .empty, .table-wrap {
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.panel { border-color: transparent; }
.button { border-radius: 999px; min-height: 48px; }
.button--small { min-height: 38px; }
input, select, textarea { border-radius: 14px; }

.home-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: .2rem 0 1.2rem;
}
.home-heading p { margin: 0 0 .2rem; }
.home-heading h1 { font-size: clamp(1.8rem, 7vw, 2.5rem); font-weight: 700; }
.home-heading h1 { font-size: clamp(2rem, 7.8vw, 2.7rem); letter-spacing: -.035em; }
.home-avatar {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    flex: none;
    border-radius: 50%;
    background: var(--ink);
    color: #fff;
    text-decoration: none;
    font: 700 1rem var(--font-display);
}
.home-voice-card {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .8rem;
    overflow: hidden;
    min-height: 210px;
    padding: 1.5rem;
    border-radius: 28px;
    background: var(--ink);
    color: #fff;
    box-shadow: 0 18px 38px rgba(17, 25, 54, .16);
}
.home-voice-card::after {
    content: "";
    position: absolute;
    width: 160px;
    height: 160px;
    right: -82px;
    top: 50%;
    border: 18px solid rgba(237, 171, 50, .14);
    border-radius: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}
.home-voice-card__copy { position: relative; z-index: 1; max-width: 64%; }
.home-voice-card__copy { max-width: 68%; }
.home-voice-card .eyebrow { color: var(--accent); }
.home-voice-card h2 { font-size: clamp(1.35rem, 5vw, 1.8rem); }
.home-voice-card p:not(.eyebrow) { color: #d6daea; }
.home-voice-card__copy > a { display: inline-flex; align-items: center; gap: .5rem; color: #fff; font-weight: 700; text-decoration: none; }
.home-voice-card__copy > a svg { width: 20px; height: 20px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.home-voice-card__mic {
    z-index: 1;
    display: grid;
    place-items: center;
    width: clamp(82px, 24vw, 112px);
    height: clamp(82px, 24vw, 112px);
    flex: none;
    border-radius: 50%;
    background: var(--accent);
    color: var(--ink);
    box-shadow: 0 0 0 14px rgba(237,171,50,.13);
}
.home-voice-card__mic svg { width: 38px; height: 38px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.home-section { margin: 1.6rem 0; }
.home-section > h2, .home-section__heading h2 { margin: 0; font-size: 1.2rem; }
.home-section__heading { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: .8rem; }
.home-section__heading a { color: var(--primary-strong); font-weight: 700; text-decoration: none; }
.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; margin-top: .7rem; }
.stat { min-height: 102px; padding: .9rem; border: 1px solid rgba(255,255,255,.9); }
.stat strong { color: var(--ink); font-size: clamp(1.35rem, 6vw, 1.8rem); overflow-wrap: anywhere; }
.stat span { font-size: .8rem; }
.home-section[aria-labelledby="home-stats-title"] .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.home-section[aria-labelledby="home-stats-title"] .stat { min-height: 92px; }
.home-budget-section > .filters { padding: 0; }
.home-budget-section .field > label { font-weight: 700; }
.home-budget-section .filters .button { align-self: end; }
.home-budget-list { display: flex; flex-direction: column; gap: .7rem; }
.home-budget-list .budget-row__ref { display: none; }
.budget-row { border: 1px solid rgba(255,255,255,.9); padding: 1rem; }
.budget-row:hover { border-color: var(--line-strong); }
.budget-row__main { gap: .2rem; }
.budget-row__ref { order: 3; }
.budget-row__side { align-items: flex-end; }
.budget-row__total { color: var(--ink); }
.quick-links { margin-top: 1rem; }
.quick-link { border: 1px solid rgba(255,255,255,.9); }

.bottom-nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    border-top-color: rgba(220,222,232,.9);
    box-shadow: 0 -8px 28px rgba(17,25,54,.06);
    padding: .28rem .35rem env(safe-area-inset-bottom);
}
.bottom-nav a { min-width: 0; padding-inline: .05rem; font-size: .62rem; }
.bottom-nav a.is-active { color: var(--ink); font-weight: 700; }
.bottom-nav svg { width: 25px; height: 25px; }
.bottom-nav .bottom-nav__voice {
    align-self: start;
    justify-self: center;
    width: 64px;
    height: 64px;
    min-height: 64px;
    margin-top: -1.35rem;
    border: 4px solid var(--paper);
    border-radius: 50%;
    background: var(--accent);
    color: var(--ink);
    box-shadow: 0 5px 18px rgba(237,171,50,.35);
}
.bottom-nav__voice svg { width: 29px; height: 29px; }
.bottom-nav { min-height: 76px; }
.bottom-nav a { font-size: .68rem; }
.bottom-nav a:not(.bottom-nav__voice) { gap: .28rem; padding-top: .55rem; }
.bottom-nav a:not(.bottom-nav__voice) { align-self: stretch; justify-content: center; padding-block: .25rem; }
.bottom-nav a.is-active { color: var(--ink); }
.bottom-nav { align-items: center; }
.pdf-preview { border: 1px solid #d7d9e2; border-radius: 18px; padding: 16px; background: #e7e9ef; }
.pdf-preview__canvas { position: relative; flex: none; margin: 0 auto; background: #fff; box-shadow: 0 8px 28px rgba(15,27,62,.18); }
.pdf-preview iframe { position: absolute; inset: 0 auto auto 0; display: block; width: 794px; height: 1123px; transform-origin: top left; border: 0; background: #fff; }
.pdf-preview__fallback { text-align: center; margin: .7rem 0 0; }
.pdf-preview__hint { margin: 0 0 .5rem; font-size: .84rem; }

.has-chat { background: var(--ink); color: #fff; }
.has-chat .topbar { background: var(--ink); border-color: rgba(255,255,255,.12); }
.has-chat .brand { color: #fff; }
.has-chat .topbar .button { background: transparent; color: #fff; border-color: rgba(255,255,255,.24); }
.has-chat .container { min-height: calc(100dvh - 62px); max-width: 760px; padding-top: 1rem; }
.has-chat .chat-head { color: #fff; align-items: center; }
.has-chat .chat-head .muted { color: #ccd2e7; }
.has-chat .chat-main { min-height: min(66vh, 650px); border: 0; border-radius: 26px; background: transparent; box-shadow: none; }
.has-chat .orb-wrap { min-height: 250px; align-content: center; border: 0; border-radius: 26px; background: radial-gradient(ellipse at center, rgba(255,121,23,.12), transparent 70%); }
.has-chat .orb-label { color: #fff; font-size: 1rem; font-weight: 700; }
.has-chat .voice-orb { width: 150px; height: 150px; }
.has-chat .voice-orb__core { width: 84px; height: 84px; background: radial-gradient(circle at 30% 25%, #fff 0%, #ffd8b8 22%, #ff8a32 58%, #c94d05 100%); }
.has-chat .voice-orb__ring { width: 116px; height: 116px; border-color: rgba(255,121,23,.45); }
.has-chat .voice-orb__ring--two { width: 144px; height: 144px; }
.has-chat .chat-log { max-height: 32vh; border-radius: 20px; background: rgba(255,255,255,.06); }
.has-chat .bubble--assistant { background: #202d53; color: #fff; }
.has-chat .bubble--user { background: var(--primary); }
.has-chat .chat-composer { border: 1px solid rgba(255,255,255,.12); border-radius: 20px; background: #192344; }
.has-chat .chat-side__inner { color: var(--ink); border: 0; }
.has-chat .chat-line { border: 0; background: var(--paper); }
.has-chat .chat-composer__box { border-color: rgba(255,255,255,.18); }
.has-chat .assistant__status { color: #f5d58f; }
.has-chat .voice-orb__glow { background: radial-gradient(circle, rgba(255,121,23,.35), transparent 70%); }
.has-chat [data-state="thinking"] .voice-orb__core { background: conic-gradient(from 0deg, #ff7917, #ffd2ad, #0d1b3e, #ff7917); }
.has-chat .chat-head h1 { font-size: clamp(1.8rem, 7vw, 2.5rem); }
.has-chat .orb-wrap { min-height: min(37vh, 300px); }
.has-chat .chat-composer { position: sticky; bottom: 0; z-index: 4; }
.has-chat .chat-side { margin-bottom: 1rem; }

/* Contraste y jerarquía de acción en el flujo de uso diario. */
.button--primary { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.button--primary:hover { background: #f36c0a; border-color: #f36c0a; color: var(--ink); }
.button--secondary { background: var(--primary-soft); border-color: #dfc7f2; color: #64208d; }
.button--secondary:hover { background: #e9d5fa; color: #501876; }
.has-chat .mic-button.is-recording { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.budget-row .badge--neutral { background: #eceef8; color: #3e4862; }
.budget-row .badge--ok { background: #e1f3e9; color: #286448; }
.budget-row .badge--bad { background: #f9e7e5; color: #923b36; }
.has-company .account-settings-nav a:hover { border-color: var(--primary); }
.has-company .form > .panel:nth-of-type(3) { border-top: 4px solid var(--primary); }
.has-company .form > .panel:nth-of-type(5) { border-top: 4px solid var(--accent); }
.has-company input[type="text"], .has-company input[type="email"], .has-company input[type="tel"], .has-company input[type="url"], .has-company input[type="number"], .has-company select, .has-company textarea { min-height: 54px; padding: .8rem .9rem; border-radius: 16px; font-size: 1rem; }
.has-company .field > label { font-size: .95rem; color: var(--ink); }

@media (min-width: 680px) {
    .home-voice-card { min-height: 250px; padding: 2rem; }
    .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .home-heading { margin-top: .6rem; }
}
@media (max-width: 420px) {
    .home-voice-card { min-height: 190px; padding: 1.2rem; }
    .home-voice-card__copy { max-width: 65%; }
    .home-voice-card__mic { width: 82px; height: 82px; }
}
@media (min-width: 900px) {
    body { padding-bottom: 0; }
    .container { padding-top: 1.8rem; }
    .home-voice-card { max-width: 760px; }
    .has-chat { background: var(--ink); }
    .has-chat .container { padding-top: 1.3rem; }
}
@media (prefers-reduced-motion: reduce) {
    .home-voice-card__mic, .bottom-nav__voice { scroll-behavior: auto; }
}

.budget-detail-head { align-items: center; }
.budget-detail-head h1 { font-size: clamp(1.9rem, 7vw, 2.7rem); font-weight: 700; }
.budget-detail-head .eyebrow { color: var(--muted); }
.has-budget .totals {
    width: min(100%, 520px);
    margin-top: 1.2rem;
    padding: 1.2rem;
    border-radius: 22px;
    background: var(--ink);
    color: #fff;
}
.has-budget .totals dt { color: #d6daea; }
.has-budget .totals__grand { border-color: rgba(255,255,255,.22); }
.has-budget .totals__grand dt, .has-budget .totals__grand dd { color: var(--accent); font-size: 1.25rem; }
.has-budget .share { display: grid; gap: .75rem; }
.has-budget .share textarea { background: var(--paper); }
.has-budget .status-actions { gap: .65rem; }
.has-budget .history-title { margin-top: 0; }
.has-budget-list .home-heading { margin-bottom: .8rem; }
.has-budget-list .home-budget-section { margin-top: .3rem; }
.has-budget-list .home-budget-section > .filters { margin-bottom: .8rem; }
.account-profile { display: flex; align-items: center; gap: .9rem; margin: .25rem 0 1rem; }
.account-profile__avatar { width: 70px; height: 70px; display: grid; place-items: center; flex: none; border-radius: 50%; background: var(--ink); color: #fff; font: 700 1.3rem var(--font-display); }
.account-profile__identity { flex: 1; min-width: 0; }
.account-profile__identity .eyebrow, .account-profile__identity p { margin: 0; }
.account-profile__identity h1 { font-size: clamp(1.4rem, 6vw, 2rem); overflow-wrap: anywhere; }
.account-settings-nav { display: grid; gap: 0; margin-bottom: 1rem; overflow: hidden; border: 1px solid rgba(255,255,255,.9); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.account-settings-nav a { display: flex; align-items: center; justify-content: space-between; min-height: 66px; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 1rem; font-weight: 600; text-decoration: none; }
.account-settings-nav a:last-child { border-bottom: 0; }
.account-settings-nav a::after { content: ""; width: 9px; height: 9px; flex: none; margin-left: .8rem; border-top: 2px solid var(--muted); border-right: 2px solid var(--muted); transform: rotate(45deg); }
.has-company .panel { scroll-margin-top: 80px; }
.has-company .account-settings-nav { scroll-margin-top: 80px; }
@media (min-width: 680px) { .account-settings-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .account-profile { flex-wrap: wrap; } .account-profile .button { width: 100%; } }
.has-catalog .table-wrap { overflow: visible; background: transparent; border: 0; box-shadow: none; }
.has-catalog .table { border-collapse: separate; border-spacing: 0 .65rem; min-width: 0; }
.has-catalog .table tbody tr { background: var(--surface); box-shadow: var(--shadow); }
.has-catalog .table tbody td:first-child strong { font-size: 1.02rem; }
.has-catalog .table tbody td[data-label="Precio"] { font-size: 1.03rem; font-weight: 700; color: var(--ink); }
.has-catalog .table td:first-child { border-radius: 18px 0 0 18px; }
.has-catalog .table td:last-child { border-radius: 0 18px 18px 0; }
.has-manual-budget .manual-budget-head { align-items: flex-start; }
.has-manual-budget .form.panel { display: grid; gap: 1rem; padding: 1.2rem; }
.has-manual-budget .field > label { font-size: .95rem; color: var(--ink); }
.has-manual-budget input, .has-manual-budget select, .has-manual-budget textarea { min-height: 54px; padding: .8rem 1rem; border-radius: 16px; }
.has-manual-budget textarea { min-height: 110px; }
.has-manual-budget .form__actions { position: sticky; bottom: 94px; z-index: 5; padding: .7rem; border-radius: 20px; background: rgba(244,245,250,.96); backdrop-filter: blur(12px); }
.has-manual-budget .form__actions .button--primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.has-manual-budget .form__actions .button--primary:hover { background: #1d2d59; border-color: #1d2d59; color: #fff; }
.guest { background: var(--ink); color: #fff; }
.guest__card { max-width: 480px; padding: 1.1rem; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.guest .brand { color: #fff; }
.guest__lead, .guest__foot { color: #d2d6e4; }
.guest .guest__title { font-size: clamp(2rem, 8vw, 3rem); font-weight: 700; }
.guest__foot a { color: var(--accent); }
.guest .field > label { color: #f4f5fa; }
.guest input:not([type="checkbox"]) { min-height: 54px; border-color: rgba(255,255,255,.55); border-radius: 16px; }
.guest .button--primary { background: var(--accent); border-color: var(--accent); color: var(--ink); font-weight: 700; }
.guest .button--primary:hover { background: #f4bf58; border-color: #f4bf58; }

@media (max-width: 679px) {
    .has-chat .topbar { display: none; }
    .has-chat .container { padding-top: .8rem; }
    .has-budget-list .filters { gap: .35rem .55rem; }
    .has-budget-list .filters .field--grow { flex: 1 1 100%; }
    .has-budget-list .filters .field:not(.field--grow) { flex: 1 1 auto; }
    .has-budget-list .filters .field > label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
    .has-budget-list .filters .field input { min-height: 58px; border-radius: 20px; padding-inline: 1.1rem; font-size: 1rem; }
    .has-budget-list .filters .field select { min-height: 48px; border-radius: 999px; }
    .has-budget-list .filters .button { min-height: 48px; }
    .has-budget .budget-lines { overflow: visible; border: 0; background: transparent; box-shadow: none; }
    .has-budget .budget-lines .table, .has-budget .budget-lines tbody { display: block; width: 100%; min-width: 0; }
    .has-budget .budget-lines thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
    .has-budget .budget-lines tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .15rem .8rem; margin-bottom: .7rem; padding: .9rem; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
    .has-budget .budget-lines tbody td { display: flex; flex-direction: column; gap: .15rem; min-width: 0; border: 0; padding: .35rem 0; overflow-wrap: anywhere; }
    .has-budget .budget-lines tbody td::before { content: attr(data-label); color: var(--muted); font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
    .has-budget .budget-lines tbody td:first-child { grid-column: 1 / -1; }
    .has-budget .budget-lines tbody td:last-child { color: var(--ink); font-weight: 700; }
    .has-budget .budget-history { overflow-x: auto; }
    .has-budget .page-head__actions { width: 100%; }
    .has-budget .page-head__actions .button { flex: 1 1 calc(50% - .4rem); font-size: .9rem; }
    .has-budget .budget-detail-head { gap: .65rem; }
    .has-budget .budget-detail-head h1 { font-size: clamp(1.8rem, 7vw, 2.35rem); }
    .budget-row__main strong { font-size: 1.14rem; }
    .budget-row__main .muted { font-size: .88rem; }
    .budget-row__total { font-size: 1.05rem; }
    .has-catalog .table tbody td:first-child strong { font-size: 1.05rem; }
    .has-catalog .table tbody td { font-size: .9rem; }
    .has-catalog .table tbody td::before { font-size: .68rem; }
    .bottom-nav a:not(.bottom-nav__voice) { font-size: .74rem; }
    .has-catalog .table, .has-catalog .table tbody { display: block; width: 100%; }
    .has-catalog .table thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
    .has-catalog .table tbody tr { display: grid; grid-template-columns: 1fr auto; gap: .1rem .8rem; margin-bottom: .7rem; padding: .75rem 1rem; border-radius: 18px; }
    .has-catalog .table tbody td { display: flex; flex-direction: column; gap: .1rem; border: 0; padding: .35rem 0; }
    .has-catalog .table tbody td::before { content: attr(data-label); color: var(--muted); font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
    .has-catalog .table tbody td:first-child { grid-column: 1 / -1; }
    .has-catalog .table tbody td:last-child { grid-column: 1 / -1; align-items: flex-end; }
    .has-manual-budget .form__actions { bottom: 84px; }
}

/* Tratto: identidad visual y componentes de uso diario. */
:root {
    --ink: #0d1b3e;
    --muted: #626b82;
    --paper: #f3f4fa;
    --surface: #fff;
    --line: #e4e7f0;
    --line-strong: #d4d9e6;
    --primary: #0d1b3e;
    --primary-strong: #1b2d59;
    --primary-soft: #e9edf7;
    --accent: #ff7917;
    --shadow: 0 12px 32px rgba(17, 25, 54, .06);
}

body { background: var(--paper); color: var(--ink); }
a { color: var(--primary); }
.brand { gap: .48rem; }
.brand__mark { width: 46px; height: 34px; display: block; padding: 0; overflow: visible; border-radius: 0; background: transparent; color: var(--ink); }
.brand__wordmark { margin-right: .32rem; color: var(--ink); font: 700 1.35rem/1 var(--font-display); letter-spacing: -.065em; }
.guest .brand__mark, .guest .brand__wordmark { color: #fff; }
.topbar { background: rgba(255,255,255,.96); border-color: var(--line); }
.button--primary { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.button--primary:hover { background: #f36c0a; border-color: #f36c0a; color: var(--ink); }
.button--secondary { background: var(--primary-soft); border-color: var(--line-strong); color: var(--ink); }
.bottom-nav a.is-active { color: var(--ink); }
.bottom-nav .bottom-nav__voice { background: var(--accent); color: var(--ink); box-shadow: 0 5px 18px rgba(255,121,23,.3); }
.bottom-nav { border-color: var(--line); background: rgba(255,255,255,.97); }
.home-voice-card { background: var(--ink); }
.has-manual-budget .form__actions .button--primary { background: var(--ink); border-color: var(--ink); color: #fff; }

/* Dictado a pantalla completa: la forma de onda refleja el nivel del micrófono. */
.has-chat { padding-bottom: 0; overflow-x: hidden; background: var(--ink); color: #fff; }
.has-chat .topbar, .has-chat .bottom-nav { display: none; }
.has-chat main.container { width: 100%; max-width: none; min-height: 100dvh; margin: 0; padding: 0; }
.has-chat .chat-page { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; width: 100%; max-width: 980px; min-height: 100dvh; margin: 0 auto; }
.has-chat .chat-main { min-height: 100dvh; padding: clamp(1.1rem, 4vw, 2rem); display: flex; flex-direction: column; justify-content: space-between; gap: clamp(.85rem, 2.6vh, 1.6rem); overflow: visible; border: 0; border-radius: 0; background: var(--ink); box-shadow: none; }
.dictation-header { display: grid; grid-template-columns: 54px 1fr 54px; align-items: center; gap: .65rem; min-height: 54px; }
.dictation-close { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: #172b5b; color: #fff; text-decoration: none; }
.dictation-close svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.dictation-state { min-width: 0; display: flex; align-items: center; justify-content: center; gap: .6rem; }
.dictation-state__dot { width: 12px; height: 12px; flex: none; border-radius: 50%; background: var(--accent); box-shadow: 7px 0 0 rgba(255,121,23,.17); }
.dictation-state__title { overflow: hidden; color: #fff; font-size: clamp(1.05rem, 4vw, 1.35rem); font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.dictation-timer { color: #c0c9e1; font: 600 1rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: right; }
.voice-wave { --voice-level: .08; height: clamp(150px, 24vh, 230px); display: flex; align-items: center; justify-content: center; gap: clamp(4px, 1.2vw, 9px); padding: .5rem 0; }
.voice-wave i { width: clamp(5px, 1.5vw, 10px); height: var(--bar-height); max-height: 100%; border-radius: 100px; background: #f8f9fd; transform: scaleY(calc(.38 + var(--voice-level) * .62)); transform-origin: center; transition: transform .12s ease, background-color .18s ease; }
.voice-wave i:nth-child(4n + 1), .voice-wave i:nth-child(4n) { background: #7e8bab; }
.voice-wave i:nth-child(8), .voice-wave i:nth-child(9), .voice-wave i:nth-child(10), .voice-wave i:nth-child(11), .voice-wave i:nth-child(12), .voice-wave i:nth-child(13) { background: var(--accent); }
.has-chat .voice-wave { --voice-level: .08; }
.has-chat .chat-page.is-listening .voice-wave i { animation: waveBreathe .8s ease-in-out infinite alternate; }
.has-chat .chat-page.is-listening .voice-wave i:nth-child(3n) { animation-delay: -.34s; }
.has-chat .chat-page.is-listening .voice-wave i:nth-child(3n + 1) { animation-delay: -.58s; }
.has-chat .chat-page.is-paused .voice-wave i { animation-play-state: paused; opacity: .5; }
@keyframes waveBreathe { to { transform: scaleY(calc(.25 + var(--voice-level) * .75)); } }
.dictation-copy { min-height: clamp(150px, 23vh, 240px); display: flex; flex: 1; flex-direction: column; justify-content: center; }
.dictation-copy__eyebrow { margin: 0 0 .8rem; color: var(--accent); font: 600 .78rem/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .2em; }
.dictation-copy__transcript { max-width: 24ch; margin: 0; color: #fff; font-size: clamp(1.55rem, 6.8vw, 2.5rem); font-weight: 650; line-height: 1.3; letter-spacing: -.025em; overflow-wrap: anywhere; }
.dictation-hint { display: flex; align-items: flex-start; gap: .75rem; max-width: 680px; margin: 0; padding: 1rem; border-radius: 24px; background: #172b5b; color: #d6deef; font-size: .95rem; line-height: 1.5; }
.dictation-hint svg { width: 22px; height: 22px; flex: none; margin-top: .05rem; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dictation-controls { display: grid; grid-template-columns: 1fr 1.45fr 1fr; align-items: center; gap: clamp(1rem, 10vw, 4.5rem); padding-top: .5rem; }
.dictation-control { display: grid; place-items: center; justify-self: center; padding: 0; cursor: pointer; }
.dictation-control svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
.dictation-control--side { width: 72px; height: 72px; border: 2px solid #2e457c; border-radius: 50%; background: transparent; color: #fff; }
.dictation-control--side svg { width: 26px; height: 26px; stroke-width: 2; }
.dictation-control--main { width: clamp(106px, 31vw, 138px); height: clamp(106px, 31vw, 138px); border: 0; border-radius: 50%; background: var(--accent); color: var(--ink); box-shadow: 19px 0 0 -1px rgba(255,121,23,.18); }
.dictation-control--main svg { width: 44px; height: 44px; stroke-width: 2; }
.dictation-check-icon { display: none; }
.dictation-control--main.is-recording .dictation-mic-icon { display: none; }
.dictation-control--main.is-recording .dictation-check-icon { display: block; width: 54px; height: 54px; stroke-width: 2.6; }
.dictation-control--main.is-recording { animation: recordingPulse 1.8s ease-in-out infinite; }
@keyframes recordingPulse { 50% { box-shadow: 19px 0 0 -1px rgba(255,121,23,.18), 0 0 0 12px rgba(255,121,23,.12); } }
.dictation-control--side.is-paused { border-color: var(--accent); color: var(--accent); }
.dictation-speech { display: flex; justify-content: center; flex-wrap: wrap; gap: .5rem; }
.button--quiet { min-height: 40px; padding: .45rem .8rem; border: 1px solid rgba(255,255,255,.18); background: transparent; color: #d6deef; font-size: .8rem; }
.button--quiet:disabled { opacity: .58; }
.dictation-speech #chat-speech-status { flex: 1 1 100%; margin: 0; color: #c0c9e1; font-size: .8rem; text-align: center; }
.chat-composer { padding: .7rem; border: 1px solid rgba(255,255,255,.14); border-radius: 20px; background: #142344; }
.chat-composer[hidden] { display: none !important; }
.chat-composer__box { align-items: center; border-color: rgba(255,255,255,.18); border-radius: 16px; background: #fff; }
.chat-composer textarea { min-height: 52px; color: var(--ink); font-size: 1rem; }
.chat-composer .mic-button { border-color: var(--line); background: var(--paper); color: var(--ink); }
.assistant__status { color: #f2d9c6; }
.chat-history { color: #c0c9e1; font-size: .85rem; }
.chat-history summary { width: fit-content; margin: 0 auto; padding: .3rem .6rem; cursor: pointer; }
.chat-log { max-height: 28vh; min-height: 0; margin-top: .6rem; padding: .8rem; border-radius: 18px; background: rgba(255,255,255,.06); }
.chat-log .bubble--assistant { background: #172b5b; color: #fff; }
.chat-log .bubble--user { background: #2d416d; color: #fff; }
.chat-side { min-width: 0; margin: 1rem; }
.chat-side__inner { padding: clamp(1rem, 4vw, 1.5rem); border: 0; border-radius: 26px; background: #fff; color: var(--ink); box-shadow: none; }
.chat-side__head h2 { color: var(--ink); font-size: 1.25rem; }
.chat-customer { color: var(--muted); font-size: .95rem; }
.chat-lines { gap: .55rem; }
.chat-line { padding: .8rem; border: 0; border-radius: 16px; background: var(--paper); font-size: .9rem; }
.chat-line__head { gap: .5rem; }
.chat-line__head strong { overflow-wrap: anywhere; }
.chat-line__detail { overflow-wrap: anywhere; }
.chat-line__total { color: var(--ink); }
.chat-totals { margin-top: .85rem; padding: .75rem 1rem; border-radius: 16px; background: var(--ink); color: #fff; }
.chat-totals > div { padding: .35rem 0; }
.chat-totals dt { color: #d6deef; }
.chat-totals__grand, .chat-totals .totals__grand { margin-top: .35rem; padding-top: .65rem; border-top: 1px solid rgba(255,255,255,.2); }
.chat-totals .totals__grand dt, .chat-totals .totals__grand dd { color: var(--accent); font-size: 1.1rem; font-weight: 700; }
.chat-side .field textarea { min-height: 86px; }
.chat-side .button--primary { width: 100%; min-height: 58px; background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 700; }
.chat-side .button--primary:disabled { opacity: .45; }
.chat-side__hint { color: var(--muted); }
.chat-pending .decision-card { padding: .9rem; border-color: #f3d7b0; border-radius: 16px; background: #fff9f1; }
.chat-pending .decision-card__actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.chat-pending .decision-card__actions .button { flex: 1 1 44%; }

/* Revisión y ficha de presupuesto: tablas en tarjetas, con etiquetas en móvil. */
.compare { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; padding: 1rem; border-radius: 22px; }
.compare > div:not(.compare__arrow) { min-width: 0; }
.compare strong { display: block; overflow-wrap: anywhere; font-size: clamp(1.05rem, 4vw, 1.5rem); }
.compare__detail { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .35rem .9rem; }
.has-budget .share { gap: .85rem; padding: 1rem; border-radius: 22px; background: #fff; }
.has-budget .share textarea { min-height: 90px; }
.has-budget .page-head__actions { display: flex; flex-wrap: wrap; }
.has-budget .page-head__actions .button { min-width: min(100%, 150px); }
.has-budget .totals { background: var(--ink); }
.has-budget .totals__grand dt, .has-budget .totals__grand dd { color: var(--accent); }
.has-budget .status-actions .button { min-height: 48px; }
.has-budget-list .filters { align-items: end; gap: .7rem; }
.has-budget-list .filters .field { min-width: 0; }
.has-budget-list .filters input, .has-budget-list .filters select { width: 100%; min-height: 52px; }
.has-budget-list .budget-row { min-width: 0; gap: .75rem; }
.has-budget-list .budget-row__main { min-width: 0; }
.has-budget-list .budget-row__main strong { overflow-wrap: anywhere; }
.has-budget-list .budget-row__side { min-width: max-content; }
.has-catalog .table-wrap { max-width: 100%; }
.has-company .form > .panel, .has-company .panel { min-width: 0; }
.has-company input, .has-company textarea, .has-company select { max-width: 100%; }
.has-manual-budget .grid-2 { grid-template-columns: minmax(0, 1fr); }
.has-manual-budget .form__actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.has-manual-budget .form__actions .button { flex: 1 1 100%; }
.has-manual-budget .table-wrap { max-width: 100%; }
.has-manual-budget .table { min-width: 540px; }
.table { font-size: .9rem; }
.table th, .table td { padding: .65rem .7rem; }

@media (min-width: 900px) {
    .has-chat main.container { padding: 1.5rem; }
    .has-chat .chat-page { grid-template-columns: minmax(0, 1.35fr) minmax(320px, .8fr); gap: 1.5rem; align-items: start; }
    .has-chat .chat-main { min-height: calc(100dvh - 3rem); border-radius: 28px; }
    .has-chat .chat-side { position: sticky; top: 1.5rem; margin: 0; }
    .has-chat .topbar, .has-chat .bottom-nav { display: none; }
    .has-manual-budget .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .has-manual-budget .form__actions .button { flex: 1 1 auto; }
}

@media (max-width: 679px) {
    .brand__wordmark { font-size: 1.18rem; }
    .pdf-preview { padding: 12px; }
    .pdf-preview-head .page-head__actions { width: 100%; }
    .has-chat .chat-main { padding: max(1rem, env(safe-area-inset-top)) 1.05rem max(1rem, env(safe-area-inset-bottom)); gap: clamp(.7rem, 2vh, 1rem); }
    .dictation-close { width: 44px; height: 44px; }
    .dictation-header { grid-template-columns: 46px minmax(0,1fr) 46px; gap: .35rem; }
    .dictation-state { gap: .42rem; }
    .dictation-state__title { font-size: 1rem; }
    .dictation-state__dot { width: 10px; height: 10px; }
    .dictation-timer { font-size: .88rem; }
    .voice-wave { height: clamp(120px, 20vh, 185px); gap: 4px; }
    .voice-wave i { width: 5px; }
    .dictation-copy { min-height: clamp(150px, 22vh, 230px); }
    .dictation-copy__transcript { max-width: 22ch; font-size: clamp(1.65rem, 7.5vw, 2.2rem); }
    .dictation-hint { padding: .85rem; border-radius: 20px; font-size: .88rem; }
    .dictation-controls { gap: clamp(1rem, 8vw, 2.5rem); }
    .dictation-control--side { width: 60px; height: 60px; }
    .dictation-control--main { width: clamp(104px, 30vw, 124px); height: clamp(104px, 30vw, 124px); }
    .dictation-speech .button--quiet { min-height: 36px; font-size: .75rem; }
    .chat-side { margin: 0 1rem 1rem; }
    .compare { grid-template-columns: minmax(0,1fr) 30px minmax(0,1fr); }
    .compare__arrow { display: grid; place-items: center; }
    .compare__detail { grid-column: 1 / -1; }
    .has-budget .page-head__actions .button { flex: 1 1 calc(50% - .4rem); }
    .has-budget .share__actions .button { flex: 1 1 calc(50% - .4rem); }
    .has-budget-list .budget-row { align-items: flex-start; }
    .has-budget-list .budget-row__side { align-items: flex-end; }
    .has-manual-budget .table-wrap { overflow-x: auto; }
    .has-budget-preview .table-wrap { overflow: visible; border: 0; background: transparent; box-shadow: none; }
    .has-budget-preview .table, .has-budget-preview .table tbody { display: block; width: 100%; min-width: 0; }
    .has-budget-preview .table thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
    .has-budget-preview .table tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .15rem .8rem; margin: 0 0 .75rem; padding: .8rem; border-radius: 18px; background: #fff; box-shadow: var(--shadow); }
    .has-budget-preview .table tbody td { display: flex; flex-direction: column; min-width: 0; gap: .2rem; border: 0; padding: .35rem 0; overflow-wrap: anywhere; }
    .has-budget-preview .table tbody td::before { content: attr(data-label); color: var(--muted); font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
    .has-budget-preview .table tbody td:nth-child(1), .has-budget-preview .table tbody td:nth-child(2) { grid-column: 1 / -1; }
    .has-budget-preview .table tbody td:last-child { align-items: flex-end; color: var(--ink); font-weight: 700; }
}

@media (max-width: 380px) {
    .brand__mark { width: 38px; }
    .brand__wordmark { font-size: 1.05rem; }
    .dictation-control--side { width: 54px; height: 54px; }
    .dictation-controls { gap: .6rem; }
    .dictation-speech { gap: .25rem; }
}
