/* Panel de Manu. Estilo «saludo editorial»: columna centrada de 12 columnas, paneles tonales,
   el color solo en los datos. Tres carriles (Personal, Familiar, Laboral), cada uno con su tinte.
   Sin fuentes ni recursos externos (la CSP los prohíbe). */
:root {
  --ground: #ffffff;
  --surface: #f6f6f4;
  --raised: #ffffff;
  --border: #e6e6e2;
  --rule: #efefec;
  --control: #d9d9d6;
  --active: #ececea;
  --text: #1f201d;
  --muted: #5f5f5c;
  --primary: #1f201d;
  --primary-ink: #ffffff;
  --accent: #1b6e66;
  --negative: #b42318;
  --rain: #2f6fa8;
  --pill-negative-bg: #fdecea; --pill-negative-ink: #7a1d14;

  /* Identidad de cada carril: tintes pálidos, no datos. */
  --lane-personal: #2f6fa8; --lane-personal-bg: #eef3f9;
  --lane-familia: #3d8a57;  --lane-familia-bg: #eef5ef;
  --lane-trabajo: #b0632a;  --lane-trabajo-bg: #f8f0e9;

  --radius-card: 22px; --radius-row: 14px; --radius-control: 999px;
  --gap: 16px; --pad: 20px; --control-height: 38px; --side: 224px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --shadow-float: 0 12px 32px rgba(0, 0, 0, .14);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0f0f0e; --surface: #1a1a19; --raised: #222221; --border: #2c2c2a; --rule: #262624; --control: #45453f; --active: #2a2a28;
    --text: #f2f2ef; --muted: #b0b0aa; --primary: #f2f2ef; --primary-ink: #111110; --accent: #5cc2b6; --negative: #f07a6a; --rain: #6eaee6;
    --pill-negative-bg: #3a1d19; --pill-negative-ink: #ffb4a8;
    --lane-personal: #79aee6; --lane-personal-bg: #1b222b;
    --lane-familia: #7cc493;  --lane-familia-bg: #1b251e;
    --lane-trabajo: #e3a06a;  --lane-trabajo-bg: #2a211a;
    --shadow-float: 0 12px 32px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #0f0f0e; --surface: #1a1a19; --raised: #222221; --border: #2c2c2a; --rule: #262624; --control: #45453f; --active: #2a2a28;
  --text: #f2f2ef; --muted: #b0b0aa; --primary: #f2f2ef; --primary-ink: #111110; --accent: #5cc2b6; --negative: #f07a6a; --rain: #6eaee6;
  --pill-negative-bg: #3a1d19; --pill-negative-ink: #ffb4a8;
  --lane-personal: #79aee6; --lane-personal-bg: #1b222b;
  --lane-familia: #7cc493;  --lane-familia-bg: #1b251e;
  --lane-trabajo: #e3a06a;  --lane-trabajo-bg: #2a211a;
  --shadow-float: 0 12px 32px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--text); font: 14px/1.5 var(--font); font-variant-numeric: tabular-nums; }
h1, h2, h3, p { margin: 0; }
ul, ol { list-style: none; margin: 0; padding: 0; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
code { font: 13px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace; background: var(--raised); border: 1px solid var(--border); padding: 2px 7px; border-radius: 6px; overflow-wrap: anywhere; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--primary); color: var(--primary-ink); padding: 8px 12px; border-radius: 8px; z-index: 20; }
.skip:focus { left: 8px; }

/* ---- marca de cada carril ---- */
.nav-mark { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; }
.nav-mark.lane-personal { background: var(--lane-personal); }
.nav-mark.lane-familia { background: var(--lane-familia); }
.nav-mark.lane-trabajo { background: var(--lane-trabajo); }
.nav-mark.big { width: 14px; height: 14px; margin-right: 14px; vertical-align: .18em; }

