/* Razhodi — камп/морска тема. Mobile-first. */
:root {
    --sea:        #0E6B7A;
    --sea-deep:   #08313a;
    --sea-light:  #1AA7B8;
    --aqua:       #3FC4D4;
    --sand:       #F4E4C1;
    --sand-soft:  #FBF6EC;
    --coral:      #FF7A59;
    --coral-deep: #E8633A;
    --sun:        #FFC857;
    --good:       #2E9E6B;
    --bad:        #E8633A;
    --accent:     #0E6B7A;   /* текст-акцент (в тъмна тема става светъл) */
    --good-txt:   #2E9E6B;   /* зелен текст-акцент */

    --bg:         #FBF6EC;
    --bg-elev:    #FFFFFF;
    --card:       #FFFFFF;
    --text:       #143B43;
    --muted:      #5E7B82;
    --line:       #E7DCC4;
    --shadow:     0 6px 22px rgba(14, 107, 122, .10);
    --radius:     18px;
    --header-h:   62px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --maxw: 640px;
}
html[data-theme="dark"] {
    --bg:      #0A2128;
    --bg-elev: #0E2C34;
    --card:    #0E2C34;
    --text:    #E8F3F2;
    --muted:   #8FB0B6;
    --line:    #1C434C;
    --sand-soft: #0A2128;
    --shadow:  0 6px 22px rgba(0,0,0,.35);
    --accent:   #4CC6D6;   /* светъл тюркоаз за текст върху тъмно */
    --good-txt: #5FD6A0;
    --bad:      #FF8863;   /* по-светъл корал за текст върху тъмно */
    --muted:    #9DBEC4;   /* по-контрастно сиво */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--sea-light); outline-offset: 2px; } /* видим фокус за клавиатура */
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    overflow-x: hidden;
}

/* decorative wave under the header */
.wave-top {
    position: fixed; inset: 0 0 auto 0; z-index: 0; pointer-events: none;
    height: calc(230px + env(safe-area-inset-top, 0px));
    background:
        radial-gradient(120% 80% at 80% -20%, var(--sun) 0%, transparent 45%),
        linear-gradient(160deg, var(--sea-light) 0%, var(--sea) 55%, var(--sea-deep) 100%);
}
/* тъмна тема: по-дълбока, приглушена вълна вместо ярък тюркоаз */
html[data-theme="dark"] .wave-top {
    background:
        radial-gradient(120% 80% at 80% -20%, rgba(255,200,87,.22) 0%, transparent 45%),
        linear-gradient(160deg, #11505E 0%, #0B3641 55%, #06222B 100%);
}
.wave-top::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 42px;
    background:
        radial-gradient(20px 22px at 20px 0, transparent 60%, var(--bg) 62%) repeat-x,
        radial-gradient(20px 22px at 60px 22px, var(--bg) 60%, transparent 62%) repeat-x;
    background-size: 80px 42px, 80px 42px;
}

/* ---- top bar ---- */
.topbar {
    position: relative; z-index: 2;
    height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px); /* iPhone notch в standalone PWA */
    max-width: var(--maxw); margin: 0 auto;
    padding-left: 16px; padding-right: 16px;
    display: flex; align-items: center; justify-content: space-between;
    color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { border-radius: 10px; box-shadow: 0 3px 8px rgba(0,0,0,.2); flex: none; }
.brand-name { display: block; font-weight: 800; font-size: 1.15rem; letter-spacing: .2px; line-height: 1.1; }
.brand-sub  { display: block; font-size: .7rem; opacity: .9; }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
    width: 40px; height: 40px; border-radius: 12px; border: 0;
    background: rgba(255,255,255,.18); color: #fff; font-size: 1.1rem;
    cursor: pointer; backdrop-filter: blur(4px); transition: transform .1s, background .15s;
}
.icon-btn:active { transform: scale(.92); }

/* ---- layout ---- */
.app {
    position: relative; z-index: 2;
    max-width: var(--maxw); margin: 0 auto;
    padding: 14px 16px calc(40px + var(--safe-bottom));
}

.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 18px; margin-bottom: 14px;
}
.card h2 { margin: 0 0 4px; font-size: 1.18rem; }
.section-title { display: flex; align-items: center; gap: 8px; margin: 4px 2px 12px; font-size: 1.25rem; font-weight: 800; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }

