:root {
    --bg:        #0f1115;
    --surface:   #1a1d24;
    --surface-2: #232730;
    --border:    #2e3340;
    --text:      #e8eaed;
    --muted:     #9aa0ab;
    --accent:    #e63327; /* Muay-Thai-Rot */
    --accent-d:  #b8241a;
    --green:     #2ecc71;
    --yellow:    #f1c40f;
    --red:       #e74c3c;
    --radius:    12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark { font-size: 26px; }
.brand-text { font-weight: 800; letter-spacing: .5px; line-height: 1; text-transform: uppercase; }
.brand-text small { color: var(--accent); font-size: 11px; letter-spacing: 2px; }
.topbar { flex-wrap: wrap; }
.topbar nav { display: flex; align-items: center; gap: 14px; }
.topbar nav a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; }
.topbar nav a:hover { color: var(--text); }
.nav-toggle { display: none; background: none; border: 0; color: var(--text); font-size: 26px; line-height: 1; cursor: pointer; padding: 4px 8px; }

.container { max-width: 920px; margin: 0 auto; padding: 20px 16px 60px; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-d); border-color: var(--accent-d); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-danger { color: var(--red); border-color: transparent; background: transparent; }

/* Search */
.searchbar { margin: 4px 0 22px; }
.searchbar input {
    width: 100%;
    padding: 13px 16px;
    font-size: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}
.searchbar input::placeholder { color: var(--muted); }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 24px; }
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    text-align: center;
}
.stat .num { font-size: 26px; font-weight: 800; }
.stat .lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat.aktiv .num { color: var(--green); }
.stat.bald  .num { color: var(--yellow); }
.stat.abgelaufen .num { color: var(--red); }
.stats.stats3 { grid-template-columns: repeat(3, 1fr); } /* KPI rows stay 3-up */

/* Section title */
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 26px 0 10px; }

/* Member cards */
.member {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 8px;
    text-decoration: none;
    color: var(--text);
}
.member:hover { border-color: var(--muted); }
.member .avatar {
    width: 42px; height: 42px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--surface-2);
    font-weight: 700; color: var(--accent);
    flex: none;
}
.member .info { flex: 1; min-width: 0; }
.member .name { font-weight: 700; }
.member .sub { font-size: 13px; color: var(--muted); }
.member .meta { text-align: right; flex: none; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}
.badge.aktiv      { background: rgba(46,204,113,.15); color: var(--green); }
.badge.bald       { background: rgba(241,196,15,.15);  color: var(--yellow); }
.badge.abgelaufen { background: rgba(231,76,60,.15);   color: var(--red); }
.badge.kein       { background: var(--surface-2);      color: var(--muted); }
.badge.paid       { background: rgba(46,204,113,.15); color: var(--green); }
.badge.unpaid     { background: rgba(231,76,60,.15);  color: var(--red); }
.badge.sess       { font-size: 11px; padding: 2px 8px; margin-left: 6px; vertical-align: middle; }
.badge.sess1      { background: var(--surface-2); color: var(--muted); }
.badge.sess2      { background: rgba(230,51,39,.18); color: var(--accent); }

