/* NTSL Dashboard – Farbkonzept der Nightshade Legion */
:root {
    --ntsl-blue: #6482d2;
    --ntsl-steel: #646e78;
    --ntsl-copper: #bea06e;

    --bg: #070b14;
    --bg-glow: rgba(100, 130, 210, 0.16);
    --panel: #0e1525;
    --panel-raised: #141d31;
    --border: rgba(100, 110, 120, 0.38);
    --border-strong: rgba(100, 110, 120, 0.65);
    --text: #e7eaf0;
    --text-muted: #9aa4b0;
    --blue-soft: rgba(100, 130, 210, 0.16);
    --copper-soft: rgba(190, 160, 110, 0.15);
    --success: #5fb98a;
    --success-soft: rgba(95, 185, 138, 0.15);
    --warning: #d9b25c;
    --danger: #d86a6a;
    --danger-soft: rgba(216, 106, 106, 0.15);
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
    background:
        radial-gradient(1200px 600px at 15% -10%, var(--bg-glow), transparent 60%),
        radial-gradient(900px 500px at 110% 10%, rgba(190, 160, 110, 0.07), transparent 60%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--ntsl-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: 0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; }

:focus-visible { outline: 2px solid var(--ntsl-blue); outline-offset: 2px; }

/* ---------- Start / Login ---------- */
.boot, .login {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 24px 16px;
    text-align: center;
}
.boot { color: var(--text-muted); }
.boot-logo { width: 96px; height: 96px; opacity: 0.85; animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { .boot-logo { animation: none; } }

.login-logo {
    width: min(260px, 60vw);
    height: auto;
    filter: drop-shadow(0 0 40px rgba(100, 130, 210, 0.35));
}
.eyebrow {
    color: var(--ntsl-copper);
    text-transform: uppercase;
    letter-spacing: 0.32em;
    font-size: 0.78rem;
    font-weight: 600;
}
.login h1 { font-size: 2rem; }
.login p { color: var(--text-muted); max-width: 420px; margin: 0; }
.login .alert { max-width: 420px; }
.noscript { text-align: center; padding: 40px; }

/* ---------- Layout ---------- */
.shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 20px;
    background: rgba(7, 11, 20, 0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { width: 40px; height: 40px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text .eyebrow { font-size: 0.66rem; letter-spacing: 0.28em; }
.brand-text strong { font-size: 1rem; }
.topbar .spacer { flex: 1; }

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 4px 4px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--panel);
}
.user-chip img { width: 30px; height: 30px; border-radius: 50%; }
.user-chip .name { font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.body { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 0; }

.sidebar {
    border-right: 1px solid var(--border);
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.sidebar .section-label {
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    padding: 14px 12px 6px;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text);
    border-left: 3px solid transparent;
}
.nav-link:hover { background: var(--panel-raised); text-decoration: none; }
.nav-link.active {
    background: var(--blue-soft);
    border-left-color: var(--ntsl-copper);
    color: #fff;
}
.nav-link .icon { width: 20px; text-align: center; }

.main { padding: 28px 32px 48px; min-width: 0; }
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}
.page-head p { margin: 4px 0 0; color: var(--text-muted); }
.page-head h1::after {
    content: "";
    display: block;
    width: 44px;
    height: 3px;
    margin-top: 8px;
    border-radius: 2px;
    background: var(--ntsl-copper);
}

/* ---------- Karten & Raster ---------- */
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); }