/* ---- armazón: barra lateral en el mismo fondo, lienzo a la derecha ---- */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; padding: 24px 12px 16px; border-right: 1px solid var(--rule); }
.who { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.who-name { font-weight: 600; font-size: 15px; line-height: 1.2; }
.who-scope { color: var(--muted); font-size: 12px; }
.search { position: relative; }
.search input { width: 100%; height: 34px; padding: 0 30px 0 12px; border-radius: 10px; border: 1px solid var(--control); background: var(--raised); }
.search input::placeholder { color: var(--muted); }
.search-key { position: absolute; right: 8px; top: 7px; font: 12px/18px var(--font); color: var(--muted); border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; }
.results { position: absolute; left: 0; top: calc(100% + 6px); width: min(440px, 80vw); background: var(--raised); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-float); max-height: 60vh; overflow: auto; z-index: 15; }
.results li { padding: 10px 14px; border-bottom: 1px solid var(--rule); }
.results li:last-child { border-bottom: 0; }
.results .path { font-weight: 600; overflow-wrap: anywhere; }
.results .snip { color: var(--muted); font-size: 13px; margin-top: 2px; }
.results .empty { padding: 14px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; border-radius: 8px; text-decoration: none; color: var(--muted); transition: background-color .12s ease, color .12s ease; }
.nav-item:hover { color: var(--text); background: var(--surface); }
.nav-item[aria-current="page"] { background: var(--active); color: var(--text); font-weight: 500; }
.nav-item .nav-mark:not([class*="lane-"]) { background: var(--text); }
.nav-group { color: var(--muted); font-size: 12px; padding: 22px 10px 6px; }
.badge { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--pill-negative-bg); color: var(--pill-negative-ink); font-size: 12px; line-height: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding: 0 8px; }
.sources { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: 12px; }
.src::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--control); margin-right: 6px; vertical-align: .15em; }
.src.ok::before { background: var(--accent); }
.side-tools { display: flex; align-items: center; gap: 2px; }
.side-tools #updated { margin-right: auto; }
.icon-btn { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; border: 0; background: transparent; cursor: pointer; color: var(--muted); transition: background-color .12s ease, color .12s ease; }
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
.link-btn { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.link-btn:hover { color: var(--text); }
.link-btn.danger:hover { color: var(--negative); }

/* ---- lienzo: columna centrada de 12 columnas ----
   1100 = 12 × 78.33 + 11 × 16. Filas: 12 · 8+4 · 4+4+4 · 4+8 · 12: cada borde interior cae en una línea de arriba (4 u 8). */
.canvas { min-width: 0; }
.grid { max-width: 1164px; margin: 0 auto; padding: 56px 32px 64px; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); align-items: start; }
.span-12 { grid-column: span 12; }
.span-8 { grid-column: span 8; }
.span-4 { grid-column: span 4; }
.stack { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }

/* ---- cabecera de la pantalla ---- */
.page-head { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; padding-bottom: 20px; }
.greet { font: 700 44px/1.08 var(--serif); letter-spacing: -.015em; }
.lede { margin-top: 10px; font-size: 16px; color: var(--muted); }
.lede .finding { color: var(--text); }
.composer { display: flex; flex-wrap: wrap; gap: 8px; }
.composer input[type="text"] { flex: 1 1 280px; }
.composer input, .composer select, .mini-form input { height: var(--control-height); padding: 0 16px; border-radius: var(--radius-control); border: 1px solid var(--control); background: var(--raised); min-width: 0; }
.composer input::placeholder, .mini-form input::placeholder { color: var(--muted); }
.btn-primary { height: var(--control-height); padding: 0 20px; border: 0; border-radius: var(--radius-control); background: var(--primary); color: var(--primary-ink); font-weight: 600; cursor: pointer; transition: transform .1s ease, opacity .12s ease; }
.btn-primary:hover { opacity: .88; }
.btn-primary:active { transform: scale(.97); }
.btn-ghost { flex: none; height: 32px; padding: 0 14px; border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--raised); cursor: pointer; font-size: 13px; transition: border-color .12s ease, transform .1s ease; }
.btn-ghost:hover { border-color: var(--text); }
.btn-ghost:active { transform: scale(.97); }

/* ---- paneles tonales ---- */
.panel { display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius-card); padding: var(--pad); min-width: 0; }
/* Las tarjetas de una fila acaban a la misma altura; lo que sobra queda abajo, tras el pie del panel. */
#view-dashboard { align-items: stretch; }
.p-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; min-height: 24px; }
.p-head h2 { font-size: 14px; font-weight: 600; }
.count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.p-extra { margin-left: auto; }
a.link { color: var(--text); font-size: 13px; text-decoration: none; border-radius: 6px; padding: 2px 4px; }
a.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.empty { color: var(--muted); padding: 12px 14px; border: 1px dashed var(--control); border-radius: var(--radius-row); }
.rows { display: flex; flex-direction: column; gap: 8px; }
.rows > li { background: var(--raised); border: 1px solid var(--border); border-radius: var(--radius-row); padding: 11px 14px; min-height: 48px; }
.mini-form { display: flex; gap: 8px; margin-top: 12px; }
.mini-form input { flex: 1; height: 34px; }
.mini-form .btn-ghost { height: 34px; }

