:root{
  --bg:#0b1220;
  --panel:#0f172a;
  --card:#111c33;
  --card2:#0f1a30;
  --text:#e7eaf0;
  --muted:#9aa3b2;
  --stroke:#23314a;
  --stroke-light: rgba(255, 255, 255, 0.08);
  --surface-hover: rgba(255, 255, 255, 0.04);

  /* BLUE THEME */
  --accent:#3b82f6;
  --accent2:#38bdf8;
  --accent-muted: rgba(59, 130, 246, 0.16);

  --radius:14px;
  --glass: rgba(15, 23, 42, 0.92);

  --btn-warning-bg: rgba(255, 193, 7, 0.18);
  --btn-warning-border: rgba(255, 193, 7, 0.40);
  --btn-warning-text: rgba(255, 255, 255, 0.95);

  --btn-danger-bg: rgba(255, 70, 70, 0.12);
  --btn-danger-border: rgba(255, 70, 70, 0.40);
  --btn-danger-text: #ff6060;

  --success: #27ae60;
  --danger: #e74c3c;
}

body.light-mode {
  --bg: #e5e9f0;
  --panel: #ffffff;
  --card: #ffffff;
  --card2: #f1f5f9;
  --text: #0f172a;
  --muted: #475569;
  --stroke: #cbd5e1;
  --stroke-light: rgba(0, 0, 0, 0.08);
  --surface-hover: rgba(0, 0, 0, 0.04);
  --accent-muted: rgba(59, 130, 246, 0.12);
  --glass: rgba(255, 255, 255, 0.90);
  --accent2: #0284c7;

  --btn-warning-bg: rgba(234, 179, 8, 0.25);
  --btn-warning-border: rgba(234, 179, 8, 0.60);
  --btn-warning-text: #000000;

  --btn-danger-bg: rgba(220, 38, 38, 0.15);
  --btn-danger-border: rgba(220, 38, 38, 0.50);
  --btn-danger-text: #dc2626;

  --success: #16a34a;
  --danger: #dc2626;
}

*{box-sizing:border-box}
html,body{height:100%}

/* background only on html/body */
html{
  background: var(--bg);
  min-height: 100%;
}
body{
  margin:0;
  min-height:100vh;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  color:var(--text);
  background-color: var(--bg);
  position: relative;
}
body::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: -1;
  background-image: 
    radial-gradient(1200px 700px at 20% 0%, rgba(59,130,246,.18), transparent 60%),
    radial-gradient(1200px 700px at 90% 10%, rgba(56,189,248,.10), transparent 55%);
  background-repeat: no-repeat;
  pointer-events: none;
}
body.light-mode::before {
  background-image: 
    radial-gradient(1200px 700px at 20% 0%, rgba(59,130,246,.10), transparent 60%),
    radial-gradient(1200px 700px at 90% 10%, rgba(56,189,248,.06), transparent 55%);
}

/* Layout */
.app{display:flex; min-height:100vh; background:transparent}

.sidebar{
  width:260px;
  background: var(--glass);
  border-right:1px solid var(--stroke);
  padding:18px 14px;
  display:flex;
  flex-direction:column;
  gap:16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.brand{font-weight:800; letter-spacing:.2px; font-size:18px}
.brand span{color:var(--accent)}

.content{
  flex:1;
  padding:18px 18px 18px;
  display:flex;
  flex-direction:column;
  min-height:100vh;
  background:transparent;
}

.main-body{flex:1;}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:16px;
}

.search{
  flex: 1;
  max-width: 1000px;
  transition: max-width 0.3s ease;
}
@media (min-width: 1400px) {
  .search {
    max-width: 1400px;
  }
}
.search input{
  width: 75%;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--surface-hover);
  border: 1px solid var(--stroke);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}
.search input:focus{
  border-color: var(--accent);
}
.search input::placeholder{
  color: var(--muted);
}
body.light-mode .search input {
    background: #ffffff;
}

