/* ==========================================================================
   Min Meny V2 — Nordiskt Designsystem (Ljust & Mörkt läge)
   Strikt enligt docs/V2_UI_AND_DESIGN.md
   ========================================================================== */

:root {
    --bg-page: #FAF8F5;
    --bg-surface: #FFFFFF;
    --bg-subtle: #F2EFE9;
    --border-subtle: #E6E0D6;
    --text-primary: #1F2421;
    --text-secondary: #5C645E;
    --brand-primary: #2F6F4E;
    --brand-hover: #25593E;
    --brand-fill: #2F6F4E;
    --brand-fill-hover: #25593E;
    --on-brand: #FFFFFF;
    --brand-soft: #E8F2EC;
    --accent-warm: #A44D1E;
    --accent-warm-soft: #FDF1E8;
    --on-accent-warm: #FFFFFF;
    --accent-star: #D99B26;
    --status-success: #2F6F4E;
    --status-warning: #D97706;
    --status-warning-soft: #FEF3C7;
    --status-danger: #C2413B;
    --status-danger-soft: #FDECEB;
    --shadow-sm: 0 1px 2px rgba(31, 36, 33, 0.05);
    --shadow-md: 0 6px 20px rgba(31, 36, 33, 0.08);
    --shadow-lg: 0 16px 36px rgba(31, 36, 33, 0.14);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-pill: 9999px;
    --header-height: 64px;
    --bottomnav-height: 68px;
    color-scheme: light;
}

html.dark {
    --bg-page: #161816;
    --bg-surface: #1F2320;
    --bg-subtle: #292E2A;
    --border-subtle: #363D38;
    --text-primary: #F3F1EC;
    --text-secondary: #A5AEA7;
    --brand-primary: #6CC296;
    --brand-hover: #7ED0A6;
    --brand-fill: #2B6B4A;
    --brand-fill-hover: #357E58;
    --on-brand: #FFFFFF;
    --brand-soft: #1D3529;
    --accent-warm: #E08654;
    --accent-warm-soft: #35241B;
    --on-accent-warm: #1A120D;
    --accent-star: #EAB344;
    --status-success: #6CC296;
    --status-warning: #F59E0B;
    --status-warning-soft: #3B2A12;
    --status-danger: #E5655F;
    --status-danger-soft: #3B1F1E;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
}

/* Bas & Reset */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-family: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a {
    color: var(--brand-primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

/* Typografi & tabellsiffror */
.tabular-nums {
    font-variant-numeric: tabular-nums;
}

h1, .h1 {
    margin: 0;
    font-size: 1.45rem;
    line-height: 1.25;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

h2, .h2 {
    margin: 0;
    font-size: 1.1rem;
    line-height: 1.3;
    font-weight: 600;
    color: var(--text-primary);
}

h3, .h3 {
    margin: 0;
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--text-primary);
}

.text-secondary {
    color: var(--text-secondary);
}

.text-sm {
    font-size: 0.875rem;
}

.text-xs {
    font-size: 0.78rem;
}

/* Safe area & liggande mobilläge (obligatoriska klasser från V2_UI_AND_DESIGN.md) */
.pb-safe {
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
}

@media (orientation: landscape) and (max-height: 600px) {
    .mobile-landscape-hide {
        display: none !important;
    }
    .mobile-landscape-compact {
        padding-top: 0.35rem !important;
        padding-bottom: 0.35rem !important;
        min-height: 48px !important;
    }
}

/* App Shell */
.app-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.initial-loader {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.85rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

.spinner-sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

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

/* Sticky Topphuvud */
.app-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-sm);
}

.header-inner {
    max-width: 72rem;
    margin: 0 auto;
    padding: 0.55rem 1rem;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex: 1 1 0;
    min-width: 0;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.02rem;
    letter-spacing: -0.02em;
    white-space: nowrap;
    flex-shrink: 0;
}

.brand-link:hover {
    text-decoration: none;
    color: var(--brand-primary);
}

.brand-icon {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    flex-shrink: 0;
    display: block;
}

.auth-card-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.auth-card-logo {
    width: 60px;
    height: 60px;
    border-radius: 14px;
    display: block;
    box-shadow: var(--shadow-sm);
}

/* Familjeväljare i sidhuvudet */
.header-desktop-family {
    display: none;
    align-items: center;
    min-width: 0;
    flex: 0 1 220px;
    max-width: 220px;
}

.header-desktop-credit {
    display: none;
    flex-shrink: 0;
}

.header-mobile-context {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    border-top: 1px solid var(--border-subtle);
    background-color: var(--bg-surface);
}

.mobile-context-family {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
}

.family-switcher-wrap {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 0;
    max-width: 100%;
}

.family-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 36px;
    min-width: 0;
    max-width: 100%;
    padding: 0.3rem 0.7rem;
    border-radius: var(--radius-pill);
    background-color: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-size: 0.84rem;
    font-weight: 500;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.family-pill svg {
    flex-shrink: 0;
}

.family-pill-text {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

button.family-pill:hover {
    border-color: var(--brand-primary);
}

.family-pill-static {
    cursor: default;
}

/* Toppmeny på dator (>= 1024px) */
.desktop-nav {
    display: none;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.desktop-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius-pill);
    color: var(--text-secondary);
    font-size: 0.92rem;
    font-weight: 500;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.desktop-nav-link:hover {
    text-decoration: none;
    background-color: var(--bg-subtle);
    color: var(--text-primary);
}

.desktop-nav-link.is-active {
    background-color: var(--brand-soft);
    color: var(--brand-primary);
    font-weight: 600;
}

/* Högerdel i sidhuvud */
.header-right {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-shrink: 0;
}

.credit-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 36px;
    padding: 0.3rem 0.7rem;
    border-radius: var(--radius-pill);
    background-color: var(--brand-soft);
    color: var(--brand-primary);
    border: 1px solid transparent;
    font-size: 0.83rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    transition: opacity 0.15s ease, border-color 0.15s ease;
}

.credit-badge:hover {
    text-decoration: none;
    border-color: var(--brand-primary);
}

.credit-badge.is-warning {
    background-color: var(--status-warning-soft);
    color: var(--status-warning);
}

.credit-badge.is-danger {
    background-color: var(--status-danger-soft);
    color: var(--status-danger);
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-pill);
    background-color: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
    background-color: var(--bg-subtle);
    color: var(--text-primary);
}

