/* ═══════════════════════════════════════════════════════════
   components.css — Alle UI-komponenter, Home Inventory
   Rækkefølge: design-tokens → inputs → knapper → kort →
   avatar/chip → auth → welcome → header/nav → sections →
   modals → opskrifter → toasts → responsiv
═══════════════════════════════════════════════════════════ */


/* ══════════════════════════════════════
   1. INPUTS & FORMULARER
══════════════════════════════════════ */

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
    font-family: var(--font-body);
    font-size: 16px; /* forhindrer iOS-zoom */
    color: var(--text);
    background: var(--surface);
    border: none;
    border-radius: var(--r-md);
    padding: 0 var(--s-4);
    height: 46px;
    width: 100%;
    min-width: 0;
    transition: outline 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
}

textarea {
    height: auto;
    min-height: 88px;
    padding: var(--s-3) var(--s-4);
    resize: vertical;
    line-height: 1.55;
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
}

/* Checkboxe — native appearance, synlig i alle browsere inkl. iPhone Safari */
input[type="checkbox"],
input[type="radio"] {
    width: 20px;
    height: 20px;
    min-width: 20px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

input::placeholder,
textarea::placeholder { color: var(--faint); }

select {
    cursor: pointer;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ABA296' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

/* Stor kode-input (2FA, reset) */
input.code-input {
    font-size: 24px;
    letter-spacing: 0.12em;
    text-align: center;
    font-weight: 700;
    font-family: var(--font-body);
}

/* Label over input */
.form-field > label,
.form-row > label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--faint);
    margin-bottom: var(--s-1);
}

/* Input-gruppe (horisontale felter) */
.input-group {
    display: flex;
    gap: var(--s-2);
    margin-bottom: var(--s-4);
    flex-wrap: wrap;
}
.input-group input,
.input-group select { flex: 1; min-width: 80px; }

/* Adgangskode-styrke */
.password-strength {
    height: 3px;
    background: var(--line);
    border-radius: var(--r-pill);
    margin-top: var(--s-2);
    overflow: hidden;
}
.password-strength::before {
    content: '';
    display: block;
    height: 100%;
    width: 0;
    border-radius: var(--r-pill);
    transition: width 0.3s ease, background 0.3s ease;
}
.password-strength.weak::before   { width: 33%; background: var(--red); }
.password-strength.medium::before { width: 66%; background: var(--amber); }
.password-strength.strong::before { width: 100%; background: var(--accent); }

/* Formular-besked */
.form-msg {
    display: none;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-sm);
    font-size: 13px;
    line-height: 1.45;
    margin-bottom: var(--s-3);
}
.form-msg.error   { background: rgba(232, 118, 94, .1); color: var(--red-text); }
.form-msg.success { background: var(--accent-soft); color: var(--accent-text); }

/* Husk mig — checkbox-række */
.remember-row {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    margin-bottom: var(--s-3);
}
.remember-row label {
    font-size: 14px;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
    margin-bottom: 0;
}

/* Formular-rækker */
.form-row { margin-bottom: var(--s-4); }

/* Auth-form: synlige inputs + korrekte labels */
.auth-form input:not([type="checkbox"]),
.auth-form select {
    background: var(--surface-2);
}

.auth-form .form-row > label {
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
}

/* Auth-logo: tema-skift */
.auth-logo--dark  { display: none; }
.auth-logo--light { display: none; }
[data-theme="dark"]  .auth-logo--dark  { display: block; }
[data-theme="light"] .auth-logo--light { display: block; }
:root:not([data-theme]) .auth-logo--dark { display: block; }

.auth-actions-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--s-2);
    margin-bottom: var(--s-3);
}
.auth-bottom { text-align: center; color: var(--muted); font-size: 14px; }

/* Quick-add grid (Oversigt/I dag) */
.quick-add-form {
    display: grid;
    grid-template-columns: 1.3fr 2fr 1fr 60px 0.9fr 1.2fr 1.1fr auto;
    gap: var(--s-2);
    align-items: end;
    background: var(--surface);
    border-radius: var(--r-lg);
    padding: var(--s-4);
    margin-bottom: var(--s-4);
}
.form-field { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.form-submit { align-self: end; }


/* ══════════════════════════════════════
   2. KNAPPER
══════════════════════════════════════ */

button {
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--muted);
    border-radius: var(--r-md);
    min-height: var(--tap);
    padding: 0 var(--s-4);
    white-space: nowrap;
    touch-action: manipulation;
    transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
}
button:active { transform: scale(0.97); }

/* Primær — én pr. sektion */
.btn-primary,
button.action {
    background: var(--accent);
    color: var(--on-accent);
    font-size: 15px;
    font-weight: 600;
    height: 48px;
    border-radius: var(--r-md);
    min-height: 48px;
    letter-spacing: 0;
    text-transform: none;
}
.btn-primary:hover,
button.action:hover { opacity: 0.88; color: var(--on-accent); }
.btn-primary:active,
button.action:active { transform: scale(0.97); }

