:root {
    --teal: #0ea5a4;
    --teal-dark: #0c8a89;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e6ebef;
    --bg: #eef3f6;
    --card: #ffffff;
    --plus: #16a34a;
    --plus-bg: #dcfce7;
    --minus: #dc2626;
    --minus-bg: #fee2e2;
    --radius: 16px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(1200px 400px at 50% -120px, #d4f1f0 0%, rgba(212, 241, 240, 0) 70%),
        var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

.wrap {
    max-width: 640px;
    margin: 0 auto;
    padding: 20px 16px calc(40px + env(safe-area-inset-bottom));
}

/* ---------- hlavička ---------- */
.head { text-align: center; padding: 8px 0 18px; }
.head h1 {
    margin: 0;
    font-size: 1.6rem;
    letter-spacing: -.02em;
}
.subtitle { margin: 6px 0 0; color: var(--muted); font-size: .95rem; }

/* ---------- flash ---------- */
.flash {
    border-radius: 12px;
    padding: 11px 14px;
    margin-bottom: 14px;
    font-size: .92rem;
    font-weight: 500;
}
.flash--success { background: var(--plus-bg); color: #166534; }
.flash--error { background: var(--minus-bg); color: #991b1b; }

/* ---------- souhrnné statistiky ---------- */
.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
.stat {
    background: var(--card);
    border-radius: var(--radius);
    padding: 14px 12px;
    text-align: center;
    box-shadow: var(--shadow);
}
.stat__label { display: block; font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat__value { display: block; margin-top: 4px; font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em; }

/* ---------- karty ---------- */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.card h2 {
    margin: 0 0 14px;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.count {
    font-size: .8rem;
    background: #eef2f5;
    color: var(--muted);
    border-radius: 999px;
    padding: 1px 9px;
    font-weight: 600;
}
.empty { color: var(--muted); margin: 4px 0; }
.hint { color: var(--muted); font-size: .82rem; margin: 12px 0 0; }

/* ---------- avatar ---------- */
.avatar {
    flex: 0 0 auto;
    width: 34px; height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: .9rem;
    overflow: hidden;
}
.avatar--img { background: #e2e8ed; }
.avatar--img img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- vyrovnání ---------- */
.transfers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.transfer {
    display: flex;
    align-items: center;
    gap: 6px 10px;
    flex-wrap: wrap;
    background: linear-gradient(0deg, #f8fafb, #fff);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
}
.transfer__people { display: flex; align-items: center; gap: 8px; flex: 1 1 auto; min-width: 0; }
.transfer__who { display: inline-flex; align-items: center; gap: 7px; }
.transfer__who strong { white-space: nowrap; }
.transfer__arrow { color: var(--muted); font-size: 1.05rem; flex: 0 0 auto; }
.transfer .avatar { width: 30px; height: 30px; font-size: .82rem; }
.transfer__amount {
    margin-left: auto;
    flex: 0 0 auto;
    font-weight: 700;
    background: var(--teal);
    color: #fff;
    padding: 5px 12px;
    border-radius: 999px;
    white-space: nowrap;
}
.transfer--done { background: #f0fdf4; border-color: #bbf7d0; }
.transfer__amount--done { background: var(--plus); }

/* ---------- bilance ---------- */
.balances { list-style: none; margin: 0; padding: 0; }
.balance {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.balance:last-child { border-bottom: 0; }
.balance__info { display: flex; flex-direction: column; min-width: 0; }
.balance__detail { font-size: .8rem; color: var(--muted); }
.badge {
    margin-left: auto;
    font-weight: 700;
    font-size: .9rem;
    padding: 4px 11px;
    border-radius: 999px;
    white-space: nowrap;
}
.badge--plus { background: var(--plus-bg); color: var(--plus); }
.badge--minus { background: var(--minus-bg); color: var(--minus); }
.badge--zero { background: #eef2f5; color: var(--muted); }

/* ---------- formuláře ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field__legend { font-size: .82rem; font-weight: 600; color: #334155; display: flex; align-items: center; gap: 8px; }
.field input, .field select {
    font: inherit;
    padding: 11px 12px;
    border: 1px solid #d6dde3;
    border-radius: 11px;
    background: #fff;
    color: var(--ink);
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
}
.field input:focus, .field select:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(14, 165, 164, .15);
}
.field select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 34px;
}

/* chips (výběr účastníků) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid #d6dde3;
    border-radius: 999px;
    padding: 7px 13px 7px 11px;
    cursor: pointer;
    user-select: none;
    font-size: .9rem;
    transition: background .12s, border-color .12s;
}
.chip input {
    -webkit-appearance: auto; appearance: auto;
    accent-color: var(--teal);
    width: 18px; height: 18px; margin: 0;
    border: 0; border-radius: 0; padding: 0; box-shadow: none;
    flex: 0 0 auto;
}
.chip:has(input:checked) { background: #e6f7f6; border-color: var(--teal); color: var(--teal-dark); font-weight: 600; }

.linkbtn {
    border: 0; background: none; color: var(--teal);
    font: inherit; font-size: .78rem; font-weight: 600;
    cursor: pointer; padding: 0; text-decoration: underline;
}

.form__actions { display: flex; gap: 10px; align-items: center; }

/* tlačítka */
.btn {
    font: inherit; font-weight: 600;
    border: 0; border-radius: 11px;
    padding: 12px 18px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex; align-items: center; justify-content: center;
    transition: transform .04s ease, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--teal); color: #fff; }
.btn--primary:hover { background: var(--teal-dark); }
.btn--ghost { background: #eef2f5; color: #334155; }

.inline-form { display: flex; gap: 10px; margin-top: 14px; }
.inline-form input { flex: 1; min-width: 0; font: inherit; padding: 11px 12px; border: 1px solid #d6dde3; border-radius: 11px; }
.inline-form input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(14,165,164,.15); }

/* ---------- seznam výdajů ---------- */
.expenses { list-style: none; margin: 0; padding: 0; }
.expense {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.expense:last-child { border-bottom: 0; }
.expense--editing { background: #fffaf0; border-radius: 10px; padding: 12px; margin: 0 -12px; border-bottom: 0; }
.expense__main { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.expense__desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
}
.expense__meta { font-size: .78rem; color: var(--muted); }
.expense__amount { font-weight: 700; white-space: nowrap; }
.expense__actions { display: flex; gap: 4px; align-items: center; }

.iconbtn {
    border: 0; background: #f1f5f8; cursor: pointer;
    width: 34px; height: 34px; border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: .95rem; text-decoration: none; line-height: 1;
}
.iconbtn:hover { background: #e2e8ed; }
.iconbtn--danger:hover { background: var(--minus-bg); }
.expense__actions form { display: inline-flex; margin: 0; }

/* ---------- poznámka (notice) ---------- */
.notice {
    display: flex; gap: 10px; align-items: flex-start;
    background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412;
    border-radius: 12px; padding: 11px 13px; margin-bottom: 14px;
    font-size: .86rem; line-height: 1.45;
}
.notice__icon { flex: 0 0 auto; font-size: 1rem; line-height: 1.4; }

/* ---------- platba ---------- */
.pay { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.pay__qr {
    flex: 0 0 auto; width: 190px; height: 190px;
    background: #fff; border: 1px solid var(--line); border-radius: 12px;
}
.pay__info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.pay__label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.pay__acc { font-size: 1.3rem; font-weight: 800; letter-spacing: -.01em; }
.pay__iban { font-size: .82rem; color: var(--muted); margin-bottom: 4px; }
@media (max-width: 440px) {
    .pay { justify-content: center; text-align: center; }
    .pay__qr { width: 210px; height: 210px; }
    .pay__info { align-items: center; flex-basis: 100%; }
}

/* ---------- zavazadla v ceně letenky ---------- */
.baglist { list-style: none; margin: 0; padding: 0; }
.baginfo { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.baginfo:last-child { border-bottom: 0; }
.baginfo__check {
    flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
    background: var(--plus-bg); color: var(--plus);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .85rem; margin-top: 1px;
}
.baginfo__text { display: flex; flex-direction: column; min-width: 0; }
.baginfo__text strong { font-size: .95rem; }
.baginfo__text span { font-size: .85rem; color: var(--muted); }

/* ---------- účastníci ---------- */
.people { list-style: none; margin: 0 0 4px; padding: 0; }
.person { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.person:last-child { border-bottom: 0; }
.person strong { flex: 1; }
.person__del { margin: 0; }

/* ---------- details ---------- */
.details summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 1.05rem;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.details summary::-webkit-details-marker { display: none; }
.details summary::after { content: "▾"; margin-left: auto; color: var(--muted); transition: transform .15s; }
.details[open] summary::after { transform: rotate(180deg); }
.details[open] summary { margin-bottom: 14px; }

/* ---------- patička ---------- */
.foot { text-align: center; color: var(--muted); font-size: .78rem; padding: 8px 0 0; }

@media (max-width: 380px) {
    .stats { grid-template-columns: 1fr; }
    .stat { display: flex; justify-content: space-between; text-align: left; }
    .stat__value { margin-top: 0; }
}