.avatar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 0.5rem;
    border-radius: var(--radius-pill);
    background-color: var(--brand-soft);
    border: 1px solid var(--border-subtle);
    color: var(--brand-primary);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.avatar-btn:hover {
    border-color: var(--brand-primary);
}

/* Dropdown-menyer */
.dropdown-anchor {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 245px;
    max-width: min(300px, calc(100vw - 1.5rem));
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 0.45rem;
    z-index: 60;
}

.dropdown-menu.dropdown-left {
    left: 0;
    right: auto;
}

.dropdown-header {
    padding: 0.55rem 0.7rem;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 0.35rem;
}

.dropdown-section-label {
    padding: 0.45rem 0.7rem 0.25rem;
    font-size: 0.73rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.dropdown-item {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    padding: 0.6rem 0.7rem;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-primary);
    font-size: 0.9rem;
    text-align: left;
    min-height: 40px;
}

.dropdown-item:hover {
    background-color: var(--bg-subtle);
    text-decoration: none;
}

.dropdown-item.is-selected {
    background-color: var(--brand-soft);
    color: var(--brand-primary);
    font-weight: 600;
}

.dropdown-item.is-danger {
    color: var(--status-danger);
}

.dropdown-item-left {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
}

.dropdown-divider {
    height: 1px;
    background-color: var(--border-subtle);
    margin: 0.35rem 0;
}

.theme-segmented {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.25rem;
    padding: 0.25rem;
    margin: 0.2rem 0.4rem 0.35rem;
    background-color: var(--bg-subtle);
    border-radius: var(--radius-sm);
}

.theme-seg-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    padding: 0.4rem 0.25rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    min-height: 32px;
}

.theme-seg-btn.is-active {
    background-color: var(--bg-surface);
    color: var(--brand-primary);
    box-shadow: var(--shadow-sm);
}

/* Fast bottenmeny på mobil (< 1024px) */
.mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: flex;
    align-items: stretch;
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    box-shadow: 0 -2px 12px rgba(31, 36, 33, 0.06);
    padding-top: 0.35rem;
}

.bottom-nav-link {
    flex: 1 1 0;
    min-height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    color: var(--text-secondary);
    font-size: 0.74rem;
    font-weight: 500;
    position: relative;
}

.bottom-nav-link:hover {
    text-decoration: none;
    color: var(--text-primary);
}

.bottom-nav-link.is-active {
    color: var(--brand-primary);
    font-weight: 600;
}

.bottom-nav-link.is-active::before {
    content: '';
    position: absolute;
    top: -0.35rem;
    width: 32px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background-color: var(--brand-primary);
}

/* Huvudinnehåll & enhetliga containerbredder */
.app-main {
    flex: 1 0 auto;
    width: 100%;
    padding: 1.25rem 1rem calc(var(--bottomnav-height) + 1.75rem);
}

.app-main.no-bottom-nav {
    padding-bottom: 2rem;
}

.container-narrow {
    width: 100%;
    max-width: 28rem; /* max-w-md */
    margin: 0 auto;
}

.container-focused {
    width: 100%;
    max-width: 42rem; /* max-w-2xl */
    margin: 0 auto;
}

.container-wide {
    width: 100%;
    max-width: 64rem; /* max-w-5xl */
    margin: 0 auto;
}

@media (min-width: 640px) {
    .header-inner {
        padding: 0.65rem 1rem;
        min-height: var(--header-height);
    }
    .header-desktop-family {
        display: flex;
    }
    .header-desktop-credit {
        display: inline-flex;
    }
    .header-mobile-context {
        display: none;
    }
}

@media (min-width: 1024px) {
    .desktop-nav {
        display: flex;
    }
    .mobile-bottom-nav {
        display: none;
    }
    .app-main {
        padding: 1.75rem 1.5rem 2.5rem;
    }
    .header-desktop-family {
        flex-basis: 210px;
        max-width: 210px;
    }
}

/* Kort & ytor */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem;
}