/* Desktop: lidt lavere */
@media (min-width: 1024px) {
    .btn-primary, button.action { height: 40px; min-height: 40px; }
}

/* Loading */
.btn-primary.loading,
button.action.loading {
    pointer-events: none;
    opacity: 0.6;
    position: relative;
    color: transparent;
}
.btn-primary.loading::after,
button.action.loading::after {
    content: '';
    position: absolute;
    width: 16px; height: 16px;
    top: 50%; left: 50%;
    margin: -8px 0 0 -8px;
    border: 2px solid var(--on-accent);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.6s linear infinite;
}

/* Sekundær */
.btn-secondary { background: var(--surface); color: var(--text); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }

/* Ghost */
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }

/* Fare */
button.action.danger {
    background: transparent;
    color: var(--red-text);
    outline: 1.5px solid var(--red);
    outline-offset: -1.5px;
}
button.action.danger:hover { background: rgba(232, 118, 94, .08); opacity: 1; color: var(--red-text); }

/* Advarsel */
button.action.warn {
    background: transparent;
    color: var(--amber-text);
    outline: 1.5px solid var(--amber);
    outline-offset: -1.5px;
}
button.action.warn:hover { background: rgba(229, 168, 75, .08); opacity: 1; color: var(--amber-text); }

/* Gem / annuller (i modals) */
.btn-save {
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
}
.btn-save:hover { opacity: 0.88; color: var(--on-accent); }

.btn-cancel { background: var(--surface-2); color: var(--muted); }
.btn-cancel:hover { color: var(--text); background: var(--surface-2); }

/* Hold skærm tændt */
.btn-keep-awake { background: transparent; color: var(--amber-text); outline: 1.5px solid var(--amber); outline-offset: -1.5px; }
.btn-keep-awake.active { background: var(--accent); color: var(--on-accent); outline: none; }

/* Menu-knap (✕, ✏️, ⋯) */
.menu-btn {
    background: transparent;
    color: var(--faint);
    min-height: var(--tap);
    min-width: var(--tap);
    font-size: 15px;
    border-radius: var(--r-sm);
    padding: 0 var(--s-2);
    flex-shrink: 0;
    letter-spacing: 0;
}
.menu-btn:hover { color: var(--muted); background: var(--surface-2); }
.menu-btn:active { transform: scale(0.93); }

/* Auth-links */
.auth-link {
    background: transparent;
    color: var(--accent-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    min-height: 36px;
    padding: 0 var(--s-1);
    border-bottom: 1px solid transparent;
}
.auth-link:hover { border-bottom-color: var(--accent); color: var(--accent-text); }

.link-btn {
    background: transparent;
    color: var(--accent-text);
    font-size: 14px;
    text-decoration: underline;
    text-underline-offset: 3px;
    min-height: 36px;
}
.link-btn:hover { opacity: 0.8; color: var(--accent-text); }

/* Sprogskift (auth) */
.auth-lang-btn {
    background: var(--surface-2);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    min-height: 34px;
    height: 34px;
    padding: 0 var(--s-3);
    border-radius: var(--r-pill);
}
.auth-lang-btn:hover { color: var(--text); background: var(--surface-2); }


/* ══════════════════════════════════════
   3. DESIGN SYSTEM — KOMPONENTER
══════════════════════════════════════ */

/* ── Kort ── */
.card {
    background: var(--surface);
    border-radius: var(--r-lg);
    overflow: hidden;
}

/* "I aften" / "I dag" fremhævning */
.card--highlight {
    background: var(--accent-soft);
    border-radius: var(--r-xl);
    box-shadow: inset 0 0 0 1.5px var(--accent);
}

/* ── Liste-rækker (inde i kort) ── */
.list-row {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    min-height: 52px;
    border-bottom: 1px solid var(--line);
    transition: background 0.12s ease;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--surface-2); }
.list-row__main { flex: 1; min-width: 0; }
.list-row__title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.list-row__sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.list-row__end { display: flex; gap: var(--s-2); align-items: center; flex-shrink: 0; }

/* ── Status-prik (ingen pill-baggrund) ── */
.status-dot {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 500;
}
.status-dot::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot.red   { color: var(--red-text); }
.status-dot.red::before   { background: var(--red); }
.status-dot.amber { color: var(--amber-text); }
.status-dot.amber::before { background: var(--amber); }

