/* ==========================================================================
   Flupy — Design System
   Soft, rounded, "blob" motif — playful consumer household SaaS.
   ========================================================================== */

:root {
    /* Brand */
    --primary:        #FF6B4A;   /* Flupy coral — CTAs, links, active states, logo */
    --primary-dark:   #E24E2E;   /* hover state for primary */
    --primary-tint:   #FFE7DE;   /* pale coral wash for badges/highlights */
    --accent:         #FFD166;   /* Flupy butter — secondary highlights, warnings */
    --accent-dark:    #E8B23D;
    --sage:           #4C9A7D;   /* secondary accent — success, "on" states, growth modules */
    --sage-tint:      #E3F2EC;
    --sage-dark:      #3B7A63;

    /* Neutrals — warm-tinted, not cold gray */
    --bg-base:        #FFF6EF;   /* page background, warm pale peach */
    --bg-surface:     #FFFFFF;   /* cards, panels */
    --bg-sunken:      #FBEEE3;   /* recessed areas, code-free "well" surfaces */
    --border-light:   #F0E0D2;   /* subtle borders */
    --text-base:      #2B2438;   /* warm plum-ink body copy */
    --text-muted:     #7A7086;   /* secondary text */
    --text-on-primary: #FFFFFF;

    /* Typography */
    --font-heading:   'Baloo 2', sans-serif;
    --font-body:      'Nunito Sans', sans-serif;

    /* Spacing / shape scale — rounder than a typical B2B app, on brand for "flupy" */
    --radius:         14px;
    --radius-lg:      26px;
    --radius-pill:    999px;
    --shadow:         0 2px 6px rgba(226, 78, 46, 0.07), 0 10px 24px rgba(226, 78, 46, 0.08);
    --shadow-lift:    0 6px 16px rgba(226, 78, 46, 0.12), 0 18px 36px rgba(226, 78, 46, 0.10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-base);
    background: var(--bg-base);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 0.5em;
    color: var(--text-base);
}

p { margin: 0 0 1em; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

:focus-visible {
    outline: 3px solid var(--accent-dark);
    outline-offset: 2px;
    border-radius: 4px;
}

img { max-width: 100%; display: block; }

.hidden { display: none !important; }

.container {
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ==========================================================================
   Header / Nav
   ========================================================================== */

.main-header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 200;
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 72px;
    position: relative;
}

/* Below 767px there isn't room for the role badge AND the full "Name ·
   Household" identity next to the wordmark — the identity text is dropped
   (still available via the sidebar/settings) rather than left to wrap and
   crowd the logo under a fixed 72px header height. */
@media (max-width: 767px) {
    .header-identity { display: none; }
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--text-base);
}

.logo:hover { color: var(--text-base); }

.logo-img { width: 38px; height: 38px; display: block; }

.logo-text { letter-spacing: -0.01em; }

.main-nav {
    display: flex;
    align-items: center;
    gap: 32px;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 28px;
    margin: 0;
    padding: 0;
}

.nav-links a {
    color: var(--text-base);
    font-weight: 600;
    font-size: 0.95rem;
}

.nav-links a:hover,
.nav-links a.is-active { color: var(--primary); }

.auth-links {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Aesthetic-review finding P2-01 (2026-09-11): a bare native <select> next to
   fully custom pill buttons read as unfinished. Matches .btn-outline's own
   pill radius/border color rather than a full custom-menu rebuild — the
   suggested, right-sized fix. */
.locale-switcher-form { display: flex; align-items: center; }

.locale-switcher-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-base);
    background-color: transparent;
    border: 2px solid var(--border-light);
    border-radius: var(--radius-pill);
    padding: 7px 34px 7px 16px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%237A7086' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 10px 6px;
    transition: border-color .15s ease, color .15s ease;
}
.locale-switcher-select:hover,
.locale-switcher-select:focus {
    border-color: var(--primary);
    color: var(--primary);
    outline: none;
}

.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    border-radius: 2px;
    background: var(--text-base);
    transition: transform .25s, opacity .25s;
}

