:root {
    --ink: #282131;
    --muted: #766d7f;
    --purple: #624181;
    --tema-suave: #d7b8f2;
    --deep: #352047;
    --line: #ebe6ef;
    --bg: #f7f5f8;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.5 system-ui, sans-serif;
}

button { cursor: pointer; }

/* Barra, navegación y pie */

.topbar {
    height: 66px;
    background: var(--deep);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    color: white;
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 800;
    color: white;
    text-decoration: none;
    font-size: 21px;
}

.brand span,
.login-card h1 span { color: #d7b8f2; }

.brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 5px;
}

.account {
    display: flex;
    gap: 18px;
    align-items: center;
}

.account form { margin: 0; }

.icon {
    display: inline-block;
    width: 32px;
    height: 32px;
    flex: none;
    opacity: .72;
    color: var(--tema-suave);
    background-color: var(--tema-suave);
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
}

.icon-gear {
    -webkit-mask: url("assets/img/icons/gear.svg") no-repeat center / contain;
    mask: url("assets/img/icons/gear.svg") no-repeat center / contain;
}

.icon-door-open {
    -webkit-mask: url("assets/img/icons/door-open.svg") no-repeat center / contain;
    mask: url("assets/img/icons/door-open.svg") no-repeat center / contain;
}

.shell {
    max-width: 1440px;
    margin: auto;
    display: grid;
    grid-template-columns: 215px 1fr;
    min-height: calc(100vh - 66px);
}

.sidebar {
    background: white;
    border-right: 1px solid var(--line);
    padding: 24px 14px;
}

.sidebar nav {
    display: grid;
    gap: 5px;
    position: sticky;
    top: 20px;
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px;
    color: #615769;
    text-decoration: none;
    border-radius: 8px;
}

.sidebar a:hover { background: #f2eef6; }

.nav-icon {
    width: 19px;
    height: 19px;
    opacity: .72;
    flex: none;
}

.content {
    padding: 32px clamp(16px, 4vw, 54px);
    min-width: 0;
    max-width: 100%;
}

footer {
    padding: 22px 0;
    color: #888;
    font-size: 12px;
}

/* Títulos */

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

.page-heading h1 {
    font-size: 30px;
    margin: 2px 0;
}

.page-heading .actions form { display: inline-flex; }

.eyebrow {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--purple);
    letter-spacing: .1em;
}

.eyebrow.is-active,
.eyebrow.is-inactive {
    display: inline-block;
    margin: 0;
    padding: 2px 8px;
    border-radius: 8px;
    letter-spacing: .06em;
}

