/* =========================================================
   Familj – stilmall (samma grund som ekonomi.lavenius.se)
   Tokens (ljust/mörkt) → bas → layout → komponenter → listor → mobil
   ========================================================= */

:root {
    color-scheme: light;
    --bg: #f4f5f7;
    --card: #ffffff;
    --surface: #fbfcfe;
    --surface-2: #eef1f6;
    --input-bg: #ffffff;
    --header-bg: rgba(255, 255, 255, 0.94);
    --text: #172033;
    --muted: #697386;
    --line: #dfe3ea;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --on-primary: #ffffff;
    --accent: #e6f6f4;
    --shadow: 0 10px 28px rgba(23, 32, 51, 0.06);

    --warn-bg: #fffbeb;
    --warn-line: #fcd34d;
    --warn: #f59e0b;
    --warn-text: #92400e;
    --ok: #22c55e;
    --ok-bg: #ecfdf3;
    --ok-line: #bbf7d0;
    --ok-text: #166534;
    --danger: #dc2626;
    --danger-text: #b91c1c;
    --done-strike: #86efac;

    --radius: 16px;
    --radius-sm: 10px;
    --gap: 1rem;
    --pad: 1.25rem;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #0f141b;
        --card: #171e28;
        --surface: #1b2330;
        --surface-2: #232d3b;
        --input-bg: #121821;
        --header-bg: rgba(20, 27, 37, 0.94);
        --text: #e6ebf2;
        --muted: #95a1b4;
        --line: #2b3646;
        --primary: #2dd4bf;
        --primary-dark: #14b8a6;
        --on-primary: #06201d;
        --accent: #12302d;
        --shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
        --warn-bg: #2a2214;
        --warn-line: #6b5518;
        --warn-text: #fcd34d;
        --ok-bg: #11291c;
        --ok-line: #1f5133;
        --ok-text: #4ade80;
        --danger: #ef4444;
        --danger-text: #f87171;
        --done-strike: #2f7a4a;
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f141b;
    --card: #171e28;
    --surface: #1b2330;
    --surface-2: #232d3b;
    --input-bg: #121821;
    --header-bg: rgba(20, 27, 37, 0.94);
    --text: #e6ebf2;
    --muted: #95a1b4;
    --line: #2b3646;
    --primary: #2dd4bf;
    --primary-dark: #14b8a6;
    --on-primary: #06201d;
    --accent: #12302d;
    --shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
    --warn-bg: #2a2214;
    --warn-line: #6b5518;
    --warn-text: #fcd34d;
    --ok-bg: #11291c;
    --ok-line: #1f5133;
    --ok-text: #4ade80;
    --danger: #ef4444;
    --danger-text: #f87171;
    --done-strike: #2f7a4a;
}

/* ---------- Bas ---------- */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
}

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

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 1.75rem; line-height: 1.2; }
h2 { margin-bottom: 0.75rem; font-size: 1.2rem; line-height: 1.25; }

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

input, select, textarea {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.7rem;
    background: var(--input-bg);
    color: var(--text);
}

textarea { resize: vertical; }

input:focus, select:focus, textarea:focus {
    outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent);
    outline-offset: 0;
    border-color: var(--primary);
}

button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 40px;
    border: 0;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: var(--on-primary);
    cursor: pointer;
    font-weight: 650;
    white-space: nowrap;
}

button:hover, .button:hover { background: var(--primary-dark); color: var(--on-primary); }

.button.secondary, button.secondary { background: var(--surface-2); color: var(--text); }
.button.secondary:hover, button.secondary:hover { background: var(--line); color: var(--text); }