.mobile-menu-btn{
  display:none;
  background:rgba(255,255,255,.03);
  border:1px solid var(--stroke);
  color:var(--text);
  border-radius:10px;
  width:40px;
  height:40px;
  font-size:20px;
  cursor:pointer;
  align-items:center;
  justify-content:center;
}
.theme-toggle-btn{
  background:rgba(255,255,255,.03);
  border:1px solid var(--stroke);
  color:var(--text);
  border-radius:10px;
  width:40px;
  height:40px;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  padding:0;
}
.theme-toggle-btn .theme-icon-light{display:none}
body.light-mode .theme-toggle-btn .theme-icon-dark{display:none}
body.light-mode .theme-toggle-btn .theme-icon-light{display:block}

.actions{
  display:flex;
  align-items:center;
  gap:12px;
}
.actions .pill{margin:0}

@media (max-width: 768px){
  .mobile-menu-btn{display:flex}
  .search{display:none}
  .sidebar-toggle{display:none}
  .sidebar{
    position:fixed;
    left:-260px;
    top:0;
    bottom:0;
    z-index:10000;
    transition:left .3s ease;
    box-shadow:20px 0 50px rgba(0,0,0,.5);
    background: var(--panel);
  }
  .sidebar.mobile-open{left:0}
  .sidebar-backdrop{
    display:none;
    position:fixed;
    inset:0;
    background:rgba(0,0,0,.5);
    z-index:9999;
  }
  .sidebar-backdrop.active{display:block}
  .content{padding:10px; width: 100%;}
  .grid{grid-template-columns:1fr}
  .card.wide{grid-column:span 1}
  .db-summary{flex-direction:column}
  .db-summary .db-box:first-child{width:100%; max-width:100%}
  .db-box-total{width:100%; min-height:auto}
  .topbar{gap:8px}
  .actions{gap:8px}
  .top-logout .logout-text{display:none}
  .actions-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
  .action-btn {
    justify-content: center;
    width: 100%;
  }
}

.pill-log {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  text-transform: uppercase;
  border-radius: 6px;
  font-weight: 700;
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--accent2);
  background: rgba(59, 130, 246, 0.05);
  letter-spacing: 0.3px;
}
body.light-mode .pill-log {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.45);
}

.pill{
  padding:8px 10px;
  border-radius:999px;
  border:1px solid var(--stroke);
  background:var(--surface-hover);
  color:var(--muted);
  font-size:12px;
}

.grid{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap:14px;
}

.card{
  background: var(--card);
  border:1px solid var(--stroke);
  border-radius:var(--radius);
  padding:14px 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.24);
}
.card.wide{grid-column: span 3}
.card-title{color:var(--muted); font-size:12px; letter-spacing:.3px; text-transform:uppercase}
.card-value{font-size:22px; font-weight:800; margin-top:6px}
.card-sub{color:var(--muted); margin-top:6px; font-size:13px}
code{color:rgba(56,189,248,.95)}

/* Topbar logout button */
.top-logout{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:6px 12px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(255,255,255,.03);
  color:rgba(255,120,120,.95);
  text-decoration:none;
  font-weight:800;
  font-size:13px;
}

.top-logout:hover{
  background:rgba(255,255,255,.06);
  border-color:rgba(255,255,255,.16);
}

.top-logout .logout-icon{
  font-size:14px;
  line-height:1;
}

.top-logout .logout-text{
  white-space:nowrap;
}

/* =========================
   LOGIN PAGE
========================= */

.login-page{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
}

.login-card{
  width:380px;
  background:linear-gradient(180deg, rgba(23,27,36,.95), rgba(21,24,36,.95));
  border:1px solid var(--stroke);
  border-radius:18px;
  padding:36px 32px;
  box-shadow:0 30px 80px rgba(0,0,0,.55);
  text-align:center;
}

.login-card h1{
  margin:0 0 6px;
  font-size:26px;
  font-weight:900;
  letter-spacing:.4px;
}

.login-card p{
  margin:0 0 22px;
  color:var(--muted);
  font-size:14px;
}

.discord-login-btn{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  width:100%;
  padding:14px 16px;
  border-radius:14px;
  font-weight:800;
  text-decoration:none;
  color:white;
  background:linear-gradient(90deg, rgba(88,101,242,.95), rgb(0, 123, 255));
  border:1px solid rgba(139,92,246,.45);
  box-shadow:0 12px 30px rgba(88,101,242,.35);
  transition:transform .15s ease, box-shadow .15s ease;
}

