/* Källarkollen — lätt, glasinspirerad stil. Handskriven, ingen Tailwind. */

:root {
    --bg: #eef2f0;
    --bg2: #e3ece8;
    --ink: #14201b;
    --ink-soft: #4a5a52;
    --muted: #7b8a82;
    --brand: #0f9d6b;
    --brand-d: #0b7a52;
    --line: rgba(20, 40, 30, 0.10);
    --glass: rgba(255, 255, 255, 0.62);
    --glass-strong: rgba(255, 255, 255, 0.82);
    --glass-soft: rgba(255, 255, 255, 0.42);
    --radius: 16px;
    --shadow: 0 8px 28px rgba(20, 50, 35, 0.10);
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }

html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(1200px 600px at 10% -10%, #d6efe3 0%, transparent 60%),
        radial-gradient(1000px 500px at 100% 0%, #dbeaf6 0%, transparent 55%),
        linear-gradient(180deg, var(--bg), var(--bg2));
    background-attachment: fixed;
    min-height: 100vh;
    line-height: 1.5;
}

.wrap { width: 100%; max-width: 980px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }

/* Topbar */
.topbar {
    position: sticky; top: 0; z-index: 20;
    background: var(--glass-strong);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.brand { font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--ink); }
.nav { display: flex; gap: 4px; align-items: center; }
.nav a {
    text-decoration: none; color: var(--ink-soft); padding: 7px 12px;
    border-radius: 10px; font-weight: 600; font-size: 0.92rem;
}
.nav a.active { background: rgba(15, 157, 107, 0.14); color: var(--brand-d); }
.nav a.logout { color: var(--muted); font-weight: 500; }
.nav a:hover { background: rgba(20, 40, 30, 0.06); }

main.wrap { padding-top: 22px; padding-bottom: 40px; }
.foot { color: var(--muted); font-size: 0.8rem; text-align: center; padding: 24px 0 40px; }

/* Glass-ytor */
.glass, .glass-soft, .glass-strong {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.glass { background: var(--glass); }
.glass-strong { background: var(--glass-strong); }
.glass-soft { background: var(--glass-soft); box-shadow: none; }

.section-title { font-size: 1.05rem; margin: 0 0 6px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 0 12px; gap: 12px; }
.section-head .section-title { margin: 0; }

/* Chatt */
.chat { padding: 18px; margin-bottom: 8px; }
.chat-log { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
.msg { display: flex; }
.msg-user { justify-content: flex-end; }
.bubble {
    max-width: 86%; padding: 9px 13px; border-radius: 14px;
    font-size: 0.95rem; white-space: pre-wrap; word-break: break-word;
}
.msg-user .bubble { background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg-assistant .bubble { background: rgba(255, 255, 255, 0.85); border: 1px solid var(--line); border-bottom-left-radius: 4px; }

.chat-input { display: flex; gap: 8px; margin-top: 12px; }
.chat-input .field { flex: 1; }

.field {
    width: 100%; padding: 11px 13px; font-size: 1rem;
    border: 1px solid var(--line); border-radius: 12px;
    background: rgba(255, 255, 255, 0.9); color: var(--ink);
}
.field:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15, 157, 107, 0.16); }

/* Knappar */
.btn {
    border: 1px solid var(--line); background: rgba(255, 255, 255, 0.9);
    color: var(--ink); padding: 10px 16px; border-radius: 12px;
    font-weight: 600; font-size: 0.95rem; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #fff; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-d); }
.btn-icon { padding: 10px 12px; }
.btn-icon.rec { background: #ef4444; border-color: #ef4444; color: #fff; animation: pulse 1.1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }

/* Bekräftelse */
.confirm { padding: 14px; margin-top: 12px; border: 1px dashed rgba(15,157,107,0.4); }
.confirm-title { font-weight: 700; margin-bottom: 8px; }
.confirm-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.confirm-list li { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.confirm-actions { display: flex; gap: 8px; }

/* Taggar */
.tag { font-size: 0.74rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.02em; }
.tag-in { background: rgba(15, 157, 107, 0.16); color: var(--brand-d); }
.tag-out { background: rgba(239, 68, 68, 0.14); color: #b91c1c; }

/* Lager-grid */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.cat-card { padding: 14px 16px; }
.cat-card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.cat-card-head h3 { margin: 0; font-size: 1rem; }
.item-list { list-style: none; margin: 0; padding: 0; }
.item-list li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.item-list li:first-child { border-top: none; }
.item-list li.neg .item-qty { color: #b91c1c; }
.item-name { color: var(--ink); }
.item-qty { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink-soft); }

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

/* Senaste händelser */
.event-list { list-style: none; margin: 0; padding: 6px 14px; }
.event-list li { display: flex; align-items: center; gap: 9px; padding: 9px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.event-list li:first-child { border-top: none; }

/* Analys */
.analys-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 720px) { .analys-grid { grid-template-columns: 1fr 1fr; } }
.panel { padding: 16px 18px; }
.panel h3 { margin: 0 0 2px; }
.donut-wrap { position: relative; height: 280px; margin-top: 10px; }
.period { display: flex; gap: 6px; }
.chip { text-decoration: none; color: var(--ink-soft); padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255,255,255,0.7); font-size: 0.86rem; font-weight: 600; }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.rank { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.rank-row { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.rank-name { font-weight: 600; }
.rank-val { color: var(--ink-soft); font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.bar { height: 8px; background: rgba(20,40,30,0.08); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #34d399); border-radius: 999px; }

/* Alert */
.alert { background: rgba(239, 68, 68, 0.12); color: #b91c1c; border: 1px solid rgba(239,68,68,0.3); padding: 10px 13px; border-radius: 12px; margin-top: 10px; font-size: 0.92rem; }

/* Rumsväljare */
.rooms-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 18px; }
.room-chip-wrap { display: inline-flex; align-items: center; gap: 2px; }
.room-pen { border: none; background: transparent; cursor: pointer; font-size: 0.85rem; opacity: 0.6; padding: 2px 4px; }
.room-pen:hover { opacity: 1; }
.chip-add { border-style: dashed; cursor: pointer; }

/* Redigeringsknapp på varurad */
.item-list li { align-items: center; }
.item-edit { border: none; background: transparent; cursor: pointer; opacity: 0; font-size: 0.85rem; padding: 0 6px 0 0; transition: opacity 0.12s; }
.item-list li:hover .item-edit { opacity: 0.6; }
.item-edit:hover { opacity: 1 !important; }
.item-name { flex: 1; }
.room-tag { font-size: 0.7rem; color: var(--muted); background: rgba(20,40,30,0.06); padding: 1px 6px; border-radius: 999px; margin-left: 6px; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20, 35, 28, 0.4); display: flex; align-items: center; justify-content: center; padding: 18px; z-index: 50; }
.modal { width: 100%; max-width: 420px; padding: 22px; display: flex; flex-direction: column; gap: 8px; max-height: 90vh; overflow: auto; }
.modal h3 { margin: 0 0 6px; }
.modal-row { display: flex; gap: 10px; }
.modal-row > div { flex: 1; }
.lbl { font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); margin-top: 6px; }
.modal-actions { display: flex; gap: 8px; margin-top: 14px; }
.btn-danger { margin-left: auto; background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.3); color: #b91c1c; }
.btn-danger:hover { background: rgba(239,68,68,0.18); }

/* Kategori-ikon */
.cat-icon { font-size: 1.05em; margin-right: 2px; }

/* Installknapp i topbar */
.nav-install { border: 1px solid var(--brand); background: rgba(15,157,107,0.12); color: var(--brand-d); padding: 6px 11px; border-radius: 10px; font-weight: 600; font-size: 0.88rem; cursor: pointer; }
.nav-install:hover { background: rgba(15,157,107,0.2); }

/* Utgångsdatum */
.expiry-banner { padding: 12px 16px; margin-bottom: 16px; border-left: 4px solid #f59e0b; }
.expiry-banner strong { display: block; margin-bottom: 6px; }
.expiry-banner ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.expiry-banner li { font-size: 0.9rem; }
.expiry-banner li.expired { color: #b91c1c; font-weight: 600; }
.expiry-banner li.soon span { color: #b45309; }
.exp-badge { font-size: 0.7rem; color: #b45309; background: rgba(245,158,11,0.14); padding: 1px 6px; border-radius: 999px; margin-left: 6px; white-space: nowrap; }
.item-list li.exp-soon { background: rgba(245,158,11,0.07); }
.item-list li.exp-expired { background: rgba(239,68,68,0.08); }
.item-list li.exp-expired .exp-badge { color: #b91c1c; background: rgba(239,68,68,0.14); }

/* Klickbar händelse */
.event-row { cursor: pointer; border-radius: 8px; }
.event-row:hover { background: rgba(20,40,30,0.05); }

/* Köplista */
.shop-card { margin-bottom: 14px; }
.shop-list { list-style: none; margin: 0; padding: 0; }
.shop-list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.shop-list li:first-child { border-top: none; }
.shop-check { border: none; background: transparent; cursor: pointer; font-size: 1.1rem; color: var(--brand); padding: 0; line-height: 1; }
.shop-check.checked { color: var(--muted); }
.shop-name { flex: 1; }
.shop-del { border: none; background: transparent; cursor: pointer; color: var(--muted); font-size: 0.95rem; padding: 0 2px; opacity: 0.5; }
.shop-del:hover { opacity: 1; color: #b91c1c; }
.shop-list li.done .shop-name { text-decoration: line-through; color: var(--muted); }
.warn-badge { font-size: 0.7rem; color: #b45309; background: rgba(245,158,11,0.16); padding: 1px 7px; border-radius: 999px; margin-left: 6px; white-space: nowrap; }

/* Förbättringsförslag */
.suggest { margin-bottom: 16px; }
.suggest-head { display: flex; align-items: center; justify-content: space-between; }
.suggest-head h3 { margin: 0; }
.suggest-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.suggest-list li { display: flex; gap: 10px; align-items: flex-start; }
.suggest-icon { font-size: 1.2rem; line-height: 1.3; }
.suggest-title { font-weight: 600; }

/* Liten knapp (förslagsåtgärd) */
.btn-small { padding: 5px 11px; font-size: 0.82rem; margin-top: 8px; }
.suggest-body { flex: 1; }

/* Klickbara svarsalternativ i chatten */
.choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.choices .choice-btn { margin-top: 0; }

/* Bottenmeny — visas bara på mobil */
.bottom-nav { display: none; }
@media (max-width: 640px) {
    .nav .navlink { display: none; }
    .topbar-inner { height: 52px; }
    .brand { font-size: 1rem; }
    .nav { gap: 6px; }
    .nav .logout { font-size: 0.82rem; padding: 6px 8px; }
    .nav-install { padding: 5px 9px; font-size: 0.8rem; }
    main.wrap { padding-bottom: 78px; }
    .foot { padding-bottom: 90px; }
    .bottom-nav {
        display: flex;
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
        background: var(--glass-strong);
        backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
        border-top: 1px solid var(--line);
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    }
    .bn-item {
        flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
        text-decoration: none; color: var(--muted); font-size: 0.72rem; font-weight: 600;
        padding: 4px 0; border-radius: 10px;
    }
    .bn-icon { font-size: 1.3rem; line-height: 1; }
    .bn-item.active { color: var(--brand-d); }
}

/* Touch-vänliga klickbara rader (hela raden är tryckyta) */
.item-row, .shop-row, .event-row, .suggest-clickable { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.item-row { padding: 11px 4px; }
.event-row { padding: 11px 6px; }
.item-row:hover, .shop-row:hover, .suggest-clickable:hover { background: rgba(20, 40, 30, 0.05); }
.item-row:active, .shop-row:active, .event-row:active, .suggest-clickable:active { background: rgba(20, 40, 30, 0.10); }
.row-chevron { color: var(--muted); font-size: 1.3rem; line-height: 1; margin-left: 4px; flex: none; align-self: center; }
.ev-name { flex: 1; }

/* Köplistans rader: större tryckyta, bocken är bara en markör */
.shop-list li { padding: 12px 4px; }
.shop-check { font-size: 1.2rem; line-height: 1; flex: none; width: 22px; text-align: center; }
.shop-del, .shop-edit { border: none; background: transparent; cursor: pointer; color: var(--muted); flex: none; padding: 6px 7px; opacity: 0.65; }
.shop-edit { font-size: 0.95rem; }
.shop-del { font-size: 1.05rem; }
.shop-edit:hover { opacity: 1; color: var(--brand-d); }
.shop-del:hover { opacity: 1; color: #b91c1c; }

/* Förslag: hela raden klickbar */
.suggest-clickable { border-radius: 10px; padding: 8px; margin: 0 -8px; }
.suggest-action-hint { display: inline-block; margin-top: 8px; font-weight: 600; color: var(--brand-d); font-size: 0.88rem; }

/* Kategori-väljare (chips) i redigeringsrutorna */
.cat-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.cat-chip { border: 1px solid var(--line); background: rgba(255, 255, 255, 0.7); color: var(--ink-soft);
    padding: 7px 13px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.cat-chip:hover { background: #fff; }
.cat-chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card { width: 100%; max-width: 360px; padding: 28px 26px; display: flex; flex-direction: column; gap: 12px; background: var(--glass-strong); }
.login-card h1 { margin: 0; font-size: 1.4rem; }
.login-card .btn { width: 100%; }