.button.danger, button.danger {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger-text);
}
.button.danger:hover, button.danger:hover { background: var(--danger); color: #fff; }

.icon-button {
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    background: transparent;
    color: var(--muted);
    font-size: 1.2rem;
    line-height: 1;
}
.icon-button:hover { background: var(--surface-2); color: var(--text); }
button.icon-button:hover { color: var(--danger-text); }

label {
    display: grid;
    gap: 0.3rem;
    color: var(--muted);
    font-size: 0.875rem;
    font-weight: 650;
}

.muted { color: var(--muted); }
.small-note { margin: 0.6rem 0 0; font-size: 0.85rem; }

/* ---------- Layout ---------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 1.5rem;
    padding-top: max(0.6rem, env(safe-area-inset-top));
    background: var(--header-bg);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: transform 180ms ease;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text);
}

.main-nav { display: flex; flex: 1; align-items: center; gap: 0.25rem; }

.main-nav > a {
    padding: 0.45rem 0.75rem;
    border-radius: 9px;
    color: var(--muted);
    font-weight: 650;
    white-space: nowrap;
}
.main-nav > a:hover { color: var(--text); background: var(--surface-2); }
.main-nav > a.active { color: var(--primary); background: var(--accent); }

.who {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin-left: auto;
    color: var(--muted);
    font-weight: 650;
    white-space: nowrap;
}

.logout-form button { min-height: 36px; background: var(--surface-2); color: var(--text); }
.logout-form button:hover { background: var(--line); color: var(--text); }

.container {
    width: min(1100px, calc(100% - 2rem));
    margin: 1.75rem auto 3rem;
    padding-bottom: env(safe-area-inset-bottom);
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.heading-meta { text-align: right; }
.heading-meta span { display: block; color: var(--muted); font-size: 0.8rem; }
.heading-meta strong { font-size: 1.15rem; }

.eyebrow {
    margin: 0 0 0.15rem;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ---------- Kort ---------- */

.auth-card, .card, .stat-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.auth-card { max-width: 430px; margin: 10vh auto; padding: 2rem; }
.auth-card h1 { margin-bottom: 1rem; }
.auth-logo { display: block; margin-bottom: 1rem; border-radius: 14px; }

.card { margin-bottom: var(--gap); padding: var(--pad); }
.card > :last-child { margin-bottom: 0; }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.85rem;
}
.card-header h2 { margin-bottom: 0; }
.card-header .button { min-height: 34px; padding: 0.3rem 0.8rem; font-size: 0.85rem; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--gap);
    margin-bottom: var(--gap);
}

.stat-card { display: block; padding: 0.9rem 1rem; color: var(--text); }
.stat-card:hover { border-color: var(--primary); }
.stat-card span { display: block; color: var(--muted); font-size: 0.85rem; }
.stat-card strong { display: block; margin: 0.1rem 0; font-size: 1.6rem; line-height: 1.2; }
.stat-card small { display: block; color: var(--muted); font-size: 0.8rem; }
.stat-card.accent { background: var(--accent); }
.stat-card.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.stat-card.warn strong { color: var(--warn-text); }

.dash-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--gap);
    align-items: start;
}
.dash-grid > .card { margin-bottom: 0; }

.flash {
    margin-bottom: var(--gap);
    border-radius: 12px;
    padding: 0.7rem 1rem;
    background: var(--ok-bg);
    border: 1px solid var(--ok-line);
    color: var(--ok-text);
}

.empty-state { margin: 0.5rem 0 1rem; color: var(--muted); text-align: center; }

/* ---------- Formulär ---------- */

.form-stack, .form-grid, .inline-form, .button-row { display: grid; gap: 0.85rem; }

.form-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; }
.form-grid .wide { grid-column: span 2; }
.form-grid .full { grid-column: 1 / -1; }

.inline-form { grid-template-columns: minmax(0, 1fr) auto; align-items: end; max-width: 560px; }

.button-row { grid-auto-flow: column; justify-content: start; }

.quick-add, .shop-add {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem;
    margin-top: 0.85rem;
}
.quick-add button { min-width: 44px; padding: 0; font-size: 1.3rem; }

.shop-add { grid-template-columns: minmax(0, 1fr) 7rem auto; margin-top: 0; padding: 0.75rem; }
.shop-add input { min-height: 46px; font-size: 1.05rem; }
.shop-add button { min-height: 46px; }

.segmented {
    display: inline-flex;
    padding: 0.2rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
}
.segmented button { min-height: 36px; padding: 0.4rem 0.9rem; background: transparent; color: var(--muted); }
.segmented button:hover { background: var(--surface-2); color: var(--text); }
.segmented button.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

/* ---------- Flikar ---------- */

.tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 var(--gap); }

.tabs a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.4rem 0.95rem;
    background: var(--card);
    color: var(--text);
    font-weight: 700;
    white-space: nowrap;
}
.tabs a:hover { background: var(--surface-2); }
.tabs a.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

