:root{
  --bg:#f3f4f6;--card:#fff;--text:#111827;--muted:#6b7280;--primary:#111827;
  --accent:#f59e0b;--danger:#dc2626;--success:#15803d;--border:#d1d5db;
  --birthday:#fef08a;--penalty:#fecaca;--brought:#bbf7d0;--adjustment:#dbeafe;
  --shadow:0 8px 24px rgba(0,0,0,.08);--radius:16px
}
*{box-sizing:border-box}
html{min-height:100%}
body{
  margin:0;min-height:100%;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;
  background:var(--bg);color:var(--text);padding-bottom:calc(98px + env(safe-area-inset-bottom))
}
.app-header{
  position:sticky;top:0;z-index:20;min-height:76px;background:rgba(17,24,39,.97);color:#fff;
  padding:calc(10px + env(safe-area-inset-top)) 14px 10px;backdrop-filter:blur(10px);
  display:grid;grid-template-columns:56px auto 56px;align-items:center;gap:8px
}
.header-brand{display:flex;align-items:center;justify-content:center;gap:9px;min-width:0}
.header-logo{width:38px;height:38px;object-fit:cover;border-radius:10px;box-shadow:0 4px 14px rgba(0,0,0,.25)}
.header-brand h1{font-size:25px;line-height:1;margin:0;font-weight:800;letter-spacing:-.4px}
.header-version{display:block;margin-top:3px;color:#cbd5e1;font-size:10px;text-align:center}
.header-refresh{
  justify-self:end;width:46px;height:46px;padding:0;border-radius:14px;background:rgba(255,255,255,.12);
  color:#fff;font-size:27px;font-weight:500;line-height:1
}
.header-refresh:active{transform:rotate(35deg);background:rgba(255,255,255,.2)}
main{max-width:900px;margin:0 auto;padding:14px}
.login-main{padding-bottom:20px}
.login-card{position:relative;max-width:390px;margin:8vh auto 0;text-align:center}
.login-logo{display:block;width:min(190px,58vw);height:auto;margin:0 auto 14px;border-radius:14px;box-shadow:0 10px 28px rgba(0,0,0,.25)}
.card{background:var(--card);border-radius:var(--radius);padding:16px;margin-bottom:14px;box-shadow:var(--shadow)}
h1{margin:0 0 8px}h2{font-size:18px;margin:0 0 14px}h3{font-size:15px}
.sub{color:var(--muted);font-size:13px;margin-top:3px}.error{color:var(--danger);font-weight:700}
.grid{display:grid;gap:10px}.grid-2{grid-template-columns:repeat(2,minmax(0,1fr))}
.form-stack{display:grid;gap:10px}
label{display:block;color:var(--muted);font-size:13px}
input,select,textarea,button{font:inherit}
input,select,textarea{
  width:100%;border:1px solid var(--border);border-radius:12px;padding:11px 12px;background:#fff;color:var(--text);margin-top:5px
}
button,.button{
  border:0;border-radius:13px;padding:13px 16px;min-height:46px;font-weight:700;cursor:pointer;background:var(--primary);
  color:#fff;text-decoration:none;display:inline-flex;align-items:center;justify-content:center;text-align:center
}
button.secondary,.button.secondary{background:#e5e7eb;color:var(--text)}
button.danger,.button.danger{background:var(--danger)}button.full,.button.full{width:100%}
button.small{padding:8px 10px;min-height:36px;font-size:12px}.file-button{cursor:pointer}
.stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin-bottom:14px}
.stat{background:#fff;border-radius:14px;padding:13px 7px;box-shadow:var(--shadow);text-align:center}
.stat strong{display:block;font-size:23px}.stat span{font-size:12px;color:var(--muted)}
.list{display:grid;gap:9px}
.list-item{
  border:1px solid #e5e7eb;border-radius:14px;padding:11px;display:flex;gap:10px;
  align-items:center;justify-content:space-between;min-width:0
}
.list-main{min-width:0}.list-main strong{display:block;overflow-wrap:anywhere}
.actions{display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end}
.open-crates-highlight{background:#fff4b8;border-color:#ead87a}
.badge{display:inline-flex;align-items:center;justify-content:center;min-width:34px;height:34px;padding:0 10px;border-radius:999px;font-weight:800;background:#fee2e2;color:#991b1b}
.tablewrap{overflow-x:auto;-webkit-overflow-scrolling:touch}
table{width:100%;border-collapse:collapse;font-size:13px;min-width:500px}
th,td{text-align:left;padding:9px 6px;border-bottom:1px solid #e5e7eb;vertical-align:top}
th{color:var(--muted);font-weight:700}
.top-three td{font-weight:800}.empty{text-align:center;color:var(--muted);padding:18px 8px}
.notice{background:#fffbeb;border:1px solid #fde68a;padding:10px;border-radius:12px;font-size:13px}
.settings-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.tab{display:none}.tab.active{display:block}.hidden{display:none!important}

/* Mobile bottom navigation */
nav{
  position:fixed;left:0;right:0;bottom:0;z-index:40;display:flex;gap:3px;overflow-x:auto;
  padding:8px 8px calc(8px + env(safe-area-inset-bottom));background:rgba(255,255,255,.98);
  border-top:1px solid var(--border);backdrop-filter:blur(12px);scrollbar-width:none
}
nav::-webkit-scrollbar{display:none}
nav button{
  flex:1 0 76px;min-width:76px;min-height:64px;background:transparent;color:var(--muted);padding:8px 6px 7px;
  border-radius:13px;font-size:11px;line-height:1.1;display:flex;flex-direction:column;gap:4px
}
nav button.active{background:#e5e7eb;color:var(--text)}
.nav-icon{display:block;font-size:24px;line-height:25px;font-weight:700}

/* Calendar like local HTML app */
.calendar-card{padding:12px}
.calendar-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px}
.calendar-head h2{text-align:center;margin:0;text-transform:capitalize}
.calendar-nav{width:44px;height:40px;padding:0;font-size:25px}
.calendar-grid{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:5px}
.calendar-weekdays{margin-bottom:5px}
.weekday{text-align:center;font-size:11px;color:var(--muted);padding:4px 0;font-weight:700}
button.day{
  display:block;width:100%;min-width:0;min-height:74px;padding:5px;border:1px solid #e5e7eb;
  border-radius:10px;background:#fff;color:var(--text);text-align:left;font:inherit;box-shadow:none;overflow:hidden
}
button.day:active{transform:scale(.98);background:#f3f4f6}
button.day.outside{opacity:.38}
button.day.today{outline:2px solid var(--accent);outline-offset:-1px}
.day-number{font-size:12px;font-weight:800;margin-bottom:4px}
.event-dot{
  font-size:9px;line-height:1.2;padding:3px 4px;border-radius:6px;margin-bottom:3px;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#111
}
.event-birthday{background:var(--birthday)}.event-penalty{background:var(--penalty)}
.event-brought{background:var(--brought)}.event-adjustment{background:var(--adjustment)}
.legend{display:flex;gap:10px;flex-wrap:wrap;font-size:12px;margin-top:10px}
.legend span::before{content:"";display:inline-block;width:10px;height:10px;border-radius:3px;margin-right:5px}
.legend .l-birthday::before{background:#facc15}.legend .l-penalty::before{background:#ef4444}
.legend .l-brought::before{background:#22c55e}.legend .l-adjustment::before{background:#60a5fa}

/* dialogs */
.app-dialog-overlay{
  position:fixed;inset:0;z-index:15000;background:rgba(0,0,0,.68);display:flex;align-items:center;
  justify-content:center;padding:16px
}
.app-dialog{
  width:100%;max-width:440px;max-height:88vh;overflow:auto;background:#fff;color:var(--text);
  border-radius:16px;padding:18px;box-shadow:0 20px 60px rgba(0,0,0,.35)
}
.day-entry{padding:11px 0;border-bottom:1px solid #e5e7eb}.day-entry:last-child{border-bottom:0}
.day-entry-head{display:flex;justify-content:space-between;gap:8px;align-items:flex-start}
.event-type-badge{font-size:11px;border-radius:999px;padding:4px 8px;white-space:nowrap}
.dialog-actions{margin-top:14px}
.toast{
  position:fixed;left:50%;top:calc(16px + env(safe-area-inset-top));transform:translateX(-50%);
  z-index:20000;max-width:calc(100% - 28px);padding:12px 16px;border-radius:12px;background:#111827;
  color:#fff;box-shadow:0 12px 30px rgba(0,0,0,.25);font-weight:700;text-align:center
}

body[data-role="viewer"] .edit-only,
body[data-role="viewer"] .logs-only,
body[data-role="viewer"] .settings-only,
body:not([data-role="admin"]) .admin-only{display:none!important}

@media(max-width:600px){
  .grid-2{grid-template-columns:1fr}
  .settings-actions{grid-template-columns:1fr}
  .card{padding:14px}
  main{padding:12px}
  button.day{min-height:64px;padding:4px}
  .event-dot{font-size:8px;padding:2px 3px}
  .list-item{align-items:flex-start;flex-direction:column}
  .actions{width:100%;justify-content:flex-start}
}


.dialog-header-row{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:12px}
.dialog-header-row h2{margin:0}
.icon-close{width:42px;height:42px;min-height:42px;padding:0;font-size:25px}
.logs-dialog{max-width:720px}
.logs-switch{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-bottom:14px}
.logs-switch button.active{background:var(--primary);color:#fff}
.logs-dialog .list{margin-top:12px;max-height:58vh;overflow:auto;padding-right:2px}

@media(max-width:390px){
  .app-header{grid-template-columns:48px auto 48px;padding-left:9px;padding-right:9px}
.header-logo{width:34px;height:34px}
  .header-brand h1{font-size:23px}
  .header-refresh{width:43px;height:43px}
}

.header-spacer{width:46px;height:46px}

/* Zentriertes Wasserzeichen auf allen Seiten */
body::before{
  content:"";
  position:fixed;
  z-index:-1;
  left:50%;
  top:50%;
  width:min(68vw,560px);
  aspect-ratio:1/1;
  transform:translate(-50%,-50%);
  background:url("handball-watermark.png") center/contain no-repeat;
  opacity:.045;
  pointer-events:none;
}
body::after{
  content:"";
  position:fixed;
  z-index:-2;
  inset:0;
  background:var(--bg);
}
header,main,nav,.app-dialog-overlay{position:relative}

/* Einheitliche Schaltflächen in den Einstellungen */
.settings-actions{
  display:grid;
  grid-template-columns:1fr;
  gap:9px;
}
.settings-actions > button,
.settings-actions > .button,
.settings-actions > label.button{
  width:100%;
  min-height:50px;
  margin:0;
  padding:13px 16px;
  border-radius:13px;
  justify-content:center;
  font-size:14px;
  line-height:1.2;
}
.settings-actions > label.button{
  display:flex;
}
.settings-user-info{
  margin:4px 2px 14px;
  padding:10px 12px;
  border-radius:12px;
  background:rgba(255,255,255,.65);
  border:1px solid rgba(209,213,219,.8);
  color:var(--muted);
  font-size:12px;
  text-align:center;
  backdrop-filter:blur(5px);
}
.settings-user-info strong{color:var(--text)}
