/* =======================================
   Gestor Familiar — Dark Premium Theme
   ======================================= */

:root {
    --bg: #0d0d14;
    --surface: #141420;
    --surface-2: #1c1c2c;
    --surface-3: #242438;
    --border: rgba(255,255,255,0.07);
    --border-strong: rgba(255,255,255,0.13);
    --text: #e8e8f2;
    --muted: #6e6e92;
    --muted-2: #4a4a68;
    --primary: #7c6af0;
    --primary-dim: rgba(124,106,240,0.15);
    --ok: #22c785;
    --ok-dim: rgba(34,199,133,0.13);
    --danger: #f4506a;
    --danger-dim: rgba(244,80,106,0.13);
    --warn: #f0b429;
    --warn-dim: rgba(240,180,41,0.13);
    --shadow: 0 4px 24px rgba(0,0,0,0.45);
    --shadow-lg: 0 12px 48px rgba(0,0,0,0.6);
    --radius-xl: 20px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --bottom-nav-h: 68px;
}

*, *::before, *::after { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Inter", system-ui, sans-serif;
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
    padding-bottom: var(--bottom-nav-h);
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
.app-body { min-height: 100vh; }

/* ── App shell ── */
.app-shell {
    width: min(100%, 1400px);
    margin: 0 auto;
    padding: 0 12px 20px;
}

/* ── Topbar ── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    margin-bottom: 14px;
    background: rgba(13,13,20,0.88);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.brand-mark {
    width: 34px; height: 34px;
    border-radius: var(--radius-sm);
    display: grid; place-items: center;
    font-size: 0.75rem; font-weight: 800;
    color: #fff; letter-spacing: -0.02em;
    background: linear-gradient(135deg, #7c6af0, #5548d4);
    box-shadow: 0 4px 12px rgba(124,106,240,0.35);
}

.brand-copy strong {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
}

.squid-toggle {
    display: inline-flex;
    width: 38px; height: 38px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    align-items: center; justify-content: center;
    padding: 0; cursor: pointer;
}

.squid-toggle svg {
    width: 20px; height: 20px;
    stroke: currentColor; stroke-width: 2.4;
    fill: none; stroke-linecap: round; stroke-linejoin: round;
}

.squid-toggle svg .squid-eye { fill: currentColor; stroke: none; }

/* Topnav hidden on mobile */
.topnav {
    display: none;
    grid-column: 1 / -1;
    flex-direction: column;
    gap: 3px;
    padding: 8px;
    border-radius: var(--radius-lg);
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    margin-top: 4px;
}

.topnav.is-open { display: flex; }

.menu-link {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 600;
    transition: background 0.15s, color 0.15s;
}

.menu-link:hover { color: var(--text); background: var(--surface-3); }
.menu-link.active { color: #fff; background: var(--primary); }

.topbar-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.profile-chip {
    display: none;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
}

/* ── Bottom nav (mobile) ── */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 30;
    height: var(--bottom-nav-h);
    display: flex;
    align-items: stretch;
    background: rgba(20,20,32,0.96);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--muted-2);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    transition: color 0.15s;
    position: relative;
}

.bottom-nav-item svg {
    width: 22px; height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: stroke 0.15s;
}

.bottom-nav-item.active {
    color: var(--primary);
}

.bottom-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0; left: 50%;
    transform: translateX(-50%);
    width: 32px; height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--primary);
}

.bottom-nav-item.active svg {
    stroke: var(--primary);
    stroke-width: 2.4;
}

/* ── Main content ── */
.main-content {
    display: grid;
    gap: 14px;
    padding-bottom: 8px;
}

/* ── Panels & cards base ── */
.page-head,
.panel,
.stat-card {
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.page-head,
.panel {
    border-radius: var(--radius-xl);
    padding: 18px;
}

.page-head h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--text);
}

.page-head p {
    margin: 4px 0 0;
    font-size: 0.84rem;
    color: var(--muted);
}

.panel h3 {
    margin: 0 0 16px;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.panel h4 {
    margin: 0;
    font-size: 0.94rem;
    font-weight: 700;
    color: var(--text);
}

.panel p {
    color: var(--muted);
    font-size: 0.86rem;
    margin: 4px 0 0;
}

.page-head-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.panel-heading h3 { margin-bottom: 0; }

.category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

/* ── Stat cards ── */
.cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat-card {
    border-radius: var(--radius-lg);
    padding: 16px;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 3px; height: 100%;
    border-radius: 3px 0 0 3px;
}

.stat-card.income::before { background: var(--ok); }
.stat-card.expense::before { background: var(--danger); }
.stat-card.net.positive::before { background: var(--ok); }
.stat-card.net.negative::before { background: var(--danger); }
.stat-card.net::before { background: var(--muted); }

.stat-card p {
    margin: 0 0 8px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.stat-card strong {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    display: block;
}

.stat-card.net { grid-column: span 2; }
.stat-card.income strong { color: var(--ok); }
.stat-card.expense strong { color: var(--danger); }

/* ── Color helpers ── */
.ok-text, .positive { color: var(--ok) !important; }
.danger-text, .negative { color: var(--danger) !important; }

/* ── Forms ── */
.form-grid,
.filters,
.filter-form {
    display: grid;
    gap: 12px;
}

label {
    display: grid;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.02em;
}

input,
select,
textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface-3);
    color: var(--text);
    outline: none;
    font-size: 0.92rem;
    transition: border-color 0.15s, box-shadow 0.15s;
    -webkit-appearance: none;
    appearance: none;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236e6e92' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

select[multiple] {
    background-image: none;
    padding-right: 14px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-dim);
}

input:disabled,
select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.6);
    cursor: pointer;
}

.actions {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 4px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 18px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    text-decoration: none;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    transition: transform 0.12s, background 0.15s, box-shadow 0.15s;
    white-space: nowrap;
    letter-spacing: -0.01em;
}

.btn:active { transform: scale(0.97); }

.btn.primary {
    color: #fff;
    background: var(--primary);
    box-shadow: 0 4px 16px rgba(124,106,240,0.3);
}

.btn.primary:hover {
    background: #6a58e0;
    box-shadow: 0 6px 20px rgba(124,106,240,0.45);
}

.btn.ghost {
    border-color: var(--border-strong);
    color: var(--text);
    background: var(--surface-2);
}

.btn.ghost:hover {
    background: var(--surface-3);
    border-color: var(--muted);
}