.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 767px) {
    .hamburger { display: flex; }
    .main-nav {
        display: none;
        flex-direction: column;
        align-items: flex-start;
        position: absolute;
        top: 72px;
        left: 0;
        right: 0;
        background: var(--bg-surface);
        border-bottom: 1px solid var(--border-light);
        padding: 16px 20px 24px;
        z-index: 100;
        box-shadow: var(--shadow);
    }
    .main-nav.open { display: flex; }
    .nav-links { flex-direction: column; gap: 16px; width: 100%; }
    .auth-links { flex-direction: column; gap: 10px; margin-top: 16px; width: 100%; align-items: stretch; }
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.95rem;
    padding: 11px 22px;
    border-radius: var(--radius-pill);
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease, color .15s ease;
    text-align: center;
    white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: var(--primary);
    color: var(--text-on-primary);
    box-shadow: var(--shadow);
}
.btn-primary:hover { background: var(--primary-dark); color: var(--text-on-primary); box-shadow: var(--shadow-lift); }

.btn-secondary {
    background: var(--sage);
    color: var(--text-on-primary);
}
.btn-secondary:hover { background: var(--sage-dark); color: var(--text-on-primary); }

.btn-outline {
    background: transparent;
    border-color: var(--border-light);
    color: var(--text-base);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-lg { padding: 15px 32px; font-size: 1.05rem; }
.btn-sm { padding: 7px 16px; font-size: 0.85rem; }
.btn-block { width: 100%; }

.btn-danger { background: #E0533E; color: #fff; }
.btn-danger:hover { background: #C4432F; color: #fff; }

/* ==========================================================================
   Layout helpers
   ========================================================================== */

.main-content { min-height: 60vh; padding: 40px 0 64px; }

.section--tint {
    background: var(--bg-surface);
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
}

.section-label {
    display: inline-block;
    font-family: var(--font-body);
    font-weight: 800;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sage-dark);
    background: var(--sage-tint);
    padding: 4px 14px;
    border-radius: var(--radius-pill);
    margin-bottom: 14px;
}

.page-title { font-size: 2rem; margin-bottom: 8px; }
.section-title { font-size: 1.7rem; text-align: center; margin-bottom: 12px; }

/* ==========================================================================
   Hero sections
   ========================================================================== */

.hero-section {
    padding: 72px 0 64px;
    text-align: center;
}

.hero-section h1 {
    font-size: 2.75rem;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
}

.hero-subhead {
    font-size: 1.2rem;
    color: var(--text-muted);
    max-width: 560px;
    margin: 0 auto 32px;
}

.hero-cta-row {
    display: flex;
    gap: 14px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.hero-fineprint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Split hero — headline/CTA left, illustrated product-peek right */
.hero-section--split {
    padding: 56px 0 72px;
    text-align: left;
}

.hero-section--split .hero-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 40px;
    align-items: center;
}

@media (min-width: 900px) {
    .hero-section--split .hero-grid { grid-template-columns: 1.05fr 1fr; gap: 56px; }
}

.hero-section--split h1 { margin-left: 0; max-width: 100%; font-size: 2.6rem; }
.hero-section--split .hero-subhead { margin: 0 0 28px; text-align: left; }
.hero-section--split .hero-cta-row { justify-content: flex-start; }
.hero-section--split .hero-fineprint { text-align: left; }

.hero-visual {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 420px;
    margin: 0 auto;
    overflow: hidden;
}

.hero-blob-bg {
    position: absolute;
    inset: -10%;
    z-index: 0;
    opacity: 0.9;
}

.hero-mock-card {
    position: relative;
    z-index: 1;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lift);
    padding: 22px;
    width: 100%;
    max-width: 360px;
}

.hero-mock-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px dashed var(--border-light);
}
.hero-mock-row:last-child { border-bottom: none; }

