/* ==========================================================================
   Verwaltungsbereich: Dashboard, Reiter und Module
   ========================================================================== */

.admin-main.is-app { display: block; min-height: 0; padding: calc(var(--header-h) + 32px) 0 72px; }
.admin-main.is-app #admin-view { display: block; }

.app { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: clamp(20px, 3vw, 36px); align-items: start; }

/* Seitenleiste */
.app-side {
  position: sticky;
  top: calc(var(--header-h) + 20px);
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: var(--surface);
}
.app-user { display: flex; align-items: center; gap: 12px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.app-user strong { display: block; line-height: 1.3; overflow-wrap: anywhere; }
.app-user small { color: var(--accent); font-size: 0.76rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; }
.app-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(24, 223, 207, 0.3), rgba(24, 223, 207, 0.08));
  border: 1px solid var(--line-strong);
  color: var(--accent);
  font-weight: 700;
}

.app-tabs { display: grid; gap: 4px; }
.app-tab {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.94rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.app-tab:hover { background: rgba(9, 78, 82, 0.25); color: var(--text); }
.app-tab.is-active { background: rgba(24, 223, 207, 0.12); border-color: rgba(24, 223, 207, 0.4); color: var(--text); }
.app-tab-icon svg, .app-logout svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.app-tab.is-active .app-tab-icon { color: var(--accent); }
.app-tab-label { flex: 1; }
.app-tab-badge { padding: 1px 8px; border-radius: 999px; background: rgba(255, 200, 87, 0.14); color: #ffc857; font-size: 0.68rem; font-weight: 600; }

.app-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.app-logout:hover { color: var(--text); border-color: var(--line-strong); }

/* Inhalt */
.app-panel { min-width: 0; min-height: 420px; padding: clamp(18px, 3vw, 30px); border: 1px solid var(--line); border-radius: 22px; background: rgba(3, 24, 30, 0.6); }

.mod-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 20px; margin-bottom: 22px; }
.mod-head h2 { font-size: clamp(1.4rem, 3vw, 1.8rem); font-style: normal; }
.mod-head p { margin-top: 4px; color: var(--muted); font-size: 0.92rem; }
.mod-head .btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.mod-loading, .mod-empty { padding: 32px 12px; color: var(--muted); text-align: center; }
.mod-note { margin-bottom: 16px; padding: 11px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--muted); font-size: 0.9rem; }
.mod-note.is-warn { border-color: rgba(255, 200, 87, 0.35); background: rgba(255, 200, 87, 0.07); color: #f4dfae; }

.mod-search { position: relative; display: flex; align-items: center; margin-bottom: 18px; }
.mod-search svg { position: absolute; left: 16px; width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.mod-search input { width: 100%; height: 44px; padding: 0 16px 0 46px; border: 1px solid var(--line-strong); border-radius: 999px; background: rgba(1, 16, 21, 0.7); color: var(--text); font: inherit; }
.mod-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(24, 223, 207, 0.15); }

/* Kapitel & Regeln */
.chapters { display: grid; gap: 12px; }
.chapter { border: 1px solid color-mix(in srgb, var(--c) 25%, transparent); border-radius: 16px; background: linear-gradient(180deg, color-mix(in srgb, var(--c) 7%, transparent), transparent 90px), var(--surface); }
.chapter[open] { border-color: color-mix(in srgb, var(--c) 45%, transparent); }
.chapter summary { display: flex; align-items: center; gap: 14px; padding: 14px 18px; list-style: none; cursor: pointer; }
.chapter summary::-webkit-details-marker { display: none; }
.chapter-no { min-width: 2ch; color: var(--c); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.1em; }
.chapter-title { flex: 1; font-weight: 600; }
.chapter-count { padding: 2px 10px; border-radius: 999px; background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); font-size: 0.76rem; font-weight: 600; }
.chapter .chev svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.25s; }
.chapter[open] .chev svg { transform: rotate(180deg); stroke: var(--c); }
.chapter-body { display: grid; gap: 8px; padding: 0 14px 14px; }