.btn.small {
    min-height: 34px;
    padding: 0 12px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.btn.ghost.subtle {
    min-height: 36px;
    padding: 0 12px;
    font-size: 0.82rem;
}

.btn.ghost.danger {
    border-color: rgba(244,80,106,0.3);
    color: var(--danger);
}

.btn.ghost.danger:hover {
    color: #fff;
    background: var(--danger);
    border-color: var(--danger);
    box-shadow: 0 4px 16px rgba(244,80,106,0.3);
}

.inline-form { margin: 0; }

/* ── Icon buttons ── */
.icon-btn {
    width: 36px; height: 36px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.icon-btn svg {
    width: 15px; height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-btn:hover:not(.disabled):not(:disabled) {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

.icon-btn.disabled,
.icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.warn-btn:hover { background: var(--warn) !important; border-color: var(--warn) !important; }
.danger-btn { color: var(--danger) !important; }
.danger-btn:hover {
    background: var(--danger) !important;
    border-color: var(--danger) !important;
    color: #fff !important;
}

/* ── Tables ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table {
    width: 100%;
    min-width: 580px;
    border-collapse: separate;
    border-spacing: 0;
}

th, td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    background: var(--surface-2);
}

td { font-size: 0.88rem; color: var(--text); }

.ledger-panel table strong { display: block; margin-bottom: 4px; }

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    font-size: 0.72rem;
    font-weight: 600;
}

.soft-badge { background: var(--ok-dim); color: var(--ok); border-color: transparent; }
.muted-badge { background: var(--surface-3); color: var(--muted); border-color: transparent; }
.table-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ── Account tabs ── */
.account-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.account-tab-btn {
    padding: 7px 16px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--surface-3);
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.account-tab-btn:hover {
    color: var(--text);
    background: var(--surface-2);
}

.account-tab-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ── Account cards ── */
.account-grid { display: grid; gap: 10px; }

.account-card {
    padding: 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--surface-2);
}

.account-card header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}

.account-card header span {
    font-size: 0.74rem;
    color: var(--muted);
    font-weight: 600;
    background: var(--surface-3);
    padding: 3px 8px;
    border-radius: 999px;
}

.account-figures {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.account-figures p {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0;
    font-size: 0.85rem;
}

.account-figures span { color: var(--muted); }
.account-figures strong { font-weight: 700; font-size: 0.9rem; }

.account-balance {
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: -0.04em;
    margin: 0;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

/* ── Panel badge ── */
.panel-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: 8px;
    vertical-align: middle;
}

/* ── Budget panel sub-header ── */
.budget-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.budget-panel-sub {
    font-size: 0.84rem;
    color: var(--muted);
    margin: 0;
}

/* ── Budget section ── */
.budget-month-picker { flex-shrink: 0; }

.month-select {
    min-width: 120px;
    padding: 8px 32px 8px 12px;
    font-size: 0.84rem;
    font-weight: 600;
}

.budget-form-details {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--surface-2);
    margin-bottom: 16px;
    overflow: hidden;
}

.budget-form-toggle {
    padding: 14px 16px;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--primary);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.budget-form-toggle::-webkit-details-marker { display: none; }

.budget-form-details[open] .budget-form-toggle {
    border-bottom: 1px solid var(--border);
}

.budget-form {
    padding: 16px;
}

.categories-select { min-height: 110px; }

.budget-grid { display: grid; gap: 12px; }

.budget-card {
    padding: 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--surface-2);
    position: relative;
    overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s;
}

.budget-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 3px;
}

.budget-card.status-under::before { background: var(--ok); }
.budget-card.status-on-track::before { background: var(--warn); }
.budget-card.status-over::before { background: var(--danger); }

.budget-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.budget-card-info h4 {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0 0 4px;
}

.budget-categories {
    font-size: 0.78rem;
    color: var(--muted);
    margin: 0;
}

.budget-pct-badge {
    flex-shrink: 0;
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    padding: 6px 10px;
    border-radius: var(--radius-md);
    min-width: 60px;
    text-align: center;
}

.budget-pct-badge.status-under { color: var(--ok); background: var(--ok-dim); }
.budget-pct-badge.status-on-track { color: var(--warn); background: var(--warn-dim); }
.budget-pct-badge.status-over { color: var(--danger); background: var(--danger-dim); }

.budget-bar {
    height: 7px;
    border-radius: 999px;
    background: var(--surface-3);
    overflow: hidden;
    margin-bottom: 14px;
}

.budget-bar-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #22c785, #1aae74);
    transition: width 0.5s ease;
}

.budget-card.status-under .budget-bar-fill {
    background: linear-gradient(90deg, #22c785, #1aae74);
}

.budget-card.status-on-track .budget-bar-fill {
    background: linear-gradient(90deg, #f0b429, #e0a020);
}

.budget-card.status-over .budget-bar-fill {
    background: linear-gradient(90deg, #f4506a, #e03050);
}

.budget-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

.budget-metric {
    padding: 10px;
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    border: 1px solid var(--border);
}

.budget-metric span {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.budget-metric strong {
    display: block;
    font-size: 0.9rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
}

.budget-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Budget history modal body ── */
.budget-history-body {
    padding: 16px 18px 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.history-months-list {
    display: grid;
    gap: 10px;
}

.history-month-row {
    display: grid;
    grid-template-columns: 80px 1fr 100px;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.history-month-label {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--muted);
}

.history-month-bar-wrap { min-width: 0; }

.history-month-bar {
    height: 6px;
    border-radius: 999px;
    background: var(--surface-3);
    overflow: hidden;
}

.history-month-bar-fill {
    height: 100%;
    border-radius: inherit;
    background: var(--ok);
    transition: width 0.4s;
}

.history-month-row.status-on-track .history-month-bar-fill { background: var(--warn); }
.history-month-row.status-over .history-month-bar-fill { background: var(--danger); }

.history-month-amount {
    font-size: 0.88rem;
    font-weight: 700;
    text-align: right;
    color: var(--text);
}

.history-limit-note {
    font-size: 0.8rem;
    color: var(--muted);
    margin: 0 0 14px;
    padding: 10px 12px;
    background: var(--surface-3);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* ── Filter totals ── */
.filter-totals {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.filter-totals-label {
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0 10px;
}

.filter-totals-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.filter-total-item {
    padding: 12px;
    border-radius: var(--radius-md);
    background: var(--surface-3);
    border: 1px solid var(--border);
}

.filter-total-item span {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 5px;
}

.filter-total-item strong {
    display: block;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.filter-total-item.income strong { color: var(--ok); }
.filter-total-item.expense strong { color: var(--danger); }

/* ── Collapsible panel (filtros) ── */
.collapsible-panel { padding: 0; overflow: hidden; }

.panel-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.panel-toggle:hover { color: var(--primary); }

.chevron-icon {
    width: 18px; height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.2s;
}

.panel-toggle[aria-expanded="true"] .chevron-icon {
    transform: rotate(180deg);
}

.panel-body {
    padding: 0 18px 18px;
}

.panel-body[hidden] { display: none; }

/* ── Charts ── */
.charts-grid { display: grid; gap: 14px; }

.chart-article h3 { margin-bottom: 12px; }

.chart-frame {
    position: relative;
    height: 220px;
}

.chart-frame canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ── Toggle ── */
.toggle-pill {
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface-2);
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
}

.toggle-pill.active {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface-2);
}

.switch-control {
    position: relative;
    display: inline-flex;
    width: 44px; height: 26px;
    flex-shrink: 0;
}

.switch-control input { opacity: 0; width: 0; height: 0; }

.switch-slider {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    transition: background 0.18s;
}

.switch-slider::before {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform 0.18s, background 0.18s;
}

.switch-control input:checked + .switch-slider { background: var(--ok); border-color: var(--ok); }
.switch-control input:checked + .switch-slider::before {
    transform: translateX(18px);
    background: #fff;
}

.inline-reveal {
    padding: 12px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface-2);
}

.category-stack { display: grid; gap: 8px; }
.field-grow { flex: 1; }

/* ── Filter drawer (legacy) ── */
.ledger-head-actions { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.filter-drawer {
    margin-top: 14px;
    padding: 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
}

/* ── Pagination ── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 16px 0 2px;
    flex-wrap: wrap;
}

.pagination-info {
    padding: 0 8px;
    font-size: 0.82rem;
    color: var(--muted);
    font-weight: 600;
}

/* ── Occurrence rows ── */
.occurrence-sub-row { display: none; }
.occurrence-sub-row.is-open { display: table-row; }
.occurrence-sub-row td {
    padding: 8px 14px 14px;
    background: var(--surface-2);
}

.occurrence-list { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 4px; }
.occurrence-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--surface-3);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
}

.empty-occurrences { font-size: 0.82rem; color: var(--muted); }
.occurrences-btn.active { background: var(--surface-3); }

/* ── Notices ── */
.notice {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface-2);
    font-size: 0.88rem;
    color: var(--text);
}

.notice.success {
    color: var(--ok);
    border-color: rgba(34,199,133,0.2);
    background: var(--ok-dim);
}

.notice.error {
    color: var(--danger);
    border-color: rgba(244,80,106,0.2);
    background: var(--danger-dim);
}

.alert-panel { border-left: 3px solid var(--warn); }
.is-hidden { display: none !important; }

/* ── Empty state ── */
.empty-state,
.empty-history {
    padding: 20px;
    text-align: center;
    border-radius: var(--radius-md);
    background: var(--surface-2);
    border: 1px dashed var(--border-strong);
    color: var(--muted);
    font-size: 0.88rem;
    margin: 0;
}

/* ── Dialogs ── */
.history-dialog,
.simple-dialog {
    width: min(520px, calc(100vw - 24px));
    max-height: 92vh;
    padding: 0;
    border: none;
    background: transparent;
}

.history-dialog::backdrop,
.simple-dialog::backdrop {
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(10px);
}

.dialog-shell {
    overflow: hidden;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}

.dialog-head h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.history-timeline {
    display: grid;
    gap: 12px;
    max-height: 65vh;
    padding: 16px 18px 18px;
    overflow: auto;
}

.history-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.history-wide { grid-column: span 2; }

.history-entry {
    padding: 14px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--surface-2);
}

.history-entry header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.history-entry header span {
    font-size: 0.76rem;
    color: var(--muted);
}

.history-grid p {
    padding: 10px;
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    margin: 0;
    font-size: 0.82rem;
    color: var(--muted);
}

.history-grid strong {
    display: block;
    margin-top: 4px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
}

/* ── Profile screen ── */
.profile-screen {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px 16px;
    background: var(--bg);
}

.profile-hero {
    width: min(560px, 100%);
    display: grid;
    gap: 28px;
    text-align: center;
}

.eyebrow {
    margin: 0 0 10px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--primary);
}

.profile-hero h1 {
    margin: 0;
    font-size: clamp(2.2rem, 8vw, 3.8rem);
    line-height: 0.95;
    letter-spacing: -0.06em;
    color: var(--text);
}

.profile-grid { display: grid; gap: 14px; }
.profile-card-form { margin: 0; }

.profile-card {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xl);
    background: var(--surface);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    text-align: left;
}