.hero-mock-check {
    width: 22px;
    height: 22px;
    border-radius: var(--radius-pill);
    border: 2px solid var(--sage);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.hero-mock-row--done .hero-mock-check { background: var(--sage); }
.hero-mock-row--done .hero-mock-text { text-decoration: line-through; color: var(--text-muted); }

.hero-mock-text { font-weight: 700; font-size: 0.95rem; }
.hero-mock-meta { font-size: 0.8rem; color: var(--text-muted); }

.hero-section--banner {
    background: var(--primary);
    color: var(--text-on-primary);
    padding: 64px 0;
    text-align: center;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.hero-section--banner h1 { color: var(--text-on-primary); }
.hero-section--banner .hero-subhead { color: rgba(255,255,255,0.85); }

/* ==========================================================================
   Blob motif
   ========================================================================== */

.blob { display: block; }

.blob-decor {
    position: absolute;
    z-index: -1;
    opacity: 0.5;
    pointer-events: none;
}

/* ==========================================================================
   Cards / grids
   ========================================================================== */

/* Flex, not CSS Grid: an incomplete last row (e.g. 5 cards in a 3-column
   layout, or 4 in a row of 3) grows its remaining cards to fill the row
   instead of leaving empty grid tracks behind them. */
.card-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    margin-top: 40px;
}

.card-grid > * {
    flex: 1 1 300px;
}

@media (max-width: 699px) {
    .card-grid > * { flex-basis: 100%; }
}

/* Settings' small single-field cards (Storage/Security/Language/Country/
   Currency/Timezone/Week-starts-on) — same responsive .card-grid base as
   everywhere else, but these don't want the general rule's flex-grow: a
   leftover single card on the last row would otherwise stretch to fill
   the whole row width, awkwardly stretching a 2-field form. Kept fixed at
   their natural ~320px so unused row space just stays empty instead. */
.settings-card-grid {
    margin-top: 0;
}
.settings-card-grid > * {
    flex-grow: 0;
    flex-basis: 320px;
}
@media (max-width: 699px) {
    /* Restates the shared .card-grid mobile rule explicitly for this class
       — .settings-card-grid > * has the same specificity as .card-grid > *
       above but comes later in the file, so without this override it would
       win even under 699px and defeat the mobile full-width collapse. */
    .settings-card-grid > * { flex-basis: 100%; }
}

.card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    box-shadow: var(--shadow);
    min-width: 0;
}

.card--bordered { box-shadow: none; border: 1px solid var(--border-light); }

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    background: var(--primary-tint);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    font-size: 1.4rem;
}

.card-title { font-size: 1.15rem; margin-bottom: 8px; }
.card-content { color: var(--text-muted); font-size: 0.95rem; }

/* Post-launch aesthetic-review follow-up (2026-09-06, finding F2): the
   handful of modules with a genuine "needs attention" signal, pulled out
   ahead of the full card grid so they don't require scanning all 19 cards
   to find. */
.attention-banner {
    background: var(--bg-surface);
    border: 1px solid var(--primary);
    border-left: 5px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-top: 32px;
}
.attention-banner-title {
    font-size: 1.1rem;
    color: var(--primary-dark);
    margin: 0 0 12px;
}
.attention-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.attention-list a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius);
    color: var(--text-base);
    text-decoration: none;
}
.attention-list a:hover { background: var(--bg-sunken); }
.attention-icon { font-size: 1.1rem; }
.attention-arrow { margin-left: auto; color: var(--primary); }

.module-group-title {
    font-size: 1.3rem;
    margin-top: 48px;
    margin-bottom: 4px;
    color: var(--primary-dark);
}
.module-group:first-child .module-group-title { margin-top: 8px; }
.module-group .card-grid { margin-top: 20px; }

/* ==========================================================================
   Forms
   ========================================================================== */

.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

/* Password show/hide toggle — same markup/behaviour as codebase/'s canonical pattern, ported for Flupy's own variable names. */
.password-field-wrapper { position: relative; }
.password-field-wrapper .form-control { padding-right: 42px; }
.password-toggle-btn {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    background: none;
    border: none;
    line-height: 0;
    color: var(--text-muted);
    cursor: pointer;
}
.password-toggle-btn:hover { color: var(--text-base); }
.password-toggle-btn svg { width: 18px; height: 18px; }

.form-control {
    width: 100%;
    padding: 11px 14px;
    border: 2px solid var(--border-light);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 1rem;
    background: var(--bg-surface);
    color: var(--text-base);
    transition: border-color .15s ease;
}

.form-control:focus {
    border-color: var(--primary);
    outline: none;
}

textarea.form-control { resize: vertical; min-height: 90px; }

.form-row { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 640px) { .form-row--split { grid-template-columns: 1fr 1fr; } }