/* ── Avatar ── */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-pill);
    font-weight: 700;
    font-size: 12px;
    line-height: 1;
    flex-shrink: 0;
    border: 2px solid var(--bg);
    width: 28px;
    height: 28px;
}
.avatar.sm { width: 22px; height: 22px; font-size: 10px; }
.avatar.lg { width: 36px; height: 36px; font-size: 14px; }
.avatar:nth-child(1) { background: var(--p1); color: var(--p1-on); }
.avatar:nth-child(2) { background: var(--p2); color: var(--p2-on); margin-left: -8px; }
.avatar:nth-child(3) { background: var(--p3); color: var(--p3-on); margin-left: -8px; }
.avatar:nth-child(4) { background: var(--p4); color: var(--p4-on); margin-left: -8px; }
.avatar:nth-child(5) { background: var(--p5); color: var(--p5-on); margin-left: -8px; }
.avatar:nth-child(6) { background: var(--p6); color: var(--p6-on); margin-left: -8px; }
/* Profilfarve pr. slot uafhængigt af rækkefølge */
.avatar[data-slot="1"] { background: var(--p1); color: var(--p1-on); }
.avatar[data-slot="2"] { background: var(--p2); color: var(--p2-on); }
.avatar[data-slot="3"] { background: var(--p3); color: var(--p3-on); }
.avatar[data-slot="4"] { background: var(--p4); color: var(--p4-on); }
.avatar[data-slot="5"] { background: var(--p5); color: var(--p5-on); }
.avatar[data-slot="6"] { background: var(--p6); color: var(--p6-on); }

.avatar-stack { display: flex; align-items: center; }

/* ── Chip (filter-pille) ── */
.chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-1);
    height: 36px;
    padding: 0 var(--s-3);
    border-radius: var(--r-pill);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid var(--line);
    color: var(--muted);
    background: transparent;
    transition: all 0.15s ease;
    min-height: 36px;
}
.chip:hover { border-color: var(--muted); color: var(--text); }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ── Tom tilstand / empty slot ── */
.empty-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    border: 1.5px dashed var(--dash);
    border-radius: var(--r-lg);
    padding: var(--s-5);
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
    min-height: 80px;
    text-align: center;
}
.empty-slot:hover { border-color: var(--muted); color: var(--text); }
.empty-slot svg { opacity: 0.5; }


/* ══════════════════════════════════════
   4. AUTH-SKÆRM
══════════════════════════════════════ */

.auth-page {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: var(--s-5);
    overflow-y: auto;
}

.auth-card {
    background: var(--surface);
    border-radius: var(--r-xl);
    padding: var(--s-8);
    width: 400px;
    max-width: 100%;
    animation: slideUp 0.28s ease-out;
}

.auth-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--s-6);
}

.auth-header h2 {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
    margin-bottom: var(--s-1);
}

.auth-header p {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: var(--s-4);
}

.auth-form { margin-top: var(--s-5); }

/* 2FA-kode — stor og centreret */
input[maxlength="6"],
input[maxlength="8"] {
    font-size: 28px;
    letter-spacing: 0.15em;
    text-align: center;
    font-weight: 700;
    height: 64px;
    animation: pulse 0.4s ease;
}

/* Nulstil-kode (maxlength 6 er 2FA også, men begge steder ok) */


/* ══════════════════════════════════════
   5. VELKOMST-SKÆRM
══════════════════════════════════════ */

.welcome-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: var(--s-5);
    overflow-y: auto;
}

.welcome-box {
    background: var(--surface);
    border-radius: var(--r-xl);
    padding: var(--s-8);
    width: 420px;
    max-width: 100%;
    text-align: center;
    animation: slideUp 0.28s ease-out;
}

.welcome-box h1 {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
    margin-bottom: var(--s-6);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-3);
}

.welcome-box h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: var(--s-4);
}

.welcome-box input,
.welcome-box select { margin-bottom: var(--s-3); }

.welcome-box button { width: 100%; margin-bottom: var(--s-2); }


/* ══════════════════════════════════════
   6. APP-CHROME — HEADER & NAVIGATION
══════════════════════════════════════ */

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--s-3) var(--s-4);
    background: var(--bar);
    border-radius: var(--r-lg);
    gap: var(--s-3);
    flex-wrap: wrap;
    margin-bottom: var(--s-3);
}

.brand { display: flex; align-items: center; gap: var(--s-3); }
.brand-logo { height: 30px; width: 30px; object-fit: contain; border-radius: 50%; }

header h1 {
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

#household-display {
    font-size: 12px;
    color: var(--faint);
    font-weight: 500;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    flex-wrap: wrap;
}