.card-subtle {
    background-color: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.stack-sm { display: flex; flex-direction: column; gap: 0.65rem; }
.stack-md { display: flex; flex-direction: column; gap: 1rem; }
.stack-lg { display: flex; flex-direction: column; gap: 1.5rem; }

.row-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.row-wrap {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 640px) {
    .grid-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 960px) {
    .grid-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Knappar */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 44px;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-size: 0.94rem;
    font-weight: 600;
    line-height: 1.2;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-sm {
    min-height: 36px;
    padding: 0.35rem 0.75rem;
    font-size: 0.84rem;
    border-radius: var(--radius-sm);
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background-color: var(--brand-fill);
    color: var(--on-brand);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--brand-fill-hover);
    text-decoration: none;
}

.btn-secondary {
    background-color: var(--bg-subtle);
    border-color: var(--border-subtle);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--brand-primary);
    text-decoration: none;
}

.btn-ghost {
    background-color: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background-color: var(--bg-subtle);
    color: var(--text-primary);
}

.btn-danger {
    background-color: var(--status-danger);
    color: #FFFFFF;
}

.btn-danger:hover:not(:disabled) {
    opacity: 0.9;
}

.btn-danger-outline {
    background-color: transparent;
    border-color: var(--status-danger);
    color: var(--status-danger);
}

.btn-danger-outline:hover:not(:disabled) {
    background-color: var(--status-danger-soft);
}

/* Formulär */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.9rem;
}

@media (min-width: 640px) {
    .form-grid-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .form-grid-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.field label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.input, .select {
    width: 100%;
    min-height: 44px;
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus, .select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-soft);
}

.checkbox-row {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 40px;
    cursor: pointer;
    font-size: 0.92rem;
}

.checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--brand-primary);
}

/* Badges & Pills */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-pill);
    font-size: 0.76rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-brand {
    background-color: var(--brand-soft);
    color: var(--brand-primary);
}

.badge-warm {
    background-color: var(--accent-warm-soft);
    color: var(--accent-warm);
}

.badge-neutral {
    background-color: var(--bg-subtle);
    color: var(--text-secondary);
}

.badge-danger {
    background-color: var(--status-danger-soft);
    color: var(--status-danger);
}

.badge-warning {
    background-color: var(--status-warning-soft);
    color: var(--status-warning);
}

/* Flikar (Admin) */
.tabs {
    display: flex;
    gap: 0.35rem;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 1.25rem;
    overflow-x: auto;
}

.tab-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.94rem;
    padding: 0.7rem 1rem;
    min-height: 44px;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.is-active {
    color: var(--brand-primary);
    border-bottom-color: var(--brand-primary);
}

/* Inloggning & Cross-Device Magic Link */
.auth-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
}

.auth-topbar {
    width: 100%;
    max-width: 28rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 28rem;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    padding: 1.75rem 1.5rem;
}

.verify-code-box {
    background-color: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    text-align: center;
}

.verify-code-digits {
    font-size: 3rem;
    line-height: 1.1;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--brand-primary);
    font-variant-numeric: tabular-nums;
    margin: 0.4rem 0;
}

/* Medlems- & administratörsrader (mobil-vänliga kort + rader) */
.entity-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.entity-row {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    background-color: var(--bg-page);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

@media (min-width: 768px) {
    .entity-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.entity-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.entity-title-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.entity-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}

/* Statuskort (Aktuellt / översikt) */
.stat-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    color: var(--brand-primary);
}

.stat-value.is-warm {
    color: var(--accent-warm);
}

.stat-value.is-warning,
.stat-value-lg.is-warning {
    color: var(--status-warning);
}

.stat-value.is-danger,
.stat-value-lg.is-danger {
    color: var(--status-danger);
}

.stat-card-hero {
    border-color: var(--brand-primary);
}

.stat-value-lg {
    font-size: 2.1rem;
    font-weight: 700;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    color: var(--brand-primary);
}

.amount-positive {
    color: var(--status-success);
}

.amount-negative {
    color: var(--text-primary);
}

.text-right {
    text-align: right;
}