.discord-login-btn:hover{
  transform:translateY(-1px);
  box-shadow:0 18px 40px rgba(88,101,242,.45);
}

body.login footer.panel-footer,
body.login-result footer.panel-footer{
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
}

/* ===== Pages ===== */
.page-header{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:12px;
  margin-bottom:14px
}
.page-title{margin:0; font-size:22px; font-weight:900; letter-spacing:.2px}
.page-subtitle{margin:6px 0 0; color:var(--muted); font-size:13px}

/* NEW: header actions */
.page-actions{
  display:flex;
  align-items:center;
  gap:10px;
}
.btn-inline{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:9px 12px;
  border-radius:12px;
  border:1px solid rgba(59,130,246,.35);
  background:var(--accent-muted);
  color:var(--text);
  cursor:pointer;
  font-size:13px;
  font-weight:800;
  white-space:nowrap;
}
.btn-inline:hover{
  background:rgba(59,130,246,.24);
  border-color:rgba(59,130,246,.55);
}
.btn-inline:active{background:rgba(59,130,246,.30)}

/* ===== Sidebar improvements ===== */
.sidebar-top{display:flex; align-items:center; justify-content:space-between; gap:10px}
.brand{display:flex; align-items:center; gap:6px}
.brand-text{font-weight:900; letter-spacing:.2px; font-size:18px}

.nav-section-title{
  margin-top:12px;
  margin-bottom:4px;
  color:rgba(154,163,178,.60);
  font-size:10.5px;
  font-weight: 800;
  letter-spacing:.5px;
  text-transform:uppercase;
  padding:0 12px;
}
body.light-mode .nav-section-title {
    color: #1e293b;
    opacity: 0.9;
}

.nav{
  display:flex;
  flex-direction:column;
  gap:6px;
  margin-top:0;
}

.nav-item{
  display:flex;
  align-items:center;
  gap:10px;
  color:var(--muted);
  text-decoration:none;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid transparent;
}
.nav-item:hover{background:rgba(255,255,255,.04); color:var(--text)}
body.light-mode .nav-item:hover{background:rgba(0,0,0,.03);}
.nav-item.active{
  background:var(--accent-muted);
  border-color:rgba(59,130,246,.22);
  color:var(--text);
}

.nav-item.danger{color:rgba(255,120,120,.9)}
.nav-icon{width:20px; display:inline-flex; align-items:center; justify-content:center}
.nav-text{white-space:nowrap; overflow:hidden; text-overflow:ellipsis}

.sidebar-footer{margin-top:16px}

.sidebar-toggle{
  border:1px solid var(--stroke);
  background:var(--surface-hover);
  color:var(--text);
  border-radius:12px;
  padding:8px 10px;
  cursor:pointer;
}
.sidebar-toggle:hover{background:rgba(255,255,255,.06)}
.sidebar.collapsed{width:78px}
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .brand-text{display:none}
.sidebar.collapsed .sidebar-footer .nav-text{display:none}
.sidebar.collapsed .brand span{display:none}

/* ===== Buttons ===== */
.btn{
  display:inline-block;
  width:100%;
  text-align:center;
  padding:10px 12px;
  border-radius:12px;
  color:var(--text);
  text-decoration:none;
  background: linear-gradient(90deg, rgba(59,130,246,.90), rgba(56,189,248,.65));
  border:1px solid rgba(59,130,246,.22);
}

/* ===== Footer Watermark ===== */
.panel-footer{
  margin-top:14px;
  padding:12px 0 10px;
  text-align:center;
  font-size:12px;
  color:rgba(231,234,240,.45);
  border-top:1px solid rgba(255,255,255,.06);
}
.panel-footer a{
  color:rgba(231,234,240,.70);
  text-decoration:none;
  font-weight:700;
}
.panel-footer a:hover{
  color:rgba(231,234,240,.90);
  text-decoration:underline;
}

/* ===== Dienstblatt (fixed ranks) ===== */
.db-summary{
  display:flex;
  gap:14px;
  margin-top:14px;
  justify-content:center;
  align-items:stretch;
}
@media (max-width: 900px){
  .db-summary{flex-direction:column; align-items:stretch;}
}

.db-box{
  padding:16px 18px;
  border-radius:14px;
  display:flex;
  flex-direction:column;
  gap:14px;
}