/* Aesthetic-review finding P3-01 (2026-09-11): marks a boundary between two
   distinct mini-forms stacked in the same card (e.g. Vehicles' mileage-update
   and cost-logging forms), which otherwise read as one long form since they
   shared the same spacing used between fields within a single form. */
.form-section-divider { border: none; border-top: 1px solid var(--border-light); margin: 20px 0; }

.form-check {
    display: flex;
    align-items: center;
    gap: 10px;
}

.success-msg, .error-msg {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.92rem;
    margin-bottom: 18px;
    font-weight: 600;
}

.success-msg { background: var(--sage-tint); color: var(--sage-dark); }
.error-msg { background: #FDE4DF; color: #B33F2A; }

/* ==========================================================================
   Auth pages
   ========================================================================== */

.auth-container {
    max-width: 420px;
    margin: 40px auto;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 40px 36px;
}

.auth-container .logo { justify-content: center; margin-bottom: 24px; }
.auth-container h1 { text-align: center; font-size: 1.5rem; }
.auth-container .hero-subhead { font-size: 0.95rem; margin-bottom: 24px; }

.auth-footer-link {
    text-align: center;
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ==========================================================================
   Pricing
   ========================================================================== */

.pricing-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    margin-top: 40px;
}
@media (min-width: 800px) { .pricing-grid { grid-template-columns: repeat(3, 1fr); } }

.pricing-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 32px 26px;
    box-shadow: var(--shadow);
    border: 2px solid transparent;
    display: flex;
    flex-direction: column;
}

.pricing-card--recommended {
    border-color: var(--primary);
    transform: scale(1.03);
}

.pricing-badge {
    align-self: flex-start;
    background: var(--primary);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    margin-bottom: 14px;
}

.pricing-name { font-family: var(--font-heading); font-size: 1.3rem; margin-bottom: 4px; }
.pricing-storage { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 18px; }

.pricing-amount { font-size: 2.1rem; font-weight: 800; font-family: var(--font-heading); }
.pricing-amount span { font-size: 0.95rem; font-weight: 600; color: var(--text-muted); }
.pricing-amount--unavailable { font-size: 1rem; font-weight: 600; color: var(--text-muted); min-height: 2.1rem; display: flex; align-items: center; }
.pricing-annual { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 20px; }

.pricing-notes { font-size: 0.88rem; color: var(--text-muted); margin: 16px 0 24px; flex-grow: 1; }

/* ==========================================================================
   App shell (logged-in household area)
   ========================================================================== */

.app-shell {
    display: flex;
    min-height: calc(100vh - 72px);
}

.app-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-light);
    padding: 24px 16px;
}

.app-sidebar-nav {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.app-sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius);
    color: var(--text-base);
    font-weight: 700;
    font-size: 0.95rem;
}

.app-sidebar-link:hover { background: var(--bg-sunken); color: var(--text-base); }
.app-sidebar-link.is-active { background: var(--primary-tint); color: var(--primary-dark); }