/* Responsiv historik: staplade kort (< 640px) och tabell (>= 640px) */
.ledger-mobile-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.ledger-card {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.9rem 1rem;
    background-color: var(--bg-page);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

.ledger-table-wrap {
    display: none;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th {
    text-align: left;
    font-size: 0.76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    padding: 0.6rem 0.65rem;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.data-table td {
    padding: 0.7rem 0.65rem;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

@media (min-width: 640px) {
    .ledger-mobile-list {
        display: none;
    }
    .ledger-table-wrap {
        display: block;
    }
}

/* Alert-banner */
.alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    font-size: 0.9rem;
}

.alert-info {
    background-color: var(--brand-soft);
    border-color: var(--brand-primary);
    color: var(--text-primary);
}

.alert-warning {
    background-color: var(--status-warning-soft);
    border-color: var(--status-warning);
    color: var(--text-primary);
}

.alert-danger {
    background-color: var(--status-danger-soft);
    border-color: var(--status-danger);
    color: var(--text-primary);
}

/* Tomlägen */
.empty-state {
    text-align: center;
    padding: 2.25rem 1.25rem;
    background-color: var(--bg-surface);
    border: 1px dashed var(--border-subtle);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
}

.empty-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-pill);
    background-color: var(--bg-subtle);
    color: var(--brand-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Toast-notiser */
.toast-root {
    position: fixed;
    right: 1rem;
    left: 1rem;
    bottom: calc(var(--bottomnav-height) + 1rem);
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    pointer-events: none;
}

@media (min-width: 1024px) {
    .toast-root {
        top: calc(var(--header-height) + 1rem);
        bottom: auto;
        left: auto;
        right: 1.25rem;
        width: 380px;
    }
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-left: 4px solid var(--brand-primary);
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.toast-success { border-left-color: var(--status-success); }
.toast-warning { border-left-color: var(--status-warning); }
.toast-error { border-left-color: var(--status-danger); }

.toast-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

/* Bekräftelsemodal (0 alert()/confirm()) */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    background-color: rgba(15, 18, 16, 0.56);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-dialog {
    width: 100%;
    max-width: 27rem;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-dialog-lg {
    max-width: 34rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    flex-wrap: wrap;
}

/* ==========================================================================
   Receptbank 2.0, Redigerare, Matlagningsläge & Delning (Fas 3)
   ========================================================================== */

.icon-btn-sm {
    width: 34px;
    height: 34px;
}

.input-sm {
    min-height: 36px;
    padding: 0.35rem 0.65rem;
    font-size: 0.85rem;
}

.textarea {
    min-height: 84px;
    resize: vertical;
    line-height: 1.55;
}

.ai-prefilled {
    background-color: var(--accent-warm-soft);
    border-color: var(--accent-warm);
}

/* Sök- och filterrad (Receptbank & Planera Steg 1 — exakt gemensam 42px-linjering) */
.recipe-filter-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(135px, 180px) minmax(185px, 225px) auto;
    gap: 0.6rem;
    align-items: center;
}

.recipe-search-wrap,
.search-input-wrap {
    position: relative;
    width: 100%;
    min-width: 0;
}

.recipe-search-icon,
.search-input-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.recipe-search-input,
.search-input-field {
    padding-left: 2.25rem;
}

.recipe-filter-bar .input,
.recipe-filter-bar .select,
.recipe-filter-bar .btn,
.planner-filter-row .input,
.planner-filter-row .select,
.planner-filter-row .btn {
    height: 2.625rem;
    min-height: 2.625rem;
    box-sizing: border-box;
    margin: 0;
}

.recipe-tag-select,
.recipe-sort-select,
.planner-tag-select {
    width: 100%;
    min-width: 0;
}

.recipe-fav-btn {
    white-space: nowrap;
}

.recipe-fav-btn.is-fav-active {
    background-color: var(--accent-warm-soft);
    border-color: var(--accent-star);
    color: var(--accent-star);
}

@media (max-width: 899px) {
    .recipe-filter-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .recipe-filter-bar .recipe-fav-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 639px) {
    .recipe-filter-bar {
        grid-template-columns: 1fr;
    }
}

/* Kompakta liggande receptkort (1 kol mobil, 2 kol >= 768px) */
.recipe-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem;
}

@media (min-width: 768px) {
    .recipe-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.recipe-card {
    display: flex;
    align-items: stretch;
    gap: 0.85rem;
    padding: 0.8rem;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.recipe-card:hover {
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-md);
}

.recipe-card-thumb-link {
    flex-shrink: 0;
    display: block;
}

.recipe-thumb {
    width: 76px;
    height: 76px;
    border-radius: 12px;
    object-fit: cover;
    display: block;
    background-color: var(--bg-subtle);
}

.recipe-thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

@media (min-width: 768px) {
    .recipe-thumb {
        width: 88px;
        height: 88px;
    }
}

.recipe-card-body {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.35rem;
}

.recipe-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.4rem;
}

.recipe-card-title {
    font-weight: 600;
    font-size: 0.98rem;
    line-height: 1.3;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-width: 0;
}

.recipe-card-title:hover {
    color: var(--brand-primary);
    text-decoration: none;
}

.recipe-card-top-right {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.recipe-card-menu {
    min-width: 175px;
}

.recipe-card-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    color: var(--text-secondary);
}

.recipe-star {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    color: var(--accent-star);
    font-weight: 600;
}

.recipe-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.16rem 0.55rem;
    border-radius: var(--radius-pill);
    background-color: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 0.74rem;
    font-weight: 500;
}

.tag-pill-removable {
    padding-right: 0.35rem;
    color: var(--text-primary);
}

.tag-remove-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 700;
    line-height: 1;
    padding: 0.1rem 0.25rem;
    border-radius: var(--radius-pill);
}

.tag-remove-btn:hover {
    color: var(--status-danger);
}

/* Interaktiv taggväljare i receptredigeraren */
.tag-choice-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.tag-choice {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    min-height: 34px;
    padding: 0.25rem 0.7rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-subtle);
    background-color: var(--bg-subtle);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tag-choice:hover {
    border-color: var(--brand-primary);
    color: var(--text-primary);
}

.tag-choice.is-selected {
    background-color: var(--brand-soft);
    border-color: var(--brand-primary);
    color: var(--brand-primary);
    font-weight: 600;
}

.tag-choice.is-selected.ai-prefilled {
    background-color: var(--accent-warm-soft);
    border-color: var(--accent-warm);
    color: var(--accent-warm);
}

/* Redigerare */
.editor-image-preview {
    width: 100%;
    max-width: 360px;
    max-height: 220px;
    object-fit: cover;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    display: block;
}

.editor-ing-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.45rem;
    padding: 0.65rem;
    border-radius: var(--radius-md);
    background-color: var(--bg-page);
    border: 1px solid var(--border-subtle);
}