.db-summary .db-box:first-child{
  width: 760px;
  max-width: calc(100% - 360px - 14px);
}

@media (max-width: 1200px) {
  .db-summary .db-box:first-child{
    width: auto;
    max-width: none;
    flex: 1;
  }
}

.db-box-total{
  width: 320px;
  min-height: 160px;
  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:center;
  text-align:center;
}
@media (max-width: 900px){
  .db-summary .db-box:first-child{width:100%; max-width:100%}
  .db-box-total{width:100%; min-height:auto}
}

.db-box-title{
  font-size:16px;
  font-weight:900;
  letter-spacing:.3px;
  text-align:center;
}

.db-counts{
  column-count:2;
  column-gap:36px;
  font-size:14px;
  text-align:center;
}
@media (max-width: 1100px){
  .db-counts{column-count:1}
}
.db-mini-item{
  break-inside:avoid;
  -webkit-column-break-inside:avoid;
  margin:0 0 9px 0;
  line-height:1.35;
  font-weight:600;
  color: var(--muted);
}
.db-mini-item b{
  color: var(--text);
  font-weight:900;
  margin-left:4px;
}

.db-total{
  font-size:58px;
  font-weight:900;
  line-height:1;
  text-align:center;
  margin-top: 2px;
}

.db-rank{margin-top:18px}
.db-rank-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.db-rank-title{font-size:18px; font-weight:900}
.db-rank-meta{color: var(--muted); font-size:13px}
.db-rank-body{margin-top:12px}

.db-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  padding:12px 10px;
  border-top:1px solid var(--stroke-light);
}

body.light-mode .db-row {
    border-color: #e5e7eb;
}
.db-row:first-child{border-top:none}
.db-row-name{font-weight:600}
.db-row-actions{display:flex; justify-content:flex-end}

.actions-row{display:flex; gap:8px; flex-wrap:wrap}

.action-btn{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:7px 11px;
  border-radius:999px;
  border:1px solid rgba(59,130,246,.35);
  background:rgba(59,130,246,.16);
  color: var(--text);
  cursor:pointer;
  font-size:12.5px;
  font-weight:800;
}
.action-btn:hover{
  background:rgba(59,130,246,.24);
  border-color:rgba(59,130,246,.55);
}
.action-btn:active{
  background:rgba(59,130,246,.30)
}
.kasse-val {
  font-size: 24px;
  font-weight: 800;
}
.kasse-val.success { color: var(--success); }
.kasse-val.danger { color: var(--danger); }

.btn-success {
  background: var(--success) !important;
  color: #fff !important;
  border-color: rgba(0,0,0,0.1) !important;
}
.btn-danger {
  background: var(--danger) !important;
  color: #fff !important;
  border-color: rgba(0,0,0,0.1) !important;
}

.action-btn.danger{
  border-color: var(--btn-danger-border);
  background: var(--btn-danger-bg);
  color: var(--btn-danger-text);
}
.action-btn.danger:hover{
  background: rgba(220, 38, 38, 0.25);
  border-color: rgba(220, 38, 38, 0.60);
  color: var(--btn-danger-text);
}
.action-btn.warning{
  border-color: var(--btn-warning-border);
  background: var(--btn-warning-bg);
  color: var(--btn-warning-text);
}
.action-btn.warning:hover{
  border-color: rgba(234, 179, 8, 0.65);
  background: rgba(234, 179, 8, 0.45);
  color: var(--btn-warning-text);
}
.action-btn.warning:active{
  background: rgba(234, 179, 8, 0.55);
}

/* Loading panel */
.db-loading{
  margin-top:14px;
  padding:12px 14px;
  border-radius:14px;
  border:1px solid var(--stroke);
  background:rgba(255,255,255,.02);
}
.db-loading-inner{
  display:flex;
  align-items:center;
  gap:10px;
  font-weight:800;
  font-size:13px;
  color:rgba(231,234,240,.85);
}
.db-spinner{
  width:16px;
  height:16px;
  border-radius:999px;
  border:2px solid rgba(255,255,255,.22);
  border-top-color:rgba(255,255,255,.85);
  animation:dbspin .7s linear infinite;
}
@keyframes dbspin{to{transform:rotate(360deg)}}