.module-icon {
    width: 30px;
    height: 30px;
    border-radius: var(--radius);
    background: var(--bg-sunken);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
}
.app-sidebar-link.is-active .module-icon { background: var(--primary); color: #fff; }

.app-sidebar-group { margin-top: 2px; }
.app-sidebar-group + .app-sidebar-group { margin-top: 6px; }

.app-sidebar-group-title {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 14px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.app-sidebar-group-title::-webkit-details-marker { display: none; }
.app-sidebar-group-title:hover { background: var(--bg-sunken); color: var(--text-base); }
.app-sidebar-group-title::after {
    content: '\25B8';
    font-size: 0.65rem;
    transition: transform 0.15s ease;
}
.app-sidebar-details[open] > .app-sidebar-group-title::after { transform: rotate(90deg); }

.app-sidebar-group-list {
    list-style: none;
    margin: 2px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-badge {
    margin-left: auto;
    background: var(--primary);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1;
    padding: 4px 7px;
    border-radius: 999px;
    min-width: 18px;
    text-align: center;
}

/* -- Family Chat ---------------------------------------------------------- */
.chat-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; }

.chat-feed {
    flex-grow: 1;
    max-height: 60vh;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-date-divider {
    text-align: center;
    margin: 16px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* width: fit-content (not just max-width) so a short message's bubble hugs
   its own text instead of always stretching to the 72% cap — aesthetic
   review 2026-09-06, finding F3. max-width remains the cap for long
   messages. */
.chat-message { max-width: 72%; width: fit-content; margin-bottom: 12px; align-self: flex-start; }
.chat-message--own { align-self: flex-end; }

.chat-message-sender {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    padding: 0 4px;
}
.chat-message--own .chat-message-sender { text-align: right; }

.chat-message-bubble {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    background: var(--bg-sunken);
    border-radius: var(--radius);
    padding: 10px 14px;
}
.chat-message--own .chat-message-bubble {
    background: var(--primary);
    color: #fff;
    flex-direction: row-reverse;
}
/* Finding F4: a removed message must not look like a normal live one —
   this needs to win over both the default and the --own bubble fill, so it
   stays a plain class-on-class rule (not nested under --own) and comes
   after both in source order. */
.chat-message-bubble.chat-message-bubble--deleted {
    background: transparent;
    border: 1px dashed var(--border-light);
    color: var(--text-muted);
}

.chat-message-body { white-space: pre-wrap; word-break: break-word; }
.chat-message-body--deleted { font-style: italic; }

.chat-message-delete { flex-shrink: 0; }

/* Finding F6: a plain opacity-dimmed glyph directly on the --own bubble's
   solid fill was nearly invisible (white-on-orange at 0.55 opacity) — a
   small solid backing circle keeps it a legible control at rest, not just
   on hover. Only ever rendered on the current member's own messages (see
   FamilyChatController's author-only delete rule), so no separate
   treatment is needed for the lighter, non-own bubble background. */
.btn-icon {
    background: rgba(0, 0, 0, 0.18);
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    color: inherit;
    padding: 0;
}
.btn-icon:hover { background: rgba(0, 0, 0, 0.3); }

.chat-compose-form {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-surface);
}
.chat-compose-form .form-control { flex-grow: 1; resize: none; min-height: 44px; max-height: 120px; }

@media (max-width: 767px) {
    .chat-message { max-width: 88%; }
}

.app-main { flex-grow: 1; min-width: 0; padding: 32px 36px; }

.app-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 28px;
}

.app-nav-toggle { display: none; }

@media (max-width: 900px) {
    .app-shell { flex-direction: column; }
    .app-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
        max-height: 0;
        overflow: hidden;
        padding-top: 0;
        padding-bottom: 0;
        transition: max-height .25s ease;
    }
    /* A dozen module links no longer fit comfortably above the fold on
       mobile (this grew from 4 in Phase 1 to 12 by Phase 3) — collapsed by
       default, toggled open via .app-nav-toggle below, same open/close
       pattern as the marketing header's .hamburger. */
    .app-sidebar.open { max-height: 70vh; overflow-y: auto; padding-top: 16px; padding-bottom: 16px; }
    .app-sidebar-nav { flex-direction: column; }
    .app-main { padding: 24px 20px; }
    .app-nav-toggle {
        display: flex;
        align-items: center;
        gap: 8px;
        background: var(--bg-sunken);
        border: none;
        border-radius: var(--radius-pill);
        padding: 8px 16px;
        font-weight: 700;
        font-size: 0.85rem;
        color: var(--text-base);
        cursor: pointer;
        width: calc(100% - 40px);
        margin: 12px 20px;
        justify-content: center;
    }
}

.trial-banner {
    background: var(--accent);
    color: #5A4207;
    font-weight: 700;
    font-size: 0.9rem;
    padding: 10px 20px;
    text-align: center;
}
.trial-banner a { color: #5A4207; text-decoration: underline; }

.trial-banner--warning { background: #B33F2A; color: #fff; }
.trial-banner--warning a { color: #fff; }

/* Idle auto-logout countdown warning (main.js) — fixed so it stays visible
   regardless of scroll position, above the sticky header (z-index 200). */
.idle-warning-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 300; }

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--border-light);
}
.empty-state .card-icon { margin: 0 auto 16px; }

/* ==========================================================================
   Badges
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 800;
    padding: 3px 11px;
    border-radius: var(--radius-pill);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.badge-role-account_holder { background: var(--primary-tint); color: var(--primary-dark); }
.badge-role-member { background: var(--sage-tint); color: var(--sage-dark); }
.badge-role-restricted { background: #FFF1D6; color: #8A6212; }
.badge-low-stock { background: #FDE4DF; color: #B33F2A; }
.badge-ok-stock { background: var(--sage-tint); color: var(--sage-dark); }

/* ==========================================================================
   Module: Tasks
   ========================================================================== */

.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.task-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: var(--bg-surface);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
}