/* Desktop nav-faner */
nav {
    display: flex;
    gap: var(--s-1);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
nav::-webkit-scrollbar { display: none; }

.tab-btn {
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    padding: 0 var(--s-3);
    height: 36px;
    min-height: 36px;
    border-radius: var(--r-md);
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.tab-btn:hover { background: var(--surface-2); color: var(--text); }
.tab-btn.active {
    background: var(--accent-soft);
    color: var(--accent-text);
    box-shadow: inset 0 0 0 1.5px var(--accent);
}
.tab-btn.active:hover { color: var(--accent-text); }

#lang-toggle {
    background: var(--surface-2);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    height: 34px;
    min-height: 34px;
    padding: 0 var(--s-3);
    border-radius: var(--r-pill);
    letter-spacing: 0.04em;
}
#lang-toggle:hover { color: var(--text); }

#logout-btn {
    background: transparent;
    color: var(--faint);
    font-size: 13px;
    height: 34px;
    min-height: 34px;
}
#logout-btn:hover { color: var(--red-text); }

/* ── Mobil bottom navigation ── */
#mobile-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--bar);
    border-top: 1px solid var(--line);
    z-index: 900;
    padding: var(--s-1) 0 calc(var(--s-2) + env(safe-area-inset-bottom, 0px));
    height: calc(60px + env(safe-area-inset-bottom, 0px));
    justify-content: space-around;
    align-items: stretch;
}

.mob-tab {
    background: transparent;
    color: var(--faint);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: var(--s-1) var(--s-2);
    font-size: 20px;
    cursor: pointer;
    flex: 1;
    border-radius: 0;
    min-height: var(--tap);
    transition: color 0.15s ease;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
}

.mob-tab i {
    font-style: normal;
    display: block;
    font-size: 22px;
    line-height: 1;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    will-change: transform;
}

.mob-tab span {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: inherit;
}

.mob-tab::after {
    content: '';
    position: absolute;
    top: 0; left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 28px; height: 2px;
    background: var(--accent);
    border-radius: 0 0 var(--r-sm) var(--r-sm);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.15s;
    opacity: 0;
}

.mob-tab.active { color: var(--accent-text); }
.mob-tab.active::after { transform: translateX(-50%) scaleX(1); opacity: 1; }
.mob-tab.active i { transform: translateY(-2px) scale(1.1); }
.mob-tab:active i { transform: scale(0.88); }

.mob-logout { color: rgba(232, 118, 94, .55) !important; }
.mob-logout.active,
.mob-logout:hover { color: var(--red-text) !important; }


/* ══════════════════════════════════════
   7. OVERSIGT / "I DAG"
══════════════════════════════════════ */

.dashboard-panel {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--s-3);
    margin-bottom: var(--s-4);
}

.stat {
    background: var(--surface);
    border-radius: var(--r-lg);
    padding: var(--s-4);
    text-align: center;
}

.stat .value {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 600;
    color: var(--text);
    display: block;
    line-height: 1.1;
}

.stat .label {
    font-size: 12px;
    font-weight: 600;
    color: var(--faint);
    margin-top: var(--s-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Indholdsgrid */
.main-content-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: var(--s-4);
}
.main-primary, .main-aside { display: flex; flex-direction: column; gap: var(--s-4); }

/* Indholds-blokke */
.content-block {
    background: var(--surface);
    border-radius: var(--r-lg);
    padding: var(--s-4);
    overflow: hidden;
}
.content-block-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: var(--s-3);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-2);
}
.content-block-title .count {
    background: var(--surface-2);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: var(--r-pill);
}


/* ══════════════════════════════════════
   8. EKSISTERENDE LISTER (.item, .list)
   Beholdes for JS-renderede elementer
══════════════════════════════════════ */

.list { display: flex; flex-direction: column; }

/* Basis-item (udløb, senest tilføjet, indkøb, etc.) */
.item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    min-height: 52px;
    border-bottom: 1px solid var(--line);
    transition: background 0.12s ease;
}
.item:last-child { border-bottom: none; }
.item:hover { background: var(--surface-2); border-radius: var(--r-sm); }

.item .left  { flex: 1; min-width: 0; }
.item .right { display: flex; gap: var(--s-2); align-items: center; flex-shrink: 0; }

.item .name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 1px;
}
.item .meta {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Udløbs-badges — nu som farvet tekst, ingen pill */
.badge {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.badge::before {
    content: '';
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}
.badge.expired { color: var(--red-text); }
.badge.expired::before { background: var(--red); }
.badge.soon    { color: var(--amber-text); }
.badge.soon::before    { background: var(--amber); }


/* ══════════════════════════════════════
   9. OPBEVARING (Hjemmet)
══════════════════════════════════════ */

.section-wrap {
    background: var(--surface);
    border-radius: var(--r-lg);
    padding: var(--s-5);
    overflow: hidden;
}

.section-wrap h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: var(--s-4);
}

.section-subheader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--s-4);
    flex-wrap: wrap;
    gap: var(--s-2);
}
.section-subheader h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}
.section-subheader-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* Opbevarings-kort */
.fridge-card {
    background: var(--surface-2);
    border-radius: var(--r-md);
    margin-bottom: var(--s-3);
    overflow: hidden;
    cursor: pointer;
    transition: background 0.15s ease;
}
.fridge-card:last-child { margin-bottom: 0; }
.fridge-card:hover { background: var(--surface-2); }