.card {
    background: linear-gradient(180deg, var(--panel-raised), var(--panel));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    min-width: 0;
}
.card > h2 { margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { padding: 18px 20px 0; }

.stat .label { color: var(--text-muted); font-size: 0.82rem; }
.stat .value { font-size: 1.9rem; font-weight: 700; line-height: 1.2; margin-top: 4px; }
.stat .value.copper { color: var(--ntsl-copper); }
.stat .value.blue { color: var(--ntsl-blue); }
.stat .sub { color: var(--text-muted); font-size: 0.82rem; }

.empty { color: var(--text-muted); padding: 6px 0; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; }
tbody tr:hover { background: rgba(100, 130, 210, 0.05); }
tbody tr:last-child td { border-bottom: none; }
td.nowrap { white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person img { width: 26px; height: 26px; border-radius: 50%; flex: none; }
.person span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
}
.list li:last-child { border-bottom: none; }
.list .meta { color: var(--text-muted); font-size: 0.84rem; }
.list li > :last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    justify-content: flex-end;
    flex: none;
}
.list li > :first-child { min-width: 0; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 600;
    white-space: nowrap;
    background: var(--panel-raised);
    border: 1px solid var(--border);
    color: var(--text-muted);
}
.badge.blue { background: var(--blue-soft); border-color: rgba(100, 130, 210, 0.45); color: #b8c8f2; }
.badge.copper { background: var(--copper-soft); border-color: rgba(190, 160, 110, 0.5); color: var(--ntsl-copper); }
.badge.success { background: var(--success-soft); border-color: rgba(95, 185, 138, 0.45); color: var(--success); }
.badge.danger { background: var(--danger-soft); border-color: rgba(216, 106, 106, 0.45); color: var(--danger); }
.amount-pos { color: var(--success); font-weight: 600; }
.amount-neg { color: var(--danger); font-weight: 600; }

/* ---------- Events ---------- */
.event-card { display: flex; flex-direction: column; gap: 10px; }
.event-date {
    display: inline-flex;
    gap: 8px;
    align-items: baseline;
    color: var(--ntsl-copper);
    font-weight: 600;
    font-size: 0.86rem;
}
.event-card p { margin: 0; color: var(--text-muted); white-space: pre-line; overflow-wrap: anywhere; }
.event-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.event-card .actions { margin-top: auto; }

/* ---------- Formulare ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--panel-raised);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { border-color: var(--ntsl-blue); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--ntsl-blue); border-color: var(--ntsl-blue); color: #0b1020; }
.btn.primary:hover { background: #7591da; }
.btn.copper { background: transparent; border-color: var(--ntsl-copper); color: var(--ntsl-copper); }
.btn.copper:hover { background: var(--copper-soft); }
.btn.discord { background: #5865f2; border-color: #5865f2; color: #fff; padding: 12px 22px; font-size: 1rem; }
.btn.discord:hover { background: #6b77f4; }
.btn.small { padding: 5px 11px; font-size: 0.84rem; }
.btn.ghost { background: transparent; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .field .label { font-size: 0.84rem; color: var(--text-muted); font-weight: 600; }
.field .hint { font-size: 0.8rem; color: var(--text-muted); }
input[type="text"], input[type="number"], input[type="search"], select, textarea {
    width: 100%;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: #0a101d;
    color: var(--text);
    font: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--ntsl-blue); outline: none; box-shadow: 0 0 0 3px var(--blue-soft); }
textarea { min-height: 90px; resize: vertical; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--ntsl-blue); }

.picker {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: #0a101d;
    padding: 6px;
}
.picker label {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 5px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 400;
    color: var(--text);
}
.picker label:hover { background: var(--panel-raised); }
.picker input { accent-color: var(--ntsl-blue); }
.role-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ntsl-steel); flex: none; }

.config-section + .config-section { margin-top: 16px; }

.search-results { list-style: none; margin: 6px 0 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.search-results:empty { display: none; }
.search-results button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--panel);
    border: 0;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font: inherit;
    cursor: pointer;
    text-align: left;
}
.search-results li:last-child button { border-bottom: 0; }
.search-results button:hover { background: var(--panel-raised); }
.search-results img { width: 24px; height: 24px; border-radius: 50%; }
.selected-member { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--ntsl-blue); border-radius: var(--radius-sm); background: var(--blue-soft); }
.selected-member img { width: 26px; height: 26px; border-radius: 50%; }
.selected-member .spacer { flex: 1; }

/* ---------- Dialog ---------- */
dialog {
    width: min(560px, calc(100vw - 32px));
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--panel);
    color: var(--text);
    padding: 22px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
dialog::backdrop { background: rgba(3, 6, 12, 0.7); backdrop-filter: blur(3px); }
dialog h2 { margin-bottom: 16px; }

/* ---------- Hinweise ---------- */
.alert {
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--panel);
    margin-bottom: 16px;
}
.alert.error { border-color: rgba(216, 106, 106, 0.55); background: var(--danger-soft); }
.alert.success { border-color: rgba(95, 185, 138, 0.55); background: var(--success-soft); }

.toast-area {
    position: fixed;
    right: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
}
.toast {
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    background: var(--panel-raised);
    border: 1px solid var(--border-strong);
    border-left: 4px solid var(--ntsl-blue);
    box-shadow: var(--shadow);
    max-width: 360px;
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }

.loading { color: var(--text-muted); padding: 30px 0; }

/* ---------- Mobil ---------- */
/* Untere Navigationsleiste und „Mehr“-Menü – nur auf dem Handy sichtbar */
.bottom-nav { display: none; }