/* smooth reveal */
.db-hidden{
  opacity:0;
  transform:translateY(6px);
  transition:opacity .12s ease, transform .12s ease;
}
.db-shown{opacity:1; transform:none}

/* ===== Settings: TagSelect / Chips ===== */
.tagselect{
  position:relative;
  margin-top:12px;
  padding:10px 10px;
  border-radius:14px;
  border:1px solid var(--stroke);
  background:var(--surface-hover);
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
}

.tagselect-tags{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-bottom:10px;
}

.tagchip{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:7px 10px;
  border-radius:999px;
  border:1px solid rgba(59,130,246,.22);
  background:rgba(59,130,246,.12);
  color:var(--text);
  font-size:13px;
  font-weight:700;
}

.tagchip button{
  cursor:pointer;
  border:none;
  background:rgba(255,255,255,.10);
  color:var(--text);
  width:20px;
  height:20px;
  border-radius:999px;
  line-height:18px;
  padding:0;
}
.tagchip button:hover{background:rgba(255,255,255,.18)}

.tagselect-input{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  background:rgba(0,0,0,.12);
  border:1px solid var(--stroke-light);
  color:var(--text);
  outline:none;
}
body.light-mode .tagselect-input {
    background: #ffffff;
    border-color: var(--stroke);
}

.tagselect-dropdown{
  position:absolute;
  left:10px;
  right:10px;
  top:100%;
  margin-top:8px;
  background:rgba(15,23,42,.98);
  border:1px solid rgba(255,255,255,.10);
  border-radius:14px;
  overflow:hidden;
  display:none;
  max-height:260px;
  overflow:auto;
  box-shadow: 0 18px 50px rgba(0,0,0,.35);
  z-index:50;
}

.tagselect-item{
  padding:10px 12px;
  color:var(--text);
  cursor:pointer;
  font-size:13.5px;
}
.tagselect-item:hover{background:rgba(255,255,255,.05)}

/* Settings Collapsible (minimal, clean) */
.sec-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:10px;
}
.sec-head .left{
  display:flex;
  flex-direction:column;
  gap:2px;
}
.sec-toggle{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(18,22,30,.35);
  color:rgba(255,255,255,.86);
  font-weight:800;
  cursor:pointer;
  user-select:none;
}
.sec-toggle:hover{ background:rgba(18,22,30,.50); }
.sec-toggle .chev{
  width:18px;
  display:inline-block;
  text-align:center;
  opacity:.9;
}
.sec-body.is-collapsed{ display:none; }

/* Settings: Rollen-Berechtigungen */
/* Mehr Luft zwischen den Textzeilen im Permissions-Block */
#rolePermsList{ margin-top:12px; }
#rolePermsList .card-sub{ margin-top:10px; }