.fridge-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    min-height: 52px;
}

.fridge-header strong {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fridge-header .expand-icon {
    font-size: 12px;
    color: var(--faint);
    transition: transform 0.25s ease;
}
.fridge-card.open .expand-icon { transform: rotate(180deg); }

.fridge-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}
.fridge-card.open .fridge-items { max-height: 2000px; }


/* ══════════════════════════════════════
   10. INDSTILLINGER
══════════════════════════════════════ */

.settings-section {
    background: var(--surface-2);
    border-radius: var(--r-md);
    margin-bottom: var(--s-2);
    overflow: hidden;
}

.settings-section h3 {
    padding: var(--s-3) var(--s-4);
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 52px;
    transition: background 0.15s;
}
.settings-section h3::after {
    content: '›';
    font-size: 18px;
    color: var(--faint);
    transform: rotate(90deg);
    transition: transform 0.25s ease;
}
.settings-section.collapsed h3::after { transform: rotate(0); }
.settings-section h3:hover { background: var(--surface); }

.settings-section.collapsed .settings-content { display: none; }
.settings-content { padding: var(--s-4); border-top: 1px solid var(--line); }

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--s-3);
    gap: var(--s-3);
    flex-wrap: wrap;
    font-size: 14px;
}
.settings-row:last-child { margin-bottom: 0; }

.key-display {
    background: var(--bg);
    border-radius: var(--r-md);
    padding: var(--s-3) var(--s-4);
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-align: center;
    color: var(--accent-text);
    margin-bottom: var(--s-3);
    word-break: break-all;
    line-height: 1.4;
}

/* Temavalg (Indstillinger) */
.theme-options {
    display: flex;
    gap: var(--s-2);
    flex-wrap: wrap;
}
.theme-btn {
    flex: 1;
    min-width: 80px;
    height: 40px;
    min-height: 40px;
    background: var(--surface);
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--r-md);
    border: 1.5px solid var(--line);
}
.theme-btn:hover { color: var(--text); border-color: var(--muted); background: var(--surface); }
.theme-btn.active { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }


/* ══════════════════════════════════════
   11. MADPLAN & OPSKRIFTER
══════════════════════════════════════ */

/* Uge-gitter */
.week-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: var(--s-3);
    margin-bottom: var(--s-6);
}

.day-card {
    background: var(--surface-2);
    border-radius: var(--r-md);
    padding: var(--s-3);
    display: flex;
    flex-direction: column;
    min-height: 160px;
    transition: background 0.15s ease;
    cursor: default;
}
.day-card:hover { background: var(--surface-2); }

.day-card h4 {
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 700;
    color: var(--faint);
    text-align: center;
    margin-bottom: var(--s-3);
    padding-bottom: var(--s-2);
    border-bottom: 1px solid var(--line);
}

.meal-item {
    background: var(--surface);
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-sm);
    margin-bottom: var(--s-2);
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    gap: var(--s-2);
    transition: background 0.12s ease;
    border-left: 2px solid var(--accent);
}
.meal-item:hover { background: var(--surface); opacity: 0.85; }
.meal-item span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.add-meal-btn {
    margin-top: auto;
    background: transparent;
    border: 1.5px dashed var(--dash);
    color: var(--faint);
    padding: var(--s-2);
    border-radius: var(--r-sm);
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: border-color 0.15s, color 0.15s;
    white-space: normal;
    text-align: center;
    min-height: 36px;
}
.add-meal-btn:hover { border-color: var(--muted); color: var(--muted); }

/* Søgefelt */
.search-box { margin-bottom: var(--s-3); }
.search-box input { background: var(--surface-2); border-radius: var(--r-md); }

/* Lagersøgning (I dag-sektionen) */
.inventory-search-wrap { margin-bottom: var(--s-4); }
.inventory-search-box { position: relative; display: flex; align-items: center; }
.inventory-search-box svg { position: absolute; left: 14px; color: var(--faint); pointer-events: none; }
.inventory-search-box input { padding-left: 38px; background: var(--surface); }
#inventory-search-results { background: var(--surface); border-radius: var(--r-lg); margin-top: var(--s-2); overflow: hidden; }
#inventory-search-results.hidden { display: none; }
.search-empty {
    text-align: center;
    padding: var(--s-5) var(--s-4);
    color: var(--muted);
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    align-items: center;
    font-size: 14px;
}
.search-loading { text-align: center; padding: var(--s-4); color: var(--faint); font-size: 14px; }

/* Opskriftsgitter */
.recipes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--s-3);
}

