:root {
    --bg: #e8f1ff;
    --panel: #ffffff;
    --panel-soft: #f1f6ff;
    --text: #081b36;
    --muted: #526985;
    --primary: #0f3d8f;
    --primary-dark: #082f73;
    --green: #059669;
    --pink: #3b82f6;
    --amber: #f59e0b;
    --red: #dc2626;
    --border: #bfd2ee;
    --shadow: 0 18px 45px rgba(8, 47, 115, 0.18);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Outfit', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text);
    background:
        radial-gradient(900px 420px at 12% 0%, rgba(15, 61, 143, 0.24), transparent 60%),
        radial-gradient(700px 380px at 96% 20%, rgba(2, 132, 199, 0.18), transparent 58%),
        linear-gradient(160deg, #e8f1ff 0%, #f8fbff 58%, #c7dafa 100%);
}

a {
    color: inherit;
    text-decoration: none;
}

.login-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 28px;
}

.login-card {
    width: min(1040px, 100%);
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 30px;
    box-shadow: var(--shadow);
    overflow: hidden;
    backdrop-filter: blur(16px);
}

.login-hero {
    padding: 48px;
    background:
        linear-gradient(180deg, rgba(8, 27, 54, 0.18), rgba(8, 27, 54, 0.42)),
        linear-gradient(140deg, #082f73, #0f3d8f 55%, #0284c7);
    color: #fff;
}

.login-hero h1 {
    margin: 12px 0;
    font-size: clamp(2.2rem, 5vw, 4.5rem);
    line-height: 0.95;
}

.login-hero p {
    max-width: 580px;
    color: rgba(255, 255, 255, 0.86);
    font-size: 1.08rem;
}

.login-family-photo {
    width: 100%;
    max-height: 360px;
    margin-top: 24px;
    object-fit: cover;
    object-position: center;
    border: 8px solid rgba(255, 255, 255, 0.38);
    border-radius: 28px;
    box-shadow: 0 24px 50px rgba(15, 35, 63, 0.32);
}

.login-hero::after {
    content: 'Juntos organizamos la casa, las metas y el futuro';
    display: block;
    margin-top: 18px;
    padding: 14px 18px;
    border: 1px solid rgba(255, 255, 255, 0.34);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.14);
    color: #e0f2fe;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.login-form {
    padding: 48px;
}

.app-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px;
    background: rgba(255, 255, 255, 0.82);
    border-right: 1px solid var(--border);
    backdrop-filter: blur(16px);
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border-radius: 18px;
    background: #eff6ff;
}

.brand-icon,
.brand-photo {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 15px;
    background: linear-gradient(135deg, var(--primary), #0284c7);
    color: #fff;
}

.brand-photo {
    overflow: hidden;
    padding: 0;
}

.brand-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    color: var(--muted);
    font-size: 0.78rem;
}

.nav {
    margin-top: 24px;
    display: grid;
    gap: 8px;
}

.nav a,
.portal-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 14px;
    color: var(--muted);
    font-weight: 700;
}

.nav a {
    --nav-color: var(--primary);
    --nav-bg: #eff6ff;
}

.nav a i {
    color: var(--nav-color);
}

.nav a.active,
.nav a:hover {
    color: var(--nav-color);
    background: var(--nav-bg);
}

.nav-dashboard {
    --nav-color: #2563eb;
    --nav-bg: #eff6ff;
}

.nav-finanzas {
    --nav-color: #e11d48;
    --nav-bg: #fff1f2;
}

.nav-metas {
    --nav-color: #7c3aed;
    --nav-bg: #f5f3ff;
}

.nav-tareas {
    --nav-color: #059669;
    --nav-bg: #ecfdf5;
}

.nav-horarios {
    --nav-color: #0891b2;
    --nav-bg: #ecfeff;
}

.nav-alertas {
    --nav-color: #d97706;
    --nav-bg: #fffbeb;
}

.nav-reportes {
    --nav-color: #4f46e5;
    --nav-bg: #eef2ff;
}

.nav-familia {
    --nav-color: #db2777;
    --nav-bg: #fdf2f8;
}

.portal-link:hover {
    color: var(--primary-dark);
    background: #eff6ff;
}