/* Grid kompakt + sauber, kein Overflow bei langen Labels (z.B. Abmahnungen) */
.perm-grid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap:8px 12px;
  margin-top:10px;
}
@media (min-width: 980px){
  .perm-grid{ grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.perm-chip{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px 10px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(18,22,30,.25);
  color:rgba(255,255,255,.88);
  font-weight:800;
  min-height:40px;
  user-select:none;
}
.perm-chip:hover{ background:rgba(18,22,30,.35); }
.perm-chip span{
  flex:1;
  min-width:0;
  font-size:13px;
  line-height:1.15;
  word-break:break-word;
}

/* Custom Checkbox – passend zum Panel */
.perm-chip input[type="checkbox"]{
  appearance:none;
  -webkit-appearance:none;
  width:18px;
  height:18px;
  border-radius:6px;
  border:1px solid rgba(255,255,255,.22);
  background:rgba(10,14,20,.55);
  position:relative;
  flex:0 0 auto;
}
.perm-chip input[type="checkbox"]:focus{ outline: none; box-shadow: 0 0 0 2px rgba(120,170,255,.25); }
.perm-chip input[type="checkbox"]:checked{
  background:rgba(120,170,255,.95);
  border-color:rgba(120,170,255,.95);
}
.perm-chip input[type="checkbox"]:checked::after{
  content:"";
  position:absolute;
  left:4px;
  top:4px;
  width:8px;
  height:4px;
  border-left:2px solid rgba(10,14,20,.95);
  border-bottom:2px solid rgba(10,14,20,.95);
  transform:rotate(-45deg);
}

/* Unit collapse */
.unit-toggle{
  width:36px;
  min-width:36px;
  height:36px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(18,22,30,.35);
  color:rgba(255,255,255,.86);
  font-weight:900;
  cursor:pointer;
}
.unit-toggle:hover{ background:rgba(18,22,30,.50); }
.unit-body.is-collapsed{ display:none; }

/* Role perms */
.perm-row{
  display:flex;
  gap:10px;
  align-items:flex-start;
  margin-bottom:12px;
}
.perm-row .leftcol{
  width:420px;
  max-width:420px;
}
.perm-row .actions{
  margin-left:auto;
  display:flex;
  gap:8px;
  align-items:center;
}
.perm-grid{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap:8px 12px;
  margin-top:8px;
}
.perm-chip{
  display:flex;
  gap:8px;
  align-items:center;
  padding:8px 10px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(18,22,30,.25);
  color:rgba(255,255,255,.86);
  font-weight:800;
  user-select:none;
}
.perm-chip input{ width:16px; height:16px; }

/* ===== Units ===== */

/* Container: Abstand zwischen Abteilungs-Boxen */
#unitsWrap{
  display:flex;
  flex-direction:column;
  gap:14px; /* verhindert "berühren" */
}

/* Abteilungs-Card */
.unit-card{
  padding:16px 18px;
}

/* Header: Titel links, Beitritt rechts (gleiche Zeile) */
.unit-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding-bottom:12px;
  margin-bottom:12px;
  border-bottom:1px solid rgba(255,255,255,.08); /* visuelle Trennung */
}

.unit-title{
  font-size:18px;
  font-weight:900;            /* Titel fett */
  letter-spacing:.2px;
}

/* Mitgliederzahl schöner in der ersten Zeile */
.unit-count{
  display:inline-flex;
  align-items:center;
  gap:8px;
  margin-top:4px;
  font-size:12.5px;
  font-weight:800;
  color: var(--muted);
}
.unit-count::before{
  content:"•";
  color:rgba(59,130,246,.75);
}

/* Beitritt oben rechts */
.unit-join{
  width:auto;
  padding:8px 12px;
  font-weight:900;
}

/* Rank Sektionen */
.unit-rank{
  margin-top:10px;
  padding-top:10px;
  border-top:1px solid rgba(255,255,255,.06);
}
.unit-rank:first-child{
  margin-top:0;
  padding-top:0;
  border-top:none;
}

/* Rank Titel (Direktor etc.) deutlich sichtbarer */
.unit-rank-title{
  font-size:16px;        /* größer als Name */
  font-weight:900;
  margin-bottom:6px;    /* weniger Abstand nach unten */
  letter-spacing:.3px;
}

/* "Keine Mitglieder" optisch klar getrennt */
.unit-rank-list .muted{
  padding:8px 0;
  color: var(--muted);
  font-size:13px;
}

/* Rows: Abstand + zuverlässige Trennlinien */
.unit-rank-list .db-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:6px 0;
}

/* Trennstrich immer (ab 2. Row) */
.unit-rank-list .db-row + .db-row{
  border-top:1px solid rgba(255,255,255,.05);
}

/* Name etwas ruhiger */
.db-row-name{
  font-size:13px;
  font-weight:700;
  color: var(--text);
}

/* Global Tables */
.w-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}
.w-table thead {
    background: rgba(255,255,255,0.03);
}
body.light-mode .w-table thead {
    background: #f3f4f6;
}
.w-table th {
    padding: 12px 16px;
    border-bottom: 1px solid var(--stroke-light);
    font-size: 13px;
    color: var(--muted);
}
.w-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--stroke-light);
}
body.light-mode .w-table th,
body.light-mode .w-table td {
    border-color: #e5e7eb;
}
.w-layout{width:100%;max-width:none;margin:0;}
.w-card{padding:18px 18px 14px;}
.w-card-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:10px;}
.w-title{font-size:18px;font-weight:800;letter-spacing:0.2px;}
.w-sub{font-size:12px;color:var(--muted);margin-top:2px;}
.w-refresh{padding:8px 12px;}