.recipe-card {
    background: var(--surface-2);
    border-radius: var(--r-md);
    padding: var(--s-4);
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}
.recipe-card:hover { background: var(--surface); transform: translateY(-2px); }
.recipe-card.hidden { display: none; }

.recipe-card strong {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 500;
    color: var(--text);
    display: block;
    margin-bottom: var(--s-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recipe-meta {
    font-size: 12px;
    color: var(--muted);
    display: flex;
    gap: var(--s-3);
    flex-wrap: wrap;
    margin-top: var(--s-1);
}

.public-badge {
    display: inline-block;
    margin-top: var(--s-2);
    padding: 2px 8px;
    border-radius: var(--r-pill);
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-text);
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1px var(--accent);
}

/* Lagerstatus-badge (opskriftskort) */
.recipe-stock {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: var(--s-2);
    font-size: 12px;
    font-weight: 600;
}
.recipe-stock::before {
    content: '';
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}
.recipe-stock.ready   { color: var(--accent-text); }
.recipe-stock.ready::before   { background: var(--accent); }
.recipe-stock.partial { color: var(--amber-text); }
.recipe-stock.partial::before { background: var(--amber); }
.recipe-stock.lacking { color: var(--red-text); }
.recipe-stock.lacking::before { background: var(--red); }

.recipe-progress {
    height: 2px;
    background: var(--line);
    border-radius: var(--r-pill);
    margin-top: var(--s-2);
    overflow: hidden;
}
.recipe-progress-fill { height: 100%; border-radius: var(--r-pill); }


/* ══════════════════════════════════════
   12. OPSKRIFT — FULDSKÆRM
══════════════════════════════════════ */

.recipe-fullscreen {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 2000;
    overflow-y: auto;
    padding: var(--s-8) var(--s-5) calc(var(--s-8) + env(safe-area-inset-bottom, 0px));
    animation: fadeIn 0.2s ease-out;
}

.recipe-fullscreen-content {
    max-width: 800px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: var(--r-xl);
    padding: var(--s-8);
}

.recipe-fullscreen h2 {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
    margin-bottom: var(--s-4);
}

.recipe-fullscreen-meta {
    display: flex;
    gap: var(--s-5);
    margin-bottom: var(--s-6);
    padding-bottom: var(--s-5);
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
}

.recipe-fullscreen-section { margin-bottom: var(--s-6); }

.recipe-fullscreen-section h3 {
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: var(--s-3);
}

.recipe-fullscreen-section p {
    font-size: 15px;
    line-height: 1.7;
    white-space: pre-wrap;
    color: var(--text);
}

.recipe-fullscreen-section ul { list-style: none; padding: 0; }
.recipe-fullscreen-section li {
    padding: var(--s-2) 0;
    border-bottom: 1px solid var(--line);
    font-size: 15px;
    color: var(--text);
}
.recipe-fullscreen-section li:last-child { border-bottom: none; }

.recipe-fullscreen-actions {
    display: flex;
    gap: var(--s-2);
    margin-top: var(--s-6);
    padding-top: var(--s-5);
    border-top: 1px solid var(--line);
    flex-wrap: wrap;
}

/* Portionsskalering */
.portion-converter {
    background: var(--surface-2);
    border-radius: var(--r-lg);
    padding: var(--s-5);
    margin: var(--s-4) 0;
}
.portion-converter h3 {
    text-align: center;
    margin-bottom: var(--s-3);
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.portion-base-info {
    text-align: center;
    font-size: 13px;
    color: var(--faint);
    margin-bottom: var(--s-4);
}
.portion-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-5);
}
.portion-step-btn {
    width: 52px;
    height: 52px;
    min-height: 52px;
    border-radius: 50%;
    background: var(--surface);
    color: var(--text);
    font-size: 26px;
    font-weight: 300;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s, transform 0.1s;
}
.portion-step-btn:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent-text); }
.portion-step-btn:active:not(:disabled) { transform: scale(0.88); }
.portion-step-btn:disabled { opacity: 0.3; cursor: default; }
.portion-display {
    min-width: 72px;
    text-align: center;
}
.portion-count {
    font-family: var(--font-display);
    font-size: 36px;
    font-weight: 600;
    color: var(--text);
    line-height: 1;
    display: block;
}
.portion-unit {
    font-size: 13px;
    color: var(--muted);
    font-weight: 600;
    display: block;
    margin-top: 2px;
}
.portion-reset {
    background: transparent;
    color: var(--faint);
    font-size: 12px;
    font-weight: 600;
    min-height: 32px;
    height: 32px;
    padding: 0 var(--s-3);
    border-radius: var(--r-pill);
    border: 1px solid var(--line);
    letter-spacing: 0;
}
.portion-reset:hover { color: var(--text); border-color: var(--muted); }