.sidebar-family-photo {
    margin-top: 18px;
    padding: 10px;
    border-radius: 20px;
    background: linear-gradient(180deg, #eff6ff, #dbeafe);
    border: 1px solid var(--border);
    box-shadow: 0 10px 26px rgba(37, 99, 235, 0.1);
}

.sidebar-family-photo img {
    width: 100%;
    height: auto;
    max-height: 320px;
    display: block;
    object-fit: contain;
    object-position: center;
    border-radius: 16px;
    background: #fff;
}

.sidebar-family-photo span {
    display: block;
    margin-top: 8px;
    color: var(--primary-dark);
    font-weight: 900;
    text-align: center;
    font-size: 0.86rem;
}

.portal-link {
    position: absolute;
    bottom: 24px;
    left: 24px;
    right: 24px;
}

.main {
    padding: 26px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    margin-bottom: 24px;
    padding: 18px;
    border: 1px solid rgba(191, 210, 238, 0.9);
    border-radius: 28px;
    background:
        linear-gradient(135deg, rgba(8, 47, 115, 0.94), rgba(15, 61, 143, 0.86)),
        radial-gradient(circle at 90% 10%, rgba(14, 165, 233, 0.5), transparent 36%);
    color: #fff;
    box-shadow: 0 18px 42px rgba(8, 47, 115, 0.22);
}

.topbar-title {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-title img {
    width: 82px;
    height: 82px;
    object-fit: cover;
    border: 4px solid #fff;
    border-radius: 22px;
    box-shadow: 0 10px 26px rgba(37, 99, 235, 0.2);
}

.topbar .eyebrow {
    color: #bfdbfe;
}

.topbar .userbox {
    background: rgba(255, 255, 255, 0.14);
    box-shadow: none;
}

.topbar .userbox a {
    color: #dbeafe;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--primary);
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.76rem;
}

h1,
h2,
h3 {
    margin-top: 0;
}

.topbar h1 {
    margin: 0;
    font-size: clamp(1.8rem, 4vw, 3rem);
}

.userbox {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    font-weight: 700;
}

.userbox a {
    color: var(--red);
}

.grid {
    display: grid;
    gap: 18px;
}

.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.card {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(219, 229, 243, 0.88);
    border-radius: 24px;
    padding: 22px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.07);
}

.collapsible-card summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    list-style: none;
    font-weight: 900;
    font-size: 1.15rem;
}

.collapsible-card summary::-webkit-details-marker {
    display: none;
}

.collapsible-card summary::after {
    content: '+';
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: #e2e8f0;
    color: #334155;
    flex: 0 0 auto;
}

.collapsible-card[open] summary::after {
    content: '-';
}

.collapsible-card summary small {
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
}

.collapsible-card form {
    margin-top: 16px;
}

.stat {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.stat i {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), #0284c7);
}

.stat strong {
    display: block;
    margin-top: 8px;
    font-size: 1.8rem;
}

.muted {
    color: var(--muted);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.btn {
    border: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 13px;
    background: linear-gradient(135deg, var(--primary), #0284c7);
    color: #fff;
    font-weight: 800;
    cursor: pointer;
}

.btn.secondary {
    background: #e2e8f0;
    color: #1e293b;
}

.btn.success {
    background: var(--green);
}

.btn.danger {
    background: var(--red);
}

.btn.warning {
    background: var(--amber);
}

.btn:disabled,
.mini-btn:disabled {
    cursor: not-allowed;
    filter: grayscale(0.45);
    opacity: 0.45;
}

form.stack,
.stack {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-weight: 700;
    font-size: 0.9rem;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 13px;
    padding: 11px 12px;
    font: inherit;
    color: var(--text);
    background: #fff;
}

textarea {
    min-height: 92px;
    resize: vertical;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #334155;
    font-weight: 800;
    font-size: 0.78rem;
}

.badge.pagado,
.badge.realizada,
.badge.cumplida,
.badge.activa {
    background: #dcfce7;
    color: #166534;
}

.badge.pendiente,
.badge.programado {
    background: #fef3c7;
    color: #92400e;
}

.badge.vencido,
.badge.omitida {
    background: #fee2e2;
    color: #991b1b;
}

.progress {
    height: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
}

.progress span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--green));
}

.flash {
    margin-bottom: 18px;
    padding: 13px 15px;
    border-radius: 14px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1d4ed8;
    font-weight: 700;
}

.flash.error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

.flash.success {
    background: #ecfdf5;
    border-color: #bbf7d0;
    color: #047857;
}

.mini-list {
    display: grid;
    gap: 10px;
}

.mini-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border-radius: 16px;
    background: var(--panel-soft);
}

.member-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
}

.dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--primary);
}

.chart-card canvas {
    width: 100%;
    max-height: 320px;
}

.person-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.person-summary {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--panel-soft);
}

.person-summary strong {
    font-size: 1.2rem;
}