/* ---- forms ---- */
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
input[type=text], input[type=number], input[type=password], input[type=email], select {
    width: 100%; padding: 13px 14px; font-size: 1.05rem;
    border: 1.5px solid var(--line); border-radius: 12px;
    background: var(--bg-elev); color: var(--text); transition: border-color .15s;
    -webkit-appearance: none; appearance: none;
}
select {
    padding-right: 40px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%231AA7B8' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center;
}
select:focus { outline: none; border-color: var(--sea-light); }
input:focus { outline: none; border-color: var(--sea-light); }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

/* stepper for counts */
.stepper { display: flex; align-items: stretch; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg-elev); }
.stepper button { width: 52px; border: 0; background: transparent; color: var(--accent); font-size: 1.5rem; font-weight: 700; cursor: pointer; }
.stepper button:active { background: rgba(26,167,184,.12); }
.stepper input { border: 0; text-align: center; border-radius: 0; font-weight: 700; font-size: 1.2rem; padding: 12px 0; }
.stepper input:focus { box-shadow: none; }

/* ---- buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 15px 18px; font-size: 1.05rem; font-weight: 700;
    border: 0; border-radius: 14px; cursor: pointer; transition: transform .1s, filter .15s;
    background: linear-gradient(135deg, var(--coral) 0%, var(--coral-deep) 100%);
    color: #fff; box-shadow: 0 6px 16px rgba(232,99,58,.32);
}
.btn:active { transform: translateY(1px) scale(.995); }
.btn.sea { background: linear-gradient(135deg, var(--sea-light) 0%, var(--sea) 100%); box-shadow: 0 6px 16px rgba(14,107,122,.3); }
.btn.ghost { background: transparent; color: var(--accent); box-shadow: none; border: 1.5px solid var(--line); }
.btn.sm { width: auto; padding: 9px 14px; font-size: .9rem; border-radius: 11px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---- expense list cards ---- */
.exp-card {
    display: block; width: 100%; text-align: left; cursor: pointer; color: var(--text);
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
    position: relative; overflow: hidden; transition: transform .1s;
}
.exp-card:active { transform: scale(.99); }
.exp-card::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px;
    background: linear-gradient(var(--aqua), var(--sea));
}
.exp-card.joined::before { background: linear-gradient(var(--sun), var(--coral)); }
.exp-card h3 { margin: 0 0 6px; font-size: 1.1rem; padding-left: 6px; }
.exp-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; padding-left: 6px; font-size: .85rem; color: var(--muted); }
.exp-total { font-weight: 800; color: var(--accent); }
.chip {
    display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; font-weight: 700;
    padding: 3px 9px; border-radius: 999px; background: rgba(26,167,184,.14); color: var(--accent);
}
.chip.gold { background: rgba(255,200,87,.25); color: #9a6b12; }
html[data-theme=dark] .chip.gold { color: var(--sun); }
.chip.paid { background: rgba(46,158,107,.16); color: var(--good-txt); }
.chip.done { background: rgba(94,123,130,.18); color: var(--muted); }
.chip.ok { background: rgba(26,167,184,.16); color: var(--accent); }
.chip.owe { background: rgba(232,99,58,.16); color: var(--bad); font-weight: 800; }

/* уреден разход — посивен */
.exp-card.settled-card { opacity: .62; filter: grayscale(.5); }
.exp-card.settled-card::before { background: linear-gradient(var(--good), var(--sea-deep)); }

/* ---- totals strip ---- */
.totals { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.tot-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; text-align: center; }
.tot-box .lbl { font-size: .78rem; color: var(--muted); margin-bottom: 4px; }
.tot-box .val { font-size: 1.5rem; font-weight: 800; color: var(--accent); }

/* balance banner */
.balance-banner { border-radius: var(--radius); padding: 18px; margin-bottom: 14px; color: #fff; text-align: center; box-shadow: var(--shadow); }
.balance-banner.receive { background: linear-gradient(135deg, #34b37a, var(--good)); }
.balance-banner.pay     { background: linear-gradient(135deg, var(--coral), var(--coral-deep)); }
.balance-banner.even    { background: linear-gradient(135deg, var(--sea-light), var(--sea)); }
.balance-banner .b-lbl { font-size: .9rem; opacity: .92; }
.balance-banner .b-val { font-size: 2rem; font-weight: 800; margin-top: 2px; }

/* items */
.item { display: flex; align-items: center; gap: 10px; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .it-main { flex: 1; min-width: 0; }
.item .it-title { font-weight: 600; }
.item .it-fam { font-size: .76rem; color: var(--muted); }
.item .it-amt { font-weight: 800; white-space: nowrap; }
.item .it-del { border: 0; background: transparent; color: var(--bad); font-size: 1.15rem; cursor: pointer; padding: 8px 10px; min-width: 40px; min-height: 40px; }
.item .it-cam { border: 0; background: transparent; font-size: 1.15rem; cursor: pointer; padding: 7px; min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
.item .it-cam svg { display: block; flex: none; }
.item.has-img { cursor: pointer; }
.it-pic { display: inline-block; }
.it-pic svg { vertical-align: -3px; }

/* преглед на снимка на цял екран */
.modal.img-modal { background: #000; }
.modal.img-modal .modal-body { padding: 40px 0 12px; }
.modal.img-modal .modal-grab { background: rgba(255,255,255,.35); }
.full-img { display: block; width: 100%; height: auto; max-height: 80vh; object-fit: contain; }

/* settlement rows */
.settle { display: flex; align-items: center; gap: 10px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.settle:last-child { border-bottom: 0; }
.settle .s-main { flex: 1; min-width: 0; }
.settle .s-name { font-weight: 700; }
.settle .s-sub { font-size: .76rem; color: var(--muted); }
.settle .s-bal { font-weight: 800; white-space: nowrap; text-align: right; }
.settle .s-bal .s-tag { display: block; font-size: .68rem; font-weight: 700; }
.s-bal.pos { color: var(--good-txt); }
.s-bal.neg { color: var(--bad); }
.s-bal.zero { color: var(--muted); }
.settle.mine { background: rgba(255,200,87,.12); border-radius: 12px; padding: 12px 8px; }
.pay-check { display: inline-flex; align-items: center; gap: 6px; margin-top: 7px; font-size: .78rem; color: var(--muted); cursor: pointer; user-select: none; }
.pay-check input { width: 19px; height: 19px; accent-color: var(--good-txt); flex: none; }
.settle.paid .s-name { text-decoration: line-through; opacity: .55; }
.settle.paid .s-bal { opacity: .5; }
.settle.paid .pay-check { color: var(--good-txt); font-weight: 700; }
.pay-status { display: inline-block; margin-top: 7px; font-size: .78rem; font-weight: 700; color: var(--good-txt); }
.rev-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 11px; flex: none; margin-left: 10px;
    background: #0666EB; color: #fff; font-weight: 800; font-size: 1.1rem; text-decoration: none;
    box-shadow: 0 3px 9px rgba(6,102,235,.4); transition: transform .1s;
}
.rev-btn:active { transform: scale(.9); }
.settle.paid .rev-btn { opacity: .5; }

/* locked */
.locked-note {
    background: rgba(255,200,87,.18); border: 1px solid var(--sun); color: var(--text);
    border-radius: var(--radius); padding: 12px 14px; font-size: .9rem; margin-bottom: 14px; line-height: 1.4;
}
html[data-theme=dark] .locked-note { background: rgba(255,200,87,.10); }
.exp-card.locked-card::before { background: linear-gradient(var(--muted), var(--sea-deep)); }

/* участие — табове режим */
.mode-tabs { display: flex; gap: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.mode-tab { flex: 1; border: 0; background: transparent; color: var(--muted); font-weight: 700; font-size: .9rem; padding: 9px 8px; border-radius: 9px; cursor: pointer; transition: all .12s; }
.mode-tab.active { background: var(--card); color: var(--accent); box-shadow: var(--shadow); }

/* участие — избор на членове */
.members-pick { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.mem-icon {
    width: 52px; height: 52px; border-radius: 14px; border: 2px solid var(--line);
    background: var(--bg-elev); font-size: 1.7rem; line-height: 1; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; transition: all .12s; position: relative;
}
.mem-icon.on { border-color: var(--good-txt); background: rgba(46,158,107,.12); }
.mem-icon.off { opacity: .4; filter: grayscale(1); }
.mem-icon.on::after {
    content: "✓"; position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%;
    background: var(--good); color: #fff; font-size: .7rem; display: flex; align-items: center; justify-content: center;
}
.mem-icon:active { transform: scale(.9); }

/* Google — акцентиран блок най-отгоре в auth */
.g-hero {
    border: 1.5px solid var(--sea-light); border-radius: 14px;
    background: rgba(26,167,184,.08); padding: 14px; text-align: center; margin-bottom: 4px;
}
.g-hero #googleBtnBox { display: flex; justify-content: center; }

/* линк-бутон (забравена парола) */
.linklike { display: block; margin: 12px auto 0; border: 0; background: none; color: var(--accent); font-size: .88rem; font-weight: 600; text-decoration: underline; cursor: pointer; padding: 6px 10px; }

/* разделител в auth формите */
.or-sep { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .8rem; margin: 14px 0; }
.or-sep::before, .or-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* версия */
.app-ver { text-align: center; color: var(--muted); font-size: .72rem; padding: 6px 0 calc(18px + var(--safe-bottom)); opacity: .7; }

/* класация */
.rank { display: flex; align-items: center; gap: 11px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.rank:last-child { border-bottom: 0; }
.rank.mine { background: rgba(255,200,87,.12); border-radius: 12px; padding: 10px 8px; }
.rk-pos { width: 28px; text-align: center; font-size: 1.1rem; font-weight: 800; flex: none; }
.rk-main { flex: 1; min-width: 0; }
.rk-name { font-weight: 600; margin-bottom: 5px; }
.rk-sub { font-size: .74rem; color: var(--muted); }
.rk-bar { height: 8px; border-radius: 5px; background: var(--line); overflow: hidden; }
.rk-bar > span { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--aqua), var(--sea)); }
.rk-val { font-weight: 800; white-space: nowrap; color: var(--accent); flex: none; }

/* длъжници */
.debt-group { margin-bottom: 14px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.debt-group:last-child { margin-bottom: 0; }
.debt-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--bg); padding: 10px 12px; font-size: .95rem; border-bottom: 1px solid var(--line); }
.debt-head .debt-total { margin-left: auto; font-weight: 800; color: var(--good-txt); }
.debt-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.debt-row:last-child { border-bottom: 0; }
.debt-row.mine { background: rgba(255,200,87,.12); }
.dr-main { flex: 1; min-width: 0; }
.dr-name { font-weight: 600; }
.dr-titles { font-size: .72rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dr-amt { font-weight: 800; white-space: nowrap; color: var(--bad); }

/* графика по дни */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 14px; overflow-x: auto; }
.bar-col { flex: 1 0 34px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 34px; }
.bar-val { font-size: .62rem; color: var(--muted); margin-bottom: 3px; }
.bar { width: 100%; max-width: 30px; border-radius: 6px 6px 0 0; background: linear-gradient(var(--aqua), var(--sea)); min-height: 3px; }
.bar-lbl { font-size: .62rem; color: var(--muted); margin-top: 5px; white-space: nowrap; transform: rotate(-45deg); transform-origin: center; height: 16px; }

/* приключения: "пощенски картички" с градиент, различни от белите карти на разходите */
.adv-card {
    display: block; width: 100%; text-align: left; cursor: pointer; color: #fff;
    position: relative; overflow: hidden; border: 0; border-radius: var(--radius);
    background: linear-gradient(135deg, var(--sea-light) 0%, var(--sea) 60%, var(--sea-deep) 100%);
    box-shadow: 0 8px 24px rgba(14, 107, 122, .35);
    padding: 18px 16px; margin-bottom: 14px; transition: transform .1s;
}
.adv-card:active { transform: scale(.99); }
.adv-card .adv-emoji { position: absolute; right: -6px; bottom: -16px; font-size: 4.8rem; opacity: .18; transform: rotate(-8deg); pointer-events: none; }
.adv-card h3 { margin: 0 0 8px; font-size: 1.25rem; letter-spacing: .2px; }
.adv-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: .85rem; position: relative; }
.adv-card .chip { background: rgba(255,255,255,.22); color: #fff; }
.adv-card .chip.ok { background: rgba(255,255,255,.22); color: #fff; }
.adv-card .chip.gold { background: rgba(255,200,87,.32); color: #FFE9B8; }
.adv-card .chip.owe { background: rgba(232,99,58,.9); color: #fff; }
.adv-card.pending { background: linear-gradient(135deg, #6E8187 0%, #4A5C62 100%); box-shadow: none; opacity: .9; }
html[data-theme=dark] .adv-card { box-shadow: 0 8px 24px rgba(0,0,0,.45); }

.list-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.list-head .section-title { min-width: 0; overflow-wrap: anywhere; } /* дълго име не избутва бутоните */
.head-actions { display: flex; gap: 8px; flex: none; }
.icon-btn2 { width: 40px; height: 40px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); font-size: 1.15rem; cursor: pointer; box-shadow: var(--shadow); }
.icon-btn2:active { transform: scale(.92); }
.notif { background: rgba(255,200,87,.16); border: 1px solid var(--sun); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.notif-txt { font-size: .9rem; margin-bottom: 8px; }
.notif-btns { display: flex; gap: 8px; }
.notif-btns .btn { width: auto; flex: 1; }
.qr-box { display: flex; justify-content: center; padding: 14px; background: #fff; border-radius: var(--radius); margin: 4px 0 12px; }
.qr-box svg { width: 220px; height: 220px; display: block; }
.code-box { text-align: center; margin-bottom: 14px; }
.code-box span { display: inline-block; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.25rem; font-weight: 800; color: var(--accent); background: var(--bg); border: 1.5px dashed var(--sea-light); border-radius: 12px; padding: 10px 16px; letter-spacing: .5px; word-break: break-word; }

/* empty state */
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .emo { font-size: 3rem; }

/* back link */
.back {
    display: inline-flex; align-items: center; gap: 7px;
    background: var(--card); border: 1.5px solid var(--accent); color: var(--accent);
    font-weight: 700; font-size: .92rem; cursor: pointer;
    padding: 9px 15px; border-radius: 999px; margin-bottom: 14px;
    box-shadow: var(--shadow); transition: transform .1s, background .15s;
}
.back .back-arrow { font-size: 1.15rem; line-height: 1; margin-top: -1px; }
.back:active { transform: scale(.96); background: rgba(26,167,184,.12); }

/* sticky add bar */
.add-bar { display: flex; gap: 8px; margin-top: 4px; }
.add-bar input.amt { max-width: 120px; }

/* банер за PWA инсталиране */
.install-banner {
    position: fixed; left: 12px; right: 12px; bottom: calc(14px + var(--safe-bottom));
    max-width: calc(var(--maxw) - 24px); margin: 0 auto; z-index: 45;
    display: flex; align-items: center; gap: 12px;
    background: var(--card); border: 1px solid var(--line); border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,.25); padding: 12px 14px;
    transform: translateY(130%); opacity: 0; transition: transform .25s ease, opacity .25s ease;
}
.install-banner.show { transform: none; opacity: 1; }
.install-banner img { border-radius: 10px; flex: none; }
.ib-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ib-txt b { font-size: .95rem; }
.ib-txt span { font-size: .78rem; color: var(--muted); }
.install-banner .btn.sm { flex: none; }
.ib-x { border: 0; background: transparent; color: var(--muted); font-size: 1rem; cursor: pointer; padding: 8px; flex: none; min-width: 36px; min-height: 36px; }

/* toast */
.toast {
    position: fixed; left: 50%; bottom: calc(20px + var(--safe-bottom)); transform: translateX(-50%) translateY(20px);
    background: var(--sea-deep); color: #fff; padding: 12px 18px; border-radius: 12px;
    font-size: .9rem; box-shadow: 0 8px 24px rgba(0,0,0,.3); opacity: 0; pointer-events: none;
    transition: opacity .2s, transform .2s; z-index: 50; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--coral-deep); }

/* modal */
.modal-host { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; background: rgba(8,20,24,.5); padding: 0; }
.modal {
    position: relative;
    background: var(--bg); width: 100%; max-width: var(--maxw); border-radius: 22px 22px 0 0;
    box-shadow: 0 -10px 40px rgba(0,0,0,.3); animation: slideUp .22s ease;
    max-height: 88vh; overflow: hidden;   /* рамката не скролира — скролът е в .modal-body */
}
.modal-body { max-height: 88vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding: 22px 18px calc(22px + var(--safe-bottom)); }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal h2 { margin-top: 0; padding-right: 40px; }
.modal-grab { width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.modal-x {   /* винаги видим — стои в неподвижната рамка, над скролиращото съдържание */
    position: absolute; top: 12px; right: 12px; z-index: 3;
    width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
    background: var(--line); color: var(--text); font-size: 1rem; line-height: 1;
    display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.modal-x:active { transform: scale(.9); }

@media (min-width: 560px) {
    .modal-host { align-items: center; }
    .modal { border-radius: 22px; margin: 16px; }
}

.spin { display: inline-block; width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: rot .8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
.loading { text-align: center; padding: 50px; }