.task-checkbox {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-pill);
    border: 2px solid var(--sage);
    flex-shrink: 0;
    cursor: pointer;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    padding: 0;
    margin-top: 2px;
}
.task-checkbox[data-checked="1"] { background: var(--sage); }

.task-body { flex-grow: 1; }
.task-title { font-weight: 700; }
.task-item[data-checked="1"] .task-title { text-decoration: line-through; color: var(--text-muted); }
.task-meta { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; }

/* ==========================================================================
   Module: Inventory
   ========================================================================== */

.inventory-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--bg-surface);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
}
.inventory-name { font-weight: 700; }
.inventory-meta { font-size: 0.82rem; color: var(--text-muted); }
.inventory-qty { display: flex; align-items: center; gap: 8px; }
.qty-btn {
    width: 28px; height: 28px; border-radius: var(--radius-pill);
    border: 2px solid var(--border-light); background: var(--bg-surface);
    font-weight: 800; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.qty-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ==========================================================================
   Module: Photos
   ========================================================================== */

.photo-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
@media (min-width: 600px) { .photo-grid { grid-template-columns: repeat(4, 1fr); } }

.photo-card {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-sunken);
    box-shadow: var(--shadow);
}
.photo-card img { width: 100%; height: 100%; object-fit: cover; }
.photo-caption {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    background: linear-gradient(to top, rgba(43,36,56,0.75), transparent);
    color: #fff;
    font-size: 0.75rem;
    padding: 16px 8px 6px;
}

.photo-delete-form { position: absolute; top: 6px; right: 6px; margin: 0; }
.photo-delete-btn {
    width: 26px; height: 26px; border-radius: var(--radius-pill);
    border: none; background: rgba(43,36,56,0.65); color: #fff;
    font-size: 1.1rem; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.photo-delete-btn:hover { background: #E0533E; }

/* Recently Deleted (product-backlog.md item 7) — mirrors .photo-delete-form/-btn's exact corner-badge positioning, distinct icon/hover colour. */
.photo-restore-form { position: absolute; top: 6px; right: 6px; margin: 0; }
.photo-restore-btn {
    width: 26px; height: 26px; border-radius: var(--radius-pill);
    border: none; background: rgba(43,36,56,0.65); color: #fff;
    font-size: 1.1rem; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.photo-restore-btn:hover { background: var(--primary); }

.upload-dropzone {
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-lg);
    padding: 32px;
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 24px;
    background: var(--bg-surface);
}

/* ==========================================================================
   Module: Calendar
   ========================================================================== */

.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day-label {
    text-align: center;
    font-weight: 800;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding-bottom: 6px;
}

.calendar-day-cell {
    min-height: 76px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 5px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow: hidden;
}

.calendar-day-cell.is-outside { background: var(--bg-base); opacity: 0.55; }
.calendar-day-cell.is-today { border-color: var(--primary); border-width: 2px; }

.calendar-day-number {
    font-weight: 700;
    font-size: 0.78rem;
    color: var(--text-base);
    text-decoration: none;
    display: inline-block;
}

.calendar-event-pill {
    font-size: 0.68rem;
    font-weight: 700;
    background: var(--primary-tint);
    color: var(--primary-dark);
    border-radius: 5px;
    padding: 2px 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
    display: block;
}

.calendar-event-pill--annual { background: var(--sage-tint); color: var(--sage-dark); }

/* Public holidays (Country/Currency/Public-Holidays CR, Phase 3) — never
   clickable/editable, unlike a real event pill, so this is a <div> with its
   own inline dismiss button rather than an <a>. */
.calendar-event-pill--holiday {
    background: var(--accent);
    color: var(--text-base);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    cursor: default;
}
.calendar-holiday-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-holiday-dismiss-form { display: inline-flex; flex-shrink: 0; }
.calendar-holiday-dismiss-btn {
    background: none;
    border: none;
    color: inherit;
    font-size: 0.9rem;
    line-height: 1;
    padding: 0 2px;
    cursor: pointer;
    opacity: 0.7;
}
.calendar-holiday-dismiss-btn:hover { opacity: 1; }

.badge-holiday { background: var(--accent); color: var(--text-base); }
.agenda-item--holiday { background: var(--bg-sunken); }

@media (max-width: 640px) {
    .calendar-day-cell { min-height: 54px; padding: 3px; }
    .calendar-day-number { font-size: 0.68rem; }
    .calendar-event-pill { font-size: 0.6rem; padding: 1px 3px; }
}

.agenda-item {
    display: flex;
    gap: 16px;
    background: var(--bg-surface);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
    margin-bottom: 10px;
}

.agenda-date {
    font-weight: 800;
    font-family: var(--font-heading);
    color: var(--primary);
    min-width: 72px;
    text-align: center;
}

/* ==========================================================================
   Module: Memories Timeline
   ========================================================================== */

.timeline {
    position: relative;
    padding-left: 36px;
    margin-top: 24px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--border-light);
}

.timeline-month {
    position: relative;
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.15rem;
    margin: 36px 0 16px;
    color: var(--text-base);
}
.timeline-month:first-child { margin-top: 0; }

.timeline-month::before {
    content: '';
    position: absolute;
    left: -31px;
    top: 5px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid var(--bg-base);
    box-shadow: 0 0 0 2px var(--primary);
}

.timeline-entry {
    position: relative;
    margin-bottom: 14px;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    box-shadow: var(--shadow);
    display: flex;
    gap: 14px;
    align-items: flex-start;
    text-decoration: none;
    color: inherit;
}

.timeline-entry::before {
    content: '';
    position: absolute;
    left: -30px;
    top: 22px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--border-light);
    border: 2px solid var(--bg-base);
}