.profile-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.profile-avatar {
    width: 56px; height: 56px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary), #5548d4);
    color: #fff;
    font-size: 1.6rem;
    font-weight: 800;
}

.profile-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}

.profile-password-row {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding: 0 4px;
}

.profile-password-row input { flex: 1; }
.profile-password-row .btn { flex-shrink: 0; }

/* ── Transaction workspace ── */
.transaction-workspace { display: grid; gap: 12px; }
.single-column { max-width: 900px; }
.compact-stats .stat-card { padding: 12px; }

/* ── Shopping list ── */
.shopping-add-form { display: flex; gap: 8px; }
.shopping-add-form input { flex: 1; }

.shopping-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0;
}

.shopping-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--border);
}

.shopping-item:last-child { border-bottom: none; }

.shopping-name {
    flex: 1;
    font-size: 0.95rem;
    color: var(--text);
}

.shopping-item.is-checked .shopping-name {
    text-decoration: line-through;
    color: var(--muted);
}

.shopping-divider {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    padding: 14px 4px 4px;
    list-style: none;
}

.check-btn {
    width: 32px; height: 32px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border: 2px solid var(--border-strong);
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    padding: 0;
    transition: border-color 0.15s, background 0.15s;
}

.check-btn svg {
    width: 16px; height: 16px;
    fill: none;
    stroke: var(--muted);
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.check-btn.checked { border-color: var(--ok); background: var(--ok-dim); }
.check-btn.checked svg { stroke: var(--ok); }

/* ── Savings ── */
.savings-goal-card { display: grid; gap: 12px; }

.savings-goal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.savings-goal-head h3 { margin: 0; font-size: 1rem; font-weight: 700; }
.savings-sub { margin: 3px 0 0; font-size: 0.82rem; color: var(--muted); }

.savings-bar-wrap { display: flex; align-items: center; gap: 10px; }

.savings-bar {
    flex: 1;
    height: 8px;
    border-radius: 999px;
    background: var(--surface-3);
    overflow: hidden;
}

.savings-bar-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--ok), #1aae74);
    transition: width 0.5s;
}

.savings-pct {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--muted);
    min-width: 36px;
    text-align: right;
}

.savings-remaining { margin: 0; font-size: 0.85rem; color: var(--muted); }

.savings-contrib-toggle,
.savings-history-toggle {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface-2);
}

.savings-contrib-toggle > summary,
.savings-history-toggle > summary {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text);
}

.savings-contrib-form {
    padding: 10px 14px 14px;
    display: grid;
    gap: 10px;
}

.savings-history-list {
    list-style: none;
    margin: 0;
    padding: 0 14px 12px;
    display: grid;
    gap: 6px;
}

.savings-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    border: 1px solid var(--border);
    font-size: 0.84rem;
}

.savings-history-item strong { font-weight: 700; color: var(--text); }
.savings-history-item span { color: var(--muted); font-size: 0.78rem; }
.savings-history-item em { display: block; color: var(--muted); font-style: normal; font-size: 0.78rem; }

.completed-goals-list { display: grid; gap: 8px; }

.completed-goal-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(34,199,133,0.2);
    background: var(--ok-dim);
}

.completed-goal-item span { flex: 1; font-size: 0.9rem; color: var(--text); }
.completed-goal-item strong { font-size: 0.9rem; color: var(--ok); }

/* ── Settings ── */
.settings-cards { display: grid; gap: 14px; }

.settings-card {
    padding: 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--surface-2);
}

.settings-card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.mini-avatar {
    width: 36px; height: 36px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #5548d4);
    color: #fff;
    font-size: 1rem;
    font-weight: 800;
}

.settings-pwd-form { display: grid; gap: 10px; }
.settings-pwd-form .btn { justify-self: start; }

/* =================================
   TABLET >= 640px
   ================================= */
@media (min-width: 640px) {
    .app-shell { padding: 0 16px 24px; }

    .topbar {
        border-radius: 999px;
        margin: 12px 0 16px;
        padding: 8px 16px;
        border: 1px solid var(--border-strong);
        box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    }

    .bottom-nav { display: none; }
    body { padding-bottom: 0; }

    .topnav {
        display: inline-flex;
        flex-direction: row;
        gap: 3px;
        padding: 5px;
        border-radius: 999px;
        background: var(--surface-2);
        border: 1px solid var(--border-strong);
        grid-column: auto;
    }

    .squid-toggle { display: none; }

    .menu-link {
        min-width: 66px;
        padding: 7px 12px;
        border-radius: 999px;
        font-size: 0.82rem;
    }

    .profile-chip { display: inline-flex; }

    .cards-grid { grid-template-columns: repeat(3, 1fr); }
    .stat-card.net { grid-column: auto; }
    .stat-card { padding: 18px; }
    .stat-card strong { font-size: 1.4rem; }

    .form-grid,
    .filter-form { grid-template-columns: repeat(2, 1fr); }

    .field-span-2 { grid-column: span 2; }

    .account-grid { grid-template-columns: repeat(3, 1fr); }
    .budget-grid { grid-template-columns: repeat(2, 1fr); }

    .profile-grid { grid-template-columns: repeat(2, 1fr); }
    .profile-card { flex-direction: column; text-align: center; padding: 24px 18px; }
    .profile-avatar { width: 72px; height: 72px; font-size: 2.2rem; }

    .settings-cards { grid-template-columns: repeat(2, 1fr); }
    .page-head { padding: 24px; }
    .page-head h2 { font-size: 2rem; }
    .panel { padding: 22px; }
    .panel-body { padding: 0 22px 22px; }
    .panel-toggle { padding: 18px 22px; }

    .savings-contrib-form { grid-template-columns: 1fr 1fr; }
    .savings-contrib-form .btn { grid-column: span 2; justify-self: start; }

    .charts-grid { grid-template-columns: 1.5fr 1fr; }
    .chart-frame { height: 260px; }
}