@media (min-width: 768px) {
    .editor-ing-row {
        grid-template-columns: 1.1fr 0.9fr 2fr auto;
        align-items: center;
        padding: 0.45rem;
        background: transparent;
        border: none;
    }
}

.editor-inst-row {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    background-color: var(--bg-page);
    border: 1px solid var(--border-subtle);
}

/* Matlagningsläge */
.cooking-topbar {
    position: sticky;
    top: var(--header-height);
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.65rem 0.85rem;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.cooking-topbar-left {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
    flex: 1 1 0;
}

.cooking-title {
    font-size: 1.12rem;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cooking-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.cooking-action-label {
    display: none;
}

@media (min-width: 640px) {
    .cooking-action-label {
        display: inline;
    }
    .cooking-title {
        font-size: 1.3rem;
    }
}

.btn-wake-active {
    background-color: var(--accent-warm);
    border-color: var(--accent-warm);
    color: #FFFFFF;
}

.cooking-hero-image {
    width: 100%;
    max-height: 14rem;
    object-fit: cover;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    display: block;
}

@media (min-width: 640px) {
    .cooking-hero-image {
        max-height: 18rem;
    }
}

.cooking-meta-bar {
    padding: 0.9rem 1.1rem;
}

.servings-control {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.servings-btn {
    min-width: 36px;
    padding: 0.3rem 0.6rem;
    font-size: 1rem;
    font-weight: 700;
}

.servings-count {
    min-width: 2rem;
    text-align: center;
    font-size: 1.05rem;
    font-weight: 700;
}

.rating-control {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.star-row {
    display: inline-flex;
    align-items: center;
    gap: 0.1rem;
}

.star-btn {
    border: none;
    background: transparent;
    color: var(--border-subtle);
    padding: 0.25rem;
    min-width: 34px;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.star-btn.is-active,
.star-btn:hover {
    color: var(--accent-star);
}

/* 12-kolumns matlagningsgrid */
.cooking-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

@media (min-width: 768px) {
    .cooking-grid {
        grid-template-columns: repeat(12, minmax(0, 1fr));
        align-items: start;
    }
    .cooking-col-ingredients {
        grid-column: span 5 / span 5;
        max-height: 72vh;
        overflow-y: auto;
    }
    .cooking-col-instructions {
        grid-column: span 7 / span 7;
        max-height: 72vh;
        overflow-y: auto;
    }
}

.cooking-section {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.cooking-section-title {
    font-size: 0.86rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent-warm);
    margin: 0.25rem 0 0.15rem;
}

.cooking-ing-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.cooking-ing-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.6rem;
    min-height: 44px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    text-align: left;
    transition: background-color 0.12s ease, opacity 0.12s ease;
}

.cooking-ing-row:hover {
    background-color: var(--bg-subtle);
}

.cooking-ing-row.is-checked {
    opacity: 0.5;
    text-decoration: line-through;
}

.cooking-ing-check {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 1.5px solid var(--border-subtle);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #FFFFFF;
}

.cooking-ing-row.is-checked .cooking-ing-check {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.cooking-ing-amount {
    font-weight: 700;
    color: var(--accent-warm);
    white-space: nowrap;
}

.cooking-ing-name {
    color: var(--text-primary);
    font-size: 0.96rem;
}

.cooking-step {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.step-num {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-pill);
    background-color: var(--brand-soft);
    color: var(--brand-primary);
    font-size: 0.84rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.cooking-step-text {
    margin: 0;
    font-size: 1rem;
    line-height: 1.65;
    color: var(--text-primary);
}

/* Liggande mobilläge i Matlagningsvyn: helskärms 2-kolumnslayout (5fr / 7fr) med individuell skroll */
@media (orientation: landscape) and (max-height: 600px) {
    html:has(body.cooking-view-active),
    body.cooking-view-active {
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    body.cooking-view-active .app-shell {
        height: 100vh;
        height: 100dvh;
        min-height: 0;
        overflow: hidden;
    }

    body.cooking-view-active .app-header {
        display: none !important;
    }

    body.cooking-view-active .app-main {
        flex: 1 1 0;
        height: 100%;
        min-height: 0;
        overflow: hidden;
        padding-top: 0.25rem;
        padding-bottom: 0.25rem;
        padding-left: max(0.5rem, env(safe-area-inset-left));
        padding-right: max(0.5rem, env(safe-area-inset-right));
    }

    body.cooking-view-active .cooking-shell {
        height: 100%;
        min-height: 0;
        gap: 0.35rem;
        max-width: 100%;
    }

    body.cooking-view-active .cooking-topbar.mobile-landscape-compact {
        position: static;
        flex-shrink: 0;
        height: 40px;
        min-height: 38px !important;
        max-height: 42px;
        padding: 0.2rem 0.5rem !important;
        border-radius: var(--radius-md);
        gap: 0.4rem;
    }

    body.cooking-view-active .cooking-back-btn {
        width: 32px;
        height: 32px;
    }

    body.cooking-view-active .cooking-title {
        font-size: 0.96rem;
        line-height: 1.2;
    }

    body.cooking-view-active .cooking-topbar-actions {
        gap: 0.3rem;
    }

    body.cooking-view-active .cooking-topbar-actions .btn-sm {
        min-height: 30px;
        height: 30px;
        padding: 0.15rem 0.55rem;
        font-size: 0.78rem;
    }

    body.cooking-view-active .cooking-topbar-actions .cooking-compact-icon {
        width: 32px;
        padding: 0;
    }

    body.cooking-view-active .cooking-secondary-label {
        display: none;
    }

    body.cooking-view-active .cooking-grid {
        display: grid;
        grid-template-columns: 5fr 7fr;
        gap: 0.5rem;
        height: calc(100vh - 3.25rem);
        height: calc(100dvh - 3.25rem);
        min-height: 0;
        align-items: stretch;
    }

    body.cooking-view-active .cooking-col-ingredients,
    body.cooking-view-active .cooking-col-instructions {
        grid-column: auto;
        height: 100%;
        max-height: none;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        padding: 0.6rem 0.75rem;
        gap: 0.6rem;
        border-radius: var(--radius-md);
    }

    body.cooking-view-active .cooking-col-ingredients h2,
    body.cooking-view-active .cooking-col-instructions h2 {
        font-size: 0.94rem;
    }

    body.cooking-view-active .cooking-section-title {
        font-size: 0.76rem;
        margin: 0.15rem 0 0.1rem;
    }

    body.cooking-view-active .cooking-ing-row {
        min-height: 36px;
        padding: 0.35rem 0.45rem;
        gap: 0.45rem;
    }

    body.cooking-view-active .cooking-ing-name {
        font-size: 0.9rem;
        line-height: 1.35;
    }

    body.cooking-view-active .cooking-ing-amount {
        font-size: 0.88rem;
    }

    body.cooking-view-active .cooking-step {
        gap: 0.55rem;
    }

    body.cooking-view-active .step-num {
        width: 24px;
        height: 24px;
        font-size: 0.76rem;
    }

    body.cooking-view-active .cooking-step-text {
        font-size: 0.93rem;
        line-height: 1.5;
    }
}

/* Delningsförhandsvisning */
.share-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.share-ing-item {
    display: flex;
    gap: 0.5rem;
    font-size: 0.95rem;
}

.share-step-item {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    font-size: 0.96rem;
    line-height: 1.6;
}

/* ==========================================================================
   FAS 4: VECKOMENY (/menu) & PLANERA / AI-KOCK (/plan)
   ========================================================================== */

.stat-value.is-brand {
    color: var(--brand-primary);
}

.stat-card-link {
    text-decoration: none;
    transition: border-color 0.15s ease, transform 0.12s ease;
}

.stat-card-link:hover {
    border-color: var(--brand-primary);
    transform: translateY(-1px);
}

.menu-meal-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.menu-meal-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    padding: 0.75rem;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s ease;
}

.menu-meal-card:hover {
    border-color: var(--brand-primary);
}

.menu-meal-main {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
    flex: 1 1 auto;
    text-decoration: none;
    color: inherit;
}

.menu-meal-thumb {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-md);
    object-fit: cover;
    flex-shrink: 0;
    display: block;
}

.menu-meal-thumb-placeholder {
    background-color: var(--bg-subtle);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-meal-body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.menu-meal-title-row {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
}

.menu-meal-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.menu-meal-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.65rem;
    font-size: 0.84rem;
    color: var(--text-secondary);
}

.menu-meal-rating {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    color: var(--accent-star);
    font-weight: 600;
}

.menu-meal-actions {
    flex-shrink: 0;
}

@media (max-width: 560px) {
    .menu-meal-card {
        flex-direction: column;
        align-items: stretch;
        gap: 0.65rem;
    }

    .menu-meal-actions {
        display: flex;
    }

    .menu-cooked-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ---------- Planera & AI-kock (/plan) ---------- */

.planner-step-num {
    width: 26px;
    height: 26px;
    border-radius: var(--radius-pill);
    background-color: var(--brand-soft);
    color: var(--brand-primary);
    font-size: 0.82rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.planner-step-card {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.planner-step1-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    min-height: 36px;
}

.planner-step-title {
    font-size: 1.02rem;
    font-weight: 600;
}

.planner-chevron {
    color: var(--text-secondary);
    display: inline-flex;
    transition: transform 0.18s ease;
}

.planner-chevron.is-open {
    transform: rotate(180deg);
}

.planner-selected-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.planner-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.32rem 0.45rem 0.32rem 0.7rem;
    border-radius: var(--radius-pill);
    background-color: var(--brand-soft);
    color: var(--brand-primary);
    font-size: 0.83rem;
    font-weight: 500;
    max-width: 100%;
}

.planner-chip-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.planner-chip-remove {
    width: 22px;
    height: 22px;
    border-radius: var(--radius-pill);
    border: none;
    background: transparent;
    color: var(--brand-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.planner-chip-remove:hover {
    background-color: rgba(61, 107, 79, 0.16);
}

.planner-step1-body {
    border-top: 1px solid var(--border-subtle);
    padding-top: 0.85rem;
}

.planner-filter-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(150px, 200px) auto;
    gap: 0.6rem;
    align-items: center;
}

@media (max-width: 639px) {
    .planner-filter-row {
        grid-template-columns: 1fr;
    }

    .planner-filter-row .recipe-fav-btn {
        width: 100%;
        justify-content: center;
    }
}

.planner-recipe-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    max-height: 290px;
    overflow-y: auto;
    padding-right: 0.15rem;
}

.planner-recipe-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem 0.7rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background-color: var(--bg-page);
    transition: border-color 0.14s ease, background-color 0.14s ease;
}

.planner-recipe-row.is-selected {
    border-color: var(--brand-primary);
    background-color: var(--brand-soft);
}

.planner-recipe-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.planner-recipe-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.planner-recipe-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.planner-row-star {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent-star);
}

.planner-recipe-controls {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-shrink: 0;
}

.servings-stepper-sm {
    padding: 0.1rem;
    gap: 0.1rem;
}

.btn-icon-xs {
    width: 28px;
    height: 28px;
    min-height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

@media (max-width: 560px) {
    .planner-recipe-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .planner-recipe-controls {
        justify-content: space-between;
    }
}

/* Steg 2: AI-chatt */

.planner-chat-card {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.planner-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
}

.planner-messages {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    min-height: 240px;
    max-height: 58vh;
    overflow-y: auto;
    padding: 0.5rem 0.25rem;
    background-color: var(--bg-page);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

.planner-chat-empty {
    margin: auto;
    padding: 1.5rem 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
}

.planner-chat-empty h3 {
    margin: 0;
    font-size: 1.05rem;
}

.planner-suggestions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.35rem;
}

.planner-suggestion-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-subtle);
    background-color: var(--bg-surface);
    color: var(--text-primary);
    font-size: 0.84rem;
    cursor: pointer;
    min-height: 38px;
    text-align: left;
    transition: border-color 0.14s ease, background-color 0.14s ease;
}

.planner-suggestion-chip:hover:not(:disabled) {
    border-color: var(--brand-primary);
    background-color: var(--brand-soft);
    color: var(--brand-primary);
}

.planner-suggestion-chip:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.chat-row {
    display: flex;
    padding: 0 0.55rem;
}

.chat-row-user {
    justify-content: flex-end;
}

.chat-row-assistant {
    justify-content: flex-start;
}

.chat-bubble {
    max-width: min(86%, 42rem);
    padding: 0.75rem 0.95rem;
    border-radius: var(--radius-lg);
    font-size: 0.94rem;
    line-height: 1.55;
    word-break: break-word;
}

.chat-bubble-user {
    background-color: var(--brand-fill);
    color: var(--on-brand);
    border-bottom-right-radius: 4px;
}

.chat-bubble-assistant {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.chat-markdown p {
    margin: 0 0 0.55rem;
}

.chat-markdown p:last-child {
    margin-bottom: 0;
}

.chat-markdown ul,
.chat-markdown ol {
    margin: 0.3rem 0 0.6rem;
    padding-left: 1.25rem;
}

.chat-markdown ul:last-child,
.chat-markdown ol:last-child {
    margin-bottom: 0;
}

.chat-markdown li {
    margin-bottom: 0.25rem;
}

.chat-bubble-meta {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.55rem;
    padding-top: 0.4rem;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.74rem;
    color: var(--text-secondary);
}

.planner-input-bar {
    display: flex;
    align-items: flex-end;
    gap: 0.55rem;
}

.planner-chat-textarea {
    flex: 1 1 auto;
    min-height: 48px;
    max-height: 140px;
    resize: vertical;
}

.planner-send-btn {
    min-height: 48px;
    flex-shrink: 0;
}

@media (max-width: 520px) {
    .chat-bubble {
        max-width: 94%;
    }

    .planner-input-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .planner-send-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Steg 3: Slutför */

.planner-finalize-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.planner-finalize-btn {
    min-height: 46px;
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .planner-finalize-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ==========================================================================
   FAS 5: REALTIDSSYNKAD INKÖPSLISTA (/shopping) & LIVE NAV-BADGE
   ========================================================================== */

.nav-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.35rem;
    border-radius: var(--radius-pill);
    background-color: var(--accent-warm);
    color: var(--on-accent-warm);
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
}

.bottom-nav-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.bottom-nav-badge {
    position: absolute;
    top: -5px;
    right: -11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 17px;
    height: 17px;
    padding: 0 0.25rem;
    border-radius: var(--radius-pill);
    background-color: var(--accent-warm);
    color: var(--on-accent-warm);
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1;
    border: 2px solid var(--bg-surface);
}

.shopping-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.sync-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    border-radius: var(--radius-pill);
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid var(--border-subtle);
    background-color: var(--bg-surface);
    color: var(--text-secondary);
    white-space: nowrap;
}

.sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-secondary);
    flex-shrink: 0;
}

.sync-status-pill.is-live {
    border-color: rgba(46, 125, 79, 0.3);
    background-color: var(--brand-soft);
    color: var(--brand-primary);
}

.sync-status-pill.is-live .sync-dot {
    background-color: var(--status-success);
}

.sync-status-pill.is-warning {
    border-color: rgba(183, 121, 31, 0.35);
    background-color: var(--status-warning-soft);
    color: var(--status-warning);
}

.sync-status-pill.is-warning .sync-dot {
    background-color: var(--status-warning);
}

.shopping-quick-form {
    padding: 0.85rem;
}

.shopping-quick-inputs {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(115px, 150px) auto;
    gap: 0.55rem;
    align-items: center;
}

.shopping-quick-inputs .input,
.shopping-quick-inputs .btn {
    height: 2.75rem;
    min-height: 2.75rem;
    box-sizing: border-box;
    margin: 0;
}

.shopping-add-btn {
    padding: 0 0.95rem;
    white-space: nowrap;
}

@media (max-width: 639px) {
    .shopping-quick-inputs {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .shopping-add-main {
        grid-column: 1 / -1;
    }

    .shopping-add-amount {
        grid-column: 1 / 2;
    }

    .shopping-add-btn {
        grid-column: 2 / 3;
    }
}

.shopping-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.shopping-toolbar .btn {
    min-height: 38px;
}

.shopping-clear-all-btn {
    color: var(--status-danger);
    margin-left: auto;
}

.shopping-clear-all-btn:hover:not(:disabled) {
    background-color: var(--status-danger-soft);
    color: var(--status-danger);
}

@media (max-width: 520px) {
    .shopping-clear-all-btn {
        margin-left: 0;
    }
}

.shopping-list-card {
    padding: 0;
    overflow: hidden;
}

.shopping-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 1rem;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    background-color: var(--bg-subtle);
    border-bottom: 1px solid var(--border-subtle);
}

.shopping-items {
    list-style: none;
    margin: 0;
    padding: 0;
}

.shopping-item-row {
    display: flex;
    align-items: center;
    min-height: 50px;
    border-bottom: 1px solid var(--border-subtle);
    transition: background-color 0.14s ease, opacity 0.15s ease;
}

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

.shopping-item-row:hover {
    background-color: var(--bg-subtle);
}

.shopping-item-toggle {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 50px;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.65rem 0.5rem 0.65rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
}

.shopping-checkbox {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--border-subtle);
    background-color: var(--bg-page);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #FFFFFF;
    transition: background-color 0.14s ease, border-color 0.14s ease;
}

.shopping-item-row:hover .shopping-checkbox {
    border-color: var(--brand-primary);
}

.shopping-item-row.is-bought .shopping-checkbox {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.shopping-item-text {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.shopping-item-name {
    font-size: 0.98rem;
    font-weight: 500;
    line-height: 1.35;
    color: var(--text-primary);
    word-break: break-word;
}

.shopping-item-amount {
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--accent-warm);
    background-color: var(--accent-warm-soft);
    padding: 0.16rem 0.55rem;
    border-radius: var(--radius-pill);
    white-space: nowrap;
}

.shopping-item-row.is-bought {
    opacity: 0.62;
}

.shopping-item-row.is-bought .shopping-item-name {
    text-decoration: line-through;
    color: var(--text-secondary);
}

.shopping-item-row.is-bought .shopping-item-amount {
    background-color: var(--bg-subtle);
    color: var(--text-secondary);
    text-decoration: line-through;
}

.shopping-item-delete {
    min-width: 44px;
    min-height: 44px;
    margin-right: 0.35rem;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.14s ease, color 0.14s ease;
}

.shopping-item-delete:hover {
    background-color: var(--status-danger-soft);
    color: var(--status-danger);
}

.shopping-all-done {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem;
    background-color: var(--brand-soft);
    border-color: rgba(61, 107, 79, 0.25);
}

.shopping-done-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background-color: var(--brand-primary);
    color: #FFFFFF;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ---------- Systemadmin: V1-migreringsverktyg ---------- */

.migration-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem 1.25rem;
}

.migration-report {
    border-top: 1px solid var(--border-subtle);
    padding-top: 1rem;
}

.migration-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
}