/* Lager-oversigt (inde i opskrift-fullscreen) */
.inventory-status {
    background: var(--surface-2);
    border-radius: var(--r-md);
    padding: var(--s-4);
    margin: var(--s-4) 0;
}
.inventory-available { color: var(--accent-text); margin-bottom: var(--s-3); font-size: 14px; font-weight: 500; }
.inventory-missing   { color: var(--amber-text); font-size: 14px; font-weight: 500; }

/* Ingrediens-rækker */
.ing-row {
    display: flex;
    align-items: flex-start;
    gap: var(--s-3);
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-sm);
    margin-bottom: var(--s-1);
}
.ing-row.has  { background: var(--accent-soft); border-left: 2.5px solid var(--accent); }
.ing-row.part { background: rgba(229, 168, 75, .08); border-left: 2.5px solid var(--amber); }
.ing-row.lack { background: rgba(232, 118, 94, .08); border-left: 2.5px solid var(--red); }
.ing-row .ing-icon   { font-size: 14px; line-height: 1.5; flex-shrink: 0; }
.ing-row .ing-name   { font-size: 14px; font-weight: 600; color: var(--text); }
.ing-row .ing-detail { font-size: 12px; color: var(--muted); margin-top: 1px; }


/* ══════════════════════════════════════
   13. MODALER
══════════════════════════════════════ */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--s-5);
    animation: fadeIn 0.15s ease-out;
}

.modal {
    background: var(--surface);
    border-radius: var(--r-xl);
    padding: var(--s-6);
    width: 480px;
    max-width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.22s ease-out;
}

.modal h3 {
    font-family: var(--font-body);
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: var(--s-5);
}

.modal label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--faint);
    margin-bottom: var(--s-1);
}

.modal input,
.modal select,
.modal textarea { margin-bottom: var(--s-3); }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--s-2);
    margin-top: var(--s-5);
}

/* Bekræft-modal */
.confirm-modal { max-width: 320px; text-align: center; }
.confirm-msg {
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: var(--s-5);
    color: var(--text);
    white-space: pre-wrap;
}
.confirm-yes {
    background: var(--red) !important;
    color: #fff !important;
}
.confirm-modal .modal-actions { justify-content: center; }

/* Modal-faner */
.modal-tabs {
    display: flex;
    gap: var(--s-1);
    background: var(--surface-2);
    border-radius: var(--r-md);
    padding: var(--s-1);
    margin-bottom: var(--s-4);
}
.modal-tab {
    flex: 1;
    height: 36px;
    min-height: 36px;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    border-radius: var(--r-sm);
    transition: all 0.15s ease;
}
.modal-tab:hover { color: var(--text); }
.modal-tab.active { background: var(--accent); color: var(--on-accent); }

/* AI-import boks */
.import-prompt-box {
    background: var(--bg);
    border-radius: var(--r-md);
    padding: var(--s-3) var(--s-4);
    font-size: 12px;
    font-family: 'Courier New', monospace;
    line-height: 1.6;
    color: var(--muted);
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: var(--s-3);
    user-select: all;
    max-height: 160px;
    overflow-y: auto;
}

/* Opskrift-vælger (modal) */
.recipe-picker-list {
    max-height: 200px;
    overflow-y: auto;
    border-radius: var(--r-md);
    margin-top: var(--s-1);
    background: var(--surface-2);
}
.recipe-picker-item {
    padding: var(--s-3) var(--s-4);
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid var(--line);
    transition: background 0.1s ease;
    color: var(--text);
}
.recipe-picker-item:last-child { border-bottom: none; }
.recipe-picker-item:hover { background: var(--surface); }
.recipe-picker-item.selected { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }

/* Dag-vælger */
.day-picker-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--s-2);
    margin: var(--s-1) 0;
}
.day-pick-btn {
    background: var(--surface-2);
    color: var(--muted);
    padding: var(--s-3) var(--s-1);
    border-radius: var(--r-md);
    font-size: 12px;
    font-weight: 600;
    min-height: var(--tap);
    transition: all 0.15s ease;
}
.day-pick-btn:hover { background: var(--accent-soft); color: var(--accent-text); }
.day-pick-btn:active { transform: scale(0.95); }


/* ══════════════════════════════════════
   14. TOAST-BESKEDER
══════════════════════════════════════ */

#toast-root {
    position: fixed;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: var(--s-2);
    pointer-events: none;
    width: min(360px, calc(100vw - 40px));
}

.toast {
    background: var(--surface);
    border-radius: var(--r-lg);
    padding: var(--s-3) var(--s-4);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    width: 100%;
    animation: toastIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: var(--s-3);
    line-height: 1.4;
    box-shadow: 0 8px 32px var(--shadow);
}

