/* Nexo · sistema visual. Tokens primero, luego estructura, componentes y vistas. */
:root {
  --bg: #f4f5fb; --surface: #ffffff; --surface-2: #f1f2f9; --border: #e4e6f0;
  --text: #171a2e; --muted: #6b7190; --faint: #9aa0bb;
  --accent: #5b4be8; --accent-strong: #4a3bd4; --accent-soft: #ecebfd; --on-accent: #ffffff;
  --pos: #0f9d6b; --neg: #d94452; --warn: #b7791f; --pos-soft: #e3f6ee; --neg-soft: #fdeaec; --warn-soft: #fdf3dc;
  --side: #0f1430; --side-text: #aab0d0; --side-active: #ffffff; --side-hover: rgba(255, 255, 255, .07);
  --shadow: 0 1px 2px rgba(20, 24, 60, .05), 0 8px 24px -12px rgba(20, 24, 60, .12);
  --shadow-pop: 0 18px 50px -12px rgba(15, 20, 48, .35);
  --radius: 16px; --radius-sm: 10px;
  --font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b0e1a; --surface: #141829; --surface-2: #1b2036; --border: #262c47;
  --text: #eceefa; --muted: #9399b8; --faint: #666c8c;
  --accent: #8a7cff; --accent-strong: #a094ff; --accent-soft: #24234a; --on-accent: #0b0e1a;
  --pos: #3ecf98; --neg: #ff7582; --warn: #e6b450; --pos-soft: #12301f; --neg-soft: #3a1a20; --warn-soft: #33290f;
  --side: #080a14; --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-pop: 0 18px 50px -12px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 28px; line-height: 1.15; letter-spacing: -.02em; font-weight: 700; }
h2 { font-size: 20px; letter-spacing: -.01em; }
h3 { font-size: 15px; font-weight: 650; }
h4 { font-size: 13px; margin-bottom: 6px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; opacity: .45; }
small { font-size: 12.5px; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 13px; }
kbd { font: 11px var(--font); color: var(--faint); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
.ic { flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .pos { color: var(--pos); } .neg { color: var(--neg); }
.pad { padding: 14px; } .spacer { flex: 1; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .12em; color: var(--accent); text-transform: uppercase; }

/* ---------- Estructura ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100dvh; }
.sidebar { background: var(--side); color: var(--side-text); padding: 22px 14px 16px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100dvh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: #fff; padding: 0 8px; letter-spacing: -.01em; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 16px; color: #fff; background: linear-gradient(135deg, #7c6cff, #4a3bd4); }
.brand-mark.big { width: 48px; height: 48px; font-size: 22px; border-radius: 14px; }
#side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
#side-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; font-weight: 550; font-size: 14px; transition: background .15s, color .15s; }
#side-nav a:hover { background: var(--side-hover); color: #fff; }
#side-nav a.active { background: var(--accent); color: #fff; }
:root[data-theme="dark"] #side-nav a.active { background: #5b4be8; }
.nav-spacer { flex: 1; }
.sidebar-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 0 10px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #3ecf98; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 12px 32px; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid transparent; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.search-wrap, .quick-wrap { position: relative; }
.search-wrap { flex: 1; max-width: 460px; }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0 12px; height: 40px; color: var(--muted); }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--text); }
.search.small { height: 34px; max-width: 220px; }
#search-icon { display: grid; }
.view { padding: 12px 32px 64px; width: 100%; max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.bottom-nav, .mobile-only { display: none; }

.popover { position: absolute; top: calc(100% + 8px); z-index: 40; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-pop); padding: 6px; max-height: 70vh; overflow: auto; }
#search-results { left: 0; right: 0; }
#quick-menu { right: 0; width: 250px; }
.popover button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 9px; text-align: left; color: var(--muted); }
.popover button:hover { background: var(--surface-2); color: var(--text); }
.popover button span { display: flex; flex-direction: column; color: var(--text); min-width: 0; }
.popover button strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.popover button small { color: var(--muted); }

/* ---------- Componentes ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 40px; padding: 0 16px; border-radius: 11px; font-weight: 600; font-size: 14px; white-space: nowrap; border: 1px solid transparent; transition: background .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-strong); }
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.ghost { border-color: var(--border); background: var(--surface); }
.btn.ghost:hover, .btn.soft:hover { filter: brightness(.97); }
.btn.danger { color: var(--neg); }
.btn.small { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.btn.full { width: 100%; }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 10px; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.link { color: var(--accent); font-size: 13px; font-weight: 600; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.danger { background: var(--neg-soft); color: var(--neg); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.tag { font-size: 12px; color: var(--accent); font-weight: 600; }

.page-head, .hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-top: 8px; }
.page-head > div:first-child, .hero > div { display: flex; flex-direction: column; gap: 4px; }
.page-actions, .inline-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hero p { color: var(--muted); margin-top: 4px; }
.hero h1 { font-size: 32px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 600; font-size: 13px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.toolbar .search { flex: 1; max-width: 420px; }
.tabs { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 2px; max-width: 100%; overflow-x: auto; }
.tabs a { padding: 7px 14px; border-radius: 9px; font-weight: 600; font-size: 13.5px; color: var(--muted); white-space: nowrap; }
.tabs a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.stepper { display: inline-flex; align-items: center; gap: 2px; }
.stepper-label { font-weight: 650; padding: 6px 10px; border-radius: 9px; min-width: 150px; text-align: center; }
.stepper-label:hover { background: var(--surface-2); }
select { height: 36px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); padding: 0 10px; max-width: 100%; }

.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 14px; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.home-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.home-grid .span-2 { grid-column: span 2; }
.home-grid .span-3 { grid-column: 1 / -1; }
.chat-layout { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; min-height: 32px; }
.card-head h3 { flex: 1; }
.card.cta { flex-direction: row; align-items: center; justify-content: space-between; gap: 16px; background: linear-gradient(120deg, var(--accent-soft), var(--surface)); }
.card.note { cursor: pointer; position: relative; gap: 8px; transition: transform .12s, border-color .12s; }
.card.note:hover { transform: translateY(-2px); border-color: var(--accent); }
.card.note p { color: var(--muted); font-size: 14px; white-space: pre-line; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; }
.card.note footer { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: auto; }
.pin { position: absolute; top: 14px; right: 14px; color: var(--accent); }
blockquote { margin: 0; padding-left: 10px; border-left: 3px solid var(--accent-soft); color: var(--muted); font-style: italic; font-size: 13.5px; }
.stars { color: #f5a623; letter-spacing: 1px; } .stars span { color: var(--border); }
.prose { white-space: pre-line; margin-bottom: 8px; }
ul.plain { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; display: flex; flex-direction: column; gap: 4px; }

.row { display: flex; align-items: center; gap: 12px; padding: 9px 8px; margin: 0 -8px; border-radius: 10px; cursor: pointer; min-width: 0; }
.row:hover { background: var(--surface-2); }
.row.tall { align-items: flex-start; padding: 12px 8px; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-main strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.tall .row-main small { white-space: normal; }
.row-main small { color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; overflow: hidden; }
a.row { color: inherit; }
.row.static { cursor: default; }
.row.static:hover { background: none; }
code.block { display: block; padding: 8px 10px; overflow-wrap: anywhere; user-select: all; }
.row.done strong { text-decoration: line-through; color: var(--faint); font-weight: 500; }
.row input[type="checkbox"] { appearance: none; -webkit-appearance: none; width: 20px; height: 20px; border-radius: 7px; border: 2px solid var(--faint); flex: none; cursor: pointer; display: grid; place-items: center; margin: 0; }
.row input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
.row input[type="checkbox"]:checked::after { content: ""; width: 9px; height: 5px; border-left: 2px solid var(--on-accent); border-bottom: 2px solid var(--on-accent); transform: rotate(-45deg) translate(1px, -1px); }
.prio { width: 8px; height: 8px; border-radius: 50%; background: var(--neg); flex: none; }
.time { font-size: 12.5px; font-weight: 650; color: var(--accent); min-width: 58px; }
.mood { font-size: 20px; width: 28px; text-align: center; flex: none; color: var(--faint); }
.cat-dot { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none; color: #fff; background: var(--c, var(--accent)); }
.cat-dot.plain { background: var(--surface-2); color: var(--muted); }
.group-label { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 14px 0 4px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.group-label.danger { color: var(--neg); }
.group-label.as-button { width: 100%; margin-top: 8px; }
.group-label span { font-weight: 600; letter-spacing: 0; text-transform: none; }
.empty { text-align: center; padding: 22px 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty p { color: var(--muted); font-size: 13.5px; max-width: 320px; }
.empty .btn { margin-top: 8px; }
.progress { height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 4px 0; }
.progress span { display: block; height: 100%; width: var(--w, 0%); background: var(--c, var(--accent)); border-radius: 99px; transition: width .3s; }
.progress.over span { background: var(--neg); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); }
.kpi small, .kpi-inline small { color: var(--muted); font-weight: 600; }
.kpi strong { font-size: 24px; letter-spacing: -.02em; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi em { font-style: normal; font-size: 12px; }
.kpi-inline { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 8px; }
.kpi-inline > div { display: flex; flex-direction: column; }
.kpi-inline strong { font-size: 20px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
label.btn { cursor: pointer; }
.health-hero { flex-direction: row; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.big-number { font-size: 44px; font-weight: 750; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.big-number span { font-size: 18px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.chip.static { cursor: default; color: var(--muted); } .chip.static strong { color: var(--text); }
.week-row { display: flex; flex-direction: column; gap: 2px; padding: 5px 0; font-size: 14px; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.tile { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile small { color: var(--muted); } .tile strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge.big { padding: 5px 12px; font-size: 13px; }
.badge.ok { background: var(--pos-soft); color: var(--pos); }
.divider { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 10px; }
.energy { width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; flex: none; grid-auto-flow: column; }
.energy small { font-size: 9px; opacity: .7; }
.clamp { display: -webkit-box !important; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal !important; }

.shortcuts { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.shortcut { flex: 1; min-width: 86px; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 8px; border: 1px solid var(--border); border-radius: 14px; font-weight: 600; font-size: 13px; transition: border-color .12s, transform .12s; }
.shortcut:hover { border-color: var(--accent); transform: translateY(-2px); }
.brand-tile { width: 48px; height: 48px; border-radius: 14px; background: #fff; display: grid; place-items: center; box-shadow: 0 1px 3px rgba(20, 24, 60, .18); }

/* ---------- Resumen y consejos ---------- */
.summary { flex-direction: row; gap: 28px; flex-wrap: wrap; }
.summary-main { flex: 3; min-width: 280px; display: flex; flex-direction: column; gap: 10px; }
.summary-tips { flex: 2; min-width: 260px; display: flex; flex-direction: column; gap: 6px; }
.summary-lines { color: var(--text) !important; font-size: 15px !important; }
.capture { display: flex; flex-direction: column; gap: 6px; margin-top: auto; }
.capture .search { height: 44px; }
.tip { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 10px; font-size: 13.5px; background: var(--surface-2); }
.tip:hover { filter: brightness(.97); }
.tip-icon { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.tip.warn .tip-icon { background: var(--warn-soft); color: var(--warn); }
.tip.good .tip-icon { background: var(--pos-soft); color: var(--pos); }
button.link { align-self: flex-start; padding: 4px 0; }
.brand-tile.letter { background: var(--c); color: #fff; font-weight: 800; font-size: 20px; }
.brand-tile.plus { background: var(--surface-2); color: var(--muted); box-shadow: none; }
.shortcut.add { border-style: dashed; color: var(--muted); }
.shortcut.editing { border-color: var(--accent); }
.icon-btn.on { background: var(--accent-soft); color: var(--accent); }

/* ---------- Páginas legales ---------- */
.legal { max-width: 760px; padding-top: 32px; }
.legal .card { gap: 10px; }
.legal ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.brand-link { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }

/* ---------- Gráficas ---------- */
.chart { display: block; overflow: visible; }
.chart .bar { fill: var(--accent); opacity: .35; } .chart .bar.hl { opacity: 1; } .chart .bar.zero { fill: var(--border); opacity: 1; }
.chart .axis { fill: var(--faint); font-size: 10px; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.chart .area { fill: var(--accent); opacity: .1; }
.chart circle.dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart-empty { color: var(--muted); font-size: 13.5px; padding: 30px 0; text-align: center; }
.donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut { flex: none; } .donut-empty { stroke: var(--surface-2); }
.donut-text { fill: var(--text); font-size: 13px; font-weight: 700; }
.legend { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 7px; }
.legend-row { display: grid; grid-template-columns: 10px 1fr auto auto; gap: 10px; align-items: center; font-size: 13.5px; }
.legend-row .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.legend-row strong { font-variant-numeric: tabular-nums; min-width: 78px; text-align: right; }

/* ---------- Hábitos ---------- */
.habit-chips, .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.habit-chips { margin-bottom: 8px; }
.habit-chip, .chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: 13.5px; }
.chip { color: var(--muted); }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.habit-chip.on { background: var(--pos-soft); border-color: transparent; color: var(--pos); }
.habit-chip em { font-style: normal; font-size: 12px; color: var(--muted); }
.habit-icon { display: grid; place-items: center; width: 18px; }
.table-scroll { overflow-x: auto; margin: 0 -6px; }
.habit-table { width: 100%; border-collapse: collapse; }
.habit-table th, .habit-table td { padding: 5px 4px; text-align: center; }
.habit-table thead th { font-size: 12px; color: var(--muted); font-weight: 700; }
.habit-table thead th small { display: block; font-weight: 500; color: var(--faint); }
.habit-table thead th.today, .habit-table thead th.today small { color: var(--accent); }
.habit-table tbody th { text-align: left; min-width: 150px; }
.habit-name { display: flex; align-items: center; gap: 8px; font-weight: 600; text-align: left; padding: 6px; border-radius: 8px; }
.habit-name:hover { background: var(--surface-2); }
.habit-cell { width: 36px; height: 36px; border-radius: 11px; background: var(--surface-2); display: inline-grid; place-items: center; color: #fff; transition: transform .1s, background .15s; }
.habit-cell:not(:disabled):hover { transform: scale(1.08); }
.habit-cell.on { background: var(--pos); }
.habit-stat { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }

/* ---------- Calendario ---------- */
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; padding: 6px 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-day { min-height: 92px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); padding: 6px; display: flex; flex-direction: column; gap: 3px; text-align: left; align-items: stretch; overflow: hidden; }
.cal-day:hover { border-color: var(--accent); }
.cal-day.out { opacity: .45; }
.cal-day.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.cal-num { font-size: 12.5px; font-weight: 700; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.cal-day.today .cal-num { background: var(--accent); color: var(--on-accent); }
.cal-chip { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--accent-soft); color: var(--accent); }
.cal-chip.task { background: var(--surface-2); color: var(--text); }
.cal-chip.done { background: var(--surface-2); color: var(--faint); text-decoration: line-through; }
.cal-chip.gevent { background: var(--pos-soft); color: var(--pos); }
.cal-chip.deadline { background: var(--warn-soft); color: var(--warn); }
.cal-more { font-size: 11px; color: var(--muted); padding-left: 4px; }
.cal-dots { display: none; gap: 3px; justify-content: center; margin-top: auto; }
.cal-dots i, .cal-mark { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }
.cal-mark { width: 8px; height: 8px; }
.cal-dots i.task, .cal-mark.task { background: var(--muted); } .cal-dots i.done, .cal-mark.done { background: var(--border); } .cal-dots i.deadline, .cal-mark.deadline { background: var(--warn); } .cal-dots i.gevent, .cal-mark.gevent { background: var(--pos); }

/* ---------- Proyectos ---------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(180px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.board-col { background: var(--surface-2); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.board-title { display: flex; justify-content: space-between; font-weight: 700; font-size: 13px; padding: 4px 6px; }
.board-title span { color: var(--muted); font-weight: 600; }
.board-title.active { color: var(--accent); } .board-title.done { color: var(--pos); }
.board-empty { text-align: center; color: var(--faint); padding: 8px; }
.board-add { display: flex; align-items: center; gap: 6px; justify-content: center; padding: 8px; border-radius: 10px; color: var(--muted); font-size: 13px; font-weight: 600; }
.board-add:hover { background: var(--surface); color: var(--text); }
.project-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; box-shadow: var(--shadow); }
.project-card:hover { border-color: var(--accent); }
.project-card p { color: var(--muted); font-size: 13px; }
.project-card .progress { width: 100%; }

/* ---------- Asistente ---------- */
.card.chat { padding: 0; height: min(68vh, 640px); }
.chat-messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.chat-welcome { margin: auto; text-align: center; max-width: 340px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.chat-welcome p { color: var(--muted); }
.msg { display: flex; } .msg.user { justify-content: flex-end; }
.bubble { max-width: 78%; padding: 10px 14px; border-radius: 16px; background: var(--surface-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 5px; }
.msg.assistant .bubble { border-bottom-left-radius: 5px; }
.bubble small { display: block; margin-top: 6px; opacity: .7; }
.bubble.typing { color: var(--muted); }
.chat-compose { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.chat-compose textarea { flex: 1; resize: none; }

/* ---------- Formularios y modales ---------- */
input[type="text"], input[type="date"], input[type="time"], input[type="password"], input[type="file"], input:not([type]), textarea, .form select { width: 100%; min-height: 42px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); padding: 9px 12px; outline: 0; }
.search input { min-height: 0; padding: 0; border: 0; border-radius: 0; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input:focus { box-shadow: none; }
textarea { resize: vertical; line-height: 1.5; }
.form { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { grid-column: span 2; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.half { grid-column: span 1; }
.field label { font-size: 13px; font-weight: 650; color: var(--muted); }
.hint { color: var(--faint); }
.check-field { grid-column: span 2; display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.check-field input { width: 18px; height: 18px; accent-color: var(--accent); }
.segmented { display: flex; background: var(--surface-2); border-radius: 11px; padding: 4px; gap: 2px; min-height: 42px; }
.segmented label { flex: 1; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: grid; place-items: center; height: 100%; min-height: 34px; border-radius: 8px; font-weight: 600; font-size: 13.5px; color: var(--muted); padding: 0 6px; }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }
.form-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.modal { border: 0; padding: 0; border-radius: 20px; background: var(--surface); color: var(--text); width: min(540px, calc(100vw - 24px)); max-height: min(calc(100vh - 32px), calc(100dvh - 32px)); box-shadow: var(--shadow-pop); }
.modal.wide { width: min(820px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(10, 12, 30, .55); backdrop-filter: blur(3px); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 6px; }
.modal[open] { display: flex; flex-direction: column; overflow: hidden; }
.modal-head { flex: none; }
.modal-body { padding: 12px 22px 0; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.modal-body::after { content: ""; flex: none; height: 10px; }
/* La barra de acciones se queda pegada abajo para que «Guardar» siempre esté a la vista. */
.modal-body .form-actions { position: sticky; bottom: 0; background: var(--surface); padding: 12px 0; margin-top: -4px; border-top: 1px solid var(--border); z-index: 1; }
.modal.login[open] { overflow: auto; }
.modal.login { width: min(400px, calc(100vw - 24px)); }
.modal.login form { padding: 28px; align-items: stretch; }
.bulk-head, .bulk-row { display: grid; grid-template-columns: 150px 110px 1fr 1.3fr; gap: 8px; }
.bulk-head { font-size: 12px; font-weight: 700; color: var(--muted); }
#bulk-rows { display: flex; flex-direction: column; gap: 8px; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 12px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 761px) { .mobile-only { display: none !important; } }

/* ---------- Tablet ---------- */
@media (max-width: 1100px) {
  .home-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chat-layout { grid-template-columns: 1fr; }
}

/* ---------- Móvil ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-only { display: inline-grid; }
  .brand.mobile-only { display: flex; padding: 0; }
  .topbar { padding: 10px 14px; gap: 8px; padding-top: calc(10px + env(safe-area-inset-top)); }
  .topbar kbd, #quick-button span { display: none; }
  #quick-button { width: 40px; padding: 0; }
  .topbar-actions { gap: 2px; }
  .view { padding: 8px 14px calc(96px + env(safe-area-inset-bottom)); gap: 14px; }
  h1, .hero h1 { font-size: 24px; }
  .grid.two, .grid.three, .home-grid { grid-template-columns: 1fr; }
  .home-grid .span-2, .home-grid .span-3 { grid-column: auto; }
  .summary { gap: 16px; }
  .page-actions .btn { height: 36px; padding: 0 12px; font-size: 13px; }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--border); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; font-size: 10.5px; font-weight: 600; color: var(--muted); border-radius: 10px; }
  .bottom-nav a.active { color: var(--accent); }
  .cal-day { min-height: 54px; align-items: center; padding: 4px 2px; }
  .cal-chip, .cal-more { display: none; }
  .cal-dots { display: flex; }
  .form-grid { grid-template-columns: 1fr; }
  .field, .field.half, .check-field { grid-column: span 1; }
  .bulk-head { display: none; }
  .bulk-row { grid-template-columns: 1fr 1fr; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
  .modal { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 20px 20px 0 0; max-height: 92dvh; }
  .modal.login { margin: auto; border-radius: 20px; width: calc(100vw - 24px); }
  .card.cta { flex-direction: column; align-items: stretch; }
  .board { grid-template-columns: repeat(5, 78vw); }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .habit-table tbody th { min-width: 110px; }
  .habit-cell { width: 32px; height: 32px; }
  .kpi strong { font-size: 20px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .big-number { font-size: 36px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