@media (min-width: 768px) {
    .migration-stats-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.migration-samples {
    padding: 0.75rem 0.9rem;
    border-radius: var(--radius-md);
    background-color: var(--bg-page);
    border: 1px solid var(--border-subtle);
}

.migration-sample-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.migration-sample-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.88rem;
}

.migration-details {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.65rem 0.85rem;
    background-color: var(--bg-page);
}

.migration-details summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.migration-name-list {
    margin: 0.6rem 0 0;
    padding-left: 1.25rem;
    max-height: 220px;
    overflow-y: auto;
    font-size: 0.88rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* ==========================================================================
   NÄRINGSBERÄKNING PER PORTION (KALORIER & MAKRON)
   ========================================================================== */

.recipe-kcal-badge,
.menu-meal-kcal {
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

.cooking-nutrition-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem 0.55rem;
    margin-top: 0.65rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.85rem;
    line-height: 1.35;
}

.cooking-nutrition-kcal {
    font-weight: 600;
    color: var(--brand-primary);
}

.cooking-nutrition-macro {
    color: var(--text-secondary);
}

.cooking-nutrition-sep {
    color: var(--text-secondary);
    opacity: 0.6;
}

.nutrition-fields-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

@media (min-width: 768px) {
    .nutrition-fields-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.batch-progress-bar {
    width: 100%;
    height: 10px;
    border-radius: var(--radius-pill);
    background-color: var(--bg-subtle);
    overflow: hidden;
    border: 1px solid var(--border-subtle);
}

.batch-progress-fill {
    height: 100%;
    background-color: var(--brand-fill);
    border-radius: var(--radius-pill);
    transition: width 0.22s ease;
}

.batch-failure-list {
    margin: 0.25rem 0 0;
    padding-left: 1.15rem;
    max-height: 160px;
    overflow-y: auto;
    font-size: 0.82rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.noscript-banner {
    margin: 1rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    background-color: var(--status-warning-soft);
    border: 1px solid var(--status-warning);
}

.hidden {
    display: none !important;
}

/* Tillgänglig minskad rörelse */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
