:root {
    --rothn-bg: #f3eee9;
    --rothn-surface: #ffffff;
    --rothn-text: #1a1a1a;
    --rothn-text-muted: #6b6b6b;
    --rothn-primary: #5b2c87;
    --rothn-primary-soft: #e8dff5;
    --rothn-accent: #d97706;
    --rothn-success: #16a34a;
    --rothn-warn: #f59e0b;
    --rothn-danger: #dc2626;
    --rothn-border: #e3ddd0;
    --rothn-radius: 14px;
    --rothn-shadow: 0 2px 8px rgba(91,44,135,.04), 0 1px 2px rgba(0,0,0,.06);
    --rothn-shadow-hover: 0 4px 16px rgba(91,44,135,.10), 0 2px 4px rgba(0,0,0,.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--rothn-bg);
    color: var(--rothn-text);
    font-size: 16px;
    line-height: 1.5;
}

h1, h2, h3, h4 { margin: 0 0 .5rem 0; font-weight: 600; letter-spacing: -.02em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
h4 { color: var(--rothn-text-muted); text-transform: uppercase; font-size: .75rem; letter-spacing: .08em; }

a { color: var(--rothn-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

#blazor-error-ui { background: var(--rothn-danger); color: white; bottom: 0; box-shadow: var(--rothn-shadow); display: none; left: 0; padding: .6rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

.app-shell {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--rothn-bg);
    padding-bottom: 84px;
    position: relative;
}

.app-header {
    background: var(--rothn-surface);
    border-bottom: 1px solid var(--rothn-border);
    padding: 1rem 1.25rem .75rem;
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.app-header h1 { font-size: 1.25rem; margin: 0; }
.app-header .meta { font-size: .8rem; color: var(--rothn-text-muted); }

.app-content { padding: 1rem 1.25rem; }

.section + .section { margin-top: 1.5rem; }

.card {
    background: var(--rothn-surface);
    border-radius: var(--rothn-radius);
    box-shadow: var(--rothn-shadow);
    padding: 1rem;
    margin-bottom: .75rem;
    transition: box-shadow .15s ease;
}
.card-clickable { cursor: pointer; }
.card-clickable:hover, .card-clickable:active { box-shadow: var(--rothn-shadow-hover); }
.card-title { font-weight: 600; font-size: 1rem; }
.card-sub { color: var(--rothn-text-muted); font-size: .85rem; }

.kids-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: .75rem;
}

.member-card {
    background: var(--rothn-surface);
    border-radius: var(--rothn-radius);
    padding: 1rem .75rem;
    text-align: center;
    box-shadow: var(--rothn-shadow);
    cursor: pointer;
    transition: transform .1s ease, box-shadow .15s ease;
    display: flex;
    flex-direction: column;
    gap: .25rem;
}
.member-card:active { transform: scale(.98); }
.member-card .avatar { font-size: 2.5rem; line-height: 1; }
.member-card .name { font-weight: 600; font-size: 1rem; }
.member-card .stats { font-size: .8rem; color: var(--rothn-text-muted); display: flex; flex-direction: column; gap: 2px; margin-top: .25rem; }
.member-card .stat-row { display: flex; justify-content: space-between; align-items: center; }
.member-card.has-warning { box-shadow: 0 0 0 2px var(--rothn-warn), var(--rothn-shadow); }

.todo-list { display: flex; flex-direction: column; gap: .5rem; }
.todo-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .65rem .85rem;
    background: var(--rothn-surface);
    border-radius: 10px;
    box-shadow: var(--rothn-shadow);
    font-size: .9rem;
}
.todo-item .icon { font-size: 1.1rem; }
.todo-item .text { flex: 1; }
.todo-item .meta { font-size: .8rem; color: var(--rothn-text-muted); }
.todo-item.danger { border-left: 3px solid var(--rothn-danger); }
.todo-item.warn { border-left: 3px solid var(--rothn-warn); }
.todo-item.info { border-left: 3px solid var(--rothn-primary); }
.todo-item.success { border-left: 3px solid var(--rothn-success); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .55rem 1rem;
    border-radius: 8px;
    border: none;
    font-weight: 500;
    font-size: .9rem;
    cursor: pointer;
    transition: background .15s ease;
    font-family: inherit;
}
.btn-primary { background: var(--rothn-primary); color: white; }
.btn-primary:hover { background: #4a2270; }
.btn-secondary { background: var(--rothn-primary-soft); color: var(--rothn-primary); }
.btn-secondary:hover { background: #d5c4ee; }
.btn-ghost { background: transparent; color: var(--rothn-text-muted); }
.btn-ghost:hover { color: var(--rothn-text); }
.btn-success { background: var(--rothn-success); color: white; }
.btn-danger { background: var(--rothn-danger); color: white; }
.btn-icon { padding: .4rem .55rem; min-width: 36px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-row { display: flex; gap: .5rem; }
.btn-row .btn { flex: 1; }

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    max-width: 480px;
    width: 100%;
    background: var(--rothn-surface);
    border-top: 1px solid var(--rothn-border);
    display: flex;
    justify-content: space-around;
    padding: .5rem 0 calc(.5rem + env(safe-area-inset-bottom, 0));
    z-index: 50;
}
.bottom-nav a {
    flex: 1;
    text-align: center;
    color: var(--rothn-text-muted);
    text-decoration: none;
    font-size: .7rem;
    padding: .25rem 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.bottom-nav a.active { color: var(--rothn-primary); }
.bottom-nav a .icon { font-size: 1.35rem; }

.login-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem 1.5rem;
    background: var(--rothn-bg);
}
.login-logo { width: 160px; height: auto; margin-bottom: 1rem; }
img.login-logo { display: block; }
.login-title { font-size: 2rem; font-weight: 700; margin: 0; letter-spacing: -.02em; }
.login-subtitle { color: var(--rothn-text-muted); margin: .5rem 0 2rem; }
.login-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    width: 100%;
    max-width: 360px;
}
.login-choice {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 320px;
}
.login-choice .login-tile { padding: 1.5rem 1rem; }
.login-choice .login-tile .avatar { font-size: 3rem; }
.pin-display span { display: inline-block; width: .8rem; text-align: center; }
.login-tile {
    background: var(--rothn-surface);
    border: none;
    border-radius: var(--rothn-radius);
    padding: 1.25rem .75rem;
    box-shadow: var(--rothn-shadow);
    cursor: pointer;
    text-align: center;
    transition: transform .1s ease, box-shadow .15s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .4rem;
    font-family: inherit;
}
.login-tile:active { transform: scale(.97); }
.login-tile:hover { box-shadow: var(--rothn-shadow-hover); }
.login-tile .avatar { font-size: 2.75rem; line-height: 1; }
.login-tile .name { font-weight: 600; font-size: 1.05rem; }
.login-tile .badge-mini { font-size: .7rem; color: var(--rothn-text-muted); margin-top: 2px; }
.login-tile.parent { background: linear-gradient(180deg, #fff 0%, #f5efff 100%); }

.pin-display { font-size: 2.5rem; letter-spacing: .8rem; text-align: center; padding: 1rem; min-height: 4rem; font-weight: 300; }

.pin-boxes {
    display: flex;
    justify-content: center;
    gap: .5rem;
    padding: 1.25rem 0;
}
.pin-box {
    width: 2.5rem;
    height: 3rem;
    border: 2px solid var(--rothn-border);
    border-radius: 10px;
    background: var(--rothn-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: var(--rothn-primary);
    transition: border-color .15s ease, background .15s ease, transform .1s ease;
}
.pin-box.filled {
    border-color: var(--rothn-primary);
    background: var(--rothn-primary-soft);
    transform: scale(1.04);
}
.pin-box.active {
    border-color: var(--rothn-primary);
    box-shadow: 0 0 0 3px rgba(91,44,135,.15);
}
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; max-width: 280px; margin: 0 auto; }
.pin-key {
    background: var(--rothn-surface);
    border: none;
    border-radius: 50%;
    aspect-ratio: 1;
    font-size: 1.5rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: var(--rothn-shadow);
    transition: transform .05s ease;
    font-family: inherit;
}
.pin-key:active { transform: scale(.92); background: var(--rothn-primary-soft); }

.tabs {
    display: flex;
    gap: .25rem;
    background: var(--rothn-surface);
    padding: .25rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    overflow-x: auto;
}
.tab {
    flex: 1;
    padding: .5rem .75rem;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--rothn-text-muted);
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
}
.tab.active { background: var(--rothn-primary); color: white; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .2rem .55rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 500;
}
.badge-success { background: #dcfce7; color: var(--rothn-success); }
.badge-warn    { background: #fef3c7; color: #a16207; }
.badge-danger  { background: #fee2e2; color: var(--rothn-danger); }
.badge-info    { background: var(--rothn-primary-soft); color: var(--rothn-primary); }
.badge-muted   { background: #f3f4f6; color: var(--rothn-text-muted); }

.stat-big { font-size: 2rem; font-weight: 700; color: var(--rothn-primary); }
.stat-label { color: var(--rothn-text-muted); font-size: .8rem; }
.stat-row-flex { display: flex; justify-content: space-between; align-items: baseline; padding: .75rem 0; border-bottom: 1px solid var(--rothn-border); }
.stat-row-flex:last-child { border-bottom: none; }

.aemtli-row {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .65rem 0;
    border-bottom: 1px solid var(--rothn-border);
}
.aemtli-row:last-child { border-bottom: none; }
.aemtli-row .check {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 2px solid var(--rothn-border);
    background: transparent;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
    color: transparent;
    flex-shrink: 0;
}
.aemtli-row .check.bestaetigt { background: var(--rothn-success); border-color: var(--rothn-success); color: white; }
.aemtli-row .check.gemeldet { background: var(--rothn-warn); border-color: var(--rothn-warn); color: white; }
.aemtli-row .check.abgelehnt { background: var(--rothn-danger); border-color: var(--rothn-danger); color: white; }
.aemtli-row .text { flex: 1; }
.aemtli-row .text .label { font-weight: 500; }
.aemtli-row .text .sub { font-size: .75rem; color: var(--rothn-text-muted); }

.event-card {
    background: var(--rothn-surface);
    border-radius: 10px;
    padding: .75rem .85rem;
    margin-bottom: .5rem;
    display: flex;
    gap: .85rem;
    align-items: center;
    box-shadow: var(--rothn-shadow);
}
.event-date {
    text-align: center;
    min-width: 48px;
    padding: .4rem 0;
    background: var(--rothn-primary-soft);
    border-radius: 8px;
}
.event-date .day { font-size: 1.3rem; font-weight: 700; color: var(--rothn-primary); line-height: 1; }
.event-date .month { font-size: .7rem; color: var(--rothn-primary); text-transform: uppercase; }
.event-info { flex: 1; min-width: 0; }
.event-info .title { font-weight: 600; }
.event-info .time { font-size: .8rem; color: var(--rothn-text-muted); }
.event-info .loc { font-size: .75rem; color: var(--rothn-text-muted); }

.progress { background: var(--rothn-border); border-radius: 999px; height: 8px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--rothn-primary); transition: width .3s ease; }
.progress-bar.warn { background: var(--rothn-warn); }
.progress-bar.danger { background: var(--rothn-danger); }

.empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--rothn-text-muted);
}
.empty .icon { font-size: 2.5rem; opacity: .4; margin-bottom: .5rem; }

.app-version {
    position: fixed;
    bottom: calc(84px + env(safe-area-inset-bottom, 0));
    left: 50%;
    transform: translateX(-50%);
    font-size: .65rem;
    color: var(--rothn-text-muted);
    background: rgba(255,255,255,.6);
    padding: 1px 6px;
    border-radius: 4px;
    z-index: 49;
    pointer-events: none;
}

.divider { height: 1px; background: var(--rothn-border); margin: 1rem 0; }