.w-loading{display:flex;align-items:center;gap:10px;padding:12px 4px;}
.w-empty{padding:10px 2px;}

.w-list{display:flex;flex-direction:column;gap:10px;margin-top:6px;}
.w-row{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  padding:12px;
  border:1px solid var(--stroke-light);
  border-radius:14px;
  background:rgba(0,0,0,.05);
}

body.light-mode .w-row {
    background: #f9fafb;
    border-color: #e5e7eb;
}
.w-row-title{display:flex;align-items:center;gap:10px;font-weight:700;}
.w-row-meta{font-size:12px;color:var(--muted);margin-top:2px;}
.w-row-reason{margin-top:8px;line-height:1.35;color:var(--text);opacity:0.9;}
.w-row-actions{display:flex;gap:10px;align-items:center;flex-wrap:wrap;min-width:170px;justify-content:flex-end;}
.w-btn{white-space:nowrap;}
.w-btn.disabled{opacity:.55;pointer-events:none;}

.w-badge{display:inline-flex;align-items:center;justify-content:center;font-size:12px;font-weight:800;padding:5px 10px;border-radius:999px;border:1px solid var(--stroke-light);background:var(--surface-hover);}
.w-badge.lvl1 {
  background: #facc15;          /* gelb */
  color: #000000;               /* dunkler Text */
  border: 1px solid #eab308;
}
.w-badge.lvl2 {
  background: #f47c23;
  color: #000000;
  border: 1px solid #f36f17;
}
.w-badge.lvl3 {
  background: #dc2626;          /* klares rot */
  color: #ffffff;
  border: 1px solid #991b1b;
}
.w-name{font-weight:800;}

/* ===== Abmahnungen Modal (Popup) ===== */
.perm-check-label {
  border: 1px solid rgba(255, 255, 255, .10);
  background: rgba(18, 22, 30, .25);
}
body.light-mode .perm-check-label {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #1e293b;
}

.w-modal-backdrop{
  position:fixed;
  inset:0;
  background: rgba(0,0,0,.55);
  z-index: 9999;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 22px;
  overflow-y: auto; /* Allow scrolling if modal is too tall */
}

.w-modal{
  width: min(620px, 100%);
  border-radius: 16px;
  border: 1px solid var(--stroke);
  background: var(--panel);
  box-shadow: 0 30px 80px rgba(0,0,0,.55);
  overflow:hidden;
}

body.light-mode .w-modal {
    background: #ffffff;
    box-shadow: 0 20px 50px rgba(0,0,0,0.1);
}

.w-modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.w-modal-title{
  font-size: 16px;
  font-weight: 900;
  letter-spacing: .2px;
}

.w-modal-x{
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.06);
  color: rgba(231,234,240,.95);
  cursor: pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 18px;
  line-height: 1;
}
.w-modal-x:hover{
  background: rgba(255,255,255,.10);
  border-color: rgba(255,255,255,.16);
}
.w-modal-x:active{
  background: rgba(255,255,255,.14);
}