.timeline-entry--photo { border-left: 4px solid var(--primary); }
.timeline-entry--diary { border-left: 4px solid var(--sage); }
.timeline-entry--event { border-left: 4px solid var(--accent-dark); }

.timeline-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.3rem;
    background: var(--bg-sunken);
    overflow: hidden;
}
.timeline-icon img { width: 100%; height: 100%; object-fit: cover; }

.timeline-entry-body { flex-grow: 1; min-width: 0; }
.timeline-entry-date { font-size: 0.75rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.timeline-entry-title { font-weight: 700; margin-top: 2px; }

@media (max-width: 500px) {
    .timeline { padding-left: 26px; }
    .timeline-month::before, .timeline-entry::before { left: -21px; }
}

/* ==========================================================================
   Module: Diary
   ========================================================================== */

.diary-entry {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}
.diary-entry-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; flex-wrap: wrap; gap: 8px; }
.diary-entry-date { font-weight: 700; font-family: var(--font-heading); }
.diary-entry-body { color: var(--text-base); white-space: pre-wrap; }
.visibility-toggle { font-size: 0.78rem; }

/* ==========================================================================
   Tables
   ========================================================================== */

/* Aesthetic review 2026-09-06, finding F5: a wide table's overflow-x:auto
   already works (confirmed live), but nothing signaled there was more to
   scroll — a column got clipped mid-word at the edge and read as broken.
   This is the standard CSS-only "scroll shadow" technique: two shadow
   layers scroll with the content (visible only while there's unscrolled
   table behind them) and two matching background-color layers mask them
   at rest/at the far edge, all sized to the wrapper's own background. */
.table-wrapper {
    overflow-x: auto;
    background:
        linear-gradient(to right, var(--bg-surface) 30%, rgba(255, 255, 255, 0)),
        linear-gradient(to left, var(--bg-surface) 30%, rgba(255, 255, 255, 0)) right,
        linear-gradient(to right, rgba(20, 20, 20, 0.12), rgba(255, 255, 255, 0)),
        linear-gradient(to left, rgba(20, 20, 20, 0.12), rgba(255, 255, 255, 0)) right;
    background-repeat: no-repeat;
    background-color: var(--bg-surface);
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
    background-attachment: local, local, scroll, scroll;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

table { width: 100%; border-collapse: collapse; min-width: 480px; }
thead { background: var(--bg-sunken); }
th {
    text-align: left;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    padding: 12px 16px;
}
td { padding: 14px 16px; border-top: 1px solid var(--border-light); font-size: 0.92rem; }
tbody tr:hover { background: var(--bg-sunken); }

/* ==========================================================================
   Footer
   ========================================================================== */

.main-footer {
    background: var(--bg-surface);
    border-top: 1px solid var(--border-light);
    padding: 32px 0;
    margin-top: 40px;
}

.footer-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    text-align: center;
}