.tabs .count {
    min-width: 1.4rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.78rem;
    text-align: center;
}
.tabs a.active .count { background: rgba(255, 255, 255, 0.25); color: inherit; }

/* ---------- Utfällbara kort ---------- */

.disclosure-card { padding: 0; }

.disclosure-card > summary {
    cursor: pointer;
    list-style: none;
    padding: 0.9rem var(--pad);
    color: var(--text);
    font-weight: 750;
}
.disclosure-card > summary::-webkit-details-marker { display: none; }
.disclosure-card > summary::after { content: "Visa"; float: right; color: var(--primary); font-size: 0.9rem; font-weight: 700; }
.disclosure-card[open] > summary { border-bottom: 1px solid var(--line); }
.disclosure-card[open] > summary::after { content: "Dölj"; }
.disclosure-card > form, .disclosure-card > .disclosure-body { padding: var(--pad); }

.add-card > summary { color: var(--primary); }

/* ---------- Listor (att göra + köplista) ---------- */

.list-card { padding: 0.5rem; }
.list-card .empty-state { margin: 1.25rem 0; }

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

.item-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.6rem;
    align-items: center;
    min-height: 52px;
    padding: 0.35rem 0.4rem 0.35rem 0.2rem;
    border-radius: 12px;
    transition: opacity 200ms ease, background 150ms ease;
}
.item-row + .item-row, .item-edit + .item-row, .item-row + .item-edit { border-top: 1px solid var(--line); border-radius: 0; }
.item-row:hover { background: var(--surface); }

.item-check { margin: 0; }

.check-button {
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    background: transparent;
}
.check-button:hover { background: transparent; }

.check-box {
    display: block;
    width: 1.5rem;
    height: 1.5rem;
    border: 2px solid var(--muted);
    border-radius: 50%;
    transition: background 150ms ease, border-color 150ms ease;
}
.check-button:hover .check-box { border-color: var(--primary); }

.is-done .check-box {
    border-color: var(--ok);
    background: var(--ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 80% no-repeat;
}

.item-main { display: grid; gap: 0.1rem; min-width: 0; }

.item-title { font-weight: 650; overflow-wrap: anywhere; }

.item-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

.item-note { color: var(--muted); font-size: 0.85rem; white-space: normal; }

.item-actions { display: flex; align-items: center; gap: 0.15rem; }
.item-actions form { margin: 0; }

.is-done .item-title {
    color: var(--muted);
    text-decoration: line-through;
    text-decoration-thickness: 2px;
    text-decoration-color: var(--done-strike);
}
.todo-row.is-done, .shop-row.is-done { opacity: 0.6; }

.is-saving { opacity: 0.5; cursor: progress; }
.is-removing { opacity: 0; }
.is-error { box-shadow: inset 3px 0 0 var(--danger); }

.due-chip, .person-chip, .role-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text);
    font-weight: 650;
    white-space: nowrap;
}
.person-chip { padding-left: 0.15rem; }
.person-chip.muted { padding-left: 0.5rem; color: var(--muted); }

.is-today .due-chip { background: var(--accent); color: var(--primary); }
.is-late .due-chip { background: var(--danger); color: #fff; }
.is-late .check-box { border-color: var(--danger); }

.role-badge.role-admin { background: var(--accent); color: var(--primary); }

.qty {
    margin-left: 0.4rem;
    padding: 0 0.45rem;
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 650;
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--primary);
    color: var(--on-primary);
    font-size: 0.8rem;
    font-weight: 800;
    flex-shrink: 0;
}
.avatar.small { width: 1.3rem; height: 1.3rem; font-size: 0.62rem; }

.user-row { padding-left: 0.6rem; }

.item-edit { padding: 0.75rem; background: var(--surface); border-radius: 12px; }

.list-footer {
    display: flex;
    justify-content: flex-end;
    margin: 0;
    padding: 0.75rem 0.4rem 0.35rem;
    border-top: 1px solid var(--line);
}