.days { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Forms */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 18px;
}
.card h2 { margin: 0 0 16px; font-size: 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea, .field select {
    width: 100%;
    padding: 11px 13px;
    font-size: 15px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
}
.field textarea { min-height: 80px; resize: vertical; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row .field { flex: 1; min-width: 140px; }
.checkrow { display: flex; align-items: center; gap: 8px; }
.checkrow input { width: auto; }

/* Duration chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    flex: 1; min-width: 90px;
    text-align: center;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    cursor: pointer;
    font-weight: 600;
    user-select: none;
}
.chip input { display: none; }
.chip.selected { border-color: var(--accent); background: rgba(230,51,39,.12); color: #fff; }

/* Detail */
.detail-head { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.detail-head .avatar { width: 58px; height: 58px; font-size: 22px; }
.detail-head h1 { margin: 0; font-size: 24px; }
.contact-line { color: var(--muted); font-size: 14px; }
.contact-line a { color: var(--accent); text-decoration: none; }

table.laufzeiten { width: 100%; border-collapse: collapse; }
table.laufzeiten th, table.laufzeiten td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
table.laufzeiten th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }

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

/* Home: 4 big buttons */
.home-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin: 8px 0 10px; }
.home-btn {
    background: #fff;
    color: #14171d;
    border: none;
    border-radius: 18px;
    padding: 30px 12px;
    min-height: 128px;
    font-size: 19px;
    font-weight: 800;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.home-btn .emo { font-size: 42px; line-height: 1; }
.home-btn:active { transform: scale(.98); }
.home-btn.b-day    { background: #3b82f6; color: #fff; }        /* blue   */
.home-btn.b-member { background: #22c55e; color: #06210f; }     /* green  */
.home-btn.b-card   { background: #f59e0b; color: #241704; }     /* amber  */
.home-btn.b-acc    { background: #8b5cf6; color: #fff; }        /* purple */
.home-btn.b-room   { background: #14b8a6; color: #04231f; }     /* teal   */
.home-btn.b-gear   { background: #ec4899; color: #fff; }        /* pink   */

/* Gear: size buttons + admin stock editor */
.size-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.size-btn {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 14px 6px; border-radius: 12px; cursor: pointer;
    border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
.size-btn .sz  { font-size: 20px; font-weight: 800; }
.size-btn .qty { font-size: 11px; color: var(--muted); }
.size-btn:active { transform: scale(.97); }
.size-btn.low  { border-color: var(--yellow); }
.size-btn.low .qty { color: var(--yellow); }
.size-btn.out  { opacity: .4; cursor: not-allowed; }
.stock-edit { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.stock-cell {
    display: flex; align-items: center; gap: 6px; padding: 6px 8px;
    border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
}
.stock-cell span { font-weight: 700; min-width: 30px; }
.stock-cell input { width: 64px; padding: 6px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }

/* Modal */
.modal {
    position: fixed; inset: 0; z-index: 60;
    background: rgba(0,0,0,.6);
    display: none; align-items: center; justify-content: center;
    padding: 16px;
}
.modal.open { display: flex; }
.modal-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; padding: 22px; width: 100%; max-width: 420px;
    max-height: 92vh; overflow: auto;
}
.modal-card h2 { margin: 0 0 16px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; text-align: center; padding: 13px; }

.pkg-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 6px 0 4px; }
.pkg {
    border: 1px solid var(--border); border-radius: 12px; padding: 14px 10px;
    text-align: center; cursor: pointer; font-size: 13px; font-weight: 600;
    background: var(--surface-2); line-height: 1.35;
}
.pkg input { display: none; }
.pkg.sel { border-color: var(--accent); background: rgba(230,51,39,.14); color: #fff; }

/* Room booking calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head { text-align: center; font-size: 11px; color: var(--muted); padding: 2px 0; text-transform: uppercase; }
.cal-day {
    position: relative; min-height: 46px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface-2);
    padding: 4px; cursor: pointer; overflow: hidden;
}
.cal-day.out { border: none; background: transparent; cursor: default; }
.cal-day .num { font-size: 12px; color: var(--muted); }
.cal-day.today { border-color: var(--accent); }
.cal-day.booked { background: rgba(230,51,39,.22); border-color: var(--accent); }
.cal-day.booked .num { color: #fff; font-weight: 700; }
.cal-day .who { display: block; font-size: 9px; color: #fff; line-height: 1.1; margin-top: 2px; white-space: nowrap; }

/* Member picker (reuse an existing member) */
.picker-search {
    width: 100%; padding: 10px 12px; margin: 6px 0 8px;
    font-size: 15px; border-radius: 10px;
    border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
.picker-list { max-height: 190px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.picker-item {
    text-align: left; padding: 10px 12px; border-radius: 9px;
    border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
    font-size: 14px; font-weight: 600; cursor: pointer;
}
.picker-item.sel { border-color: var(--accent); background: rgba(230,51,39,.14); color: #fff; }

/* Photo lightbox (tap an avatar with a photo) */
.foto-lightbox {
    position: fixed; inset: 0; z-index: 80;
    background: rgba(0,0,0,.85);
    display: none; align-items: center; justify-content: center; padding: 20px;
}
.foto-lightbox.open { display: flex; }
.foto-lb-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.foto-lb-inner img {
    max-width: min(512px, 86vw); max-height: 70vh; width: auto; height: auto;
    border-radius: 14px; box-shadow: 0 8px 40px rgba(0,0,0,.5);
}
.foto-lb-actions { display: flex; gap: 10px; }

/* Check-in circle */
.checkin {
    display: inline-flex; align-items: center; justify-content: center;
    width: 42px; height: 42px; border-radius: 50%;
    border: 2px solid var(--border); background: var(--surface-2);
    color: #fff; font-size: 14px; font-weight: 800;
    text-decoration: none; vertical-align: middle; flex: none;
}
.checkin.on   { background: var(--green);  border-color: var(--green); }
.checkin.part { background: var(--yellow); border-color: var(--yellow); color: #14171d; }
.member.present { border-color: var(--green); background: rgba(46,204,113,.08); }

/* Undo an accidental check-in */
.btn-undo {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 42px; margin-right: 4px; vertical-align: middle;
    color: var(--muted); font-size: 18px; text-decoration: none;
}
.btn-undo:hover { color: var(--red); }

/* Avatars: photo support + tap-to-capture */
button.avatar {
    -webkit-appearance: none; appearance: none;
    border: 0; padding: 0; margin: 0; font-family: inherit; cursor: pointer;
}
.avatar.cam { position: relative; }
.avatar.cam::after {
    content: "📷"; position: absolute; right: -3px; bottom: -3px;
    font-size: 11px; line-height: 1; background: var(--surface);
    border-radius: 50%; padding: 2px; opacity: .9; color: initial;
}
.avatar.has-foto {
    background-size: cover; background-position: center;
    color: transparent; font-size: 0;
}
.avatar.uploading { opacity: .5; }

/* Punch-card dots (list) */
.dots { display: inline-flex; gap: 3px; vertical-align: middle; margin-right: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--muted); }
.dot.on { background: var(--accent); border-color: var(--accent); }

/* Punch-card dots (stamp modal) */
.dots-big { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 6px 0 4px; }
.dot-big {
    aspect-ratio: 1; border-radius: 50%; border: 2px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; color: var(--muted); font-size: 18px;
}
.dot-big.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Collapsible income details */
details { border-top: 1px solid var(--border); }
details:last-of-type { border-bottom: 1px solid var(--border); margin-bottom: 4px; }
details > summary {
    cursor: pointer;
    padding: 12px 4px;
    font-size: 14px;
    user-select: none;
    list-style-position: inside;
}
details > summary:hover { color: #fff; }
details > summary::marker { color: var(--accent); }

.flash { background: rgba(46,204,113,.12); border: 1px solid var(--green); color: var(--green); padding: 12px 16px; border-radius: var(--radius); margin-bottom: 18px; }

.foot { text-align: center; color: var(--muted); padding: 30px; font-size: 12px; }

.backlink { color: var(--muted); text-decoration: none; font-size: 14px; display: inline-block; margin-bottom: 14px; }

/* Login page */
.login-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 20px;
}
.login-brand { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.login-brand .brand-text { font-weight: 800; letter-spacing: .5px; text-transform: uppercase; line-height: 1.1; }
.login-brand .brand-text small { color: var(--accent); font-size: 11px; letter-spacing: 2px; }

select {
    width: 100%;
    padding: 11px 13px;
    font-size: 15px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
}

@media (max-width: 560px) {
    .stats { grid-template-columns: repeat(2, 1fr); }

    /* Accounting: keep the 3 KPI tiles in one row but shrink to fit baht numbers */
    .stats.stats3 { gap: 6px; }
    .stats.stats3 .stat { padding: 10px 4px; }
    .stats.stats3 .num { font-size: 13px !important; line-height: 1.2; }
    .stats.stats3 .lbl { font-size: 9px; letter-spacing: 0; }

    /* Tighter tables so more fits without horizontal scrolling */
    table.laufzeiten th, table.laufzeiten td { padding: 8px 6px; font-size: 13px; }
    .card { padding: 16px 14px; }
    .card h2 { font-size: 16px; }
}

/* Mobile header: collapse the nav into a hamburger menu */
@media (max-width: 640px) {
    .nav-toggle { display: block; }
    .topbar nav {
        display: none;
        flex-basis: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        margin-top: 8px;
    }
    .topbar nav.open { display: flex; }
    .topbar nav a {
        padding: 13px 6px;
        font-size: 16px;
        border-top: 1px solid var(--border);
    }
    .topbar nav a.btn-primary {
        margin-top: 10px;
        text-align: center;
        border-top: none;
    }
}