/* =================================
   DESKTOP >= 1024px
   ================================= */
@media (min-width: 1024px) {
    .app-shell { padding: 0 24px 32px; }
    .topbar { margin: 16px 0 22px; }
    .menu-link { min-width: 76px; padding: 8px 14px; font-size: 0.86rem; }
    .main-content { gap: 20px; }
    .page-head { padding: 28px 30px; }
    .page-head h2 { font-size: 2.2rem; }
    .panel { padding: 26px; }
    .panel-body { padding: 0 26px 26px; }
    .panel-toggle { padding: 20px 26px; }
    .form-grid,
    .filter-form { grid-template-columns: repeat(3, 1fr); }
    .field-span-2 { grid-column: span 2; }
    .field-span-3 { grid-column: span 3; }
    .budget-grid { grid-template-columns: repeat(3, 1fr); }
    .charts-grid { grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); }
    .chart-frame { height: 300px; }
    .stat-card strong { font-size: 1.6rem; }
}

/* =================================
   Mobile card-style tables
   ================================= */
@media (max-width: 639px) {
    .table-wrap { overflow: visible; }

    .ledger-panel table { min-width: 0; border-collapse: collapse; }
    .ledger-panel thead { display: none; }
    .ledger-panel tbody,
    .ledger-panel tr,
    .ledger-panel td { display: block; width: 100%; }

    .ledger-panel tr {
        margin-bottom: 10px;
        padding: 12px;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: var(--surface-2);
    }

    .ledger-panel td { border: 0; padding: 4px 0; }

    .ledger-panel td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 2px;
        font-size: 0.67rem;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--muted);
        font-weight: 700;
    }

    .ledger-panel .table-actions { justify-content: flex-start; }

    .occurrence-sub-row.is-open { display: block; }
    .occurrence-sub-row td { border-radius: var(--radius-md); padding: 10px 12px; }

    .budget-metrics { grid-template-columns: 1fr 1fr 1fr; }
    .budget-metric strong { font-size: 0.82rem; }

    .history-grid { grid-template-columns: 1fr; }
    .history-wide { grid-column: auto; }

    .history-month-row {
        grid-template-columns: 70px 1fr 80px;
        gap: 8px;
    }

    .alert-panel table { min-width: 0; }
    .alert-panel thead { display: none; }
    .alert-panel tbody, .alert-panel tr, .alert-panel td { display: block; }
    .alert-panel tr {
        margin-bottom: 8px;
        padding: 10px 12px;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: var(--surface-2);
    }
    .alert-panel td { border: 0; padding: 3px 0; font-size: 0.85rem; }
    .alert-panel td::before {
        content: attr(data-label);
        display: block;
        font-size: 0.65rem;
        text-transform: uppercase;
        letter-spacing: 0.07em;
        color: var(--muted);
        font-weight: 700;
        margin-bottom: 1px;
    }
}

/* ═══════════════════════════════════════════════════════
   Dieta module styles
   ═══════════════════════════════════════════════════════ */

/* ── Tab bar ── */
.diet-tabs {
    display: flex;
    gap: 4px;
    padding: 6px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin-bottom: 18px;
}

.diet-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 6px;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.diet-tab svg {
    width: 18px; height: 18px;
    stroke: currentColor; fill: none;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

.diet-tab:hover { color: var(--text); background: var(--surface-2); }
.diet-tab.active { color: #fff; background: var(--primary); }
.diet-tab.active svg { stroke: #fff; }

/* ── Panel ── */
.diet-panel { animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:none; } }

/* ── Profile cards ── */
.diet-profiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

.diet-profile-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.diet-profile-card.is-me {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary-dim);
}

.diet-profile-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.diet-profile-avatar {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #5548d4);
    display: grid; place-items: center;
    font-size: 1.1rem; font-weight: 800; color: #fff;
    flex-shrink: 0;
}

/* ── Kcal ring ── */
.diet-kcal-ring-wrap {
    position: relative;
    width: 110px;
    height: 110px;
    margin: 0 auto;
}

.diet-kcal-ring { width: 100%; height: 100%; transform: rotate(-90deg); }

.ring-track {
    fill: none;
    stroke: var(--surface-3);
    stroke-width: 8;
}

.ring-fill {
    fill: none;
    stroke: var(--primary);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 251.2;
    stroke-dashoffset: calc(251.2 - (251.2 * var(--pct) / 100));
    transition: stroke-dashoffset 0.6s ease;
}

.diet-kcal-ring-label {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.diet-kcal-num {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.03em;
}

.diet-kcal-unit {
    font-size: 0.72rem;
    color: var(--muted);
    font-weight: 600;
}

.diet-profile-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.diet-stat {
    font-size: 0.84rem;
    color: var(--text);
}

.diet-no-profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    text-align: center;
}

.diet-no-profile svg {
    width: 36px; height: 36px;
    stroke: var(--muted); fill: none;
    stroke-width: 2;
}

.diet-no-profile p { color: var(--muted); font-size: 0.87rem; margin: 0; }

/* ── Badges ── */
.diet-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.diet-badge.ok { background: var(--ok-dim); color: var(--ok); }
.diet-badge.warn { background: var(--warn-dim); color: var(--warn); }
.diet-badge.danger { background: var(--danger-dim); color: var(--danger); }
.diet-badge.primary { background: var(--primary-dim); color: var(--primary); }
.diet-badge.primary-dim { background: rgba(124,106,240,0.1); color: #a89df5; }
.diet-badge.neutral { background: var(--surface-3); color: var(--muted); }

/* ── Profile form ── */
.diet-form-wrap {
    margin-top: 0;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 20px;
    background: var(--surface);
}

.diet-form-wrap h3 { margin: 0 0 16px; font-size: 1rem; }

.diet-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.diet-form-grid .full-width { grid-column: 1 / -1; }

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.9rem;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.diet-radio-group {
    display: flex;
    gap: 12px;
}

.diet-radio {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    cursor: pointer;
}

.diet-goal-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.diet-goal-btn {
    position: relative;
    cursor: pointer;
}

.diet-goal-btn input { display: none; }

.diet-goal-btn span {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--muted);
    transition: all 0.15s;
    text-align: center;
}

.diet-goal-btn input:checked + span {
    background: var(--primary-dim);
    border-color: var(--primary);
    color: var(--primary);
}

.diet-form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ── Excluded list ── */
.diet-excluded-list {
    list-style: none;
    margin: 0; padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.diet-excluded-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    font-size: 0.87rem;
}

.diet-excluded-list em { margin-left: auto; font-size: 0.78rem; }

/* ── Search panel ── */
.diet-search-panel h3 { margin: 0 0 4px; }

.diet-tag-wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 8px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    cursor: text;
    margin-bottom: 14px;
}

.diet-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.diet-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: var(--primary-dim);
    border: 1px solid rgba(124,106,240,0.3);
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--primary);
}

.diet-tag button {
    background: none; border: none;
    color: inherit; cursor: pointer;
    padding: 0; line-height: 1;
    font-size: 1rem; opacity: 0.7;
}

.diet-tag button:hover { opacity: 1; }

#diet-ing-input {
    flex: 1;
    min-width: 160px;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
    padding: 0 4px;
}

.diet-search-btns {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.diet-search-btns .btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.diet-search-btns svg {
    width: 16px; height: 16px;
    stroke: currentColor; fill: none;
    stroke-width: 2;
}

/* ── Recipe cards grid ── */
.diet-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
    margin-top: 14px;
}

.diet-recipe-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.diet-recipe-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
}

.diet-recipe-card--ai { border-color: rgba(124,106,240,0.3); }

.diet-recipe-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.diet-recipe-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.diet-fav-btn {
    background: none; border: none;
    padding: 4px; cursor: pointer;
    color: var(--muted-2);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    transition: color 0.15s;
}