/* ---- carriles: el tinte de cada pestaña ---- */
.lane-personal.panel { background: var(--lane-personal-bg); }
.lane-familia.panel { background: var(--lane-familia-bg); }
.lane-trabajo.panel { background: var(--lane-trabajo-bg); }
.lane .p-head .nav-mark { width: 10px; height: 10px; }
.lane-foot { margin-top: auto; padding-top: 12px; }

/* ---- pendientes ---- */
.task { display: flex; align-items: flex-start; gap: 12px; }
.check { flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%; border: 1.5px solid var(--control); background: var(--raised); cursor: pointer; display: grid; place-items: center; padding: 0; transition: border-color .12s ease, background-color .12s ease; }
.check svg { width: 12px; height: 12px; opacity: 0; color: var(--accent); transition: opacity .12s ease; }
.check:hover { border-color: var(--accent); }
.check:hover svg { opacity: 1; }
.check:active { background: var(--accent); }
.task-main { flex: 1; min-width: 0; }
.task-title { overflow-wrap: anywhere; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; color: var(--muted); font-size: 12px; margin-top: 2px; }
.task-meta .late { color: var(--negative); font-weight: 600; }
.task-meta .today { color: var(--text); font-weight: 600; }
.move { background: none; border: 0; color: var(--muted); font-size: 12px; padding: 0; cursor: pointer; }
.move:hover { color: var(--text); }

/* ---- agenda de hoy ---- */
.timeline { display: flex; flex-direction: column; }
.timeline .time { width: 88px; flex: none; font-variant-numeric: tabular-nums; color: var(--muted); }
.ev { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.ev:last-child { border-bottom: 0; }
.ev .time { color: var(--text); font-weight: 600; }
.ev-title { font-size: 15px; overflow-wrap: anywhere; }
.ev-meta { color: var(--muted); font-size: 12px; }
.ev.past { opacity: .5; }
.ev.live .ev-title { font-weight: 600; }
.ev.live .time { color: var(--accent); }
.now { display: flex; align-items: center; gap: 12px; padding: 4px 0; }
.now .time { color: var(--accent); font-weight: 600; font-size: 12px; }
.now-line { flex: 1; height: 2px; border-radius: 2px; background: var(--accent); }

/* ---- el tiempo ---- */
.wx-now { display: flex; align-items: center; gap: 16px; }
.wx-temp { font-size: 40px; line-height: 1; font-weight: 400; letter-spacing: -.02em; }
.wx-cond { display: flex; flex-direction: column; font-size: 14px; }
.wx-tip { margin-top: 14px; padding: 8px 12px; background: var(--raised); border-radius: 12px; font-size: 13px; }
.wx-hours { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; margin-top: 16px; text-align: center; font-size: 12px; }
.wx-h { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.wx-bar { width: 6px; height: 40px; border-radius: 3px; background: var(--border); position: relative; overflow: hidden; }
.wx-bar i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--rain); }
.wx p.small { margin-top: auto; padding-top: 10px; }