.danger-zone {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.danger-zone p { margin: 0; font-size: 0.85rem; }

.account-logout { display: none; }

/* =========================================================
   Mobil
   ========================================================= */

@media (max-width: 900px) {
    :root {
        --gap: 0.65rem;
        --pad: 0.85rem;
        --radius: 14px;
    }

    body.nav-hidden .site-header { transform: translateY(-100%); }

    h1 { font-size: 1.4rem; }
    h2 { font-size: 1.08rem; margin-bottom: 0.6rem; }

    .container { width: calc(100% - 1.25rem); margin: 0.85rem auto 2rem; }

    .site-header { gap: 0; padding: 0.3rem 0.35rem; padding-top: max(0.3rem, env(safe-area-inset-top)); }
    .site-header .brand, .site-header .who, .site-header .logout-form { display: none; }

    .main-nav { justify-content: space-between; gap: 0; }
    .main-nav > a { padding: 0.55rem 0.6rem; font-size: 0.95rem; }

    .account-logout { display: block; }

    .page-heading { margin-bottom: 0.65rem; }

    .card { box-shadow: none; }
    .stat-card { padding: 0.55rem 0.7rem; border-radius: 12px; box-shadow: none; }
    .stat-card strong { font-size: 1.25rem; }
    .stat-card span, .stat-card small { font-size: 0.72rem; }

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

    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
    .form-grid .wide, .form-grid > button { grid-column: 1 / -1; }

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

    input, select, textarea { font-size: 16px; } /* förhindrar iOS-zoom */

    .shop-add { grid-template-columns: minmax(0, 1fr) 5rem; padding: 0.55rem; }
    .shop-add button { grid-column: 1 / -1; }

    .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        margin-left: -0.625rem;
        margin-right: -0.625rem;
        padding: 0 0.625rem 0.1rem;
        scrollbar-width: none;
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tabs a { flex: 0 0 auto; padding: 0.35rem 0.85rem; font-size: 0.9rem; }

    .list-card { padding: 0.25rem 0.35rem; }
    .item-row { gap: 0.4rem; padding-right: 0.1rem; }

    .user-row { grid-template-columns: auto minmax(0, 1fr); }
    .user-row .item-actions { grid-column: 2; }

    .danger-zone { align-items: flex-start; flex-direction: column; }

    .segmented { display: flex; }
    .segmented button { flex: 1; padding-inline: 0.5rem; }
}

/* ---------- MCP-token ---------- */

.token-reveal {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--warn-line);
    border-radius: 12px;
    background: var(--warn-bg);
    color: var(--warn-text);
}
.token-reveal p { margin: 0; }
.token-reveal input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }

.token-list { margin: 0.75rem 0; border: 1px solid var(--line); border-radius: 12px; }
.token-list .item-row { padding-left: 0.6rem; }
.token-list form { margin: 0; }
.token-list button.danger { min-height: 34px; padding: 0.25rem 0.75rem; font-size: 0.85rem; }

.token-create { margin-top: 0.85rem; }

/* ---------- Redigera rad på plats ---------- */

.item-main[data-edit-toggle] { cursor: pointer; border-radius: 8px; }
.item-main[data-edit-toggle]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.row-edit-form {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) 7rem auto;
    gap: 0.5rem;
    align-items: center;
    padding: 0.25rem 0.2rem 0.35rem 0.4rem;
}
.row-edit-form[hidden] { display: none; }
.row-edit-actions { display: flex; gap: 0.4rem; }

.item-row.is-editing { background: var(--surface); }
.item-row.is-editing > .item-check,
.item-row.is-editing > .item-main,
.item-row.is-editing > .item-actions { display: none; }

@media (max-width: 900px) {
    .row-edit-form { grid-template-columns: minmax(0, 1fr) 5rem; }
    .row-edit-actions { grid-column: 1 / -1; }
    .row-edit-actions button { flex: 1; }
}

/* ---------- Butik ---------- */

.shop-add { grid-template-columns: minmax(0, 1fr) 6rem auto; }

.row-edit-form { grid-template-columns: minmax(0, 1fr) 6rem auto; }

/* Butiksväljare: chips under fälten, fritext bara när "Annan…" är vald */
.store-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; grid-column: 1 / -1; }
.store-pick .chip-check span { display: inline-block; padding: 0.4rem 0.85rem; }
.store-pick .store-other { display: none; flex: 1 1 10rem; min-height: 38px; font-size: 1rem; }
.store-pick:has(input[value="__other"]:checked) .store-other,
.store-pick.is-other .store-other { display: block; }