.rule-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(1, 16, 21, 0.5); }
.chapter .rule-row:hover { border-color: color-mix(in srgb, var(--c) 35%, transparent); }
.rule-no { flex: none; padding: 2px 10px; border-radius: 999px; background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c); font-size: 0.82rem; font-weight: 700; }
.rule-main { flex: 1; min-width: 0; }
.rule-main p { line-height: 1.55; color: #d6ecea; overflow-wrap: anywhere; }
.rule-main small { display: block; margin-top: 4px; color: var(--muted); font-size: 0.78rem; }
.rule-actions { display: flex; gap: 4px; flex: none; }

.icon-btn { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; transition: background 0.2s, color 0.2s, border-color 0.2s; }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { background: var(--surface-hover); color: var(--accent); }
.icon-btn.is-danger:hover { background: rgba(255, 107, 107, 0.14); color: #ff6b6b; }

/* Dialoge */
.dlg { width: min(720px, calc(100% - 24px)); max-height: 92vh; padding: 0; border: 1px solid var(--line-strong); border-radius: 22px; background: #03181e; color: var(--text); box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.9); overflow: hidden; }
.dlg.dlg-small { width: min(520px, calc(100% - 24px)); }
.dlg::backdrop { background: rgba(0, 8, 10, 0.72); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.dlg-form { display: flex; flex-direction: column; min-height: 0; max-height: 92vh; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.dlg-head h3 { font-size: 1.15rem; font-style: normal; }
.dlg-body { display: grid; gap: 16px; padding: 20px 22px; overflow-y: auto; }
.dlg-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); }
.dlg-error { flex: 1 1 100%; color: #ff8f8f; font-size: 0.88rem; }
.dlg-error:empty { display: none; }
.dlg-quote { padding: 12px 14px; border-left: 3px solid var(--line-strong); border-radius: 8px; background: rgba(1, 16, 21, 0.6); color: #cfe6e5; line-height: 1.6; overflow-wrap: anywhere; }

.grid2 { display: grid; grid-template-columns: 1fr 140px; gap: 14px; }

.fld { display: grid; gap: 6px; color: var(--muted); font-size: 0.84rem; font-weight: 500; }
.fld small { color: #6c8f8f; font-weight: 400; }
.fld input, .fld select, .fld textarea, .row-fld input, .row-fld select, .role-add select, .role-add input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(1, 16, 21, 0.75);
  color: var(--text);
  font: inherit;
  font-size: 0.94rem;
}
.fld textarea { resize: vertical; line-height: 1.55; }
.fld input:focus, .fld select:focus, .fld textarea:focus, .row-fld input:focus, .row-fld select:focus, .role-add select:focus, .role-add input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(24, 223, 207, 0.14); }
.fld input[readonly], .fld select:disabled { opacity: 0.6; }
select option { background: #03181e; color: var(--text); }

.fld-group { display: grid; gap: 10px; min-width: 0; margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: 14px; }
.fld-group legend { padding: 0 8px; color: var(--muted); font-size: 0.84rem; font-weight: 500; }
.fld-group legend small { color: #6c8f8f; }
.row-fld { display: grid; grid-template-columns: 120px 1fr 34px; gap: 8px; align-items: center; }
.row-fld[data-example] { grid-template-columns: 130px 1fr 34px; }
.btn-mini { justify-self: start; display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 1px dashed var(--line-strong); border-radius: 999px; background: transparent; color: var(--accent); font: inherit; font-size: 0.84rem; font-weight: 500; cursor: pointer; }
.btn-mini svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.btn-mini:hover { background: rgba(24, 223, 207, 0.1); }

.check-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; font-size: 0.92rem; }
.check-row input { flex: none; width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }
.check-row small { color: var(--muted); }

.btn-danger { background: rgba(255, 107, 107, 0.16); border-color: rgba(255, 107, 107, 0.5); color: #ff9c9c; }
.btn-danger:hover { background: rgba(255, 107, 107, 0.28); }
.btn:disabled { opacity: 0.6; cursor: wait; }

/* Account Management */
.info-card { margin-bottom: 18px; padding: 14px 18px; border: 1px solid var(--line-strong); border-left: 4px solid var(--accent); border-radius: 12px; background: rgba(24, 223, 207, 0.06); line-height: 1.6; }
.info-card p { margin-top: 4px; color: var(--muted); font-size: 0.92rem; }
.info-card code, .role-row code { padding: 1px 8px; border-radius: 6px; background: rgba(232, 247, 246, 0.08); color: #cfe6e5; font-size: 0.82rem; }

.role-add { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.role-add select, .role-add input { flex: 1 1 240px; width: auto; }
.role-add .btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

.role-list { display: grid; gap: 12px; }
.role-row { display: grid; gap: 14px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.role-row.is-new { border-color: rgba(24, 223, 207, 0.5); box-shadow: 0 0 0 3px rgba(24, 223, 207, 0.08); }
.role-row header { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.role-row header .icon-btn { margin-left: auto; }
.role-dot { width: 12px; height: 12px; border-radius: 50%; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.role-row footer { display: flex; justify-content: flex-end; }
.tag { padding: 2px 10px; border-radius: 999px; background: rgba(24, 223, 207, 0.14); color: var(--accent); font-size: 0.72rem; font-weight: 600; }

/* Platzhalter-Bereiche */
.soon-card { display: grid; justify-items: center; gap: 10px; padding: clamp(36px, 8vw, 72px) 20px; border: 1px dashed var(--line-strong); border-radius: 18px; text-align: center; }
.soon-card h3 { font-style: normal; }
.soon-card p { max-width: 46ch; color: var(--muted); }
.soon-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: linear-gradient(145deg, rgba(24, 223, 207, 0.22), rgba(24, 223, 207, 0.05)); border: 1px solid var(--line-strong); }
.soon-icon svg { width: 26px; height: 26px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Hinweis-Toast */
.admin-toast { position: fixed; left: 50%; bottom: 24px; z-index: 300; max-width: min(92vw, 520px); padding: 12px 22px; border: 1px solid var(--line-strong); border-radius: 999px; background: #06262c; color: var(--text); font-size: 0.92rem; font-weight: 500; box-shadow: 0 14px 34px -12px rgba(0, 0, 0, 0.8); opacity: 0; transform: translate(-50%, 16px); pointer-events: none; transition: opacity 0.25s, transform 0.25s; }
.admin-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.admin-toast.is-warn { border-color: rgba(255, 200, 87, 0.5); }
.admin-toast.is-error { border-color: rgba(255, 107, 107, 0.6); color: #ffb3b3; }

/* Responsive */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .app-side { position: static; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 14px; }
  .app-user { padding-bottom: 0; border-bottom: 0; }
  .app-tabs { grid-column: 1 / -1; grid-row: 2; display: flex; margin-inline: -4px; padding: 0 4px 4px; overflow-x: auto; scrollbar-width: none; }
  .app-tabs::-webkit-scrollbar { display: none; }
  .app-tab { flex: none; width: auto; padding: 9px 16px; border-color: var(--line); border-radius: 999px; white-space: nowrap; }
  .app-logout { padding: 9px 14px; }
}

@media (max-width: 560px) {
  .grid2 { grid-template-columns: 1fr; }
  .row-fld, .row-fld[data-example] { grid-template-columns: 1fr 34px; }
  .row-fld > :first-child { grid-column: 1 / -1; }
  .rule-row { flex-wrap: wrap; }
  .rule-actions { margin-left: auto; }
  .app-panel { padding: 16px; }
}