/* ---- compras y correo ---- */
.buy { display: flex; align-items: center; gap: 12px; }
.buy-main { flex: 1; min-width: 0; }
.buy-shop { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-top { display: flex; gap: 8px; align-items: baseline; }
.mail-from { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-when { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mail-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.chip { flex: none; font-size: 12px; line-height: 20px; padding: 0 8px; border-radius: 999px; background: var(--active); color: var(--muted); white-space: nowrap; }

/* ---- próximos días ---- */
.days { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 32px; }
.day { display: grid; grid-template-columns: 11em minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.day-label { font-weight: 600; }
.day-ev { display: flex; gap: 10px; }
.day-ev .time { color: var(--muted); min-width: 4.6em; }

/* ---- notas ---- */
.note { display: flex; align-items: baseline; gap: 12px; }
.note-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tip p + p { margin-top: 10px; }

/* ---- avisos ---- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--primary); color: var(--primary-ink); padding: 10px 18px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow-float); max-width: calc(100vw - 32px); z-index: 30; }

/* ---- acceso ---- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login { width: 100%; max-width: 340px; display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center; }
.login h1 { font: 700 32px var(--serif); }
.login form { width: 100%; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.login label { color: var(--muted); font-size: 14px; }
.login input { height: 42px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--control); background: var(--raised); }
.login .btn-primary { height: 42px; margin-top: 4px; }
.login-error { color: var(--negative); font-size: 14px; }

@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } .icon-btn.spin svg { animation: none; } }

/* ---- tableta: las filas de tres se quedan en dos columnas ---- */
@media (max-width: 1180px) {
  .grid { grid-template-columns: repeat(6, minmax(0, 1fr)); padding: 40px 24px 56px; }
  .span-12, .span-8 { grid-column: span 6; }
  .span-4 { grid-column: span 3; }
  .lane { grid-column: span 2; }
  .days { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1000px) {
  .lane { grid-column: span 6; }
  .wx, .stack.span-4 { grid-column: span 6; }
}

/* ---- móvil: la barra lateral se pliega en una cabecera con las cuatro secciones ---- */
@media (max-width: 760px) {
  .shell { display: block; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--rule); }
  .sources, #updated, .search-key, .nav-group { display: none; }
  /* las cuatro secciones, en una fila bajo la cabecera (sin barra fija que tape nada) */
  .nav { order: 4; flex-basis: 100%; flex-direction: row; gap: 4px; margin: 2px -4px 0; }
  .nav-item { flex: 1; justify-content: center; gap: 6px; height: 40px; padding: 0 6px; font-size: 13px; }
  .badge { margin-left: 0; }
  .side-foot { margin: 0 0 0 auto; padding: 0; }
  .search { order: 3; flex-basis: 100%; }
  .search input { height: 40px; font-size: 16px; }
  .grid { display: flex; flex-direction: column; align-items: stretch; padding: 24px 16px 48px; }
  .greet { font-size: 28px; }
  .lede { font-size: 15px; }
  .composer input, .composer select, .mini-form input { font-size: 16px; height: 44px; }
  .composer input[type="date"] { flex: 1 1 140px; }
  .btn-primary { height: 44px; }
  .day { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .toast { bottom: 24px; }
}
.panel > .mini-form:last-child { margin-top: auto; padding-top: 12px; }

/* ---- ajustes ---- */
.nav-settings { margin-top: 14px; }
.settings-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-weight: 500; }
.field input[type="time"], .field input[type="text"], .field input[type="password"], .field select {
  height: var(--control-height); padding: 0 14px; border-radius: 10px; border: 1px solid var(--control); background: var(--raised); max-width: 360px; }
.field-pair { display: flex; flex-wrap: wrap; gap: 12px; }
.field-pair .field { flex: 1 1 140px; }
.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch { appearance: none; -webkit-appearance: none; flex: none; width: 36px; height: 20px; margin: 0; border-radius: 999px; background: var(--control); position: relative; cursor: pointer; transition: background-color .15s ease; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--raised); transition: transform .15s ease; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(16px); }
.checks { display: flex; flex-direction: column; gap: 4px; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--raised); border: 1px solid var(--border); border-radius: 12px; cursor: pointer; }
.check-row input { width: 16px; height: 16px; accent-color: var(--accent); }
.form-foot { display: flex; justify-content: flex-end; }
.group-row { display: flex; align-items: center; gap: 12px; }
.row-actions { display: flex; gap: 6px; flex: none; }
.help { margin-top: 14px; }
.help summary { cursor: pointer; color: var(--muted); }
.help summary:hover { color: var(--text); }
.steps-list { list-style: decimal; padding-left: 20px; margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 760px) {
  .nav-settings { margin-top: 0; }
  .nav .nav-mark { display: none; }   /* cinco secciones en 390px: sin los puntos de color caben */
  .group-row { flex-wrap: wrap; }
  .field input[type="time"], .field input[type="text"], .field input[type="password"], .field select { max-width: none; font-size: 16px; height: 44px; }
}
.field textarea { padding: 10px 14px; border-radius: 12px; border: 1px solid var(--control); background: var(--raised); font: inherit; resize: vertical; max-width: 520px; }
.field select { max-width: 520px; }
.mail-bottom { display: flex; align-items: baseline; gap: 8px; }
.mail-bottom .mail-subject { flex: 1; min-width: 0; }
.hide-btn { flex: none; font-size: 12px; padding: 0 4px; opacity: 0; transition: opacity .12s ease; }
.mail:hover .hide-btn, .hide-btn:focus-visible { opacity: 1; }
@media (hover: none) { .hide-btn { opacity: 1; } }
