:root {
  --bg: #f4f6f8; --card: #fff; --text: #1d2733; --muted: #667483; --line: #dde3e9;
  --brand: #0b6b57; --brand-d: #084e40; --brand-soft: #e3f2ee; --danger: #b3261e;
  --acc: var(--brand); --acc-soft: var(--brand-soft);
  --warn-bg: #fff4d6; --ok-bg: #dff3e8; --topbar-h: 56px; --sb-w: 264px; --shadow: 0 8px 28px rgba(15, 30, 45, .18);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11161b; --card: #1a2128; --text: #e6ebf0; --muted: #94a1ae; --line: #2b353f; --brand: #2fb596; --brand-d: #249278; --brand-soft: #173a2f; --warn-bg: #3b3216; --ok-bg: #173a2c; --shadow: 0 8px 28px rgba(0, 0, 0, .5); }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font: 15px/1.5 system-ui, sans-serif; background: var(--bg); color: var(--text); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.icon { width: 20px; height: 20px; flex: none; }

/* ----- Estructura ----- */
.topbar { position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 30; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; white-space: nowrap; }
.brand-sub { font-weight: 400; color: var(--muted); }
.topbar-title { color: var(--muted); padding-left: 12px; border-left: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.user img { width: 30px; height: 30px; border-radius: 50%; }
.user-mail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 10px; background: none; color: var(--text); cursor: pointer; }
.icon-btn:hover { background: var(--brand-soft); }

.sidebar { position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--sb-w); z-index: 25; overflow-y: auto; padding: 12px 10px 24px; background: var(--card); border-right: 1px solid var(--line); transform: translateX(-100%); transition: transform .22s ease; }
.shell.sb-open .sidebar { transform: none; }
.nav-title { padding: 14px 12px 6px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border: 0; border-radius: 10px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.nav-item:hover { background: var(--brand-soft); }
.nav-item.on { background: var(--brand); color: #fff; }

.backdrop { position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 20; background: rgba(10, 18, 26, .45); opacity: 0; pointer-events: none; transition: opacity .22s ease; }
.content { padding: calc(var(--topbar-h) + 24px) 24px 60px; width: 100%; transition: margin-left .22s ease; }

@media (min-width: 900px) {
  .shell.sb-open .content { margin-left: var(--sb-w); width: calc(100% - var(--sb-w)); }
}
@media (max-width: 899px) {
  .shell.sb-open .sidebar { box-shadow: var(--shadow); }
  .shell.sb-open .backdrop { opacity: 1; pointer-events: auto; }
  .content { padding: calc(var(--topbar-h) + 16px) 16px 48px; }
  .topbar-title, .brand-sub, .user-mail { display: none; }
}
@media (prefers-reduced-motion: reduce) { .sidebar, .backdrop, .content { transition: none; } }

/* ----- Componentes ----- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.card h2 { margin: 0 0 8px; font-size: 16px; }
.stack { display: grid; gap: 20px; }
.section-title { margin: 0 0 10px; font-size: 14px; color: var(--muted); font-weight: 600; }
.hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.hero h2 { font-size: 20px; }
.hero p, .callout p { margin: 0; }
.callout { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-left: 4px solid var(--brand); background: var(--brand-soft); }
.tiles { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tile { display: flex; align-items: flex-start; gap: 14px; padding: 16px; text-align: left; font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; transition: border-color .15s, transform .15s; }
.tile:hover { border-color: var(--brand); transform: translateY(-2px); }
.tile-ico { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); flex: none; }
.tile-body { display: grid; gap: 4px; justify-items: start; min-width: 0; }
.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.stat { display: grid; gap: 2px; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.stat strong { font-size: 26px; line-height: 1.1; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }

.login { max-width: 380px; margin: 14vh auto; padding: 24px; text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; background: var(--line); white-space: nowrap; }
.badge.admin { background: var(--brand); color: #fff; }
.badge.ok { background: var(--ok-bg); }
.badge.off { background: var(--warn-bg); }
button.btn, a.btn { background: var(--brand); color: #fff; border: 0; padding: 8px 16px; border-radius: 8px; cursor: pointer; font: inherit; text-decoration: none; display: inline-block; }
button.btn:hover, a.btn:hover { background: var(--brand-d); }
button.btn:disabled { opacity: .6; cursor: default; }
button.btn.ghost { background: none; color: var(--text); border: 1px solid var(--line); }
button.btn.danger { background: var(--danger); }
button.btn.small { padding: 3px 10px; font-size: 13px; }
.card form { display: grid; gap: 10px; max-width: 760px; }
input, select, textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; min-width: 0; }
textarea { min-height: 90px; resize: vertical; }
label { font-size: 13px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 600px; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: break-word; }
th { color: var(--muted); font-weight: 600; }
.msg { padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; background: var(--ok-bg); }
.msg.err { background: var(--warn-bg); border-left: 4px solid var(--danger); }
.muted { color: var(--muted); font-size: 13px; }
pre { white-space: pre-wrap; background: var(--bg); padding: 10px; border-radius: 8px; max-height: 60vh; overflow: auto; }
.content > #view > .card, .content > #view > div > .card { margin-bottom: 16px; }

/* ===== Módulos de Google con apariencia original ===== */
.gmail { --acc: #c5221f; --acc-soft: #fce8e6; }
.cal, .docs { --acc: #1a73e8; --acc-soft: #e8f0fe; }
.drive { --acc: #1a73e8; --acc-soft: #e8f0fe; }
.sheets { --acc: #188038; --acc-soft: #e6f4ea; }
@media (prefers-color-scheme: dark) {
  .gmail { --acc: #f28b82; --acc-soft: #3c2220; }
  .cal, .docs, .drive { --acc: #8ab4f8; --acc-soft: #1f2d45; }
  .sheets { --acc: #81c995; --acc-soft: #1b3326; }
}
#view > .gmail, #view > .cal, #view > .drive, #view > .sheets, #view > .docs { min-height: calc(100vh - var(--topbar-h) - 90px); }
.btn.acc { background: var(--acc); color: #fff; }
.btn.acc:hover { filter: brightness(.92); background: var(--acc); }
@media (prefers-color-scheme: dark) { .btn.acc { color: #11161b; } }
.btn.pill { border-radius: 999px; padding: 10px 20px; display: inline-flex; align-items: center; gap: 8px; }
.icon-btn.light { color: #fff; width: 30px; height: 30px; }
.spacer { flex: 1; }
.pad { padding: 20px; }
.pad-top { padding-top: 16px; }
.hidden { display: none !important; }
.stack-sm { display: grid; gap: 10px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.empty { display: grid; justify-items: center; gap: 4px; padding: 56px 16px; color: var(--muted); }
.empty .icon { width: 44px; height: 44px; opacity: .5; }

.app-top { margin-bottom: 14px; }
.searchbar { display: flex; align-items: center; gap: 10px; max-width: 720px; padding: 0 16px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); }
.searchbar:focus-within { border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft); }
.searchbar input { flex: 1; border: 0; background: none; padding: 11px 0; outline: none; }
.app-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; }
.app-rail { display: grid; gap: 2px; position: sticky; top: calc(var(--topbar-h) + 16px); }
.rail-note { padding: 8px 4px; }
.compose-btn { margin-bottom: 12px; justify-self: start; box-shadow: 0 1px 4px rgba(0, 0, 0, .2); }
.rail-item { display: flex; align-items: center; gap: 14px; padding: 8px 16px; border: 0; border-radius: 999px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.rail-item:hover { background: var(--line); }
.rail-item.on { background: var(--acc-soft); color: var(--acc); font-weight: 600; }
.rail-item span { flex: 1; }
.rail-count { font-size: 12px; font-weight: 700; flex: none !important; }
.app-main { background: var(--card); border: 1px solid var(--line); border-radius: 16px; min-height: 420px; overflow: hidden; }
.toolbar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.doc-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50vw; }
@media (max-width: 899px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-rail { position: static; display: flex; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .compose-btn { margin: 0; flex: none; }
  .rail-item { flex: none; padding: 8px 14px; }
}

/* Gmail */
.mail-row { display: grid; grid-template-columns: 24px 190px minmax(0, 1fr) auto; align-items: center; gap: 12px; width: 100%; padding: 9px 16px; border: 0; border-bottom: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.mail-row:hover { box-shadow: inset 3px 0 0 var(--acc); background: var(--bg); }
.mail-row:not(.unread) { background: var(--bg); }
.mail-row:not(.unread) .mail-from, .mail-row:not(.unread) strong { font-weight: 400; }
.mail-row.unread .mail-from, .mail-row.unread strong { font-weight: 700; }
.mail-from, .mail-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-date { font-size: 12px; color: var(--muted); white-space: nowrap; }
.mail-star { color: var(--muted); display: grid; }
.mail-star.on { color: #f4b400; }
.mail-star.on .icon { fill: #f4b400; }
.mail-star .icon { width: 18px; height: 18px; }
@media (max-width: 899px) { .mail-row { grid-template-columns: 24px minmax(0, 1fr) auto; } .mail-from { grid-column: 2; font-weight: 700; } .mail-text { grid-column: 2 / 4; grid-row: 2; } .mail-date { grid-column: 3; grid-row: 1; } }
.mail-view { padding: 0 24px 24px; }
.mail-view .toolbar { margin: 0 -24px; }
.mail-subject { font-size: 22px; font-weight: 400; margin: 18px 0; }
.mail-meta { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.mail-meta .mail-date { margin-left: auto; }
.avatar { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--acc); color: #fff; font-weight: 700; flex: none; }
.mail-body { max-height: none; background: none; padding: 0; font: inherit; line-height: 1.6; }
.compose { position: fixed; right: 24px; bottom: 0; z-index: 40; width: min(480px, calc(100vw - 16px)); background: var(--card); border: 1px solid var(--line); border-radius: 12px 12px 0 0; box-shadow: var(--shadow); }
.compose-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 16px; background: #404040; color: #fff; border-radius: 12px 12px 0 0; }
.compose form { padding: 8px 12px 12px; gap: 6px; max-width: none; }
.compose input, .compose textarea { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; }
.compose textarea { min-height: 200px; }

/* Calendar */
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.cal-title { margin: 0 0 0 8px; font-size: 22px; font-weight: 400; }
.cal-title::first-letter { text-transform: uppercase; }
.cal-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.cal-week, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-week span { padding: 8px; text-align: center; font-size: 12px; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); }
.cal-cell { min-height: 112px; padding: 4px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: grid; align-content: start; gap: 2px; cursor: default; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell.other { background: var(--bg); color: var(--muted); }
.cal-num { justify-self: center; display: grid; place-items: center; min-width: 26px; height: 26px; padding: 0 4px; border-radius: 99px; font-size: 12px; }
.cal-num.today { background: var(--acc); color: #fff; }
@media (prefers-color-scheme: dark) { .cal-num.today { color: #11161b; } }
.cal-chip { display: flex; gap: 4px; align-items: center; width: 100%; border: 0; border-radius: 4px; padding: 1px 6px; font: inherit; font-size: 12px; text-align: left; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text); background: transparent; }
.cal-chip:hover { filter: brightness(.95); }
.cal-chip.solid { color: #fff; }
.cal-time { color: var(--muted); }
.cal-more { font-size: 12px; color: var(--muted); padding-left: 6px; }
.ev-0 { background: #d2e3fc; } .ev-1 { background: #ceead6; } .ev-2 { background: #feefc3; } .ev-3 { background: #fad2cf; } .ev-4 { background: #e9d2fd; } .ev-5 { background: #d3f0f5; }
.cal-chip.solid.ev-0 { background: #1a73e8; } .cal-chip.solid.ev-1 { background: #188038; } .cal-chip.solid.ev-2 { background: #b06000; } .cal-chip.solid.ev-3 { background: #c5221f; } .cal-chip.solid.ev-4 { background: #8430ce; } .cal-chip.solid.ev-5 { background: #0b7285; }
@media (prefers-color-scheme: dark) { .ev-0, .ev-1, .ev-2, .ev-3, .ev-4, .ev-5 { color: #202124; } .cal-chip.solid { color: #fff; } .cal-time { color: #3c4043; } }
.cal.loading { opacity: .6; }
@media (max-width: 899px) { .cal-cell { min-height: 78px; } .cal-chip { font-size: 12px; padding: 0 3px; } .cal-time { display: none; } }

/* Drive */
.crumbs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: 15px; }
.crumb { border: 0; background: none; color: var(--muted); font: inherit; padding: 4px 8px; border-radius: 8px; cursor: pointer; }
.crumb:hover { background: var(--line); }
.sep { color: var(--muted); }
.file-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); padding: 16px; }
.file-card { display: grid; gap: 4px; justify-items: start; padding: 12px; text-align: left; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; min-width: 0; }
.file-card:hover { background: var(--acc-soft); border-color: var(--acc); }
.file-card .muted { font-size: 12px; }
.file-ico { display: grid; place-items: center; width: 100%; height: 84px; border-radius: 8px; background: var(--card); }
.file-ico .icon { width: 40px; height: 40px; }
.file-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.ft-folder { color: #5f6368; } .ft-doc { color: #1a73e8; } .ft-sheet { color: #188038; } .ft-pdf { color: #c5221f; } .ft-img { color: #b06000; } .ft-other { color: var(--muted); }
.file-inline { display: inline-flex; vertical-align: middle; } .file-inline .icon { width: 18px; height: 18px; }
.file-table { min-width: 520px; }
.file-table tr.clickable { cursor: pointer; }
.file-table tr.clickable:hover { background: var(--acc-soft); }

/* Sheets */
.home-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.home-head h2 { margin: 0; font-size: 22px; font-weight: 400; }
.sheets .file-grid, .docs .file-grid { padding: 0; }
.sheets > .toolbar, .docs > .toolbar { background: var(--card); border: 1px solid var(--line); border-radius: 12px 12px 0 0; border-bottom: 0; }
.fx-bar { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: var(--card); border: 1px solid var(--line); border-bottom: 0; }
.cell-ref { min-width: 54px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; text-align: center; font-size: 13px; }
.fx-label { color: var(--muted); font-style: italic; font-family: serif; }
.fx { flex: 1; border-radius: 4px; padding: 4px 8px; }
.sheet-grid { overflow: auto; max-height: calc(100vh - 290px); background: var(--card); border: 1px solid var(--line); }
.sheet-grid table { min-width: 0; width: auto; border-collapse: separate; border-spacing: 0; font-size: 13px; table-layout: fixed; }
.sheet-grid th, .sheet-grid td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 2px 6px; height: 24px; min-width: 96px; max-width: 220px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; vertical-align: middle; }
.sheet-grid thead th { position: sticky; top: 0; z-index: 2; background: var(--bg); text-align: center; font-weight: 500; color: var(--muted); }
.sheet-grid .row-h { position: sticky; left: 0; z-index: 1; min-width: 44px; max-width: 44px; width: 44px; background: var(--bg); text-align: center; font-weight: 400; color: var(--muted); }
.sheet-grid .corner { left: 0; z-index: 3; min-width: 44px; max-width: 44px; }
.sheet-grid td { cursor: cell; }
.sheet-grid td.sel { outline: 2px solid var(--acc); outline-offset: -2px; background: var(--acc-soft); }
.sheet-tabs { display: flex; align-items: center; gap: 4px; padding: 6px 10px; background: var(--bg); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 12px 12px; overflow-x: auto; }
.sheet-tab { border: 0; background: none; padding: 6px 14px; font: inherit; color: var(--muted); border-radius: 6px; cursor: pointer; white-space: nowrap; }
.sheet-tab.on { background: var(--acc-soft); color: var(--acc); font-weight: 600; }
.tabs-note { margin-left: auto; white-space: nowrap; }

/* Docs */
.docs-new { margin-bottom: 18px; }
.doc-blank { display: grid; place-items: center; gap: 8px; width: 150px; height: 180px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; color: var(--acc); font: inherit; cursor: pointer; }
.doc-blank:hover { border-color: var(--acc); }
.doc-blank .icon { width: 44px; height: 44px; }
.paper-bg { background: #e9edf2; padding: 28px 12px 40px; border: 1px solid var(--line); border-radius: 0 0 12px 12px; overflow-x: auto; }
@media (prefers-color-scheme: dark) { .paper-bg { background: #0d1115; } }
.paper { max-width: 816px; min-height: 600px; margin: 0 auto; padding: 72px 80px; background: #fff; color: #202124; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 1.6; }
@media (max-width: 899px) { .paper { padding: 28px 20px; } }
.paper p { margin: 0 0 6px; overflow-wrap: break-word; }
.paper .muted { color: #5f6368; }
.paper-title { font-size: 30px; font-weight: 400; margin: 0 0 18px; }
.doc-title-p { font-size: 26px; } .doc-subtitle { font-size: 17px; color: #5f6368; }
.doc-h1 { font-size: 22px; margin-top: 16px !important; } .doc-h2 { font-size: 18px; margin-top: 12px !important; } .doc-h3 { font-size: 16px; font-weight: 700; margin-top: 10px !important; }
.doc-empty { min-height: 12px; }
.doc-bullet { padding-left: 14px; }

/* Modal y avisos */
.modal-back { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(10, 18, 26, .5); }
.modal { width: min(480px, 100%); max-height: 90vh; overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 12px 20px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 16px 20px 20px; }
.modal-body form { max-width: none; gap: 12px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70; padding: 10px 18px; border-radius: 8px; background: #323232; color: #fff; box-shadow: var(--shadow); }

/* Formularios fuera de tarjetas (modales y redactar) */
form { display: grid; gap: 10px; }
form.row { display: flex; }
.compose input, .compose textarea, .modal-body input:not([type=checkbox]), .modal-body textarea, .modal-body select { width: 100%; }
.compose textarea { min-height: 160px; }
.compose { max-height: calc(100vh - var(--topbar-h) - 8px); overflow: auto; }

/* Enlaces con apariencia de botón */
a.btn { display: inline-flex; align-items: center; gap: 6px; }
a.btn.ghost { background: none; color: var(--text); border: 1px solid var(--line); }
a.btn.ghost:hover { background: var(--line); }
a.btn.small { padding: 3px 10px; font-size: 13px; }
button.btn.small { display: inline-flex; align-items: center; gap: 6px; }
.paper > p:first-child { margin-top: 0; }

/* ===== Chat de Gemini (estilo asistente conversacional) ===== */
.chat { --acc: #5b6cf0; --acc-soft: #eceefe; position: relative; display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; height: calc(100vh - var(--topbar-h) - 90px); min-height: 440px; }
@media (prefers-color-scheme: dark) { .chat { --acc: #aab4ff; --acc-soft: #252a4d; } }
.chat-side { display: flex; flex-direction: column; gap: 10px; padding: 12px; min-height: 0; background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
.new-chat { justify-content: center; }
.side-title { padding: 6px 8px 0; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.chat-list { flex: 1; overflow-y: auto; display: grid; align-content: start; gap: 2px; }
.chat-item { display: flex; align-items: center; border-radius: 10px; }
.chat-item:hover { background: var(--line); }
.chat-item.on { background: var(--acc-soft); }
.chat-open { flex: 1; min-width: 0; display: grid; gap: 1px; padding: 8px 10px; border: 0; background: none; color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.chat-open .muted { font-size: 12px; }
.chat-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.small-ico { width: 30px; height: 30px; flex: none; opacity: 0; color: var(--muted); }
.small-ico .icon { width: 16px; height: 16px; }
.chat-item:hover .small-ico, .chat-item:focus-within .small-ico { opacity: 1; }
@media (hover: none) { .small-ico { opacity: 1; } }

.chat-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.chat-top { display: none; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.chat-feed { flex: 1; min-height: 0; overflow-y: auto; padding: 24px 16px 8px; scroll-behavior: auto; }
.chat-feed > * { max-width: 760px; margin-left: auto; margin-right: auto; }

.welcome { margin-top: 9vh; text-align: center; display: grid; justify-items: center; gap: 4px; }
.welcome h2 { margin: 6px 0 0; font-size: 30px; font-weight: 500; }
.welcome p { margin: 0 0 18px; font-size: 16px; }
.welcome-ico { color: var(--acc); }
.welcome-ico .icon { width: 40px; height: 40px; }
.chips { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; max-width: 640px; }
.chip { padding: 12px 14px; text-align: left; font: inherit; font-size: 14px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 14px; cursor: pointer; }
.chip:hover { border-color: var(--acc); background: var(--acc-soft); }

.cmsg { display: flex; gap: 12px; margin-bottom: 22px; }
.cmsg.user { justify-content: flex-end; }
.bubble { max-width: 85%; padding: 10px 16px; background: var(--bg); border: 1px solid var(--line); border-radius: 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-ico { flex: none; display: grid; place-items: center; width: 28px; height: 28px; margin-top: 1px; color: var(--acc); }
.msg-body { flex: 1; min-width: 0; }
.msg-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; }
.msg-act { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; }
.msg-act:hover { background: var(--line); color: var(--text); }
.msg-act .icon { width: 16px; height: 16px; }
.cmsg.err-msg { display: block; }

.md { line-height: 1.65; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md p { margin: 0 0 12px; white-space: pre-wrap; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 24px; }
.md li { margin: 3px 0; }
.md .md-h { margin: 18px 0 8px; line-height: 1.3; }
.md h2.md-h { font-size: 20px; } .md h3.md-h { font-size: 17px; } .md h4.md-h, .md h5.md-h { font-size: 15px; }
.md code { padding: 1px 6px; font: 13px/1.5 ui-monospace, Menlo, Consolas, monospace; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
.md blockquote { margin: 0 0 12px; padding: 2px 14px; color: var(--muted); border-left: 3px solid var(--line); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.md a { color: var(--acc); }
.md-table { min-width: 0; margin-bottom: 12px; }
.md-table th { background: var(--bg); }
.code-block { margin: 0 0 14px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg); }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
.code-copy { border: 0; background: none; color: var(--muted); font: inherit; cursor: pointer; padding: 2px 8px; border-radius: 6px; }
.code-copy:hover { background: var(--line); color: var(--text); }
.code-block pre { margin: 0; max-height: none; padding: 12px; background: none; border-radius: 0; overflow-x: auto; white-space: pre; }
.code-block code { padding: 0; border: 0; background: none; font-size: 13px; }

.typing { display: inline-flex; gap: 4px; padding: 8px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .typing i { animation: none; opacity: .6; } }

.composer-wrap { width: 100%; max-width: 792px; margin: 0 auto; padding: 0 16px 12px; }
.composer { padding: 10px 12px 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 2px 10px rgba(15, 30, 45, .08); }
.composer:focus-within { border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft); }
.chat-input { display: block; width: 100%; min-height: 28px; max-height: 200px; padding: 4px; border: 0; border-radius: 0; background: none; outline: none; resize: none; line-height: 1.5; }
.composer-bar { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.model-pill { max-width: 55%; padding: 5px 12px; font-size: 13px; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.send-btn { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--acc); color: #fff; cursor: pointer; }
@media (prefers-color-scheme: dark) { .send-btn { color: #11161b; } }
.send-btn:disabled { opacity: .35; cursor: default; }
.send-btn.stop { background: var(--text); color: var(--bg); }
.chat-note { margin: 8px 0 0; font-size: 12px; line-height: 1.4; color: var(--muted); text-align: center; }

@media (max-width: 899px) {
  .chat { grid-template-columns: 1fr; height: calc(100vh - var(--topbar-h) - 70px); }
  .chat-side { position: absolute; inset: 0 auto 0 0; z-index: 5; width: min(310px, 88%); transform: translateX(-105%); transition: transform .2s ease; }
  .chat.side-open .chat-side { transform: none; box-shadow: var(--shadow); }
  .chat-top { display: flex; }
  .chips { grid-template-columns: 1fr; }
  .welcome { margin-top: 4vh; }
  .bubble { max-width: 92%; }
  .chat-note { font-size: 12px; }
}

/* Interruptor de Gmail y pasos de herramientas */
.tool-toggle { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; font: inherit; font-size: 13px; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.tool-toggle .icon { width: 15px; height: 15px; }
.tool-toggle:hover:not(:disabled) { border-color: var(--acc); }
.tool-toggle.on { color: var(--acc); background: var(--acc-soft); border-color: var(--acc); font-weight: 600; }
.tool-toggle:disabled { opacity: .5; cursor: not-allowed; }
.inbox-cta { display: flex; align-items: center; gap: 14px; width: 100%; max-width: 640px; margin-bottom: 14px; padding: 14px 16px; text-align: left; font: inherit; color: var(--text); background: var(--acc-soft); border: 1px solid var(--acc); border-radius: 14px; cursor: pointer; }
.inbox-cta:hover { filter: brightness(.97); }
.inbox-cta .icon { width: 24px; height: 24px; color: var(--acc); flex: none; }
.inbox-cta span { display: grid; gap: 2px; }
.tool-steps { display: grid; gap: 4px; margin-bottom: 8px; }
.tool-steps:empty { display: none; }
.tool-step { display: flex; align-items: center; gap: 8px; width: fit-content; max-width: 100%; padding: 3px 12px 3px 10px; font-size: 13px; color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; overflow-wrap: anywhere; }
.tool-step::before { content: ''; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--acc); animation: blink 1.2s infinite ease-in-out; }
.tool-step.ok::before { animation: none; background: #188038; }
.tool-step.error::before { animation: none; background: var(--danger); }
@media (prefers-reduced-motion: reduce) { .tool-step::before { animation: none; } }
@media (max-width: 899px) { .composer-bar { flex-wrap: wrap; } .model-pill { max-width: 46%; } }

/* Tablas dentro del chat: legibles aunque haya muchas columnas (se desplazan de lado) */
.md .table-wrap { margin-bottom: 14px; }
.md-table { min-width: 0; margin: 0; font-size: 13px; }
.md-table th, .md-table td { min-width: 130px; padding: 7px 10px; vertical-align: top; overflow-wrap: break-word; }
.md-table th:first-child, .md-table td:first-child { min-width: 92px; }
.md-table code { overflow-wrap: anywhere; }

/* Cambios propuestos en Drive */
.proposals { display: grid; gap: 10px; margin-top: 10px; }
.proposals:empty { display: none; }
.proposal { padding: 12px 14px; background: var(--bg); border: 1px solid var(--acc); border-radius: 14px; }
.proposal.applied { border-color: #188038; }
.proposal.rejected { border-color: var(--line); opacity: .8; }
.prop-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.prop-head .icon { width: 18px; height: 18px; color: var(--acc); }
.prop-head .badge { margin-left: auto; }
.prop-file { margin: 4px 0 8px; font-size: 14px; overflow-wrap: anywhere; }
.prop-body { margin-bottom: 10px; }
.prop-body p { margin: 0 0 6px; }
.prop-ctx { padding: 6px 10px; margin-bottom: 4px; font-size: 13px; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow-wrap: anywhere; }
.prop-pre { max-height: 220px; margin: 0; padding: 8px 10px; font-size: 13px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.prop-cols { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.prop-cols .md-table td { min-width: 70px; padding: 4px 8px; }
.prop-status { margin-top: 8px; font-size: 13px; color: var(--muted); }
.prop-status.err { color: var(--danger); }
.gate-list { margin: 0; padding-left: 20px; }
.gate-list li { margin: 4px 0; }
@media (max-width: 899px) { .prop-cols { grid-template-columns: 1fr; } }

/* La barra del cuadro de mensaje pasa a otra línea en vez de aplastar el selector de modelo */
.composer-bar { flex-wrap: wrap; row-gap: 6px; }
.model-pill { flex: 0 0 auto; min-width: 118px; max-width: 46%; }

/* Gestión de archivos: tarjetas de riesgo */
.proposal.danger { border-color: var(--danger); }
.proposal.danger .prop-head .icon { color: var(--danger); }
.prop-warn { margin: 6px 0; padding: 7px 10px; font-size: 13px; color: var(--danger); background: var(--warn-bg); border-left: 3px solid var(--danger); border-radius: 6px; }
.badge.danger { color: #fff; background: var(--danger); }

/* ===== Licitaciones ===== */
.lic { --acc: #0b6b57; --acc-soft: #e3f2ee; }
@media (prefers-color-scheme: dark) { .lic { --acc: #2fb596; --acc-soft: #173a2f; } }
.lic .home-head { margin-bottom: 12px; }
.lic .stats { margin-bottom: 8px; }
.lic-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0; max-width: none; }
.lic-filters input[type=search] { min-width: 190px; }
.lic-list { display: grid; gap: 12px; }
.lic-card { padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 12px; display: grid; gap: 8px; }
.lic-card.fit-alto { border-left-color: #188038; }
.lic-card.fit-medio { border-left-color: #f4b400; }
.lic-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.lic-plazo { margin-left: auto; font-size: 13px; color: var(--muted); }
.lic-plazo.urgente { color: var(--danger); font-weight: 600; }
.lic-title { margin: 0; font-size: 16px; line-height: 1.35; }
.link-btn { padding: 0; border: 0; background: none; color: var(--text); font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.link-btn:hover { color: var(--acc); text-decoration: underline; }
.lic-org { margin: 0; overflow-wrap: anywhere; }
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; }
.mini-chip { padding: 2px 10px; font-size: 12px; color: var(--acc); background: var(--acc-soft); border-radius: 999px; }
.lic-alertas { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.lic-alertas li { margin: 2px 0; }
.lic-modal-title { margin: 0; font-size: 17px; line-height: 1.35; }
.progress { height: 6px; margin-bottom: 12px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--acc); transition: width .4s ease; }
.progress-bar.w0 { width: 0%; }
.progress-bar.w5 { width: 5%; }
.progress-bar.w10 { width: 10%; }
.progress-bar.w15 { width: 15%; }
.progress-bar.w20 { width: 20%; }
.progress-bar.w25 { width: 25%; }
.progress-bar.w30 { width: 30%; }
.progress-bar.w35 { width: 35%; }
.progress-bar.w40 { width: 40%; }
.progress-bar.w45 { width: 45%; }
.progress-bar.w50 { width: 50%; }
.progress-bar.w55 { width: 55%; }
.progress-bar.w60 { width: 60%; }
.progress-bar.w65 { width: 65%; }
.progress-bar.w70 { width: 70%; }
.progress-bar.w75 { width: 75%; }
.progress-bar.w80 { width: 80%; }
.progress-bar.w85 { width: 85%; }
.progress-bar.w90 { width: 90%; }
.progress-bar.w95 { width: 95%; }
.progress-bar.w100 { width: 100%; }

/* Los recuadros no se ensanchan por tablas o textos largos: se desplazan dentro */
.stack-sm { grid-template-columns: minmax(0, 1fr); }
.modal-body { overflow-wrap: anywhere; }

/* ===== PWA ===== */
/* Zonas seguras: muescas y barras del sistema en iPhone y Android cuando se abre como app */
:root { --topbar-h: calc(56px + env(safe-area-inset-top, 0px)); }
.topbar { padding-top: env(safe-area-inset-top, 0px); }
.content { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
.composer-wrap { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
body { overscroll-behavior-y: contain; }
@media (display-mode: standalone) { body { -webkit-user-select: none; user-select: none; } input, textarea, pre, .md, .mail-body, .paper, td { -webkit-user-select: text; user-select: text; } }

.install-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; font: inherit; font-size: 13px; color: var(--brand); background: var(--brand-soft); border: 1px solid var(--brand); border-radius: 999px; cursor: pointer; white-space: nowrap; }
.install-btn:hover { filter: brightness(.96); }
.install-btn .icon { width: 16px; height: 16px; }
.install-link { margin-top: 4px; }
@media (max-width: 899px) { .install-btn span { display: none; } .install-btn { padding: 6px 8px; } }

.pwa-banner { position: fixed; z-index: 50; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); display: flex; align-items: center; gap: 12px; width: min(520px, calc(100vw - 24px)); padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.pwa-banner img { border-radius: 10px; flex: none; }
.pwa-banner-text { display: grid; flex: 1; min-width: 0; line-height: 1.3; }
.pwa-banner-text .muted { font-size: 12px; }
.update-bar { position: fixed; z-index: 55; top: calc(var(--topbar-h) + 8px); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--card); border: 1px solid var(--acc, var(--brand)); border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; }
.steps { margin: 0; padding-left: 20px; }
.steps li { margin: 6px 0; }
.muted.small { font-size: 12px; }
.offline { display: grid; justify-items: center; gap: 4px; max-width: 420px; margin: 18vh auto 0; padding: 0 20px; text-align: center; }
.offline img { border-radius: 22px; }
.offline h1 { margin: 12px 0 0; font-size: 24px; }

/* ===== Móviles (v1.2) ===== */
:root { --bottombar-h: 0px; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
button, a, input, select, textarea, label, summary { touch-action: manipulation; }
body.drawer-open { overflow: hidden; }

/* Vista agenda y vista mes del calendario */
.seg { display: inline-flex; margin-left: auto; padding: 3px; background: var(--line); border-radius: 999px; }
.seg-btn { padding: 6px 14px; border: 0; border-radius: 999px; background: none; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.seg-btn.on { background: var(--card); color: var(--acc); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.cal-dots { display: none; justify-content: center; gap: 3px; min-height: 8px; }
.ev-d { display: block; width: 6px; height: 6px; border-radius: 50%; background: #1a73e8; }
.ev-d.ev-1 { background: #188038; } .ev-d.ev-2 { background: #b06000; } .ev-d.ev-3 { background: #c5221f; } .ev-d.ev-4 { background: #8430ce; } .ev-d.ev-5 { background: #0b7285; }
.agenda { display: grid; gap: 14px; }
.agenda-day { scroll-margin-top: calc(var(--topbar-h) + 8px); display: grid; gap: 6px; }
.agenda-date { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; font-weight: 500; color: var(--muted); text-transform: capitalize; }
.agenda-num { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; font-size: 16px; color: var(--text); background: var(--card); border: 1px solid var(--line); }
.agenda-day.today .agenda-num { background: var(--acc); border-color: var(--acc); color: #fff; }
@media (prefers-color-scheme: dark) { .agenda-day.today .agenda-num { color: #11161b; } }
.agenda-ev { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 8px 12px; text-align: left; font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-left: 4px solid #1a73e8; border-radius: 10px; cursor: pointer; }
.agenda-ev.ev-1 { border-left-color: #188038; } .agenda-ev.ev-2 { border-left-color: #b06000; } .agenda-ev.ev-3 { border-left-color: #c5221f; } .agenda-ev.ev-4 { border-left-color: #8430ce; } .agenda-ev.ev-5 { border-left-color: #0b7285; }
.agenda-time { flex: none; min-width: 72px; font-size: 13px; color: var(--muted); }
.agenda-title { min-width: 0; overflow-wrap: anywhere; }
.agenda-ev:active { background: var(--acc-soft); }

/* Barra inferior: solo en pantallas angostas */
.bottombar { display: none; }
.note-short, .note-more { display: none; }

@media (max-width: 899px) {
  :root { --bottombar-h: calc(58px + env(safe-area-inset-bottom, 0px)); }
  .bottombar { position: fixed; z-index: 19; left: 0; right: 0; bottom: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); height: var(--bottombar-h); padding-bottom: env(safe-area-inset-bottom, 0px); background: var(--card); border-top: 1px solid var(--line); }
  .bottom-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 44px; min-height: 44px; padding: 4px 2px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px; line-height: 1.2; cursor: pointer; }
  .bottom-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bottom-item .icon { width: 24px; height: 24px; }
  .bottom-item.on { color: var(--brand); font-weight: 600; }
  .bottom-item:active { background: var(--brand-soft); }
  body.kb-open { --bottombar-h: 0px; }
  body.kb-open .bottombar { display: none; }
  .content { padding-bottom: calc(24px + var(--bottombar-h)); }
  .toast { bottom: calc(16px + var(--bottombar-h)); max-width: calc(100vw - 24px); }
  .pwa-banner { bottom: calc(10px + var(--bottombar-h)); }
  .chat { height: calc(100vh - var(--topbar-h) - var(--bottombar-h) - 40px); min-height: 360px; }
  .composer-wrap { padding-bottom: 8px; }
  .sidebar { padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); overscroll-behavior: contain; }
}
@media (max-width: 899px) and (max-height: 500px) {
  :root { --bottombar-h: 0px; }
  .bottombar { display: none; }
}
@supports (height: 100dvh) {
  #view > .gmail, #view > .cal, #view > .drive, #view > .sheets, #view > .docs { min-height: calc(100dvh - var(--topbar-h) - 90px); }
  .sheet-grid { max-height: calc(100dvh - 290px); }
  .modal { max-height: 90dvh; }
  .compose { max-height: calc(100dvh - var(--topbar-h) - 8px); }
  .chat { height: calc(100dvh - var(--topbar-h) - 90px); }
}
@supports (height: 100dvh) {
  @media (max-width: 899px) { .chat { height: calc(100dvh - var(--topbar-h) - var(--bottombar-h) - 40px); } }
}

/* Dedos: objetivos táctiles de 44 px y texto de 16 px (evita el zoom de iOS al escribir) */
@media (pointer: coarse), (max-width: 899px) {
  .icon-btn { width: 44px; height: 44px; flex: none; }
  .install-btn { flex: none; min-width: 44px; justify-content: center; }
  select.model-pill { font-size: 16px; }
  button.btn, a.btn, button.btn.small, a.btn.small { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
  button.btn.small, a.btn.small { padding: 6px 14px; }
  input:not([type=checkbox]):not([type=radio]), select, textarea { min-height: 44px; font-size: 16px; }
  input[type=checkbox], input[type=radio] { width: 22px; height: 22px; }
  label.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; }
  .nav-item { min-height: 44px; }
  .rail-item { min-height: 44px; }
  .tool-toggle, .model-pill, .chip, .sheet-tab, .install-btn, .seg-btn { min-height: 44px; }
  .send-btn { width: 44px; height: 44px; }
  .msg-act, .small-ico { width: 44px; height: 44px; }
  .link-btn { min-height: 44px; }
  .chat-input { font-size: 16px; min-height: 44px; }
  .searchbar input { min-height: 44px; }
  button:active:not(:disabled), a.btn:active, .tile:active { filter: brightness(.93); }
}
@media (hover: none) {
  .tile:hover { transform: none; border-color: var(--line); }
  .icon-btn:hover, .nav-item:hover, .rail-item:hover { background: none; }
  .nav-item.on:hover { background: var(--brand); }
  .rail-item.on:hover { background: var(--acc-soft); }
}

/* Aviso de versión nueva: ancho completo en el celular */
.update-bar { width: min(480px, calc(100vw - 24px)); justify-content: space-between; }
.update-bar > span, .update-bar > p { flex: 1; min-width: 0; margin: 0; }

/* Pantallas muy angostas (celulares verticales) */
@media (max-width: 599px) {
  .content { padding-left: 12px; padding-right: 12px; }
  .topbar { gap: 8px; padding-left: 8px; padding-right: 8px; }
  .topbar-title { padding-left: 8px; }
  .brand-sub { display: none; }
  .user-mail, .role-badge { display: none; }
  .tiles { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card { padding: 14px; }

  /* Modales como hoja inferior */
  .modal-back { place-items: end stretch; padding: 0; }
  .modal { width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; border-bottom: 0; animation: sheet-up .2s ease-out; }
  .modal-body { padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
  @keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

  /* Redactar correo a pantalla completa */
  .compose { inset: 0; width: 100%; max-height: none; height: 100vh; border-radius: 0; z-index: 58; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px); }
  .compose-head { border-radius: 0; }
  .compose form { flex: 1; display: flex; flex-direction: column; padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .compose textarea { flex: 1; min-height: 140px; }

  /* Tablas convertidas en tarjetas */
  table.responsive { min-width: 0; }
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive tr { margin-bottom: 10px; padding: 6px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
  table.responsive td { display: grid; grid-template-columns: minmax(84px, 36%) minmax(0, 1fr); gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
  table.responsive td:last-child { border-bottom: 0; }
  table.responsive td::before { content: attr(data-label); font-size: 12px; font-weight: 600; color: var(--muted); }
  table.responsive td[data-label='']::before { display: none; }
  table.responsive td[data-label=''] { display: block; }
  .file-table { min-width: 0; }
  .file-table th:nth-child(2), .file-table td:nth-child(2), .file-table th:nth-child(4), .file-table td:nth-child(4) { display: none; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; padding: 10px; }

  /* Calendario: puntos de color y toque para abrir el día */
  .cal-head { gap: 6px; }
  .cal-title { order: 5; flex-basis: 100%; margin: 4px 0 0; font-size: 20px; }
  .seg { margin-left: auto; }
  .cal-cell { min-height: 54px; padding: 2px; align-content: start; justify-items: center; cursor: pointer; }
  .cal-chip, .cal-more { display: none; }
  .cal-dots { display: flex; }
  .cal-num { min-width: 28px; height: 28px; font-size: 13px; }

  /* Licitaciones */
  .lic-filters { gap: 8px; }
  .lic-filters .lic-q { flex: 1 1 100%; }
  .lic-filters > select, .lic-filters > input[type=search]:not(.lic-q), .lic-filters > label.check { display: none; }
  .lic-filters.open > select, .lic-filters.open > input[type=search], .lic-filters.open > label.check { display: block; flex: 1 1 100%; width: 100%; }
  .lic-filters.open > label.check { display: inline-flex; }
  .lic-card { padding: 12px; }
  .lic-card .row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .lic-card .row > :first-child { grid-column: 1 / -1; }
  .lic-plazo { margin-left: 0; flex-basis: 100%; }

  /* Gemini */
  .composer-bar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .composer-bar::-webkit-scrollbar { display: none; }
  .composer-bar > * { flex: none; }
  .composer-bar .spacer { flex: 1 0 8px; }
  .model-pill { max-width: 160px; min-width: 0; }
  .note-long { display: none; }
  .note-short, .note-more { display: inline; }
  .chat-note.open .note-long { display: inline; }
  .chat-note.open .note-short { display: none; }
  .note-more { min-height: 0; margin: -14px 0; padding: 14px 8px; font-size: 12px; font-weight: 600; color: var(--acc); }
}
@media (min-width: 600px) { .lic-toggle { display: none; } }
@media (prefers-reduced-motion: reduce) { .modal { animation: none; } }
body.drawer-open .pwa-banner, body.drawer-open .update-bar { display: none; }

/* ===== Mi cuenta (claves personales) ===== */
.secret-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.secret-head h2 { margin: 0; }
.secret form { max-width: 520px; }
.secret .row { margin-top: 10px; }
.profile { display: flex; align-items: center; gap: 14px; min-width: 0; }
.profile h2, .profile p { margin: 0; overflow-wrap: anywhere; }
.avatar { border-radius: 50%; flex: none; }
#view > section.card, #view > div > section.card { margin-bottom: 16px; }

/* Correo con formato (iframe sin scripts) */
.mail-frame { display: block; width: 100%; min-height: 240px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.mail-content { margin-top: 4px; }
.mail-subject { overflow-wrap: anywhere; }
@media (max-width: 599px) {
  .mail-view { padding: 0 12px 16px; } .mail-view .toolbar { margin: 0 -12px; } .mail-frame { border-radius: 6px; }
  .mail-subject { font-size: 19px; margin: 14px 0; }
  .mail-meta { flex-wrap: wrap; row-gap: 4px; }
  .mail-meta > div { min-width: 0; flex: 1; overflow-wrap: anywhere; }
  .mail-meta .mail-date { margin-left: 52px; flex-basis: 100%; font-size: 13px; color: var(--muted); }
}

/* ===== Manos libres (voz) ===== */
body.voice-open { overflow: hidden; }
.voice { position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 18px; padding: calc(16px + env(safe-area-inset-top, 0px)) 20px calc(20px + env(safe-area-inset-bottom, 0px)); background: #0f1720; color: #fff; text-align: center; overflow-y: auto; }
.voice-top { display: flex; align-items: center; justify-content: space-between; width: 100%; max-width: 560px; font-size: 18px; }
.voice-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 10px 20px; font: inherit; font-size: 16px; color: #fff; background: #1f2d3a; border: 1px solid #3a4b5b; border-radius: 14px; cursor: pointer; }
.voice-btn:active { background: #2b3d4e; }
.voice-close { background: #7a1f1a; border-color: #b3261e; }
.voice-status { margin-top: 4vh; min-height: 2.6em; font-size: clamp(20px, 5vw, 28px); font-weight: 600; max-width: 560px; }
.voice-orb { position: relative; display: grid; place-items: center; width: min(52vw, 220px); height: min(52vw, 220px); border: 0; border-radius: 50%; color: #fff; background: #3b82f6; cursor: pointer; box-shadow: 0 0 0 0 rgba(59, 130, 246, .5); }
.voice-orb .icon { width: 42%; height: 42%; }
.voice[data-state='listening'] .voice-orb { background: #16a34a; animation: voice-pulse 1.6s ease-out infinite; }
.voice[data-state='thinking'] .voice-orb { background: #a16207; animation: voice-spin 1.2s linear infinite; border: 6px dashed rgba(255, 255, 255, .55); }
.voice[data-state='speaking'] .voice-orb { background: #2563eb; animation: voice-pulse 1s ease-out infinite; }
.voice[data-state='paused'] .voice-orb, .voice[data-state='idle'] .voice-orb { background: #475569; }
@keyframes voice-pulse { 0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, .45); } 100% { box-shadow: 0 0 0 36px rgba(255, 255, 255, 0); } }
@keyframes voice-spin { to { transform: rotate(360deg); } }
.voice-you { min-height: 1.6em; margin: 0; max-width: 560px; font-size: 18px; color: #93c5fd; overflow-wrap: anywhere; }
.voice-ans { margin: 0; max-width: 560px; max-height: 22vh; overflow-y: auto; font-size: 17px; line-height: 1.5; color: #e2e8f0; overflow-wrap: anywhere; }
.voice-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: auto; }
.voice-hint { margin: 0; max-width: 520px; font-size: 13px; color: #94a3b8; }
@media (max-height: 560px) { .voice { gap: 8px; } .voice-orb { width: 110px; height: 110px; } .voice-status { margin-top: 0; } }
@media (prefers-reduced-motion: reduce) { .voice[data-state] .voice-orb { animation: none; } }

/* ===== WherEX ===== */
.wx .home-head .row { flex-wrap: wrap; }
.wx textarea[aria-label='Configuración de la API de WherEX'] { width: 100%; font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; min-height: 180px; }
.modal-body h3 { margin: 14px 0 6px; font-size: 16px; }

/* ===== SII: emisión ===== */
.doc-item { align-items: center; gap: 8px; }
.doc-item input:not([type=checkbox]) { flex: 1 1 110px; min-width: 0; }
.doc-item input:first-child { flex: 3 1 200px; }

.msg.warn { background: var(--warn-bg); border-left: 4px solid var(--danger); }

/* ===== Diseño más claro y amable (v1.8) ===== */
body { font-size: 16px; line-height: 1.55; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.section-title { margin: 22px 0 10px; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.section-title.flat { margin: 0; }
hr.soft { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

/* Menú: sin título para Inicio y más aire */
.nav-title { padding: 18px 12px 6px; }
.nav-item { padding: 10px 12px; font-size: 15px; }

/* Aviso informativo (reemplaza párrafos largos de advertencia) */
.callout.info { padding: 10px 14px; border-radius: 10px; background: var(--brand-soft); border-left: 4px solid var(--brand); font-size: 14px; line-height: 1.5; color: var(--text); }

/* Inicio */
.greet h2 { margin: 0; font-size: 28px; font-weight: 600; }
.greet p { margin: 2px 0 0; font-size: 15px; }
.attn-list { display: grid; gap: 10px; }
.attn { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--brand); border-radius: 12px; }
.attn.warn { border-left-color: #f4b400; background: var(--warn-bg); }
.attn.ok { border-left-color: #188038; background: var(--ok-bg); }
.attn-ico { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--brand-soft); color: var(--brand); }
.attn-text { flex: 1; min-width: 0; font-size: 16px; }
.actions { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.action { display: grid; gap: 6px; align-content: start; padding: 18px; text-align: left; font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 16px; cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; }
.action strong { font-size: 18px; }
.action .muted { font-size: 14px; line-height: 1.45; }
.action-ico { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--brand-soft); color: var(--brand); margin-bottom: 4px; }
.action-ico .icon { width: 26px; height: 26px; }
@media (hover: hover) { .action:hover { border-color: var(--brand); box-shadow: 0 6px 18px rgba(15, 30, 45, .08); transform: translateY(-2px); } }
.action:active { background: var(--brand-soft); }
.checklist { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.checklist li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist .check-text { flex: 1; min-width: 0; }
.checklist .done .check-text { color: var(--muted); text-decoration: line-through; }
.check-dot { display: grid; place-items: center; width: 26px; height: 26px; flex: none; border-radius: 50%; border: 2px solid var(--line); font-size: 14px; font-weight: 700; }
.checklist .done .check-dot { background: var(--brand); border-color: var(--brand); color: #fff; }
.admin-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding-top: 6px; }

/* Pasos plegables (SII) */
.step { background: var(--card); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 12px; overflow: hidden; }
.step > summary { display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; list-style: none; font-weight: 600; min-height: 56px; }
.step > summary::-webkit-details-marker { display: none; }
.step > summary::after { content: '▾'; margin-left: auto; color: var(--muted); transition: transform .15s; }
.step[open] > summary::after { transform: rotate(180deg); }
.step[open] > summary { border-bottom: 1px solid var(--line); }
.step-n { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--line); color: var(--text); font-size: 14px; }
.step-n.ok { background: var(--brand); color: #fff; }
.step-n.danger { background: var(--danger); color: #fff; }
.step-title { flex: 0 1 auto; font-size: 16px; }
.step > summary .badge { margin-left: 6px; }
.step-body { padding: 16px; display: grid; gap: 12px; }
.step-body .card { border: 0; padding: 0; background: none; box-shadow: none; }
.step-body h3 { margin: 10px 0 4px; }

/* Selector de archivo */
.file-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 12px; border: 2px dashed var(--line); border-radius: 12px; background: var(--bg); }
.file-name { overflow-wrap: anywhere; font-size: 14px; }

@media (max-width: 599px) {
  .greet h2 { font-size: 24px; }
  .actions { grid-template-columns: 1fr; gap: 10px; }
  .action { grid-template-columns: 48px 1fr; align-items: center; column-gap: 14px; padding: 14px; }
  .action-ico { grid-row: 1 / span 2; margin: 0; }
  .attn { flex-wrap: wrap; }
  .attn .btn { width: 100%; }
  .step > summary { flex-wrap: wrap; }
}