.store-heading {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin: 0.85rem 0.4rem 0.2rem;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.store-heading:first-child { margin-top: 0.35rem; }
.store-heading a { color: var(--text); }
.store-heading a:hover { color: var(--primary); }

.store-chip {
    display: inline-flex;
    padding: 0 0.5rem;
    border-radius: 999px;
    background: var(--accent);
    color: var(--primary);
    font-weight: 700;
    white-space: nowrap;
}

@media (max-width: 900px) {
    /* Vara + antal på samma rad, knappen under i full bredd */
    .shop-add { grid-template-columns: minmax(0, 1fr) 5.5rem; }
    .shop-add button[type="submit"] { grid-column: 1 / -1; }
    .row-edit-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .row-edit-form input[name="name"] { grid-column: 1 / -1; }
}

/* ---------- Prioritet ---------- */

.prio-chip {
    display: inline-flex;
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    font-weight: 750;
    white-space: nowrap;
}
.prio-chip.prio-3 { background: var(--danger); color: #fff; }
.prio-chip.prio-2 { background: var(--warn-bg); color: var(--warn-text); border: 1px solid var(--warn-line); }
.prio-chip.prio-0 { background: transparent; color: var(--muted); border: 1px dashed var(--line); }

.todo-row.prio-3:not(.is-done) { box-shadow: inset 4px 0 0 var(--danger); }
.todo-row.prio-2:not(.is-done) { box-shadow: inset 4px 0 0 var(--warn); }
.todo-row.prio-0:not(.is-done) .item-title { color: var(--muted); font-weight: 600; }

/* ---------- Uppgift: klickbar rad + formulär ---------- */

.item-link { color: inherit; border-radius: 8px; }
.item-link:hover .item-title { color: var(--primary); }
.item-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.item-chevron {
    padding: 0 0.35rem;
    color: var(--muted);
    font-size: 1.4rem;
    line-height: 1;
    opacity: 0.6;
}
.item-row:hover .item-chevron { opacity: 1; color: var(--primary); }

.item-note {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.todo-form {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.85rem 1rem;
    align-items: start;
}
.todo-form .span-all { grid-column: 1 / -1; }
.todo-form textarea { min-height: 5.5rem; line-height: 1.45; }

.todo-form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding-top: 0.25rem;
}
.todo-form-actions .push-right { margin-left: auto; }

.item-edit {
    margin: 0.35rem 0;
    padding: 1rem;
    border: 1px solid var(--primary);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
    scroll-margin-top: 5rem;
}
.item-edit + .item-row, .item-row + .item-edit { border-top: 0; }
.item-edit .small-note { margin-top: 0.75rem; }

@media (max-width: 900px) {
    .todo-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0.65rem; }
    .todo-form .field-who { grid-column: 1 / -1; }
    .todo-form-actions > button:not(.push-right), .todo-form-actions > .button { flex: 1; }
    .todo-form-actions .push-right { flex-basis: 100%; margin-left: 0; }
    .item-edit { padding: 0.75rem; }
}

.todo-form label, .todo-form input, .todo-form select { min-width: 0; }
.todo-form input[type="date"] { max-width: 100%; -webkit-appearance: none; appearance: none; }
.todo-row.prio-2, .todo-row.prio-3 { border-radius: 0; }

/* ---------- Enhetliga fält: egen dropdown-stil, samma höjd överallt ---------- */

input:not([type="checkbox"]):not([type="radio"]),
select {
    height: 44px;
    min-height: 44px;
    line-height: 1.3;
}

select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 2.4rem;
    background-color: var(--input-bg);
    /* Pil ritad med gradienter – följer temafärgerna i ljust/mörkt läge */
    background-image:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position:
        calc(100% - 1.15rem) 50%,
        calc(100% - 0.8rem) 50%;
    background-size: 0.35rem 0.35rem, 0.35rem 0.35rem;
    background-repeat: no-repeat;
    cursor: pointer;
    text-overflow: ellipsis;
}
select:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--line)); }
select:focus {
    background-image:
        linear-gradient(45deg, transparent 50%, var(--primary) 50%),
        linear-gradient(135deg, var(--primary) 50%, transparent 50%);
}
select::-ms-expand { display: none; }