.toast-icon {
    flex-shrink: 0;
    width: 22px; height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    font-style: normal;
}
.toast.success { box-shadow: 0 0 0 1.5px var(--accent), 0 8px 32px var(--shadow); }
.toast.success .toast-icon { background: var(--accent); color: var(--on-accent); }
.toast.error   { box-shadow: 0 0 0 1.5px var(--red), 0 8px 32px var(--shadow); }
.toast.error   .toast-icon { background: var(--red); color: #fff; }
.toast.info    { box-shadow: 0 0 0 1.5px var(--amber), 0 8px 32px var(--shadow); }
.toast.info    .toast-icon { background: var(--amber); color: var(--on-accent); }


/* ══════════════════════════════════════
   15. RESPONSIV
══════════════════════════════════════ */

/* ── Mellemstor skærm ── */
@media (max-width: 1100px) {
    .week-grid { grid-template-columns: repeat(4, 1fr); }
    .dashboard-panel { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
    .quick-add-form { grid-template-columns: 1fr 1fr 1fr 1fr; }
    .quick-add-form .form-submit { grid-column: 1 / -1; }
    .quick-add-form .form-submit button { width: 100%; }
    .main-content-grid { grid-template-columns: 1fr; }
}

/* ── Mobil ── */
@media (max-width: 640px) {
    body { padding: 0; }

    nav, .desktop-only { display: none; }

    /* Forhindrer iOS-zoom */
    input, select, textarea { font-size: 16px !important; }

    /* Minimum trykflade på alle knapper */
    button, .tab-btn, .auth-link { min-height: var(--tap); }
    .menu-btn { min-height: 40px; }

    /* Header */
    header { padding: var(--s-2) var(--s-3); gap: var(--s-2); }

    /* Auth */
    .auth-card { padding: var(--s-5) var(--s-4); border-radius: var(--r-xl); }
    .auth-page { align-items: flex-start; }
    .welcome-box { padding: var(--s-5) var(--s-4); border-radius: var(--r-xl); }
    .welcome-screen { align-items: flex-start; }

    /* Stats */
    .dashboard-panel { grid-template-columns: repeat(2, 1fr); gap: var(--s-2); }
    .stat .value { font-size: 24px; }

    /* Quick-add */
    .quick-add-form { grid-template-columns: 1fr; }

    /* Uge-gitter: vandret scroll */
    .week-grid {
        grid-template-columns: repeat(7, 240px);
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        padding-bottom: var(--s-2);
        margin-left: calc(-1 * var(--s-5));
        margin-right: calc(-1 * var(--s-5));
        padding-left: var(--s-5);
        padding-right: var(--s-5);
    }
    .day-card { scroll-snap-align: start; }

    /* Opskrifter */
    .recipes-grid { grid-template-columns: 1fr; }

    /* Modaler → bundark */
    .modal-backdrop { align-items: flex-end; padding: 0; }
    .modal {
        width: 100%;
        max-width: 100%;
        max-height: 94vh;
        border-radius: var(--r-xl) var(--r-xl) 0 0;
        padding: var(--s-5) var(--s-5) calc(var(--s-5) + env(safe-area-inset-bottom, 0px));
        animation: sheetUp 0.28s ease-out;
    }
    .confirm-modal { max-width: 100%; }

    /* Input-gruppe */
    .input-group { flex-direction: column; }
    .input-group input, .input-group select { min-width: unset; width: 100%; }

    /* Modal-handlinger */
    .modal-actions { flex-direction: column-reverse; }
    .modal-actions button { width: 100%; }

    /* Indstillinger */
    .settings-row { flex-direction: column; align-items: flex-start; }

    /* Toast — over tab bar */
    #toast-root {
        bottom: calc(72px + env(safe-area-inset-bottom, 0px));
        left: var(--s-4); right: var(--s-4);
        transform: none;
        width: auto;
    }

    /* Opskrift-fullscreen */
    .recipe-fullscreen { padding: var(--s-4); }
    .recipe-fullscreen-content { padding: var(--s-5) var(--s-4); border-radius: var(--r-lg); }
    .recipe-fullscreen h2 { font-size: 22px; }
    .recipe-fullscreen-meta { gap: var(--s-3); margin-bottom: var(--s-4); }
    .recipe-fullscreen-actions { flex-direction: column; gap: var(--s-2); }
    .recipe-fullscreen-actions button { width: 100%; }
    .portion-controls { flex-direction: column; gap: var(--s-3); }
    .portion-input-group input { width: 60px; }

    /* Toasts animationsretning fra bunden */
    @keyframes toastIn {
        from { opacity: 0; transform: translateY(16px) scale(0.94); }
        to   { opacity: 1; transform: translateY(0) scale(1); }
    }
}

@media (max-width: 380px) {
    .dashboard-panel { grid-template-columns: 1fr; }
    .auth-card { padding: var(--s-4) var(--s-3); }
}