.sheet {
    margin: auto auto 0;
    width: 100%;
    max-width: 520px;
    border-radius: 18px 18px 0 0;
    border-bottom: 0;
    padding: 8px 12px calc(16px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sheet:not([open]) { display: none; }
.sheet-handle {
    width: 42px;
    height: 5px;
    border-radius: 3px;
    background: var(--border-strong);
    margin: 4px auto 10px;
}
.sheet-label {
    color: var(--text-muted);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: 12px 12px 4px;
}
.sheet-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 50px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 1rem;
    text-align: left;
    cursor: pointer;
}
.sheet-item:hover, .sheet-item:active { background: var(--panel-raised); text-decoration: none; }
.sheet-item.active { background: var(--blue-soft); }
.sheet-item.danger { color: var(--danger); }
.sheet-item .check { margin-left: auto; color: var(--ntsl-copper); }

@media (max-width: 860px) {
    body { font-size: 16px; }

    .shell { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
    .body { grid-template-columns: minmax(0, 1fr); }
    .sidebar { display: none; }

    /* Kopfzeile: kompakt, mit Rand für Notch/Statusleiste */
    .topbar {
        padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
        gap: 10px;
    }
    .brand-text .eyebrow { display: none; }
    .topbar select { max-width: 45vw; }
    .user-chip { padding: 3px; }
    .user-chip .name, .user-chip .badge { display: none; }
    .topbar .logout { display: none; }

    .bottom-nav {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 20;
        padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
        background: rgba(10, 15, 27, 0.94);
        backdrop-filter: blur(12px);
        border-top: 1px solid var(--border);
    }
    .tab {
        flex: 1 1 0;
        min-width: 0;
        min-height: 52px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        border: 0;
        border-radius: var(--radius-sm);
        background: transparent;
        color: var(--text-muted);
        font: inherit;
        font-size: 0.7rem;
        font-weight: 600;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .tab:hover { text-decoration: none; }
    .tab-icon { font-size: 1.2rem; line-height: 1; }
    .tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .tab.active { color: var(--ntsl-copper); background: var(--copper-soft); }

    .main { padding: 18px 14px 28px; }
    .page-head { margin-bottom: 16px; }
    .page-head h1 { font-size: 1.3rem; }
    .page-head > div:last-child:not(:first-child) { width: 100%; }

    .card { padding: 16px; border-radius: 12px; }
    .card.flush > h2 { padding: 16px 16px 0; }
    .grid { gap: 12px; }
    .grid.two { grid-template-columns: 1fr; }
    .grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .stat .value { font-size: 1.5rem; }
    .list li { flex-wrap: wrap; }

    /* Größere Tippflächen; 16px verhindert das automatische Zoomen auf iOS */
    .btn { min-height: 44px; padding: 10px 16px; }
    .btn.small { min-height: 38px; padding: 7px 12px; font-size: 0.9rem; }
    input[type="text"], input[type="number"], input[type="search"], select, textarea {
        font-size: 16px;
        min-height: 46px;
    }
    .form-actions .btn { flex: 1 1 auto; }
    .picker label { min-height: 40px; }

    /* Tabellen als Kartenliste */
    .table-wrap { overflow: visible; }
    table.responsive thead { display: none; }
    table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
    table.responsive tr {
        padding: 12px 16px;
        border-bottom: 1px solid var(--border);
    }
    table.responsive tbody tr:last-child { border-bottom: none; }
    table.responsive td {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        align-items: center;
        gap: 12px;
        padding: 4px 0;
        border: 0;
        text-align: right;
    }
    table.responsive td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 0.78rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        text-align: left;
        flex: none;
        margin-right: auto;
    }
    table.responsive td[data-label=""]::before,
    table.responsive td[colspan]::before { content: none; }
    table.responsive td[data-label=""] { justify-content: flex-end; padding-top: 8px; }
    table.responsive td[colspan] { justify-content: flex-start; text-align: left; }
    /* Erste Spalte wird zum Kartentitel */
    table.responsive td:first-child {
        display: block;
        text-align: left;
        font-size: 1.02rem;
        font-weight: 650;
        color: var(--text);
        padding-bottom: 8px;
    }
    table.responsive td:first-child::before { content: none; }
    table.responsive td:first-child .meta { font-weight: 400; }
    table.responsive td:first-child > div { text-align: left; }
    table.responsive td .person { justify-content: flex-end; }
    table.responsive td > div { text-align: right; }

    /* Dialoge gleiten von unten herein */
    dialog:not(.sheet) {
        margin: auto auto 0;
        width: 100%;
        max-width: 100%;
        max-height: 92vh;
        overflow-y: auto;
        border-radius: 18px 18px 0 0;
        padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    }
    .toast-area { left: 14px; right: 14px; bottom: calc(80px + env(safe-area-inset-bottom)); }
    .toast { max-width: none; }
}

@media (min-width: 861px) {
    .sheet { margin: auto; border-radius: var(--radius); border-bottom: 1px solid var(--border-strong); }
}

.meta { color: var(--text-muted); font-size: 0.84rem; }
.card-body { padding: 0 20px 18px; }
.hint { font-size: 0.8rem; color: var(--text-muted); margin: 10px 0 0; }
