:root {
    --bg: #eef2f7;
    --card: #ffffff;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --brand: #4f46e5;
    --brand-2: #7c3aed;
    --in: #16a34a;
    --in-soft: #dcfce7;
    --accent: #f97316;
    --danger: #e11d48;
    --shadow: 0 10px 30px -12px rgba(15, 23, 42, .25);
    --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(1200px 500px at 80% -10%, #ddd6fe55, transparent 60%),
        radial-gradient(900px 500px at -10% 0%, #c7d2fe55, transparent 55%),
        var(--bg);
    min-height: 100vh;
    line-height: 1.45;
}

.loading {
    text-align: center;
    color: var(--muted);
    padding: 80px 20px;
}

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

.topbar {
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff;
    padding: calc(22px + env(safe-area-inset-top)) 0 26px;
    box-shadow: var(--shadow);
}
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -.3px; }
.brand .ball { font-size: 24px; }
.topbar .who { font-size: 13px; opacity: .9; }

.linkbtn {
    background: rgba(255, 255, 255, .18);
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.linkbtn:active { transform: scale(.97); }

/* ---------- Cards ---------- */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-top: 16px;
}
.card h2 { margin: 0 0 4px; font-size: 17px; }
.card .sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; }

.section-title {
    margin: 26px 4px 6px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--muted);
}

/* ---------- Login ---------- */
.login {
    max-width: 380px;
    margin: 12vh auto 0;
    text-align: center;
    padding: 0 16px;
}
.login .ball { font-size: 56px; }
.login h1 { font-size: 24px; margin: 8px 0 2px; }
.login p { color: var(--muted); margin: 0 0 24px; }

input[type="password"], input[type="text"], input[type="date"], input[type="number"] {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--line);
    border-radius: 14px;
    font-size: 16px;
    background: #fff;
    color: var(--ink);
    transition: border-color .15s;
}
input:focus { outline: none; border-color: var(--brand); }

textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--line);
    border-radius: 14px;
    font-size: 15px;
    font-family: inherit;
    background: #fff;
    color: var(--ink);
    resize: vertical;
    transition: border-color .15s;
}
textarea:focus { outline: none; border-color: var(--brand); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 16px;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff;
    margin-top: 12px;
    transition: transform .08s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.ghost { background: #fff; color: var(--brand); border: 1.5px solid var(--line); }
.btn.sm { width: auto; padding: 9px 14px; font-size: 14px; margin: 0; }
.btn.danger { background: #fff; color: var(--danger); border: 1.5px solid #fecdd3; }

.err {
    color: var(--danger);
    font-size: 14px;
    min-height: 20px;
    margin-top: 10px;
}

/* ---------- Name picker ---------- */
.names {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.name-chip {
    border: 1.5px solid var(--line);
    background: #fff;
    color: var(--ink);
    padding: 10px 14px;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
.name-chip:active { transform: scale(.97); }
.name-chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- Session card ---------- */
.session {
    border: 1.5px solid var(--line);
    border-radius: 16px;
    padding: 14px 16px;
    margin-top: 12px;
    transition: border-color .15s, background .15s;
}
.session.in { border-color: var(--in); background: linear-gradient(0deg, var(--in-soft), #fff 70%); }
.session.closed { opacity: .92; background: #f8fafc; }

.session .row1 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.session .date { font-weight: 800; font-size: 16px; }
.session .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }

.toggle {
    border: 1.5px solid var(--brand);
    background: #fff;
    color: var(--brand);
    padding: 11px 18px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    white-space: nowrap;
    transition: transform .08s;
}
.toggle:active { transform: scale(.96); }
.toggle.in { background: var(--in); border-color: var(--in); color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip {
    font-size: 12.5px;
    background: #eef2ff;
    color: #3730a3;
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 600;
}
.chip.me { background: var(--in); color: #fff; }
.chips .empty { color: var(--muted); font-size: 13px; }

/* ---------- Alap / póthely lista (nyitott alkalom) ---------- */
.roster { margin-top: 12px; }
.roster-group + .roster-group { margin-top: 12px; }
.roster-title {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 6px;
}
.roster-title .rt-count {
    font-size: 11px;
    background: #eef2ff;
    color: #3730a3;
    padding: 1px 7px;
    border-radius: 999px;
}
.wait-group .roster-title { color: #b45309; }
.wait-group .roster-title .rt-count { background: #fef3c7; color: #b45309; }
.roster .chips { margin-top: 7px; }
.chip .chip-num { opacity: .55; font-weight: 700; margin-right: 4px; }
.chip.wait { background: #f4f4f5; color: #52525b; }
.chip.wait.plays { background: #dcfce7; color: #15803d; }
.chip .chip-play { margin-left: 6px; font-size: 11px; font-weight: 800; }
.chip.me .chip-num { opacity: .8; }

/* Feliratkozás-sorrend az admin szerkesztőben */
.att-order { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; }
.att-ord-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
}
.att-ord-pos { color: var(--muted); font-weight: 700; min-width: 24px; }
.att-ord-name { flex: 1; font-weight: 600; }
.att-ord-tag {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .3px;
    padding: 2px 8px;
    border-radius: 999px;
}
.att-ord-tag.base { background: #eef2ff; color: #3730a3; }
.att-ord-tag.wait { background: #fef3c7; color: #b45309; }
.att-ord-tag.plays { background: #dcfce7; color: #15803d; }
.att-force { white-space: nowrap; }

.badge {
    display: inline-block;
    font-size: 11.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .4px;
    padding: 3px 9px;
    border-radius: 999px;
}
.badge.closed { background: #fee2e2; color: #b91c1c; }
.badge.open { background: #dcfce7; color: #15803d; }

/* ---------- Szintjelölés (terem: kedd=középhaladó, péntek=kezdő) ---------- */
.level-tag {
    display: inline-block;
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: .3px;
    padding: 3px 10px;
    border-radius: 999px;
    margin-right: 6px;
    vertical-align: middle;
}
.level-tag.kezdo       { background: #e6f6ea; color: #157f3c; }  /* kezdő – zöld */
.level-tag.kozephalado { background: #e9e9ff; color: #4338ca; }  /* középhaladó – indigó */

/* Bal oldali színes csík a kártyán – ránézésre elkülöníti a két szintet. */
.session.level-kezdo       { box-shadow: inset 5px 0 0 #22a34a; }
.session.level-kozephalado { box-shadow: inset 5px 0 0 #4f46e5; }
/* Nagyon enyhe háttérszín a szinthez, ha még NEM jelentkeztél. */
.session.level-kezdo:not(.in)       { background: #f1faf4; }
.session.level-kozephalado:not(.in) { background: #f4f4fe; }

/* Ha jelentkeztél ("Jövök"), a háttér a SZINT erősebb árnyalatára vált – így egy
   középhaladó alkalom sosem tűnik zöldnek (kezdőnek). A keret és a gomb is a szint színe. */
.session.level-kezdo.in {
    border-color: #22a34a;
    background: linear-gradient(0deg, #d3f3de, #fff 75%);
}
.session.level-kezdo .toggle.in { background: #16a34a; border-color: #16a34a; }

.session.level-kozephalado.in {
    border-color: #4f46e5;
    background: linear-gradient(0deg, #dedcff, #fff 75%);
}
.session.level-kozephalado .toggle.in { background: #4f46e5; border-color: #4f46e5; }

/* ---------- Admin résztvevő-szerkesztő ---------- */
.att-edit { margin-top: 12px; }
.att-toggle.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.att-panel {
    margin-top: 10px;
    padding: 12px;
    border: 1.5px dashed var(--line);
    border-radius: 12px;
    background: #fbfbfd;
}
.att-note { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.att-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.att-chips .empty { color: var(--muted); font-size: 13px; }
.att-chip {
    border: 1.5px solid var(--line);
    background: #fff;
    color: var(--ink);
    padding: 7px 12px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.att-chip:active { transform: scale(.97); }
.att-chip.in { background: var(--in); color: #fff; border-color: var(--in); }
.att-chip[disabled] { opacity: .55; cursor: default; }

.payline {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--line);
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.payline b { font-size: 17px; color: var(--ink); }
.payline .mine { color: var(--in); font-weight: 800; }

/* ---------- Admin ---------- */
.tabs {
    display: flex;
    gap: 6px;
    background: #e9edf5;
    padding: 5px;
    border-radius: 14px;
    margin-top: 18px;
}
.tab {
    flex: 1;
    text-align: center;
    padding: 10px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 14px;
    color: var(--muted);
    cursor: pointer;
    border: none;
    background: transparent;
}
.tab.active { background: #fff; color: var(--brand); box-shadow: 0 2px 6px rgba(0,0,0,.06); }

.inline-form { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 120px; }

.admin-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 4px;
    border-bottom: 1px solid var(--line);
    gap: 10px;
}
.admin-row:last-child { border-bottom: none; }
.admin-row .x {
    border: none;
    background: #fff1f2;
    color: var(--danger);
    width: 32px; height: 32px;
    border-radius: 9px;
    font-size: 16px;
    cursor: pointer;
    flex: none;
}
.admin-row .info small { color: var(--muted); }

.hint { font-size: 12.5px; color: var(--muted); margin-top: 8px; }

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(20px + env(safe-area-inset-bottom));
    transform: translateX(-50%) translateY(20px);
    background: #0f172a;
    color: #fff;
    padding: 11px 18px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
    z-index: 50;
    max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { background: var(--danger); }

/* ---------- Info card ---------- */
.info-card {
    background: linear-gradient(135deg, #fff7ed, #fffbeb);
    border: 1.5px solid #fed7aa;
}
.info-head {
    font-weight: 800;
    font-size: 14px;
    color: #c2410c;
    margin-bottom: 8px;
}
.info-body { font-size: 15px; color: var(--ink); word-break: break-word; }
.info-body a { color: var(--brand); font-weight: 600; }

/* ---------- Owe card ---------- */
.owe-card { border: 1.5px solid #ddd6fe; }
.owe-total {
    font-size: 30px;
    font-weight: 900;
    color: var(--brand-2);
    letter-spacing: -.5px;
}
.owe-total.zero { color: var(--in); font-size: 22px; }
.owe-list { margin-top: 12px; }
.owe-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    padding: 7px 0;
    border-bottom: 1px dashed var(--line);
}
.owe-row:last-child { border-bottom: none; }
.owe-row span:last-child { font-weight: 700; }

/* ---------- Chat ---------- */
.chat-list {
    max-height: 340px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px;
    margin: 4px 0 12px;
}
.chat-empty { color: var(--muted); font-size: 14px; text-align: center; padding: 18px 0; }
.msg {
    background: #f1f5f9;
    border-radius: 12px;
    padding: 8px 12px;
    max-width: 85%;
    align-self: flex-start;
}
.msg.mine { background: var(--in-soft); align-self: flex-end; }
.msg-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}
.msg-name { font-weight: 700; font-size: 13px; color: var(--brand); }
.msg.mine .msg-name { color: var(--in); }
.msg-time { font-size: 11px; color: var(--muted); }
.msg-body { font-size: 15px; word-break: break-word; }
.msg-body a { color: var(--brand); }
.msg-del {
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 13px;
    margin-left: auto;
    padding: 0 2px;
}
.msg-del:hover { color: var(--danger); }
.chat-input { display: flex; gap: 8px; }
.chat-input input { flex: 1; }

/* ---------- Két oszlopos elrendezés (jelentkezés + chat) ---------- */
.wrap.wide { max-width: 1000px; }
.signup-cols { display: block; }
.col-main { min-width: 0; }
.col-chat { min-width: 0; }

@media (min-width: 900px) {
    .signup-cols {
        display: grid;
        grid-template-columns: 1fr 360px;
        gap: 18px;
        align-items: start;
    }
    .col-chat {
        position: sticky;
        top: 16px;
    }
    .col-chat .chat-list { max-height: calc(100vh - 230px); }
    /* a jobb oszlopban a kártyák felső margóját igazítjuk */
    .col-chat .card { margin-top: 16px; }
}

/* ---------- Részvételi díj kártya (havi) ---------- */
.fee-month {
    border: 1.5px solid var(--line);
    border-radius: 14px;
    padding: 12px 14px;
    margin-top: 12px;
}
.fee-month.prev { border-color: #ddd6fe; background: linear-gradient(0deg, #f5f3ff, #fff 70%); }
.fee-row-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.fee-label { font-size: 13px; color: var(--muted); font-weight: 600; line-height: 1.3; }
.fee-label small { color: var(--muted); font-weight: 400; }
.fee-amount { font-size: 24px; font-weight: 900; letter-spacing: -.5px; white-space: nowrap; }
.fee-month.prev .fee-amount { color: var(--brand-2); }
.fee-month.cur .fee-amount { color: var(--ink); }
.fee-list { margin-top: 10px; }
.fee-item {
    display: flex;
    justify-content: space-between;
    font-size: 13.5px;
    padding: 6px 0;
    border-bottom: 1px dashed var(--line);
}
.fee-item:last-child { border-bottom: none; }
.fee-item span:last-child { font-weight: 700; }
.fee-empty { font-size: 13px; color: var(--muted); margin-top: 8px; }

/* ---------- Admin havi összesítő ---------- */
.ov-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 12px;
    padding: 9px 4px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
}
.ov-row span:not(:first-child) { text-align: right; min-width: 80px; font-weight: 700; }
.ov-head { font-weight: 700; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.ov-head span:not(:first-child) { font-weight: 700; }
.ov-total { border-bottom: none; border-top: 2px solid var(--line); font-weight: 800; }
.ov-total span:first-child { font-weight: 800; }

/* ---------- Sportág + archiválás (2026 ősz: terem szezon) ---------- */

/* Sportág címke az alkalom kártyán és az admin listában */
.sport-tag {
    display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .02em;
    padding: 2px 8px; border-radius: 999px; margin-right: 6px; vertical-align: middle;
}
.sport-tag.terem  { background: #e8f0fe; color: #1a56b3; }
.sport-tag.strand { background: #fdf0dc; color: #a35f10; }

.badge.arch { background: #ece9e4; color: #6b6157; }
.session.archived { opacity: .72; }
.admin-row.is-arch { opacity: .72; }

/* Admin szűrősáv */
.filterbar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    background: #fff; border: 1px solid var(--line, #e3e3e3); border-radius: 12px;
    padding: 8px 12px; margin: 10px 0;
}
.fb-label { font-size: .8rem; color: #8a8178; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.fb-sports { display: flex; gap: 6px; flex-wrap: wrap; }
.fb-chip {
    display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
    border: 1px solid var(--line, #e3e3e3); background: #fff; color: inherit;
    border-radius: 999px; padding: 6px 12px; font-size: .88rem; font-weight: 600;
}
.fb-chip.active { background: #1a56b3; border-color: #1a56b3; color: #fff; }
.fb-count {
    font-size: .72rem; background: rgba(0, 0, 0, .09); border-radius: 999px;
    padding: 1px 7px; font-weight: 700;
}
.fb-chip.active .fb-count { background: rgba(255, 255, 255, .25); }
.fb-arch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: .88rem; margin-left: auto; }
.fb-arch input { width: 17px; height: 17px; }
.fb-arch small { color: #8a8178; }

/* Sportág választó az új alkalom felvitelénél */
.sport-pick { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.sport-opt {
    flex: 1 1 190px; display: flex; flex-direction: column; gap: 2px; cursor: pointer;
    border: 2px solid var(--line, #e3e3e3); background: #fff; color: inherit;
    border-radius: 12px; padding: 10px 12px; font-size: .95rem; font-weight: 700; text-align: left;
}
.sport-opt small { font-weight: 400; font-size: .78rem; color: #8a8178; }
.sport-opt.active { border-color: #1a56b3; background: #f2f7ff; }
.sport-opt.active small { color: #1a56b3; }

/* Jelentkezési napló (admin) */
.log-box { margin-top: 10px; border-top: 1px solid var(--line, #e3e3e3); padding-top: 10px; }
.log-list { margin-top: 8px; max-height: 260px; overflow-y: auto; }
.log-row {
    display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
    padding: 5px 2px; border-bottom: 1px solid #f0eeea; font-size: .86rem;
}
.log-act { font-weight: 700; white-space: nowrap; }
.log-act.up { color: #2e7d32; }
.log-act.down { color: #b3261e; }
.log-name { flex: 1; min-width: 90px; }
.log-time { color: #8a8178; font-size: .8rem; white-space: nowrap; }