@media (min-width: 640px) {
    .footer-container { flex-direction: row; justify-content: space-between; text-align: left; }
}

.footer-links { display: flex; gap: 20px; }
.footer-links a { color: var(--text-muted); font-size: 0.9rem; }
.footer-copy { color: var(--text-muted); font-size: 0.85rem; }

/* ==========================================================================
   Misc utility
   ========================================================================== */

.text-center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.cluster { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

/* ==========================================================================
   Legal content (Privacy Policy / Terms & Conditions) — long-form,
   numbered-section body copy, narrower than the full 1140px container for
   readability.
   ========================================================================== */

.legal-content {
    max-width: 760px;
    margin: 0 auto;
    padding-bottom: 40px;
}
.legal-content .legal-dates { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 4px; }
.legal-content h2 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    margin: 40px 0 12px;
    color: var(--text-base);
}
.legal-content h2:first-of-type { margin-top: 28px; }
.legal-content h3 { font-size: 1.05rem; margin: 24px 0 8px; color: var(--text-base); }
.legal-content p { color: var(--text-base); line-height: 1.65; margin: 0 0 14px; }
.legal-content ul { margin: 0 0 14px; padding-left: 22px; }
.legal-content li { color: var(--text-base); line-height: 1.6; margin-bottom: 8px; }

/* ==========================================================================
   Help & User Guide — docs-style sidebar + content (ManualController).
   Reuses .legal-content for the article typography; overrides its own
   max-width/margin since here it's the right-hand column of a grid, not a
   standalone centered page.
   ========================================================================== */
.manual-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 40px;
    padding: 40px 0 60px;
    align-items: start;
}
.manual-sidebar { position: sticky; top: 24px; }
.manual-sidebar-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.manual-sidebar-link {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-md, 12px);
    color: var(--text-muted);
    font-size: 0.92rem;
    line-height: 1.35;
}
.manual-sidebar-link:hover { background: var(--bg-sunken); color: var(--text-base); }
.manual-sidebar-link.is-active { background: var(--primary-tint); color: var(--primary-dark); font-weight: 700; }
.manual-sidebar-number { color: var(--text-muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.manual-sidebar-link.is-active .manual-sidebar-number { color: var(--primary-dark); }
.manual-content.legal-content { max-width: none; margin: 0; padding-bottom: 0; }
.manual-content h1 { margin: 0 0 24px; }

.manual-callout {
    border-radius: var(--radius-md, 12px);
    padding: 14px 18px;
    margin: 0 0 18px;
    line-height: 1.55;
}
.manual-callout strong { margin-right: 4px; }
.manual-callout--note { background: var(--primary-tint); color: var(--text-base); }
.manual-callout--note strong { color: var(--primary-dark); }
.manual-callout--tip { background: var(--sage-tint); color: var(--text-base); }
.manual-callout--tip strong { color: var(--sage); }
.manual-callout--important { background: var(--bg-sunken); color: var(--text-base); }
.manual-callout--important strong { color: var(--primary-dark); }

.manual-body dl { margin: 0; }
.manual-body dt { font-weight: 700; color: var(--text-base); margin: 18px 0 2px; }
.manual-body dt:first-child { margin-top: 0; }
.manual-body dd { margin: 0 0 4px; color: var(--text-base); line-height: 1.6; }

@media (max-width: 767px) {
    .manual-layout { grid-template-columns: 1fr; gap: 24px; padding: 24px 0 40px; }
    .manual-sidebar { position: static; }
    .manual-sidebar-list { flex-direction: row; flex-wrap: wrap; gap: 8px; }
    .manual-sidebar-link { padding: 7px 12px; background: var(--bg-sunken); }
}