.task-icon-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.task-icon-columns h4 {
    margin: 0 0 8px;
    font-size: 0.82rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.task-icon-list {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    min-height: 34px;
}

.task-icon-chip {
    position: relative;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: #e2e8f0;
    color: #334155;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.task-icon-list.done .task-icon-chip {
    background: #dcfce7;
    color: #166534;
}

.task-icon-list.pending .task-icon-chip {
    background: #fef3c7;
    color: #92400e;
}

.task-icon-list.pending .task-icon-chip.omitida {
    background: #fee2e2;
    color: #991b1b;
}

.task-icon-chip small {
    position: absolute;
    right: -5px;
    top: -6px;
    min-width: 17px;
    height: 17px;
    display: grid;
    place-items: center;
    padding: 0 4px;
    border-radius: 999px;
    background: #0f172a;
    color: #fff;
    font-size: 0.64rem;
    font-weight: 900;
}

.calendar-card {
    overflow-x: auto;
}

.calendar-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.calendar-toolbar h2 {
    margin: 0;
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    color: #164e3f;
    text-align: center;
}

.calendar-toolbar.compact {
    align-items: flex-start;
}

.calendar-weekdays,
.calendar-grid {
    min-width: 980px;
    display: grid;
    grid-template-columns: repeat(7, minmax(132px, 1fr));
}

.calendar-weekdays span {
    padding: 12px;
    text-align: center;
    color: #36584e;
    font-size: 0.8rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    border: 1px solid var(--border);
    border-bottom: 0;
    background: #f8fafc;
}

.calendar-day {
    min-height: 176px;
    padding: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.9);
}

.calendar-day.muted-day {
    background: #f8fafc;
    color: #94a3b8;
}

.calendar-day.today {
    background: #eef5ff;
    box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.24);
}

.calendar-day.selected {
    background: #eaf2ff;
    box-shadow: inset 0 0 0 2px rgba(5, 150, 105, 0.35);
}

.day-number {
    display: grid;
    place-items: center;
    margin-left: auto;
    width: 30px;
    height: 30px;
    border-radius: 10px;
    color: #24493f;
    font-weight: 900;
}

.today .day-number,
.selected .day-number {
    background: #155e4b;
    color: #fff;
}

.calendar-events {
    display: grid;
    gap: 7px;
    margin-top: 8px;
}

.task-event {
    padding: 8px;
    border-radius: 11px;
    background: linear-gradient(135deg, #ffffff, #f8fbff);
    box-shadow: 0 5px 12px rgba(15, 23, 42, 0.06);
}

.task-event.realizada {
    background: #ecfdf5;
}

.task-event.pendiente {
    background: #fffbeb;
}

.task-event.omitida {
    background: #fef2f2;
}

.task-event-title {
    font-size: 0.76rem;
    font-weight: 900;
    text-transform: uppercase;
    line-height: 1.1;
}

.task-event-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 800;
}

.task-event-actions {
    display: flex;
    gap: 5px;
    margin-top: 7px;
}

.person-event {
    border-left: 5px solid var(--primary);
    border-radius: 13px;
    background: #fff;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.person-event summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 8px;
    cursor: pointer;
    list-style: none;
}

.person-event summary::-webkit-details-marker {
    display: none;
}

.person-event summary::after {
    content: '+';
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #e2e8f0;
    color: #334155;
    font-weight: 900;
    flex: 0 0 auto;
}

.person-event[open] summary::after {
    content: '-';
}

.person-event .member-pill {
    min-width: 0;
    font-size: 0.78rem;
}

.person-counts {
    display: inline-flex;
    gap: 4px;
    margin-left: auto;
    font-size: 0.68rem;
    font-weight: 900;
    color: var(--muted);
    white-space: nowrap;
}

.person-counts span {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px 5px;
    border-radius: 999px;
    background: #f1f5f9;
}

.person-counts .fa-check {
    color: var(--green);
}

.person-counts .fa-clock {
    color: var(--amber);
}

.person-counts .fa-xmark {
    color: var(--red);
}

.person-task-list {
    display: grid;
    gap: 6px;
    padding: 0 8px 8px;
}

.mini-btn {
    width: 27px;
    height: 27px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 9px;
    color: #fff;
    cursor: pointer;
    font-size: 0.74rem;
}

.mini-btn.success {
    background: var(--green);
}

.mini-btn.warning {
    background: var(--amber);
}

.mini-btn.danger {
    background: var(--red);
}

@media (max-width: 980px) {
    .app-shell,
    .login-card {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
    }

    .portal-link {
        position: static;
        margin-top: 18px;
    }

    .grid-2,
    .grid-3,
    .grid-4,
    .person-summary-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .calendar-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }
}