/* ---------- Notiser (Konto) ---------- */
.push-device { display: grid; gap: 0.75rem; margin-bottom: 1rem; }
.push-status { margin: 0; }
.push-status.is-ok { color: var(--ok-text); }
.push-status.is-warn { color: var(--warn-text); }
.push-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.push-device [hidden], .push-devices [hidden], .store-picks[hidden] { display: none !important; }
.push-devices { margin-bottom: 1.25rem; }
.pill {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    background: var(--accent);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 650;
    vertical-align: middle;
}

.notify-form { display: grid; gap: 1rem; }
.notify-form > button { justify-self: start; }
.notify-group {
    display: grid;
    gap: 0.6rem;
    min-width: 0;
    margin: 0;
    padding: 0.85rem 1rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}
.notify-group legend { padding: 0 0.35rem; font-weight: 700; }
.notify-group .small-note { margin: 0 0 0.15rem; }

label.check {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
}
label.check input {
    flex: none;
    width: 1.15rem;
    height: 1.15rem;
    min-height: 0;
    margin: 0;
    padding: 0;
    accent-color: var(--primary);
}
.notify-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.notify-row select { width: auto; min-width: 7.5rem; }

.store-picks { display: flex; flex-wrap: wrap; gap: 0.4rem; padding-left: 1.75rem; }
.store-picks .small-note { flex-basis: 100%; margin: 0.15rem 0 0; }
.chip-check { position: relative; display: inline-flex; cursor: pointer; }
.chip-check input { position: absolute; width: 1px; height: 1px; min-height: 0; opacity: 0; pointer-events: none; }
.chip-check span {
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-weight: 500;
}
.chip-check input:checked + span { border-color: var(--primary); background: var(--accent); color: var(--primary); }
.chip-check input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.cron-info { margin-top: 1rem; }
.cron-info summary { color: var(--muted); font-size: 0.9rem; font-weight: 650; cursor: pointer; }
.cron-info input { margin-top: 0.5rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; }

/* Datumfält (Safari/iOS): samma höjd, textfärg och justering som övriga fält */
input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    text-align: left;
}
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
input[type="date"]::-webkit-datetime-edit,
input[type="date"]::-webkit-datetime-edit-fields-wrapper { padding: 0; color: var(--text); }
input[type="date"]::-webkit-calendar-picker-indicator { opacity: 0.6; cursor: pointer; }

/* ---------- Beskrivning på varor ---------- */

.note-toggle { grid-column: 1 / -1; }
.note-toggle summary {
    display: inline-block;
    padding: 0.15rem 0.1rem;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 650;
    cursor: pointer;
    list-style: none;
}
.note-toggle summary::-webkit-details-marker { display: none; }
.note-toggle[open] summary { margin-bottom: 0.35rem; }

.note-input {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 3.2rem;
    resize: vertical;
    font: inherit;
    font-size: 0.95rem;
}
@media (max-width: 900px) { .note-input { font-size: 16px; } } /* förhindrar iOS-zoom */

.shop-row .item-note { overflow-wrap: anywhere; line-height: 1.35; }
.shop-row .item-note a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Typ (avdelning) + förslag vid inmatning ---------- */

.cat-select { grid-column: 1 / -1; min-height: 40px; }

.cat-heading {
    margin: 0.6rem 0.4rem 0.05rem;
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.store-heading + .cat-heading { margin-top: 0.3rem; }

.suggest-wrap { position: relative; min-width: 0; }
.suggest-wrap input { width: 100%; }
.suggest-list {
    position: absolute;
    z-index: 20;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
}
.suggest-list[hidden] { display: none; }
.suggest-list li {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 44px;
    padding: 0.6rem 0.7rem;
    border-radius: 8px;
    cursor: pointer;
}
.suggest-list li:hover, .suggest-list li.is-active { background: var(--surface-2); }
.suggest-list small { color: var(--muted); white-space: nowrap; }

@media (max-width: 900px) {
    .suggest-list { right: calc(-5.5rem - 0.5rem); } /* hela formulärets bredd (över antal-fältet) */
}