.eyebrow.is-active { background: #effaf4; color: #276d4b; }

.eyebrow.is-inactive { background: #fff2f0; color: #9b4037; }

.eyebrow p{
    margin-top: 0;
}
.muted,
small { color: var(--muted); }

/* Botones */

.primary,
.secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 0;
    border-radius: 8px;
    padding: 0 15px;
    font: inherit;
    font-weight: 650;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

.primary { background: var(--purple); color: white; }

.secondary { background: #f0ecf3; color: var(--ink); }

.full { width: 100%; }

.actions { display: flex; gap: 10px; }

.actions form { margin: 0; }

.link-button {
    background: none;
    border: 0;
    color: var(--purple);
    font: inherit;
    cursor: pointer;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 38px;
    padding: 6px 10px;
    border: 1px solid currentColor;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font: inherit;
}

.icon-button img { width: 18px; height: 18px; }

.danger { color: #a3464e; }

.icon-button.danger { color: var(--danger, #b42318); }

/* Avisos */

.notice {
    padding: 12px;
    background: #effaf4;
    color: #276d4b;
    border-radius: 8px;
    margin-bottom: 16px;
}

.notice.error { background: #fff2f0; color: #9b4037; }

/* Paneles, totales y gráfico */

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 13px;
    margin: 20px 0;
}

.stat,
.panel {
    background: white;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.stat {
    padding: 17px;
    display: grid;
    gap: 6px;
}

.stat span { color: var(--muted); font-size: 13px; }

.stat strong { font-size: 25px; }

.panel { padding: 20px; margin-bottom: 18px; min-width: 0; max-width: 100%; }

.panel h2 { margin: 0 0 10px; font-size: 19px; }

.columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.chart { max-width: 800px; }

.bar-row {
    display: grid;
    grid-template-columns: 120px 1fr 85px;
    gap: 10px;
    align-items: center;
    padding: 6px 0;
    font-size: 13px;
}

.bar-track {
    height: 9px;
    background: #eee8f2;
    border-radius: 8px;
}

.bar-track i {
    display: block;
    height: 100%;
    background: #8060a0;
    border-radius: 8px;
}

.chart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 2px solid var(--line);
    font-weight: 750;
    font-size: 17px;
}

.chart.consumption .bar-row { grid-template-columns: 120px 1fr 110px; }

.chart-month { padding: 8px 0; border-bottom: 1px solid var(--line); }

.chart-month > span { display: block; margin-bottom: 4px; font-weight: 650; }

.bar-track i.tone-0 { background: #8060a0; }

.bar-track i.tone-1 { background: #624181; }

.bar-track i.tone-2 { background: #352047; }

.bar-track i.tone-3 { background: #d7b8f2; }

.empty {
    text-align: center;
    padding: 24px;
    color: var(--muted);
}

/* Filtros y formularios */

.filters {
    display: flex;
    align-items: end;
    gap: 10px;
    flex-wrap: wrap;
    background: white;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    margin-bottom: 15px;
    min-width: 0;
    max-width: 100%;
}

.filters label,
.form-grid label,
.stack label {
    display: grid;
    gap: 5px;
    font-size: 13px;
    font-weight: 600;
}

.filters input,
.filters select,
.form-grid input,
.form-grid textarea,
.form-grid select,
.stack input {
    padding: 10px;
    border: 1px solid #dcd5e1;
    border-radius: 7px;
    font: inherit;
    max-width: 100%;
    min-width: 0;
}

.filters label,
.form-grid > *,
.stack > * { flex: 1 1 10rem; min-width: 0; max-width: 100%; }

input[type="date"] {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    -webkit-appearance: none;
    appearance: none;
    background: #fff;
}

input[type="date"]::-webkit-datetime-edit,
input[type="date"]::-webkit-datetime-edit-fields-wrapper,
input[type="date"]::-webkit-date-and-time-value { min-width: 0; padding: 0; }

.filter-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.filter-actions .secondary { width: auto; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 15px;
    max-width: 820px;
    min-width: 0;
}

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

.check { display: flex !important; align-items: center; }

.form-actions { display: flex; gap: 9px; }

.stack { display: grid; gap: 12px; }

[data-fuel-only][hidden] { display: none !important; }

/* Familia */

.member-block { padding: 14px 0; border-bottom: 1px solid var(--line); }

.member-block:last-child { border-bottom: 0; }

.member-row {
    display: flex;
    justify-content: space-between;
    padding: 13px 0;
    border-bottom: 1px solid var(--line);
}

.member-row small { display: block; }

.module-access {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    align-items: center;
    margin-top: 8px;
}

.module-access label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-size: 14px;
}

/* Ingredientes */

.ingredient-editor { display: grid; gap: 8px; }

.ingredient-row {
    display: grid;
    grid-template-columns: 1.4fr .7fr .8fr 1.2fr auto;
    gap: 8px;
    align-items: end;
}

.ingredient-row .link-button { min-height: 40px; }

/* Fichas de listado */

.entry-list { display: grid; gap: 12px; }

.entry-card {
    background: #faf8fb;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px;
    display: grid;
    gap: 12px;
    min-width: 0;
}

.entry-card header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 12px;
    row-gap: 6px;
    align-items: start;
    min-width: 0;
}

.entry-card header > div { display: contents; }

.entry-card header .eyebrow { grid-column: 1; grid-row: 1; }

.entry-card h2 { margin: 0; font-size: 18px; overflow-wrap: anywhere; grid-column: 1 / -1; }

.entry-card header .muted { grid-column: 1 / -1; }

.entry-card .muted { margin: 2px 0 0; overflow-wrap: anywhere; }

.entry-card header strong { grid-column: 2; grid-row: 1; justify-self: end; font-size: 20px; white-space: nowrap; }

.expense-card header .eyebrow,
.expense-card header strong {
    margin: 0;
    align-self: start;
    line-height: 1;
}

.expense-card h2 {
    grid-column: 1 / -1;
    grid-row: 2;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.clickable-row { cursor: pointer; }

.clickable-row:hover { background: #faf8fb; }

.entry-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px 18px;
    margin: 0;
}

.entry-metrics div { display: grid; gap: 2px; min-width: 0; }

.entry-metrics dt {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.entry-metrics dd { margin: 0; font-size: 15px; overflow-wrap: anywhere; }

.entry-person,
.entry-note { margin: 0; overflow-wrap: anywhere; }

.entry-person { color: var(--muted); font-size: 13px; }

.entry-note small,
.entry-line small {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 450;
}

.entry-lines { display: grid; gap: 8px; }

.entry-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    min-width: 0;
}

.entry-line span:first-child { font-weight: 650; min-width: 0; }

.entry-line span:last-child { color: var(--muted); text-align: right; }

/* Paginación */

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 18px;
    color: var(--muted);
    font-size: 13px;
}

.pagination-controls { display: flex; align-items: center; gap: 8px; }

.pagination-controls a,
.pagination-disabled {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: 7px;
    text-decoration: none;
    color: var(--purple);
    background: #fff;
}

.pagination-disabled { color: #aaa; background: #f8f7f9; }

/* Acceso */

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #352047, #74538d);
    padding: 18px;
}

.login-card {
    width: min(100%, 410px);
    padding: 32px;
    background: white;
    border-radius: 15px;
    display: grid;
    gap: 16px;
}

.login-card h1 { margin: 0; color: var(--deep); }

.login-brand { display: flex; align-items: center; gap: 11px; }

.login-brand img { width: 100px; height: 100px; }

.login-card p { color: var(--muted); }

.login-card label { display: grid; gap: 6px; font-size: 13px; }

.login-card input { padding: 11px; border: 1px solid #ddd; border-radius: 7px; }

.login-card .remember { display: flex; align-items: center; }

/* Pantallas estrechas */

@media (max-width: 850px) {
    .topbar {
        height: auto;
        flex-wrap: wrap;
        align-items: flex-start;
        padding: 10px 14px;
        gap: 8px;
    }

    .account { flex-wrap: wrap; gap: 8px 12px; }

    .shell {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto 1fr;
    }

    .panel,
    .content { max-width: 100%; }

    .sidebar {
        overflow: visible;
        padding: 8px 10px;
        border: 0;
        border-bottom: 1px solid var(--line);
    }

    .sidebar nav {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        width: 100%;
        gap: 6px;
        position: static;
    }

    .sidebar a {
        flex-direction: column;
        justify-content: center;
        text-align: center;
        gap: 4px;
        min-width: 0;
        padding: 8px 4px;
        font-size: 12px;
    }

    .sidebar a span { white-space: normal; line-height: 1.2; }

    .content { padding: 22px 15px; }

    .columns { grid-template-columns: 1fr; }

    .page-heading { flex-wrap: nowrap; align-items: flex-start; }

    .filters {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .filters label,
    .filters input,
    .filters select { width: 100%; max-width: 100%; min-width: 0; }

    .filters input[type="date"],
    .filters input[type="search"] { display: block; }

    .filter-actions { display: contents; }

    .filter-actions .secondary {
        /* width: 100px;
        margin: auto; */
    }

    .ingredient-row { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .entry-card { padding: 14px; }

    .entry-card header { column-gap: 8px; }

    .entry-card h2 { font-size: 17px; }

    .entry-card header strong { font-size: 18px; }

    .entry-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px 12px;
    }

    .entry-line {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    .entry-line span:last-child { text-align: left; }
}

@media (max-width: 560px) {
    .stats { grid-template-columns: 1fr 1fr; gap: 8px; }

    .stat { padding: 12px; }

    .stat strong { font-size: 21px; }

    .page-heading h1 { font-size: 25px; }

    .form-grid { grid-template-columns: minmax(0, 1fr); }

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

    .panel { padding: 15px; }

    .bar-row { grid-template-columns: 85px 1fr 70px; }

    .chart.consumption .bar-row { grid-template-columns: 85px 1fr 92px; }
}

@media (max-width: 420px) {
    .pagination { align-items: flex-start; flex-direction: column; }
}

/* Viajes */

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

.trip-people { display: grid; gap: 10px; margin: 10px 0; }

.trip-person,
.share-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 8px;
    align-items: end;
}

.share-row { grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); }

.trip-person label,
.share-row label {
    display: grid;
    gap: 5px;
    font-size: 13px;
    font-weight: 600;
    min-width: 0;
}

.trip-person input,
.trip-person select,
.share-row input:not([type="checkbox"]) {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 10px;
    border: 1px solid #dcd5e1;
    border-radius: 7px;
    font: inherit;
}

.entry-card.trip-card header strong { white-space: normal; text-align: right; max-width: 11rem; }

.trip-person .link-button { min-height: 40px; }

.person-line { display: flex; align-items: center; gap: 8px; min-width: 0; }

.invite { position: relative; display: inline-flex; }

.invite-toggle { width: 34px; height: 34px; min-height: 34px; padding: 6px; }

.invite-menu {
    position: absolute;
    z-index: 4;
    top: calc(100% + 4px);
    left: 0;
    min-width: 11rem;
    padding: 6px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(53, 32, 71, .12);
    display: grid;
}

.invite-menu[hidden] { display: none !important; }

.invite-menu a,
.invite-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

.invite-menu a:hover,
.invite-menu button:hover { background: #f7f5f8; }

[data-weight][hidden] { display: none !important; }

.balance-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.people-panel { padding-top: 14px; padding-bottom: 14px; }

.people-panel h2 { margin-bottom: 8px; }

.people-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.people-list li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.people-list .muted { font-size: 12px; }

.people-list .invite-toggle { width: 28px; height: 28px; min-height: 28px; padding: 4px; }

.scroll-top {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 20;
    border: 0;
    border-radius: 999px;
    padding: 10px 16px;
    background: var(--deep);
    color: white;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(53, 32, 71, .25);
}

.scroll-top[hidden] { display: none; }

.nav-more {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: #615769;
    border-radius: 8px;
    font: inherit;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    padding: 11px;
}

.nav-more:hover { background: #f2eef6; }

.sidebar a[hidden],
.nav-more[hidden] { display: none !important; }

@media (max-width: 850px) {
    .nav-more {
        flex-direction: column;
        min-width: 0;
        padding: 8px 4px;
        font-size: 12px;
    }
}

@media (max-width: 720px) {
    .trip-person,
    .share-row { grid-template-columns: minmax(0, 1fr); }
}