.diet-fav-btn svg {
    width: 20px; height: 20px;
    stroke: currentColor; fill: none;
    stroke-width: 2;
}

.diet-fav-btn.is-fav { color: var(--danger); }
.diet-fav-btn.is-fav svg { fill: var(--danger); }
.diet-fav-btn:hover { color: var(--danger); }

.diet-recipe-name {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
}

.diet-recipe-desc {
    margin: 0;
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.diet-recipe-kcal {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    margin-top: auto;
}

.diet-recipe-kcal svg {
    width: 16px; height: 16px;
    stroke: var(--warn); fill: none;
    stroke-width: 2;
}

.diet-recipe-kcal strong { color: var(--warn); font-size: 1rem; }

.diet-recipe-card-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.diet-recipe-card-actions .btn { flex: 1; justify-content: center; min-width: 0; }

.diet-recipe-card-actions .icon-btn-like {
    width: 34px; height: 34px;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    display: grid; place-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

/* ── Results header ── */
.diet-results-header {
    padding: 10px 0;
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 600;
}

/* ── Empty state ── */
.diet-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 48px 20px;
    text-align: center;
    color: var(--muted);
}

.diet-empty-state svg {
    width: 48px; height: 48px;
    stroke: var(--muted-2); fill: none; stroke-width: 1.5;
}

.diet-empty-state p { margin: 0; font-size: 0.9rem; line-height: 1.5; }

/* ── AI loading ── */
.diet-ai-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 40px 20px;
    text-align: center;
    color: var(--muted);
}

.diet-spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Week calendar ── */
.diet-week-header { margin-bottom: 14px; }

.diet-week-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.diet-week-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.diet-avatar-sm {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #5548d4);
    display: grid; place-items: center;
    font-size: 0.78rem;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
}

.diet-day-selector {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
}

.diet-day-btn {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}

.diet-day-btn.has-meals { border-color: var(--primary); }
.diet-day-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.diet-day-dot {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--primary);
}

.diet-day-btn.active .diet-day-dot { background: rgba(255,255,255,0.6); }

/* ── Day kcal summary ── */
.diet-day-kcal-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.diet-day-kcal-item { display: flex; flex-direction: column; gap: 6px; }

.diet-kcal-person-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
}

.diet-day-bar {
    height: 5px;
    background: var(--surface-3);
    border-radius: 999px;
    overflow: hidden;
}

.diet-day-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease;
}

.diet-day-bar-fill.ok { background: var(--ok); }
.diet-day-bar-fill.warn { background: var(--warn); }
.diet-day-bar-fill.danger { background: var(--danger); }

/* ── Meal slots ── */
.diet-slots-list { display: flex; flex-direction: column; gap: 10px; }

.diet-slot {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 62px;
}

.diet-slot.has-recipe { border-color: var(--border-strong); }

.diet-slot-label {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 90px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: capitalize;
    flex-shrink: 0;
}

.diet-slot-icon { font-size: 1rem; }

.diet-slot-recipe {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: space-between;
    min-width: 0;
}

.diet-slot-recipe-info { min-width: 0; }
.diet-slot-recipe-info strong {
    display: block;
    font-size: 0.88rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.diet-slot-meta { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; align-items: center; }
.diet-slot-meta .muted { font-size: 0.75rem; }

.diet-slot-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

.diet-slot-add-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    background: none;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--muted-2);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 8px 14px;
    cursor: pointer;
    transition: all 0.15s;
}

.diet-slot-add-btn svg {
    width: 16px; height: 16px;
    stroke: currentColor; fill: none; stroke-width: 2;
}

.diet-slot-add-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-dim);
}

/* ── Modals ── */
.diet-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.72);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

.diet-modal {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px 20px;
    position: relative;
    -webkit-overflow-scrolling: touch;
}

.diet-modal-sm { max-height: 70vh; }

.diet-modal-close {
    position: sticky;
    float: right;
    top: 0;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    width: 32px; height: 32px;
    display: grid; place-items: center;
    cursor: pointer;
    color: var(--muted);
    padding: 0;
    z-index: 10;
}

.diet-modal-close svg {
    width: 16px; height: 16px;
    stroke: currentColor; fill: none; stroke-width: 2.5;
}

.diet-modal-close:hover { color: var(--text); background: var(--surface-3); }

body.modal-open { overflow: hidden; }

/* ── Recipe modal content ── */
.diet-modal-recipe { padding-top: 8px; }

.diet-modal-recipe-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 800;
    line-height: 1.3;
}

.diet-modal-section { margin-top: 22px; }
.diet-modal-section h4 {
    margin: 0 0 12px;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.diet-table-wrap { overflow-x: auto; }

.diet-portions-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.diet-portions-table th {
    text-align: left;
    padding: 8px 10px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
}

.diet-portions-table td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.diet-portions-table tr:last-child td { border-bottom: none; }
.diet-portions-table td:not(:first-child) { text-align: right; }

.diet-cook-steps {
    padding: 0;
    list-style: none;
    counter-reset: step;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
}

.diet-cook-steps li {
    display: flex;
    gap: 12px;
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--text);
    counter-increment: step;
    padding: 10px 12px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
}

.diet-cook-steps li::before {
    content: counter(step);
    min-width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--primary-dim);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 800;
    display: grid; place-items: center;
    flex-shrink: 0;
}

.diet-modal-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ── Cook mode ── */
.diet-cook-mode { padding-top: 8px; }
.diet-cook-title { margin: 0 0 14px; font-size: 1.1rem; font-weight: 800; }

.diet-cook-kcal-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 18px;
}

.diet-cook-kcal-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: var(--surface-2);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    flex-wrap: wrap;
}

.diet-cook-kcal-item strong { color: var(--warn); font-size: 0.95rem; }

.cook-steps-interactive {
    list-style: none;
    padding: 0; margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cook-step {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--surface-2);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    transition: all 0.2s;
    opacity: 0.5;
}

.cook-step.active {
    opacity: 1;
    border-color: var(--primary);
    background: var(--primary-dim);
}

.cook-step-num {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--surface-3);
    display: grid; place-items: center;
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--muted);
    flex-shrink: 0;
}

.cook-step.active .cook-step-num {
    background: var(--primary);
    color: #fff;
}

.cook-step-text { font-size: 0.88rem; line-height: 1.5; color: var(--text); }
.cook-next-btn { margin-top: 16px; width: 100%; }

.text-right { text-align: right !important; }
.cook-total { color: var(--primary); }

/* ── Btn secondary ── */
.btn.secondary {
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    color: var(--text);
}
.btn.secondary:hover { background: var(--surface-2); }

/* ── Bottom nav diet item ── */
.bottom-nav-item.diet-item svg path {
    stroke-linecap: round;
}

/* ── Responsive tablet+ ── */
@media (min-width: 640px) {
    .diet-modal-overlay {
        align-items: center;
        padding: 20px;
    }
    .diet-modal {
        border-radius: var(--radius-xl);
        max-height: 85vh;
    }
    .diet-tabs .diet-tab span { font-size: 0.72rem; }
    .diet-slots-list { gap: 8px; }
    .diet-profile-chip { display: inline; }
}

/* ══════════════════════════════════════════════════════
   DIET v2 — new styles
   ══════════════════════════════════════════════════════ */