.w-modal-body{ padding: 14px 16px; }
.w-modal-foot{
  display:flex;
  gap:10px;
  justify-content:flex-end;
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.w-label{display:block;font-size:12px;color:var(--muted);margin-bottom:6px;font-weight:700;}
.w-textarea{width:100%;border-radius:12px;border:1px solid var(--stroke-light);background:rgba(0,0,0,.12);color:var(--text);padding:10px 12px;outline:none;resize:vertical;min-height:88px;}
body.light-mode .w-textarea { background: #fff; }
.w-textarea:focus{border-color:rgba(80,180,255,.55);box-shadow:0 0 0 3px rgba(80,180,255,.12);}

.w-levels{display:flex;gap:10px;}
.w-level{flex:1;border-radius:12px;border:1px solid var(--stroke-light);background:rgba(0,0,0,.12);color:var(--text);padding:10px 10px;font-weight:800;cursor:pointer;}
body.light-mode .w-level { background: #fff; }
.w-level:hover{background:rgba(255,255,255,.06);}
.w-level.active{border-color:rgba(80,180,255,.55);box-shadow:0 0 0 3px rgba(80,180,255,.12);background:rgba(80,180,255,.08);}

.w-error{margin-top:10px;padding:10px 12px;border-radius:12px;border:1px solid rgba(255,80,120,.35);background:rgba(255,80,120,.10);color:#ef4444;font-size:13px;}

.w-row-exp{font-size:12px;color: var(--muted);margin-top:2px;}

.w-expiry{margin-top:12px;padding:12px;border-radius:14px;border:1px solid rgba(255,255,255,.10);background:rgba(255,255,255,.03);}
.w-expiry-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:10px;}
.w-expiry-row{display:flex;gap:10px;flex-wrap:wrap;}
.w-expiry-row .tagselect-input{flex:1;min-width:180px;}
.w-hint{margin-top:6px;font-size:12px;color:var(--muted);}

.w-row-gap-sm{ height: 8px; }
.w-row-gap-xs{ height: 5px; }

.w-row-footer{
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

/* ================================
   UI Notifications (Toast) + Confirm
   ================================ */

.ui-toast-wrap{
  position:fixed;
  bottom:100px;            /* unter Topbar */
  right:25px;
  z-index:9999;
  display:flex;
  flex-direction:column;
  gap:10px;
  pointer-events:none;
}

.ui-toast{
  pointer-events:auto;
  min-width:280px;
  max-width:420px;
  padding:12px 12px;
  border-radius:14px;
  background: var(--panel);
  border:1px solid var(--stroke);
  box-shadow:0 12px 40px rgba(0,0,0,.35);
  backdrop-filter: blur(8px);
}

body.light-mode .ui-toast {
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.ui-toast-title{
  font-weight:900;
  font-size:14px;
  letter-spacing:.2px;
  margin-bottom:4px;
  color: var(--text);
}

.ui-toast-msg{
  font-size:13px;
  font-weight:600;
  color: var(--muted);
  line-height:1.45;
}
body.light-mode .ui-toast-msg {
    color: #1e293b;
}

.ui-toast.info{ border-left:4px solid rgba(80,180,255,.95); }
.ui-toast.success{ border-left:4px solid rgba(80,220,160,.95); }
.ui-toast.warn{ border-left:4px solid rgba(250,204,21,.95); }
.ui-toast.error{ border-left:4px solid rgba(239,68,68,.95); }

/* Confirm-Modal (nutzt vorhandenes w-modal-backdrop Layout) */
.ui-confirm .w-modal{
  width:420px;
  max-width:calc(100vw - 30px);
}

.ui-confirm .ui-confirm-msg{
  font-weight:500;
  font-size:13px;
  color: var(--text);
  line-height:1.4;
}

/* ============================================================
   Settings & Custom Cards
   ============================================================ */
.settings-header-btn {
  padding: 7px 10px;
  border-radius: 10px;
}

.perm-group-card {
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid var(--stroke-light);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border-radius: 12px;
}

body.light-mode .perm-group-card {
    background: #f9fafb;
    border-color: #e5e7eb;
}

.perm-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.kasse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  align-items: flex-start;
}

.status-online { color: var(--success) !important; font-weight: 700; }
.status-offline { color: var(--danger) !important; font-weight: 700; }

/* Styling für Select-Dropdowns (z.B. in den Logs) */
select.tagselect-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='rgba(154,163,178,0.8)'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
  cursor: pointer;
  background-color: rgba(255, 255, 255, 0.03); /* Dezenter, cleaner Hintergrund */
  color: var(--text);
  border: none; /* Rand entfernt für einen flacheren Look */
  transition: background-color 0.2s ease, transform 0.1s ease; /* Weicher Übergang */
}

select.tagselect-input:hover {
  background-color: rgba(255, 255, 255, 0.07); /* Subtiles Aufhellen beim Hovern */
}

select.tagselect-input:active {
  transform: scale(0.99); /* Kleines haptisches Feedback beim Klicken */
}

body.light-mode select.tagselect-input {
  background-color: rgba(0, 0, 0, 0.04);
  color: #0f172a;
  border: none;
}

body.light-mode select.tagselect-input:hover {
  background-color: rgba(0, 0, 0, 0.08);
}

/* Styling der Optionen innerhalb des Dropdowns */
select.tagselect-input option {
  background-color: var(--panel);
  color: var(--text);
  padding: 10px;
}

body.light-mode select.tagselect-input option {
  background-color: #ffffff;
  color: #0f172a;
}
