:root {
  --text: #1f2937;
  --muted: #6b7280;
  --panel: rgba(255, 255, 255, 0.8);
  --panel-border: rgba(255, 255, 255, 0.55);
  --accent: #2563eb;
  --danger: #dc2626;
  --default-bg:
    radial-gradient(ellipse at 15% 0%, #f3c98f 0%, transparent 55%),
    radial-gradient(ellipse at 85% 15%, #d0805e 0%, transparent 50%),
    linear-gradient(180deg, #9a6a4d 0%, #5b4038 45%, #2d2f3a 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background-color: #3b2a22;
  background-image: var(--bg, var(--default-bg));
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; border-radius: 0.6rem; padding: 0.6rem 1rem; background: var(--accent); color: #fff; font-weight: 600; }
button:hover { filter: brightness(1.08); }
button.secondary { background: #e5e7eb; color: var(--text); }
button.danger { background: #fee2e2; color: var(--danger); }
button.icon { background: transparent; color: var(--muted); padding: 0.1rem 0.5rem; font-size: 1.4rem; line-height: 1; }
input, select { width: 100%; margin-top: 0.35rem; padding: 0.65rem 0.75rem; border: 1px solid #d1d5db; border-radius: 0.55rem; background: #fff; color: var(--text); }
label { display: block; margin: 0.85rem 0; font-size: 0.9rem; font-weight: 600; }
.muted { color: var(--muted); font-size: 0.9rem; }
.error { min-height: 1.2em; margin: 0.4rem 0; color: var(--danger); font-size: 0.9rem; }
.panel { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(100%, 430px); padding: 2rem; }
.eyebrow { margin: 0 0 0.4rem; color: var(--accent); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.13em; }
.login h1 { margin: 0 0 0.5rem; font-size: 1.7rem; }
.login button[type='submit'] { width: 100%; margin-top: 0.5rem; }

/* Barra superior y buscador */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.6rem 1.25rem; color: #fff; background: rgba(40, 28, 22, 0.55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.brand { white-space: nowrap; flex-shrink: 0; display: flex; align-items: center; gap: 0.6rem; color: inherit; font-weight: 700; text-decoration: none; }
.sections { display: flex; flex-wrap: wrap; gap: 0.25rem; min-width: 0; margin-right: auto; margin-left: 1rem; }
.sections a { padding: 0.4rem 0.8rem; border-radius: 0.6rem; color: rgba(255, 255, 255, 0.85); font-weight: 600; text-decoration: none; }
.sections a:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.sections a[aria-current='page'] { background: rgba(255, 255, 255, 0.2); color: #fff; }
.brand img { border-radius: 7px; }
.actions { display: flex; gap: 0.4rem; }
.ghost { background: rgba(255, 255, 255, 0.14); color: #fff; padding: 0.45rem 0.9rem; }
.ghost[aria-pressed='true'] { background: #fff; color: var(--text); }
.search { display: flex; justify-content: center; padding: 1.6rem 1rem 1.2rem; }
.search input { max-width: 640px; margin: 0; padding: 0.9rem 1.3rem; border: 0; border-radius: 999px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); font-size: 1.05rem; }
.banner:empty { display: none; }
.banner { max-width: 640px; margin: 0 auto 1rem; padding: 0.6rem 1rem; border-radius: 0.6rem; background: #fff; }
.edit-hint { max-width: 760px; margin: -0.4rem auto 1rem; padding: 0.5rem 1rem; border-radius: 0.6rem; background: rgba(255, 255, 255, 0.9); text-align: center; font-size: 0.9rem; }

/* Bloques */
.board { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; max-width: 1500px; margin: 0 auto; padding: 0 1.5rem 3rem; align-items: start; }
.column { display: flex; flex-direction: column; gap: 1.25rem; min-height: 4rem; }
.widget { padding: 0.9rem 1.1rem 1.1rem; }
.widget-header { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.6rem; }
.widget-header h2 { flex: 1; margin: 0; font-size: 1.05rem; font-weight: 650; }
.widget-handle, .widget-tools { display: none; }
.widget-tools { gap: 0.2rem; }
.widget-tools button { background: transparent; color: var(--muted); padding: 0.15rem 0.5rem; font-size: 1.05rem; }
.widget-tools button:hover { background: rgba(0, 0, 0, 0.06); color: var(--text); }
.widget-handle { cursor: grab; color: var(--muted); padding: 0 0.2rem; user-select: none; }
.link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 0.6rem 0.3rem; min-height: 3rem; }
.empty { grid-column: 1 / -1; margin: 0.3rem 0; color: var(--muted); font-size: 0.9rem; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; padding: 0.4rem 0.2rem; border-radius: 10px; color: var(--text); text-decoration: none; }
.tile:hover { background: rgba(0, 0, 0, 0.05); }
.tile-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 12px; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18); overflow: hidden; }
.tile-icon img { width: 32px; height: 32px; object-fit: contain; }
.letter { display: grid; place-items: center; width: 100%; height: 100%; background: hsl(var(--hue, 210) 55% 48%); color: #fff; font-size: 1.3rem; font-weight: 700; }
.tile-label { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 90px; font-size: 0.78rem; line-height: 1.25; text-align: center; overflow-wrap: anywhere; }

/* Reloj */
.clock-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem 2.5rem; padding: 0.5rem 0 0.3rem; }
.clock { text-align: center; }
.clock-time { font-size: 2.2rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.clock-label { color: var(--muted); font-size: 0.9rem; }

/* Modo edición */
body.editing .widget-handle, body.editing .widget-tools { display: flex; }
body.editing .tile { outline: 1px dashed rgba(0, 0, 0, 0.18); cursor: grab; }
.dragging { opacity: 0.35; }
.add-widget { padding: 1rem; border: 2px dashed rgba(255, 255, 255, 0.7); background: rgba(255, 255, 255, 0.25); color: #fff; font-weight: 700; }

/* Diálogos */
dialog { width: min(94vw, 440px); border: 0; border-radius: 16px; padding: 1.3rem; color: var(--text); background: #fff; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; }
.dialog-heading h2 { margin: 0; font-size: 1.2rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.8rem; }
.dialog-actions .danger, .dialog-actions .secondary { margin-right: auto; }
.row { display: flex; gap: 0.5rem; align-items: center; }
.row select { margin: 0; }
.city-list { list-style: none; margin: 1rem 0; padding: 0; }
.city-list li { display: flex; align-items: center; justify-content: space-between; padding: 0.4rem 0; border-bottom: 1px solid #eee; }

@media (max-width: 900px) {
  .board { grid-template-columns: 1fr; padding: 0 1rem 2rem; }
  .topbar { padding: 0.5rem 1rem; }
  .brand span { display: none; }
  .sections { margin-left: 0.25rem; }
  .search { padding: 1rem; }
  .link-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
  .widget { padding: 0.8rem; }
}

/* Cuenta y recuperación */
a.ghost { border-radius: 0.6rem; font-weight: 600; text-decoration: none; }
a.ghost[aria-current='page'] { background: #fff; color: var(--text); }
.narrow { display: grid; gap: 1.25rem; max-width: 640px; margin: 1.5rem auto 3rem; padding: 0 1rem; }
.card { padding: 1.4rem 1.5rem; }
.card h2 { margin: 0 0 0.3rem; font-size: 1.2rem; }
.ok { color: #15803d; font-size: 0.9rem; }
.ok:empty { display: none; }
.warning { padding: 0.6rem 0.8rem; border-radius: 0.6rem; background: #fef3c7; font-weight: 600; }
.codes { columns: 2; margin: 0.8rem 0; padding-left: 1.6rem; font-family: ui-monospace, Menlo, monospace; font-size: 1.05rem; line-height: 1.8; }
.forgot { margin: 0.8rem 0 0; text-align: center; font-size: 0.9rem; }
.forgot a { color: var(--accent); }

/* Elegir icono */
.icon-field { margin: 0.9rem 0 0; padding: 0.7rem 0.9rem 0.9rem; border: 1px solid #e5e7eb; border-radius: 0.7rem; }
.icon-field legend { padding: 0 0.3rem; font-size: 0.9rem; font-weight: 600; }
.icon-row { display: flex; align-items: center; gap: 0.8rem; }
.icon-row select { margin: 0; }
.icon-field label { margin: 0.7rem 0 0; }
button.small { margin-top: 0.7rem; padding: 0.4rem 0.8rem; font-size: 0.85rem; }

/* Horarios */
.hz-wrap { max-width: 1240px; margin: 1.5rem auto 3rem; padding: 0 1rem; }
.hz-panel { --slot: 44px; --line: #e2e5ec; --line-hour: #c9ceda; --marcos: #b5651d; --marcos-soft: #fbeedd; --miguel: #1f6f78; --miguel-soft: #ddf0f1; padding: 1.2rem; background: rgba(255, 255, 255, 0.92); }
.hz-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 0.8rem 1.5rem; margin-bottom: 1rem; }
.hz-head h1 { margin: 0; font-size: 1.6rem; text-wrap: balance; }
.hz-head p { margin: 0.3rem 0 0; }
.hz-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; font-size: 0.85rem; }
.hz-chip { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 700; }
.hz-chip i { width: 14px; height: 14px; border-radius: 4px; }
.hz-chip.marcos i { background: var(--marcos); }
.hz-chip.miguel i { background: var(--miguel); }
.hz-chip small { font-weight: 400; color: var(--muted); }
.hz-kind { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--muted); }
.hz-kind i { width: 22px; height: 12px; border-radius: 3px; border: 1px solid var(--line-hour); }
.hz-kind.soft i { background: linear-gradient(90deg, var(--marcos-soft) 50%, var(--miguel-soft) 50%); }
.hz-kind.solid i { background: linear-gradient(90deg, var(--marcos) 50%, var(--miguel) 50%); }
.hz-scroller { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.hz-grid { display: grid; min-width: 900px; grid-template-columns: 56px repeat(10, minmax(0, 1fr)); }
.hz-corner { border-bottom: 1px solid var(--line-hour); }
.hz-day { grid-row: 1; padding: 0.7rem 0.25rem 0.2rem; border-left: 1px solid var(--line-hour); font-weight: 700; text-align: center; }
.hz-who { grid-row: 2; padding: 0.1rem 0.25rem 0.5rem; border-bottom: 1px solid var(--line-hour); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-align: center; text-transform: uppercase; }
.hz-who.marcos { color: var(--marcos); border-left: 1px solid var(--line-hour); }
.hz-who.miguel { color: var(--miguel); border-left: 1px dashed var(--line); }
.hz-time { grid-column: 1; padding-right: 0.5rem; color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; text-align: right; transform: translateY(-0.5rem); }
.hz-cell { border-top: 1px solid var(--line); }
.hz-cell.hour { border-top-color: var(--line-hour); }
.hz-cell.dl { border-left: 1px solid var(--line-hour); }
.hz-cell.dr { border-left: 1px dashed var(--line); }
.hz-empty { z-index: 1; align-self: center; color: var(--muted); font-size: 0.8rem; text-align: center; }
.hz-ev { z-index: 2; display: flex; flex-direction: column; justify-content: center; min-width: 0; margin: 2px 3px; padding: 0.25rem 0.45rem; overflow: hidden; border-left: 4px solid; border-radius: 7px; }
.hz-ev.marcos { background: var(--marcos-soft); border-color: var(--marcos); }
.hz-ev.miguel { background: var(--miguel-soft); border-color: var(--miguel); }
.hz-ev.deporte.marcos { background: var(--marcos); }
.hz-ev.deporte.miguel { background: var(--miguel); }
.hz-ev b { font-size: 0.8rem; line-height: 1.2; }
.hz-ev span { color: var(--muted); font-size: 0.72rem; line-height: 1.25; }
.hz-ev.deporte b, .hz-ev.deporte span { color: #fff; }
.hz-ev .h { font-variant-numeric: tabular-nums; }
.hz-ev.short .h { display: none; }

/* Passkeys */
.passkey-list { list-style: none; margin: 0.8rem 0; padding: 0; }
.passkey-list li { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; padding: 0.55rem 0; border-bottom: 1px solid #eee; }
.passkey-list li button { margin: 0; }
.passkey-list small { color: var(--muted); }
.row input { margin: 0; }

/* Finanzas */
.fin-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem 1rem; max-width: 1240px; margin: 1rem auto 0; padding: 0 1rem; }
.fin-tabs { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.fin-tabs button { background: rgba(255, 255, 255, 0.75); color: var(--text); padding: 0.45rem 0.85rem; }
.fin-tabs button[aria-current='page'] { background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18); }
.fin-tools { display: flex; align-items: center; gap: 1rem; color: #fff; font-size: 0.9rem; }
.switch { display: inline-flex; align-items: center; gap: 0.4rem; margin: 0; font-weight: 600; }
.switch input, label.check input { width: auto; margin: 0; }
label.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
.save-status { padding: 0.25rem 0.6rem; border-radius: 999px; background: rgba(0, 0, 0, 0.25); }
.save-status:empty { display: none; }
.save-status[data-kind='error'] { background: #fee2e2; color: var(--danger); }
.fin-content { display: grid; gap: 1.1rem; max-width: 1240px; margin: 1rem auto 3rem; padding: 0 1rem; }
.fin-content .intro { margin: 0; padding: 0.7rem 1rem; border-radius: 0.7rem; background: rgba(255, 255, 255, 0.9); color: var(--text); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.4rem; }
.card-head h2 { margin: 0; }
.card-head select { width: auto; margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.8rem; }
.kpis > .kpi { padding: 0.9rem 1rem; border-radius: 14px; background: var(--panel); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.kpis.small > .kpi { background: #f8fafc; box-shadow: none; }
.kpi { display: flex; flex-direction: column; gap: 0.15rem; }
.kpi-label { color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.kpi strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: 0.78rem; }
.badge { display: inline-block; margin-left: 0.45rem; padding: 0.05rem 0.45rem; border-radius: 999px; background: #ede9fe; color: #5b21b6; font-size: 0.72rem; font-weight: 700; vertical-align: middle; }
.badge.real { background: #dcfce7; color: #166534; }
.item-list { list-style: none; margin: 0.4rem 0 0; padding: 0; }
.item-list li { border-bottom: 1px solid #eef0f3; }
.item { display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem; width: 100%; padding: 0.6rem 0.3rem; border-radius: 0.5rem; background: transparent; color: var(--text); font-weight: 400; text-align: left; }
.item:hover { background: rgba(0, 0, 0, 0.04); filter: none; }
.item-name { font-weight: 650; }
.item-summary { color: var(--muted); font-size: 0.85rem; }
.history { display: flex; align-items: center; justify-content: space-between; padding: 0.4rem 0.3rem; }
.history button { margin: 0; }
.table-wrap { overflow-x: auto; }
.fin-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.fin-table th, .fin-table td { padding: 0.45rem 0.6rem; border-bottom: 1px solid #eef0f3; text-align: right; white-space: nowrap; }
.fin-table th:first-child, .fin-table td:first-child { text-align: left; }
.fin-table th { color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.fin-table tr.year td { font-weight: 650; }
.fin-table tr.month td { background: #f8fafc; font-size: 0.82rem; }
button.link { background: none; color: var(--accent); padding: 0; font-weight: 700; }
.compare { padding: 0.6rem 0.8rem; border-radius: 0.6rem; background: #ede9fe; }
details summary { cursor: pointer; margin: 0.8rem 0 0.4rem; font-weight: 600; }
.chart { width: 100%; height: auto; }
.chart .grid { stroke: #e5e7eb; }
.chart .axis { fill: var(--muted); font-size: 12px; }
.chart .today { stroke: #9ca3af; stroke-dasharray: 3 4; }
.chart .line { fill: none; stroke-width: 2.4; }
.chart .line.savings { stroke: #16a34a; }
.chart .line.debt { stroke: #dc2626; }
.chart .line.networth { stroke: #2563eb; }
.chart .line.needed { stroke: #ea580c; }
.chart .line.available { stroke: #0d9488; }
.chart .marker { fill: #fff; stroke: #2563eb; stroke-width: 3; }
.chart .zero { stroke: #9ca3af; }
.chart .line.sim { stroke-dasharray: 7 5; stroke-width: 2; opacity: 0.85; }
.legend { display: flex; gap: 1rem; font-size: 0.85rem; }
.legend span::before { content: ''; display: inline-block; width: 16px; height: 3px; margin-right: 0.35rem; vertical-align: middle; background: currentColor; }
.legend .savings { color: #16a34a; }
.legend .debt { color: #dc2626; }
.legend .networth { color: #2563eb; }
.legend .needed { color: #ea580c; }
.legend .available { color: #0d9488; }
.cross { margin: 0.6rem 0 0; padding: 0.6rem 0.8rem; border-radius: 0.6rem; background: #eff6ff; font-weight: 600; }
.small-print { margin: 0.4rem 0 0; font-size: 0.8rem; }
.legend { flex-wrap: wrap; }
.legend .sim { color: var(--muted); }
.legend .sim::before { background: repeating-linear-gradient(90deg, currentColor 0 5px, transparent 5px 9px); }
.actuals-form h3 { margin: 1rem 0 0; font-size: 1rem; }
.actuals-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 1rem; }
.actuals-form h3, .actuals-form .dialog-actions { grid-column: 1 / -1; }
.row-form { display: flex; flex-wrap: wrap; align-items: end; gap: 0.8rem; }
.row-form label { margin: 0; }
#item-dialog { width: min(94vw, 520px); }

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

.overdraft ul { margin: 0.4rem 0 0; padding-left: 1.2rem; font-weight: 500; }
/* Que las tablas anchas se desplacen dentro de su bloque y no ensanchen la página */
.fin-content > * { min-width: 0; }
/* Barra superior en móvil: el menú de secciones baja a su propia línea */
@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; row-gap: 0.4rem; }
  .sections { order: 3; width: 100%; margin: 0; flex-wrap: wrap; }
  .actions { flex-wrap: wrap; justify-content: flex-end; }
  .ghost { padding: 0.4rem 0.7rem; }
}

.error-detail { white-space: pre-wrap; overflow-wrap: anywhere; padding: 0.7rem; border-radius: 0.5rem; background: #fef2f2; color: #991b1b; font-size: 0.82rem; }

/* Avisos en Marcadores */
.alerts { max-width: 1500px; margin: 0 auto 1rem; padding: 0 1.5rem; }
.alerts-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem 0.8rem; margin-bottom: 0.4rem; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
.alerts ul { display: grid; gap: 0.4rem; margin: 0; padding: 0; list-style: none; }
.alert a { display: block; padding: 0.65rem 0.9rem; border-left: 5px solid; border-radius: 0.6rem; background: rgba(255, 255, 255, 0.92); color: var(--text); font-weight: 600; text-decoration: none; }
.alert a:hover { background: #fff; }
.alert.danger a { border-color: #dc2626; }
.alert.warning a { border-color: #f59e0b; }
.alert.info a { border-color: #3b82f6; }
@media (max-width: 900px) { .alerts { padding: 0 1rem; } }

.safe-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 1rem; }
.safe-form .small-print, .safe-form .dialog-actions { grid-column: 1 / -1; }
.safe-form .row input { flex: 1; }
.kpi button.small { align-self: flex-start; }

textarea { width: 100%; margin-top: 0.35rem; padding: 0.65rem 0.75rem; border: 1px solid #d1d5db; border-radius: 0.55rem; background: #fff; color: var(--text); resize: vertical; }
.safe-form .wide { grid-column: 1 / -1; }

h3.sub { margin: 1rem 0 0.2rem; font-size: 0.95rem; }

.badge.danger { background: #fee2e2; color: #991b1b; }

/* Desglose de gastos de un mes */
.fin-table tr.detail > td { padding: 0.3rem 0.4rem 0.9rem 1.4rem; background: #f8fafc; text-align: left; white-space: normal; }
.fin-table.breakdown { font-size: 0.84rem; }
.fin-table.breakdown td, .fin-table.breakdown th { padding: 0.35rem 0.5rem; }
.fin-table.breakdown td:nth-child(2), .fin-table.breakdown td:nth-child(3), .fin-table.breakdown th:nth-child(2), .fin-table.breakdown th:nth-child(3) { text-align: left; }
.fin-table.breakdown tfoot td { font-weight: 700; border-bottom: 0; }
.type { display: inline-block; padding: 0.05rem 0.45rem; border-radius: 999px; background: #e5e7eb; font-size: 0.74rem; font-weight: 700; }
.type-variable { background: #fef3c7; color: #92400e; }
.type-suscripcion { background: #ede9fe; color: #5b21b6; }
.type-puntual { background: #ffedd5; color: #9a3412; }
.type-cuota, .type-amortizacion, .type-cancelacion, .type-entrada { background: #fee2e2; color: #991b1b; }
.type-fijo { background: #dbeafe; color: #1e40af; }

/* Selector discreto, del mismo color que la tabla */
.card-head select.quiet-select { width: auto; padding: 0.3rem 0.5rem; border: 1px solid #eef0f3; border-radius: 0.5rem; background: transparent; color: var(--text); font-size: 0.9rem; font-weight: 600; }
.type-traspaso { background: #e0f2fe; color: #075985; }

/* Elegir meses concretos */
.field { margin: 0.85rem 0; }
.field-label { display: block; font-size: 0.9rem; font-weight: 600; }
.month-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.3rem; margin-top: 0.4rem; }
.month-chip { display: flex; align-items: center; justify-content: center; margin: 0; padding: 0.35rem 0; border: 1px solid #d1d5db; border-radius: 0.5rem; font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.month-chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.month-chip:has(input:checked) { border-color: var(--accent); background: var(--accent); color: #fff; }
.presets { flex-wrap: wrap; margin-top: 0.4rem; }
.presets button.small { margin: 0; }

/* Biblioteca */
.library { max-width: 1400px; margin: 1rem auto 3rem; padding: 0 1rem; }
.lib-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.7rem; padding: 0.9rem 1rem; margin-bottom: 1rem; }
.lib-bar input[type='search'] { flex: 1 1 220px; margin: 0; }
.lib-bar select { width: auto; max-width: 100%; margin: 0; }
.lib-bar label.check { margin: 0; font-size: 0.88rem; }
.lib-stats { flex-basis: 100%; margin: 0.2rem 0 0; font-size: 0.85rem; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 1rem; }
.book { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.6rem; border-radius: 12px; background: var(--panel); color: var(--text); text-align: left; font-weight: 400; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12); }
.book:hover { filter: none; background: #fff; }
.cover { aspect-ratio: 2 / 3; overflow: hidden; border-radius: 6px; background: #e5e7eb; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-text { display: flex; flex-direction: column; justify-content: space-between; height: 100%; padding: 0.7rem; background: hsl(var(--hue, 210) 35% 42%); color: #fff; }
.cover-text strong { font-size: 0.9rem; line-height: 1.2; overflow-wrap: anywhere; }
.cover-text span { font-size: 0.75rem; opacity: 0.85; }
.cover.large { width: 180px; flex: none; }
.book-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-weight: 650; font-size: 0.88rem; line-height: 1.25; }
.book-author { color: var(--muted); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-badges { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.chip { padding: 0.02rem 0.4rem; border-radius: 999px; background: #e5e7eb; font-size: 0.68rem; font-weight: 700; }
.chip.copies { background: #fef3c7; color: #92400e; }
.chip.review { background: #fee2e2; color: #991b1b; }
.chip.mark-leido { background: #dcfce7; color: #166534; }
.chip.mark-proxima { background: #dbeafe; color: #1e40af; }
.mark-picker { display: flex; gap: 0.4rem; margin: 0.6rem 0; }
.mark-picker button { margin: 0; }
.theme-picker { width: auto; max-width: 100%; margin: 0 0 0.6rem; }
.mark-picker button[aria-pressed='true'] { background: var(--accent); color: #fff; }
.book-dialog { width: min(96vw, 820px); }
.book-detail { display: flex; gap: 1.2rem; margin: 0.8rem 0; }
.book-description { max-height: 9rem; overflow: auto; font-size: 0.9rem; }
.book-files td.path { white-space: normal; overflow-wrap: anywhere; font-size: 0.8rem; color: var(--muted); }
.file-actions { display: flex; gap: 0.4rem; justify-content: flex-end; }
.file-actions .small { margin: 0; }
a.button { display: inline-block; text-decoration: none; }
a.button.secondary { background: #e5e7eb; color: var(--text); }
.lib-deleted { margin-top: 1.2rem; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
.lib-deleted .link { color: #bfdbfe; }
@media (max-width: 600px) { .lib-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); } .book-detail { flex-direction: column; } .cover.large { width: 140px; } }

.lib-zip { margin: 0; }

/* Lector */
body.reader { background-image: none; background-color: #ffffff; }
body.reader[data-theme='sepia'] { background-color: #f4ecd8; }
body.reader[data-theme='oscuro'] { background-color: #15171c; color: #d6d3cd; }
.reader #app-view { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.reader #app-view[hidden] { display: none; }
.reader-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.7rem; padding: 0.5rem 0.9rem; border-bottom: 1px solid rgba(127, 127, 127, 0.25); }
.reader-back { padding: 0.2rem 0.5rem; border-radius: 0.5rem; color: inherit; font-size: 1.3rem; text-decoration: none; }
.reader-heading { display: flex; flex-direction: column; flex: 1 1 200px; min-width: 0; }
.reader-heading strong, .reader-heading span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.reader-heading span { font-size: 0.8rem; }
.reader-bar select { width: auto; max-width: 15rem; margin: 0; padding: 0.35rem 0.5rem; }
.reader-tools { display: flex; gap: 0.3rem; align-items: center; }
.reader-btn { padding: 0.35rem 0.6rem; background: rgba(127, 127, 127, 0.15); color: inherit; }
.reader[data-theme='oscuro'] select { background: #22252c; color: #d6d3cd; border-color: #3a3f4a; }
.reader-stage { position: relative; flex: 1; display: flex; align-items: stretch; min-height: 0; }
#viewer { flex: 1; min-width: 0; padding: 1rem 0; }
.reader-turn { flex: none; width: 3rem; background: transparent; color: rgba(127, 127, 127, 0.7); font-size: 2rem; font-weight: 400; }
.reader-turn:hover { background: rgba(127, 127, 127, 0.08); filter: none; }
.reader-foot { display: flex; align-items: center; gap: 0.8rem; padding: 0.4rem 1rem 0.6rem; font-size: 0.8rem; }
.reader-progress { flex: 1; height: 4px; border-radius: 999px; background: rgba(127, 127, 127, 0.2); overflow: hidden; }
.reader-progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
@media (max-width: 600px) { .reader-turn { width: 1.6rem; font-size: 1.4rem; } .reader-bar select { max-width: 9rem; } #viewer { padding: 0.5rem 0; } }

.lib-reading { margin-bottom: 1rem; padding: 0.9rem 1rem; }
.lib-reading h2 { margin: 0 0 0.6rem; font-size: 1.05rem; }
.reading-list { display: flex; gap: 0.9rem; overflow-x: auto; padding-bottom: 0.3rem; }
.reading-item { display: flex; flex-direction: column; gap: 0.3rem; flex: none; width: 110px; color: var(--text); text-decoration: none; }
.reading-bar { height: 4px; border-radius: 999px; background: #e5e7eb; overflow: hidden; }
.reading-bar span { display: block; height: 100%; background: var(--accent); }
a.button.small { padding: 0.4rem 0.8rem; font-size: 0.85rem; border-radius: 0.6rem; background: var(--accent); color: #fff; font-weight: 600; }
a.button.secondary.small { background: #e5e7eb; color: var(--text); }

/* Blog */
.blog { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 1rem; max-width: 1200px; margin: 1rem auto 3rem; padding: 0 1rem; align-items: start; }
.blog-side { display: flex; flex-direction: column; gap: 0.6rem; padding: 1rem; position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; }
.blog-side input, .blog-side select { margin: 0; }
.post-list { display: flex; flex-direction: column; gap: 0.2rem; margin-top: 0.3rem; }
.post-link { display: flex; flex-direction: column; gap: 0.1rem; padding: 0.5rem 0.6rem; border-radius: 0.55rem; color: var(--text); text-decoration: none; }
.post-link:hover { background: rgba(255, 255, 255, 0.7); }
.post-link.active { background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); }
.post-link .muted { font-size: 0.78rem; }
.blog-main { min-width: 0; padding: 1.5rem 1.8rem; background: rgba(255, 255, 255, 0.94); }
.post-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.post-head h1 { margin: 0 0 0.2rem; font-size: 1.6rem; line-height: 1.2; }
.post-head button.small { margin: 0; flex: none; }
.post-body { max-width: 72ch; line-height: 1.6; overflow-wrap: anywhere; }
.post-body h2 { margin: 1.6rem 0 0.4rem; font-size: 1.25rem; }
.post-body h3 { margin: 1.3rem 0 0.3rem; font-size: 1.08rem; }
.post-body h4, .post-body h5 { margin: 1rem 0 0.3rem; font-size: 1rem; }
.post-body ul, .post-body ol { padding-left: 1.4rem; }
.post-body li { margin: 0.2rem 0; }
.post-body code { padding: 0.05rem 0.3rem; border-radius: 0.3rem; background: #f1f5f9; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.88em; }
.post-body blockquote { margin: 0.8rem 0; padding: 0.4rem 0.9rem; border-left: 4px solid #f59e0b; border-radius: 0 0.5rem 0.5rem 0; background: #fffbeb; }
.post-body blockquote p { margin: 0.3rem 0; }
.post-body hr { border: 0; border-top: 1px solid #e5e7eb; margin: 1.4rem 0; }
.code-block { position: relative; margin: 0.8rem 0; }
.code-block pre { margin: 0; padding: 0.9rem 1rem; padding-right: 5.5rem; border-radius: 0.6rem; background: #1e293b; color: #e2e8f0; overflow-x: auto; }
.code-block pre code { padding: 0; background: none; color: inherit; font-size: 0.86rem; }
.code-block .copy { position: absolute; top: 0.45rem; right: 0.45rem; padding: 0.25rem 0.6rem; border-radius: 0.4rem; background: rgba(255, 255, 255, 0.15); font-size: 0.78rem; }
.code-lang { position: absolute; bottom: 0.35rem; right: 0.6rem; color: #94a3b8; font-size: 0.7rem; }
.post-editor textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.88rem; }
.post-editor .preview { padding: 0.8rem 1rem; border: 1px dashed #d1d5db; border-radius: 0.6rem; }
.md-help summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; }
.md-help pre { padding: 0.7rem; border-radius: 0.5rem; background: #f8fafc; font-size: 0.8rem; white-space: pre-wrap; }
@media (max-width: 800px) {
  .blog { grid-template-columns: 1fr; }
  .blog-side { position: static; max-height: none; }
  .blog-main { padding: 1.1rem; }
}

/* Entreno */
.training { max-width: 1000px; margin: 1rem auto 3rem; padding: 0 1rem; display: flex; flex-direction: column; gap: 1rem; }
.tr-tab { display: flex; flex-direction: column; gap: 1rem; }
.tr-tab[hidden] { display: none !important; }
.tr-tab .card p:last-child, .tr-tab .card ul:last-child, .tr-tab .card ol:last-child { margin-bottom: 0; }
.week-nav { display: flex; gap: 0.4rem; }
.week-nav button.small { margin: 0; }
.slot { display: grid; grid-template-columns: minmax(220px, 1fr) 1.2fr; align-items: center; gap: 0.4rem 1rem; padding: 0.55rem 0; border-top: 1px solid #eef0f3; }
.slot-check { margin: 0; font-weight: 400; }
.slot-check input { flex: none; width: 1.15rem; height: 1.15rem; }
.slot.done strong { text-decoration: line-through; text-decoration-color: #16a34a; }
.slot-note { margin: 0; padding: 0.4rem 0.6rem; font-size: 0.88rem; }
.plain-list { padding-left: 1.2rem; line-height: 1.55; }
.exercises td { vertical-align: top; }
.exercises th, .exercises td { text-align: left; white-space: normal; }
.exercise-tip { display: block; margin-top: 0.15rem; color: var(--muted); font-size: 0.82rem; white-space: normal; }
.load-input { width: 9rem; margin: 0; padding: 0.35rem 0.5rem; font-size: 0.88rem; }
.stats-line { margin: 0; font-weight: 600; }
.km-bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 0.35rem; align-items: end; height: 170px; margin-top: 0.6rem; }
.km-bar { display: flex; flex-direction: column; align-items: center; height: 100%; }
.km-value { min-height: 1.1rem; font-size: 0.72rem; font-weight: 700; }
.km-track { display: flex; align-items: flex-end; width: 100%; flex: 1; }
.km-fill { width: 100%; min-height: 2px; border-radius: 4px 4px 0 0; background: var(--accent); }
.km-week { margin-top: 0.25rem; color: var(--muted); font-size: 0.68rem; white-space: nowrap; }
@media (max-width: 700px) {
  .slot { grid-template-columns: 1fr; }
  .km-week { writing-mode: vertical-rl; transform: rotate(180deg); }
}
.csv-import summary { cursor: pointer; list-style-position: outside; }
.csv-import summary h2 { display: inline; }
.csv-import[open] summary { margin-bottom: 0.6rem; }
.figure-cell { width: 104px; padding-right: 0.4rem; }
.figure { display: block; width: 96px; height: 64px; border-radius: 0.5rem; background: #fff; }
.fig-body { stroke: #1f2937; stroke-width: 3.2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.fig-head { fill: #1f2937; }
.fig-gear { stroke: #2563eb; stroke-width: 3; fill: none; stroke-linecap: round; }
.fig-weight { fill: #2563eb; }
.fig-band { stroke: #16a34a; stroke-width: 2.2; fill: none; }
.fig-strap { stroke: #f59e0b; stroke-width: 2.2; fill: none; }
.fig-ground { stroke: #cbd5e1; stroke-width: 1.5; }
.fig-mat { stroke: #a855f7; stroke-width: 3; }
.fig-block { fill: #cbd5e1; }
.exercise-video { display: inline-block; margin-top: 0.2rem; font-size: 0.8rem; }
@media (max-width: 700px) {
  .exercises thead { display: none; }
  .exercises, .exercises tbody { display: block; width: 100%; }
  .exercises tr { display: grid; grid-template-columns: 100px 1fr; gap: 0.25rem 0.7rem; padding: 0.7rem 0; border-top: 1px solid #eef0f3; }
  .exercises td { display: block; padding: 0; border: 0; }
  .exercises td.figure-cell { grid-row: span 4; width: auto; }
  .exercises td:nth-child(3)::before { content: 'Series: '; color: var(--muted); }
  .exercises td:nth-child(4)::before { content: 'Material: '; color: var(--muted); }
  .exercises .load-input { width: 100%; }
}

/* Documentos */
.docs { max-width: 1000px; margin: 1rem auto 3rem; padding: 0 1rem; display: flex; flex-direction: column; gap: 1rem; }
.docs-bar input { margin: 0; }
.docs-bar p { margin: 0.5rem 0 0; }
.doc-tree { display: flex; flex-direction: column; gap: 0.8rem; }
.doc-group summary { display: flex; align-items: baseline; gap: 0.3rem; cursor: pointer; }
.doc-group summary h2 { margin: 0; }
.doc-drive { margin-left: auto; font-size: 0.85rem; }
.doc-sub h3 { margin: 1rem 0 0.3rem; color: var(--muted); font-size: 0.9rem; }
.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-file { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 0.6rem; padding: 0.4rem 0; border-top: 1px solid #eef0f3; }
.doc-name { overflow-wrap: anywhere; }
.doc-name .chip { margin-left: 0.4rem; }
.doc-size { font-size: 0.8rem; white-space: nowrap; }
.doc-actions { display: flex; gap: 0.3rem; }
.doc-actions .small { margin: 0; }
.chip.expiry.ok { background: #dcfce7; color: #166534; }
.chip.expiry.soon { background: #fef3c7; color: #92400e; }
.chip.expiry.expired { background: #fee2e2; color: #991b1b; }
@media (max-width: 600px) {
  .doc-file { grid-template-columns: 1fr auto; }
  .doc-size { display: none; }
}

/* Inglés B1: pensado primero para el móvil (botones grandes, texto de 17 px) */
.en-title { display: none; font-weight: 700; }
.english { max-width: 760px; margin: 0 auto 4rem; padding: 0 1rem; display: flex; flex-direction: column; gap: 0.9rem; font-size: 17px; line-height: 1.5; }
.en-top { position: sticky; top: 0; z-index: 5; display: flex; flex-direction: column; gap: 0.35rem; padding: 0.6rem 0 0.4rem; background: linear-gradient(180deg, rgba(59, 42, 34, 0.92) 70%, rgba(59, 42, 34, 0)); }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0.25rem; padding: 0.25rem; border-radius: 0.8rem; background: rgba(255, 255, 255, 0.18); }
.segmented button { min-height: 44px; padding: 0.4rem 0.3rem; background: transparent; color: #fff; font-size: 0.95rem; }
.segmented button[aria-pressed='true'] { background: #fff; color: var(--text); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); }
.en-card .segmented { background: #eef0f3; }
.en-card .segmented button { color: var(--text); }
.en-status { margin: 0; color: rgba(255, 255, 255, 0.85); font-size: 0.82rem; text-align: center; }
.en-status.offline { color: #fde68a; font-weight: 700; }
.en-status.busy { color: #bfdbfe; }
.en-tabs { display: grid; grid-template-columns: repeat(7, auto); justify-content: start; }
.en-tabs button { min-height: 42px; }
.en-tab { display: flex; flex-direction: column; gap: 0.9rem; }
.en-card { padding: 1rem 1.1rem; border-radius: 16px; background: rgba(255, 255, 255, 0.94); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16); }
.en-card h2 { margin: 0 0 0.3rem; font-size: 1.3rem; }
.en-card > p:last-child { margin-bottom: 0; }
.en-hero h2 { margin: 0.1rem 0 0.2rem; }
.en-sub { margin: 0 0 0.6rem; font-size: 1.1rem; }
button.big { width: 100%; min-height: 52px; font-size: 1.05rem; border-radius: 0.8rem; }
.english button.secondary { min-height: 44px; }
.mode-choices { display: grid; gap: 0.55rem; }
.mode-choice { display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem; min-height: 64px; padding: 0.7rem 1rem; border: 2px solid #e5e7eb; background: #fff; color: var(--text); text-align: left; }
.mode-choice span { color: var(--muted); font-size: 0.9rem; font-weight: 400; }
.mode-choice.current { border-color: var(--accent); }
.block-row { display: flex; flex-direction: column; gap: 0.45rem; padding: 0.8rem 0; border-top: 1px solid #eef0f3; }
.block-row:first-child { border-top: 0; padding-top: 0; }
.block-row:last-child { padding-bottom: 0; }
.block-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem; }
.block-state { margin: 0; font-weight: 700; }
.block-row.done strong { color: #166534; }
.ok-line { color: #166534; }
.ko-line { color: #991b1b; }
.done-card { background: #ecfdf5; }
.notice-card { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; background: #eff6ff; }
.notice-card p { margin: 0; }
.practice-grid { display: grid; gap: 0.6rem; }
.practice-button { display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem; min-height: 64px; padding: 0.75rem 1rem; border-radius: 14px; background: rgba(255, 255, 255, 0.94); color: var(--text); text-align: left; }
.practice-button span { color: var(--muted); font-size: 0.88rem; font-weight: 400; }
.practice-button:disabled { opacity: 0.6; cursor: default; }
.list-button { display: flex; justify-content: space-between; gap: 0.8rem; width: 100%; min-height: 48px; margin-top: 0.4rem; background: #f3f4f6; color: var(--text); font-weight: 400; text-align: left; }
.level-row { margin-bottom: 0.9rem; }
.level-bar { position: relative; height: 10px; margin-top: 0.35rem; border-radius: 999px; background: #e5e7eb; overflow: hidden; }
.level-fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--accent); }
.level-pass { position: absolute; top: 0; bottom: 0; left: 65.9%; width: 2px; background: #111827; z-index: 1; }
.center { text-align: center; }
.english .small-print { color: inherit; }
.english > .small-print { color: rgba(255, 255, 255, 0.85); }

/* Pantalla de ejercicio */
.en-run { display: flex; flex-direction: column; gap: 0.9rem; }
.run-head { display: flex; align-items: flex-start; gap: 0.8rem; padding: 0.9rem 1rem; border-radius: 16px; background: rgba(255, 255, 255, 0.94); }
.run-head h2 { margin: 0; font-size: 1.15rem; }
.run-head > button { flex: none; white-space: nowrap; }
.run-head p { margin: 0.15rem 0 0; }
.run-body, .exercise { display: flex; flex-direction: column; gap: 0.8rem; }
.en-text p { margin: 0 0 0.8rem; white-space: pre-line; }
.en-text p:last-child { margin-bottom: 0; }
.en-plain { margin: 0; white-space: pre-line; }
.notice { margin: 0.2rem 0 0.6rem; padding: 0.7rem 0.9rem; border-left: 4px solid #f59e0b; border-radius: 0.5rem; background: #fffbeb; white-space: pre-line; }
.q-label { margin: 0 0 0.35rem; color: var(--muted); font-size: 0.85rem; font-weight: 700; letter-spacing: 0.02em; }
.question { margin: 0.2rem 0 0.6rem; font-weight: 650; }
.sentence { margin: 0 0 0.6rem; }
.q-num { display: inline-grid; place-items: center; min-width: 1.6rem; height: 1.6rem; margin-right: 0.45rem; border-radius: 999px; background: #e0e7ff; color: #3730a3; font-size: 0.82rem; font-weight: 800; vertical-align: 0.1em; }
.intro { margin: 0; padding: 0.8rem 1rem; border-radius: 14px; background: rgba(255, 255, 255, 0.94); font-weight: 600; }
.person { margin: 0 0 0.6rem; }
.text-title { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.3rem; font-weight: 700; }
.options { display: grid; gap: 0.45rem; }
.opt { display: flex; align-items: center; gap: 0.7rem; width: 100%; min-height: 50px; padding: 0.55rem 0.8rem; border: 2px solid #e5e7eb; background: #fff; color: var(--text); font-weight: 400; text-align: left; }
.opt-letter { display: inline-grid; flex: none; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 999px; background: #f3f4f6; font-size: 0.85rem; font-weight: 800; }
.opt.picked { border-color: var(--accent); background: #eff6ff; }
.opt.picked .opt-letter { background: var(--accent); color: #fff; }
.opt.right { border-color: #16a34a; background: #f0fdf4; }
.opt.right .opt-letter { background: #16a34a; color: #fff; }
.opt.wrong { border-color: #dc2626; background: #fef2f2; }
.opt.wrong .opt-letter { background: #dc2626; color: #fff; }
.opt:disabled { cursor: default; filter: none; }
.options.letters { grid-template-columns: repeat(4, 1fr); }
.letter-opt { justify-content: center; padding: 0.4rem; }
.letter-opt .opt-letter { background: transparent; font-size: 1.05rem; }
.gap { display: inline-flex; align-items: baseline; gap: 0.3rem; margin: 0 0.1rem; padding: 0 0.4rem; border-radius: 0.4rem; background: #eef2ff; }
.gap b { color: #3730a3; font-size: 0.8rem; }
.gap-fill { font-weight: 650; }
.gap.filled { background: #dbeafe; }
.gap.right { background: #dcfce7; }
.gap.wrong { background: #fee2e2; }
.sentences { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.5rem; }
.sentences li { display: flex; gap: 0.6rem; align-items: flex-start; }
.word-input { max-width: 16rem; min-height: 48px; font-size: 1.05rem; }
.word-input.right { border-color: #16a34a; background: #f0fdf4; }
.word-input.wrong { border-color: #dc2626; background: #fef2f2; }
.explain { margin: 0.55rem 0 0; font-size: 0.95rem; }
.score-line { margin: 0; padding: 0.8rem 1rem; border-radius: 14px; background: #fff; font-weight: 700; }
.extra summary { cursor: pointer; color: var(--accent); font-weight: 600; margin-bottom: 0.4rem; }
.mail-head { margin: 0 0 0.6rem; font-size: 0.95rem; }
.notes { margin: 0; padding-left: 1.2rem; }
.notes li { margin: 0.2rem 0; font-family: 'Comic Sans MS', 'Chalkboard SE', cursive; color: #1e40af; }
.writing-area { width: 100%; min-height: 15rem; padding: 0.75rem; border: 1px solid #d1d5db; border-radius: 0.6rem; font-size: 1.05rem; line-height: 1.5; resize: vertical; }
.criteria { display: grid; gap: 0.6rem; margin: 0.8rem 0; }
.criterion { padding: 0.6rem 0.8rem; border-radius: 0.6rem; background: #f9fafb; }
.criterion p { margin: 0.3rem 0 0; font-size: 0.95rem; }
.criterion-head { display: flex; align-items: baseline; gap: 0.5rem; }
.criterion-head .muted { flex: 1; font-size: 0.8rem; }
.score { padding: 0.05rem 0.5rem; border-radius: 999px; background: #e5e7eb; font-weight: 800; }
.score.s4, .score.s5 { background: #dcfce7; color: #166534; }
.score.s3 { background: #fef3c7; color: #92400e; }
.score.s0, .score.s1, .score.s2 { background: #fee2e2; color: #991b1b; }
.next-step { padding: 0.6rem 0.8rem; border-radius: 0.6rem; background: #eff6ff; }
.marked mark { padding: 0 0.15rem; border-radius: 0.25rem; background: #fee2e2; }
.marked sup { margin-left: 0.1rem; color: #991b1b; font-weight: 800; }
.error-list { margin: 0.8rem 0 0; padding-left: 1.4rem; display: grid; gap: 0.45rem; font-size: 0.95rem; }
.error-list s { color: #991b1b; }
/* Inglés, fase 2: audio, Speaking, tarjetas, reglas y gráficas */
.marked { white-space: pre-line; }
.tag { margin-right: auto; margin-left: 0.5rem; padding: 0.05rem 0.5rem; border-radius: 999px; background: #eef0f3; color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.block-row.waiting { opacity: 0.85; }
.pending-card { background: #fff7ed; }
.player { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin: 0.2rem 0 0.7rem; }
.player .play { min-height: 48px; min-width: 9rem; border-radius: 999px; }
.transcript { display: grid; gap: 0.4rem; padding: 0.6rem 0.8rem; border-radius: 0.6rem; background: #f9fafb; }
.transcript p { margin: 0; }
.warn-line { margin: 0 0 0.5rem; padding: 0.6rem 0.8rem; border-radius: 0.6rem; background: #fef3c7; color: #78350f; }
.note-line { margin: 0 0 0.5rem; }
.notes-title { margin: 0.2rem 0 0; color: #fff; }
.notes.plain li { font-family: inherit; color: var(--text); }
.timer { font-variant-numeric: tabular-nums; font-size: 1.4rem; font-weight: 800; }
.timer.ending { color: #dc2626; }
.speak-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0; }
.live-text { min-height: 4.5rem; margin: 0.4rem 0 0.8rem; padding: 0.7rem 0.8rem; border-radius: 0.6rem; background: #f9fafb; font-size: 1.05rem; }
.writing-area.short { min-height: 7rem; margin: 0.4rem 0 0.8rem; }
.model-answers { margin: 0; padding-left: 1.3rem; display: grid; gap: 0.6rem; }
.useful { margin: 0; padding-left: 1.2rem; display: grid; gap: 0.25rem; }
.overall { margin: 0 0 0.9rem; }
.card-front { margin: 0.6rem 0; font-size: 1.45rem; font-weight: 750; line-height: 1.3; }
.card-front.rule-front { font-size: 1.2rem; color: #991b1b; }
.card-back { margin: 0.8rem 0 0.3rem; padding-top: 0.8rem; border-top: 2px dashed #e5e7eb; font-size: 1.35rem; font-weight: 750; color: #166534; }
.card-example { margin: 0.2rem 0 0.5rem; font-style: italic; }
.grade-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.grade-buttons button { min-height: 56px; padding: 0.4rem; font-size: 0.95rem; }
.grade-again { background: #dc2626; }
.grade-hard { background: #d97706; }
.grade-good { background: #16a34a; }
.form-stack { display: grid; gap: 0.5rem; }
.form-stack input, .topic-select { min-height: 48px; font-size: 1rem; }
.rule { border-top: 1px solid #eef0f3; padding: 0.55rem 0; }
.scheme-picker { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
.scheme-picker button { min-height: 44px; }
.scheme-scroll { overflow-x: auto; margin: 0.4rem 0 0.6rem; }
.scheme-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.scheme-table th, .scheme-table td { padding: 0.4rem 0.5rem; border-bottom: 1px solid #eef0f3; text-align: left; vertical-align: top; }
.scheme-table thead th { background: #f3f4f6; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: #4b5563; }
.scheme-table tbody th { font-weight: 700; color: #1f2937; }
.scheme-table.verbs td:nth-child(2), .scheme-table.verbs td:nth-child(3) { font-weight: 600; color: #1d4ed8; }
.scheme-table .scheme-es { color: #4b5563; }
.scheme-table tr.speakable { cursor: pointer; }
.scheme-table tr.speakable:active { background: #eff6ff; }
.scheme-notes { margin: 0.3rem 0; padding-left: 1.1rem; display: grid; gap: 0.45rem; }
.scheme-example { display: block; color: #166534; margin-top: 0.15rem; }
.scheme-groups { display: flex; flex-direction: column; gap: 0.9rem; }
.rule summary { display: flex; justify-content: space-between; gap: 0.6rem; min-height: 32px; align-items: center; cursor: pointer; font-weight: 650; }
.rule p { margin: 0.5rem 0; font-size: 0.97rem; }
.rule-hits { flex: none; padding: 0.05rem 0.55rem; border-radius: 999px; background: #fee2e2; color: #991b1b; font-size: 0.8rem; font-weight: 800; }
.rule-examples { margin: 0.3rem 0; padding-left: 1.2rem; color: #166534; }
.rule-checks { display: grid; gap: 0.4rem; margin: 0.5rem 0 0.7rem; }
.rule-checks p { margin: 0; padding: 0.4rem 0.6rem; border-radius: 0.5rem; background: #f9fafb; }
.rule-checks s { color: #991b1b; }
.charts { display: grid; gap: 0.9rem; }
.chart-box .block-head { margin-bottom: 0.2rem; }
.skill-chart { display: block; width: 100%; height: auto; }
.skill-chart .grid-line { stroke: #e5e7eb; stroke-width: 1; }
.skill-chart .pass-line { stroke: #111827; stroke-width: 1.5; stroke-dasharray: 4 3; }
.skill-chart .axis-label { fill: #6b7280; font-size: 10px; }
.skill-chart .series { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.skill-chart .dot { fill: var(--accent); }

@media (max-width: 760px) {
  .en-tabs { grid-template-columns: repeat(4, 1fr); }
  .en-tabs button { padding-left: 0.3rem; padding-right: 0.3rem; font-size: 0.88rem; }
  .page-english .sections { display: none; }
  .page-english .en-title { display: block; margin-right: auto; }
  .page-english .actions .ghost[href='/cuenta'] { display: none; }
  .english { padding: 0 0.75rem; }
  .en-card { padding: 0.9rem; }
}
@media (display-mode: standalone) {
  .page-english .topbar { padding-top: max(0.5rem, env(safe-area-inset-top)); }
}

/* Inglés: preparar la clase de la unidad */
.prep-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.55rem 0; border-top: 1px solid #eef0f3; }
.prep-row label.check { font-weight: 400; align-items: flex-start; }
.prep-row label.check input { flex: none; width: 1.15rem; height: 1.15rem; margin-top: 0.15rem; }
.prep-row.done label span { text-decoration: line-through; text-decoration-color: #16a34a; color: #6b7280; }
.prep-row button { flex: none; }

/* Inglés: el libro del curso por páginas */
.book-parts { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 0.4rem; margin: 0.75rem 0 0.4rem; }
.book-parts.extras { grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); margin-top: 0; margin-bottom: 0.7rem; }
.book-parts button { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 0.1rem; min-height: 44px; padding: 0.4rem 0.6rem; background: #eef0f3; color: var(--text); text-align: left; }
.book-parts button span { font-size: 0.85rem; font-weight: 400; line-height: 1.25; }
.book-parts button em { font-size: 0.72rem; font-style: normal; font-weight: 700; color: #2563eb; text-transform: uppercase; }
.book-parts button.next-class { box-shadow: inset 0 0 0 2px #2563eb; }
.book-parts button.current { background: #2563eb; color: #fff; }
.book-parts button.current em { color: #dbeafe; }

.book-goto { display: flex; gap: 0.5rem; max-width: 14rem; }
.book-goto input { flex: 1; min-width: 0; }
.book-title { margin: 0.2rem 0 0; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); scroll-margin-top: 7.5rem; }
.book-page { margin: 0; padding: 0.4rem; border-radius: 12px; background: #fff; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16); }
.book-page img { display: block; width: 100%; height: auto; border-radius: 8px; background: #f3f4f6; }
.book-page figcaption { padding: 0.35rem 0.2rem 0.1rem; color: #6b7280; font-size: 0.8rem; text-align: center; }
@media (max-width: 760px) {
  .page-english .book-page { margin: 0 -0.5rem; padding: 0.2rem; border-radius: 8px; }
}

/* Inversión */
.inv-wrap { --sube: #15803d; --baja: #b91c1c; --vivo: #c7861a; --bolsa: #2f5d8a; --fija: #7fa0bc; --mon: #c3cfd9; display: grid; gap: 1rem; max-width: 640px; margin: 1.5rem auto 3rem; padding: 0 1rem; font-variant-numeric: tabular-nums; }
.inv-panel { padding: 1.3rem 1.4rem 1.4rem; background: rgba(255, 255, 255, 0.92); }
.inv-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.5rem 1rem; }
.inv-head h1 { margin: 0; font-size: 1.15rem; }
.inv-estado { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.85rem; }
.inv-punto { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.inv-estado.vivo .inv-punto { background: var(--vivo); animation: inv-latido 2s ease-in-out infinite; }
@keyframes inv-latido { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .inv-estado.vivo .inv-punto { animation: none; } }
.inv-total { margin: 1.6rem 0 0.4rem; font-size: clamp(2.4rem, 11vw, 3.6rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.inv-total small { font-size: 0.45em; font-weight: 700; letter-spacing: 0; }
.inv-resumen { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1.2rem 0 1.4rem; }
.inv-resumen span { display: block; color: var(--muted); font-size: 0.85rem; }
.inv-resumen b { font-size: 1.1rem; }
.inv-wrap .sube { color: var(--sube); }
.inv-wrap .baja { color: var(--baja); }
.inv-reparto { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: #e5e7eb; }
.inv-reparto i { display: block; }
.inv-reparto .bolsa, .inv-leyenda .bolsa { --c: var(--bolsa); }
.inv-reparto .fija, .inv-leyenda .fija { --c: var(--fija); }
.inv-reparto .mon, .inv-leyenda .mon { --c: var(--mon); }
.inv-reparto i { background: var(--c); }
.inv-leyenda { display: flex; flex-wrap: wrap; gap: 0.35rem 1.1rem; margin-top: 0.6rem; color: var(--muted); font-size: 0.85rem; }
.inv-leyenda span::before { content: ''; display: inline-block; width: 9px; height: 9px; margin-right: 0.4rem; border-radius: 2px; background: var(--c); }
.inv-grupo { padding: 0.3rem 1.2rem; background: rgba(255, 255, 255, 0.92); }
.inv-grupo h2 { display: flex; justify-content: space-between; margin: 0.9rem 0 0.2rem; font-size: 1rem; }
.inv-grupo h2 span { color: var(--muted); font-weight: 600; }
.inv-fondo { display: grid; grid-template-columns: 1fr auto; gap: 0.1rem 0.75rem; padding: 0.85rem 0; border-top: 1px solid #e5e7eb; }
.inv-grupo h2 + .inv-fondo { border-top: 0; }
.inv-fondo .nombre { font-weight: 600; }
.inv-fondo .valor { font-weight: 700; text-align: right; }
.inv-fondo .ref { color: var(--muted); font-size: 0.8rem; }
.inv-fondo .var { font-size: 0.85rem; font-weight: 600; text-align: right; }
#avisos:empty { display: none; }
#avisos { display: grid; gap: 0.6rem; }
#grupos { display: grid; gap: 1rem; }
.inv-aviso { padding: 0.75rem 0.9rem; border-left: 3px solid var(--baja); border-radius: 0.6rem; background: #fff; font-size: 0.9rem; }
.inv-pie { padding: 0.9rem 1.1rem; border-radius: 12px; background: rgba(255, 255, 255, 0.82); color: var(--muted); font-size: 0.82rem; }
.inv-pie p { margin: 0.35rem 0; }
.inv-pie button { padding: 0.4rem 0.9rem; font-size: 0.85rem; }
.inv-botones { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.inv-editor-fondo { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.6rem; margin: 0.8rem 0 0; padding: 0.3rem 0.8rem 0.6rem; border: 1px solid #e5e7eb; border-radius: 0.7rem; }
.inv-editor-fondo legend { padding: 0 0.3rem; font-size: 0.9rem; font-weight: 600; }
.inv-editor-fondo label { margin: 0.4rem 0 0; font-size: 0.85rem; }
.inv-yahoo { grid-column: 1 / -1; margin: 0.3rem 0 0; color: var(--muted); font-size: 0.78rem; }
.inv-oficial { display: grid; grid-template-columns: 1fr auto; gap: 0.15rem 1rem; align-items: baseline; margin: 0 0 1.3rem; padding: 0.7rem 0.9rem; border-radius: 0.7rem; background: #f3f4f6; font-size: 0.9rem; }
.inv-oficial span { color: var(--muted); }
.inv-oficial b { text-align: right; }
.inv-oficial small { grid-column: 1 / -1; color: var(--muted); font-size: 0.78rem; }
.inv-fondo .oficial { color: var(--muted); font-size: 0.78rem; }
.inv-fondo .oficial + .oficial { text-align: right; }
.inv-historial { padding-bottom: 1rem; }
.inv-grafico { display: block; width: 100%; height: auto; margin: 0.6rem 0 0.2rem; }
.inv-grafico .area { fill: var(--bolsa); opacity: 0.08; }
.inv-grafico .valor { fill: none; stroke: var(--bolsa); stroke-width: 2.5; stroke-linejoin: round; }
.inv-grafico .aportado { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 4; }
.inv-grafico .punto { fill: var(--bolsa); }
.inv-grafico text { fill: var(--muted); font-size: 11px; }
.inv-leyenda-graf { margin: 0 0 0.6rem; }
.inv-leyenda-graf .linea-valor { --c: var(--bolsa); }
.inv-leyenda-graf .linea-aportado { --c: var(--muted); }
.inv-wrap > * { min-width: 0; }
.inv-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.5rem 0 0.9rem; }
.inv-chip { padding: 0.3rem 0.75rem; border: 1px solid #d1d5db; border-radius: 999px; background: #fff; color: var(--text); font-size: 0.8rem; font-weight: 600; }
.inv-chip.activo { border-color: var(--bolsa); background: var(--bolsa); color: #fff; }
.inv-evo-resumen { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0.6rem 1rem; margin-bottom: 0.4rem; }
.inv-evo-resumen span { display: block; color: var(--muted); font-size: 0.78rem; }
.inv-evo-resumen b { font-size: 0.95rem; }
.inv-barras rect.sube { fill: var(--sube); }
.inv-barras rect.baja { fill: var(--baja); }
.inv-barras .eje { stroke: #d1d5db; stroke-width: 1; }
.inv-periodo { margin-top: -0.4rem; }
.inv-periodo .inv-chip { font-weight: 500; }
.inv-nota { margin: 0 0 0.6rem; color: var(--muted); font-size: 0.78rem; }
.inv-tabla-caja { overflow-x: auto; }
@media (max-width: 520px) { .inv-tabla { font-size: 0.78rem; } .inv-tabla th, .inv-tabla td { padding-left: 0.2rem; padding-right: 0.2rem; } .inv-tabla th { white-space: normal; } }
.inv-tabla { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.inv-tabla th { color: var(--muted); font-weight: 600; font-size: 0.75rem; text-align: right; padding: 0.4rem 0.3rem; }
.inv-tabla td { text-align: right; padding: 0.45rem 0.3rem; border-top: 1px solid #e5e7eb; white-space: nowrap; }
.inv-tabla th:first-child, .inv-tabla td:first-child { text-align: left; }
.inv-tabla td small { display: block; color: var(--muted); font-size: 0.72rem; }
#operaciones { width: min(96vw, 560px); }
#operaciones h3 { margin: 1.2rem 0 0.2rem; font-size: 1rem; }
.inv-op-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.6rem; align-items: end; }
.inv-op-form label { margin: 0.4rem 0 0; font-size: 0.85rem; }
.inv-op-form button { grid-column: 1 / -1; justify-self: start; margin-top: 0.6rem; }
.inv-lista { margin: 0.6rem 0 0; padding: 0; list-style: none; font-size: 0.85rem; }
.inv-lista li { display: grid; grid-template-columns: 1fr auto auto; gap: 0.6rem; align-items: center; padding: 0.35rem 0; border-top: 1px solid #e5e7eb; }
.inv-lista li.muted { display: block; }
.inv-lista .cifras { font-variant-numeric: tabular-nums; }
#editor { max-height: 90vh; overflow-y: auto; }