/* Profile action buttons row */
.diet-profile-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* Inline kcal adjust form */
.diet-adjust-kcal-form {
  margin-top: 12px;
  padding: 12px;
  background: var(--surface-raised, rgba(255,255,255,.04));
  border-radius: 10px;
  border: 1px solid var(--border, rgba(255,255,255,.08));
}
.diet-adjust-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-secondary, #a0a0b0);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.diet-adjust-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.diet-adjust-input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(255,255,255,.12));
  background: var(--surface, #1a1a2e);
  color: var(--text, #e0e0f0);
  font-size: .95rem;
}
.btn.xsmall { padding: 4px 8px; font-size: .75rem; }

/* Disliked ingredients panel */
.diet-disliked-panel { padding: 16px; }
.diet-disliked-title {
  margin: 0 0 12px;
  font-size: .9rem;
  font-weight: 600;
}
.diet-disliked-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  min-height: 20px;
}
.diet-tag--disliked {
  background: rgba(220, 60, 60, .15);
  border: 1px solid rgba(220, 60, 60, .3);
  color: #ff7070;
}
.diet-tag--disliked button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0 0 0 6px;
  font-size: 1rem;
  line-height: 1;
  opacity: .7;
}
.diet-tag--disliked button:hover { opacity: 1; }
.diet-disliked-add-form {
  display: flex;
  gap: 8px;
  align-items: center;
}
.diet-disliked-add-form input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(255,255,255,.12));
  background: var(--surface, #1a1a2e);
  color: var(--text, #e0e0f0);
  font-size: .9rem;
}

/* ── Week table ─────────────────────────────────────── */
.diet-week-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 16px;
  border-radius: 12px;
  border: 1px solid var(--border, rgba(255,255,255,.08));
}
.diet-week-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  font-size: .82rem;
}
.diet-week-table thead th {
  padding: 10px 8px;
  text-align: center;
  background: var(--surface-raised, rgba(255,255,255,.04));
  border-bottom: 1px solid var(--border, rgba(255,255,255,.08));
  font-weight: 600;
  white-space: nowrap;
}
.diet-wt-slot-col {
  width: 80px;
  min-width: 72px;
  text-align: left !important;
  padding-left: 12px !important;
  position: sticky;
  left: 0;
  background: var(--surface, #12122a) !important;
  z-index: 2;
  border-right: 1px solid var(--border, rgba(255,255,255,.1));
}
.diet-wt-day-col { min-width: 105px; }
.diet-wt-weekend th,
.diet-wt-weekend td,
th.diet-wt-weekend,
td.diet-wt-weekend {
  background: rgba(255,255,255,.025);
}
.diet-wt-day-name { display: block; font-size: .85rem; }
.diet-wt-day-date { display: block; font-size: .7rem; color: var(--text-secondary, #a0a0b0); }

/* Row */
.diet-wt-row { border-bottom: 1px solid var(--border, rgba(255,255,255,.06)); }
.diet-wt-row:last-child { border-bottom: none; }
.diet-wt-cell {
  padding: 6px 6px;
  vertical-align: top;
  text-align: center;
}
.diet-wt-slot-icon { margin-right: 4px; font-size: 1rem; }
.diet-wt-slot-name { font-size: .78rem; font-weight: 600; color: var(--text-secondary, #a0a0b0); }

/* Recipe pill in cell */
.diet-wt-recipe {
  background: rgba(var(--accent-rgb, 99,102,241), .12);
  border: 1px solid rgba(var(--accent-rgb, 99,102,241), .25);
  border-radius: 8px;
  padding: 5px 6px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.diet-wt-recipe-name {
  display: block;
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text, #e0e0f0);
  word-break: break-word;
}
.diet-wt-recipe-meta {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}
.diet-wt-recipe-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-top: 2px;
}

/* Add button in empty cell */
.diet-wt-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 52px;
  border: 1px dashed var(--border, rgba(255,255,255,.12));
  border-radius: 8px;
  background: none;
  color: var(--text-secondary, #a0a0b0);
  cursor: pointer;
  transition: border-color .18s, color .18s, background .18s;
}
.diet-wt-add-btn svg {
  width: 16px; height: 16px;
  stroke: currentColor; fill: none;
  stroke-width: 2;
}
.diet-wt-add-btn:hover {
  border-color: var(--accent, #6366f1);
  color: var(--accent, #6366f1);
  background: rgba(var(--accent-rgb, 99,102,241), .06);
}

/* Totals footer */
.diet-wt-totals-row {
  background: var(--surface-raised, rgba(255,255,255,.03));
  border-top: 2px solid var(--border, rgba(255,255,255,.1));
}
.diet-wt-totals-label {
  font-size: .75rem;
  font-weight: 700;
  color: var(--text-secondary, #a0a0b0);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.diet-wt-totals-cell { padding: 8px 6px; }
.diet-wt-kcal-line {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
  font-size: .75rem;
  margin-bottom: 2px;
}
.diet-avatar-xs {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent, #6366f1);
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  flex-shrink: 0;
}
.diet-kcal-ok    { color: #4ade80; font-weight: 600; }
.diet-kcal-warn  { color: #facc15; font-weight: 600; }
.diet-kcal-danger{ color: #f87171; font-weight: 600; }

/* Week legend at top of Semana tab */
.diet-week-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface-raised, rgba(255,255,255,.04));
  border-radius: 10px;
  margin-bottom: 4px;
}
.diet-week-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .82rem;
}

/* ══════════════════════════════════════════════════════
   Juegos Hub — juegos_styles.css
   ══════════════════════════════════════════════════════ */

/* ── App wrapper ── */
#juegos-app { max-width: 640px; margin: 0 auto; padding: 16px; }

/* ── Screens ── */
.juegos-screen { width: 100%; position: relative; }

/* ── Back button ── */
.juegos-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text-secondary, #a0a0b0);
  font-size: .9rem;
  cursor: pointer;
  padding: 6px 0;
  margin-bottom: 16px;
  transition: color .18s;
}
.juegos-back-btn svg {
  width: 18px; height: 18px;
  stroke: currentColor; fill: none; stroke-width: 2;
}
.juegos-back-btn:hover { color: var(--text, #e0e0f0); }

/* ── Hub header ── */
.juegos-hub-header { text-align: center; margin-bottom: 24px; }
.juegos-hub-header h2 { font-size: 1.6rem; margin: 0 0 4px; }
.juegos-hub-header .muted { font-size: .9rem; }

/* ── Hub grid ── */
.juegos-hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

/* ── Game cards ── */
.juegos-card {
  background: var(--surface-raised, rgba(255,255,255,.04));
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  padding: 24px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  border-top: 3px solid var(--gc, #6366f1);
  transition: transform .18s, box-shadow .18s;
}
.juegos-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.juegos-card-icon { font-size: 2.2rem; line-height: 1; }
.juegos-card-name { font-size: 1.1rem; font-weight: 700; margin: 0; }
.juegos-card-desc { font-size: .82rem; color: var(--text-secondary, #a0a0b0); margin: 0; line-height: 1.4; flex: 1; }
.juegos-card-btn { margin-top: 8px; align-self: stretch; text-align: center; border-radius: 10px; font-weight: 600; color: #fff; border: none; padding: 10px; cursor: pointer; font-size: .9rem; transition: filter .18s; }
.juegos-card-btn:hover { filter: brightness(1.1); }

/* ── Setup ── */
.setup-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 24px;
  padding: 16px;
  background: var(--surface-raised, rgba(255,255,255,.04));
  border-radius: 14px;
}
.setup-game-icon { font-size: 2.5rem; line-height: 1; flex-shrink: 0; }
.setup-header h3 { font-size: 1.25rem; margin: 0 0 4px; }
.setup-header .muted { font-size: .82rem; }

.setup-section { margin-bottom: 20px; }
.setup-section h4 { font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-secondary, #a0a0b0); margin: 0 0 10px; }

/* Mode toggle buttons */
.setup-modes { display: flex; flex-wrap: wrap; gap: 8px; }
.setup-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 20px;
  border: 1px solid var(--border, rgba(255,255,255,.12));
  background: var(--surface, rgba(255,255,255,.03));
  color: var(--text-secondary, #a0a0b0);
  font-size: .85rem;
  cursor: pointer;
  user-select: none;
  transition: background .18s, border-color .18s, color .18s;
}
.setup-mode-btn.active {
  background: rgba(99,102,241,.18);
  border-color: rgba(99,102,241,.5);
  color: #a5b4fc;
  font-weight: 600;
}

/* Player add */
.setup-player-add { display: flex; gap: 8px; margin-bottom: 10px; }
.setup-player-add input {
  flex: 1; padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(255,255,255,.12));
  background: var(--surface, rgba(255,255,255,.03));
  color: var(--text, #e0e0f0);
  font-size: .9rem;
}
.setup-players-list { display: flex; flex-wrap: wrap; gap: 8px; }
.setup-player-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(99,102,241,.12);
  border: 1px solid rgba(99,102,241,.25);
  border-radius: 20px;
  padding: 4px 10px 4px 6px;
  font-size: .85rem;
}
.setup-player-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #6366f1;
  color: #fff;
  font-size: .7rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.setup-remove-player {
  background: none; border: none;
  color: var(--text-secondary, #a0a0b0);
  cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 0 0 2px;
  opacity: .7; transition: opacity .18s;
}
.setup-remove-player:hover { opacity: 1; }

.setup-black-info {
  margin-bottom: 16px;
  padding: 12px 14px;
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  font-size: .82rem;
  color: var(--text-secondary, #a0a0b0);
  line-height: 1.5;
}

.juegos-start-btn { width: 100%; padding: 14px; font-size: 1rem; }

/* ── Game screen ── */
.game-header { margin-bottom: 20px; text-align: center; }
.game-header h3 { font-size: 1.3rem; margin: 0 0 4px; }
.game-modes-active { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 6px; }

/* Generic game card */
.game-card {
  background: var(--surface-raised, rgba(255,255,255,.05));
  border: 1px solid var(--border, rgba(255,255,255,.1));
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  margin-bottom: 16px;
}
.game-card-type {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-secondary, #a0a0b0);
  margin-bottom: 12px;
}
.game-card-text {
  font-size: 1.05rem;
  line-height: 1.5;
  margin: 0;
  color: var(--text, #e0e0f0);
}

/* Change buttons row */
.change-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }

/* Game actions */
.game-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.game-rule { font-size: .82rem; text-align: center; margin-top: 8px; }

/* ── Yo Nunca card ── */
.yn-card {
  background: linear-gradient(145deg, rgba(59,130,246,.12), rgba(99,102,241,.08));
  border: 1px solid rgba(59,130,246,.3);
  border-radius: 20px;
  padding: 36px 24px;
  text-align: center;
  margin-bottom: 20px;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.yn-card-inner { max-width: 380px; }
.yn-prefix { font-size: .85rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: #93c5fd; margin: 0 0 12px; }
.yn-text { font-size: 1.15rem; line-height: 1.5; margin: 0; transition: opacity .2s; }

/* ── Slot machine ── */
.slot-machine {
  background: linear-gradient(180deg, #1a1025 0%, #0d0a18 100%);
  border: 2px solid #4a3060;
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: 0 0 30px rgba(120,60,200,.25), inset 0 0 20px rgba(0,0,0,.5);
  position: relative;
}
.slot-machine-lights {
  display: flex;
  justify-content: space-around;
  padding: 4px 8px;
}
.slot-machine-lights.bottom { margin-top: 4px; }
.slot-light {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #7c3aed;
  box-shadow: 0 0 6px #7c3aed;
  animation: slot-blink 1.2s infinite alternate;
}
.slot-light:nth-child(2) { animation-delay: .17s; }
.slot-light:nth-child(3) { animation-delay: .34s; }
.slot-light:nth-child(4) { animation-delay: .51s; }
.slot-light:nth-child(5) { animation-delay: .68s; }
.slot-light:nth-child(6) { animation-delay: .85s; }
.slot-light:nth-child(7) { animation-delay: 1.02s; }
@keyframes slot-blink {
  0%   { opacity: 1;   box-shadow: 0 0 8px #7c3aed; }
  100% { opacity: .25; box-shadow: none; }
}
.slot-header {
  text-align: center;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .15em;
  color: #c084fc;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.slot-reel-wrap {
  display: flex;
  justify-content: center;
  padding: 4px;
}
.slot-reel-frame {
  background: #0a0814;
  border: 2px solid #6d28d9;
  border-radius: 12px;
  padding: 16px 32px;
  min-width: 220px;
  text-align: center;
  box-shadow: inset 0 4px 12px rgba(0,0,0,.6), 0 0 16px rgba(109,40,217,.2);
  position: relative;
  overflow: hidden;
}
.slot-reel-frame::before,
.slot-reel-frame::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 18px;
  z-index: 2;
  pointer-events: none;
}
.slot-reel-frame::before { top: 0; background: linear-gradient(to bottom, #0a0814, transparent); }
.slot-reel-frame::after  { bottom: 0; background: linear-gradient(to top, #0a0814, transparent); }
.slot-reel {
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: .03em;
  transition: transform .12s, color .12s;
  min-height: 2rem;
  line-height: 2rem;
}
.slot-winner-flash { animation: slot-flash .18s ease-in-out 3; }
@keyframes slot-flash {
  0%,100% { opacity: 1; }
  50%      { opacity: .3; }
}
.slot-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 14px;
  padding: 12px;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  border: 1px solid #8b5cf6;
  border-radius: 10px;
  color: #fff;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter .18s, transform .1s;
  letter-spacing: .03em;
}
.slot-btn:hover:not(:disabled) { filter: brightness(1.15); transform: translateY(-1px); }
.slot-btn:disabled { opacity: .45; cursor: not-allowed; }
.slot-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2.5; }

/* ── Verdad o Reto ── */
.vor-player-title { text-align: center; font-size: 1.05rem; margin-bottom: 14px; }
.vor-choice-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 20px; }
.vor-btn-truth {
  flex: 1; min-width: 130px; max-width: 200px;
  padding: 14px; border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border: 1px solid #60a5fa;
  color: #fff; font-size: 1rem; font-weight: 700;
  cursor: pointer; transition: filter .18s;
}
.vor-btn-dare {
  flex: 1; min-width: 130px; max-width: 200px;
  padding: 14px; border-radius: 12px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border: 1px solid #f87171;
  color: #fff; font-size: 1rem; font-weight: 700;
  cursor: pointer; transition: filter .18s;
}
.vor-btn-truth:hover, .vor-btn-dare:hover { filter: brightness(1.1); }
.vor-next-round-btn { width: 100%; margin-top: 8px; }

/* ── Verde Amarillo Rojo ── */
.var-levels-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.var-player-level {
  flex: 1;
  min-width: 120px;
  background: var(--surface-raised, rgba(255,255,255,.04));
  border: 1px solid;
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.var-player-name { font-size: .8rem; font-weight: 700; color: var(--text, #e0e0f0); }
.var-level-label { font-size: .85rem; font-weight: 600; }
.var-progress-dots { display: flex; gap: 5px; margin-top: 2px; }
.var-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  transition: background .25s, box-shadow .25s;
}
.var-dot.filled {
  background: var(--dc, #10b981);
  box-shadow: 0 0 6px var(--dc, #10b981);
  border-color: transparent;
}

.var-card-wrap { position: relative; }
.var-level-badge {
  text-align: center;
  font-size: .82rem;
  margin-bottom: 10px;
  padding: 6px 12px;
  background: rgba(255,255,255,.04);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.08);
}

.var-result-btns { display: flex; gap: 12px; }
.var-result-btns .btn { flex: 1; padding: 12px; font-size: .9rem; }
.btn.ok {
  background: linear-gradient(135deg, #059669, #047857);
  border: 1px solid #34d399;
  color: #fff;
  cursor: pointer;
  border-radius: 10px;
  font-weight: 600;
}
.btn.danger {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  border: 1px solid #f87171;
  color: #fff;
  cursor: pointer;
  border-radius: 10px;
  font-weight: 600;
}
.btn.ok:hover { filter: brightness(1.1); }
.btn.danger:hover { filter: brightness(1.1); }

/* Level-up notification */
.var-levelup-notif {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1025;
  border: 2px solid #7c3aed;
  border-radius: 14px;
  padding: 14px 24px;
  font-size: .95rem;
  z-index: 9999;
  animation: levelup-in .4s cubic-bezier(.34,1.56,.64,1) both, levelup-out .4s ease-in 2.5s both;
  white-space: nowrap;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
@keyframes levelup-in {
  from { opacity: 0; transform: translateX(-50%) scale(.7); }
  to   { opacity: 1; transform: translateX(-50%) scale(1); }
}
@keyframes levelup-out {
  to { opacity: 0; transform: translateX(-50%) translateY(-12px); }
}

/* ── ¿Quién es más probable? ── */
.qmp-card {
  background: linear-gradient(145deg, rgba(245,158,11,.1), rgba(251,191,36,.06));
  border: 1px solid rgba(245,158,11,.3);
  border-radius: 20px;
  padding: 40px 24px;
  text-align: center;
  margin-bottom: 20px;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qmp-text { font-size: 1.15rem; line-height: 1.5; margin: 0; transition: opacity .2s; }

/* ── Shared btn sizes ── */
.btn.primary.large { padding: 13px 28px; font-size: 1rem; width: 100%; }
.btn.ghost.small {
  background: none;
  border: 1px solid var(--border, rgba(255,255,255,.12));
  color: var(--text-secondary, #a0a0b0);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: .8rem;
  cursor: pointer;
  transition: border-color .18s, color .18s;
}
.btn.ghost.small:hover { border-color: var(--accent, #6366f1); color: var(--text, #e0e0f0); }
.btn.primary.small {
  padding: 8px 14px; font-size: .85rem;
  background: var(--accent, #6366f1);
  border: none; border-radius: 8px;
  color: #fff; cursor: pointer; font-weight: 600;
  transition: filter .18s;
}
.btn.primary.small:hover { filter: brightness(1.1); }

/* ── Responsive ── */
@media (max-width: 480px) {
  .juegos-hub-grid { grid-template-columns: 1fr; }
  .slot-reel-frame { min-width: 160px; padding: 14px 20px; }
  .var-levels-bar { flex-direction: column; }
  .vor-choice-btns { flex-direction: column; align-items: center; }
}

/* ── Heaviness bar ── */
.heaviness-bar-wrap {
  margin-top: 10px;
  padding: 8px 12px;
  background: rgba(255,255,255,.04);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.06);
}
.heaviness-bar-track {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,.1);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.heaviness-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .4s ease, background .4s ease;
}
.heaviness-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .78rem;
  color: var(--text-secondary, #a0a0b0);
}
.heaviness-score { font-weight: 700; font-size: .82rem; }

/* ── Slot skip button ── */
.slot-btn-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.slot-btn { flex: 1; margin-top: 0 !important; }
.slot-skip-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 14px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 10px;
  color: #e0e0f0;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .18s;
  flex-shrink: 0;
}
.slot-skip-btn:hover:not(:disabled) { background: rgba(255,255,255,.12); }
.slot-skip-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── VAR advance button ── */
.var-advance-btn {
  margin-top: 6px;
  padding: 5px 8px;
  font-size: .72rem;
  font-weight: 600;
  background: transparent;
  border: 1px solid;
  border-radius: 6px;
  cursor: pointer;
  transition: background .18s;
  width: 100%;
}
.var-advance-btn:hover { background: rgba(255,255,255,.06); }

/* ── QMP mode list in game ── */
.qmp-modes { margin-bottom: 6px; }

/* ── setup-mode-btn fix: ensure button not double-firing ── */
.setup-mode-btn { cursor: pointer; font-family: inherit; }

/* ── Game list button ── */
.game-list-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  padding: 7px 13px;
  font-size: .8rem;
  font-weight: 600;
  font-family: inherit;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  color: #e2e8f0;
  cursor: pointer;
  transition: background .18s, transform .12s;
  z-index: 10;
}
.game-list-btn:hover { background: rgba(255,255,255,.15); transform: scale(1.04); }

/* ── List modal overlay ── */
.list-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 9000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity .22s ease;
}
.list-modal-overlay.list-modal-visible { opacity: 1; }
.list-modal-overlay.list-modal-closing { opacity: 0; }

/* ── List modal container ── */
.list-modal {
  background: #1e2030;
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  transform: translateY(40px);
  transition: transform .22s ease;
  overflow: hidden;
}
.list-modal-overlay.list-modal-visible .list-modal { transform: translateY(0); }
.list-modal-overlay.list-modal-closing .list-modal { transform: translateY(40px); }

/* ── List modal header ── */
.list-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.list-modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #f1f5f9;
  margin: 0;
}
.list-modal-close {
  background: rgba(255,255,255,.07);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  color: #94a3b8;
  cursor: pointer;
  font-size: .95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.list-modal-close:hover { background: rgba(255,255,255,.15); color: #f1f5f9; }

/* ── Tabs ── */
.list-modal-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.list-modal-tabs::-webkit-scrollbar { display: none; }
.list-tab-btn {
  flex-shrink: 0;
  padding: 6px 13px;
  font-size: .78rem;
  font-weight: 600;
  font-family: inherit;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 20px;
  color: #94a3b8;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.list-tab-btn:hover { background: rgba(255,255,255,.11); color: #e2e8f0; }
.list-tab-btn.active {
  background: rgba(99,102,241,.25);
  border-color: rgba(99,102,241,.6);
  color: #a5b4fc;
}

/* ── Modal body ── */
.list-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 0 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}

/* ── Sections ── */
.list-section { padding: 12px 16px 6px; }
.list-add-section { border-top: 1px solid rgba(255,255,255,.07); margin-top: 4px; padding-top: 14px; }
.list-section-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #64748b;
  margin-bottom: 8px;
}

/* ── Items scroll ── */
.list-items-scroll {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.08) transparent;
}
.list-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 10px;
  background: rgba(255,255,255,.04);
  border-radius: 8px;
  font-size: .82rem;
  color: #cbd5e1;
  line-height: 1.4;
}
.list-item-custom {
  background: rgba(99,102,241,.08);
  border: 1px solid rgba(99,102,241,.2);
}
.list-item-text { flex: 1; }
.list-item-del {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: .8rem;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
  transition: background .15s;
  margin-top: 1px;
}
.list-item-del:hover { background: rgba(239,68,68,.15); }
.list-item-tag {
  display: inline-block;
  font-size: .68rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  margin-right: 5px;
  vertical-align: middle;
}
.tag-reto { background: rgba(239,68,68,.2); color: #fca5a5; }
.tag-preg { background: rgba(99,102,241,.2); color: #a5b4fc; }
.list-empty { color: #475569; font-size: .8rem; font-style: italic; padding: 4px 0; }

/* ── Add form ── */
.list-add-type-row {
  display: flex;
  gap: 16px;
  margin-bottom: 8px;
}
.list-type-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .83rem;
  color: #94a3b8;
  cursor: pointer;
}
.list-add-textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px 12px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  color: #e2e8f0;
  font-family: inherit;
  font-size: .85rem;
  resize: vertical;
  box-sizing: border-box;
  transition: border-color .15s;
}
.list-add-textarea::placeholder { color: #475569; }
.list-add-textarea:focus { outline: none; border-color: rgba(99,102,241,.5); }
.list-add-btn {
  margin-top: 8px;
  width: 100%;
  padding: 11px;
  font-size: .88rem;
  font-weight: 700;
  font-family: inherit;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border: none;
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  transition: opacity .15s, transform .12s;
}
.list-add-btn:hover { opacity: .9; transform: scale(1.02); }
.list-add-btn:active { transform: scale(.98); }
