/* =================================================================
   Leitstelle – Design
   Dunkles Leitstellen-Pult, Signalrot als Akzent.
   Farben zentral hier anpassen.
   ================================================================= */
:root {
    --bg: #0f1318;
    --panel: #171d24;
    --panel-2: #1f2730;
    --panel-3: #27313c;
    --line: #2c3743;
    --text: #e6eaf0;
    --muted: #8b97a6;
    --accent: #e8453c;
    --accent-2: #ff6a5f;
    --ok: #3cb371;
    --pend: #e0a83a;
    --warn: #ef6b5b;
    --fw: #d7332b;
    --rd: #f2f2f2;
    --pol: #1f6fd1;
    --radius: 8px;
    --gap: 10px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

button {
    font: inherit;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }

.hidden { display: none !important; }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.pend { color: var(--pend); }
.empty { color: var(--muted); list-style: none; margin: 0; padding: 12px 4px; }

.link-btn { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; font-size: 12px; }
.link-btn:hover { color: var(--text); }
.small-btn { padding: 3px 9px; font-size: 12px; }
.icon-btn { padding: 2px 7px; font-size: 16px; line-height: 1.4; position: relative; }
.icon-btn.locked::after {
    content: '';
    position: absolute;
    top: -3px;
    right: -3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--pend);
}

/* =================================================================
   Grundgerüst
   ================================================================= */
#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- Kopfleiste ---------- */
#topbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 16px;
    height: 52px;
    padding: 0 16px;
    background: linear-gradient(180deg, #1c232b, #151b21);
    border-bottom: 2px solid var(--accent);
    box-shadow: 0 2px 12px rgba(0,0,0,.35);
    z-index: 1100;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.brand-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
    animation: beacon 2.4s infinite;
}
@keyframes beacon { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

.tb-stats { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.tb-stats::-webkit-scrollbar { display: none; }
.tb-sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    font-size: 12px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip.c-warn { color: var(--warn); }
.chip.c-pend { color: var(--pend); }
.chip.c-warn b, .chip.c-pend b { color: var(--text); }
.chip .fms { width: 16px; height: 16px; font-size: 10px; }

.tb-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.credits {
    font-weight: 700;
    color: var(--pend);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.credits::after { content: ' Cr'; font-weight: 400; color: var(--muted); font-size: 12px; }
.tb-sound { position: relative; }
.tb-user { position: relative; }

/* ---------- Raster ---------- */
#grid {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: minmax(0, 60fr) minmax(0, 40fr);
    grid-template-areas:
        "map      map  missions"
        "stations funk fleet";
    gap: var(--gap);
    padding: var(--gap);
}
#map-wrap       { grid-area: map; }
#mission-panel  { grid-area: missions; }
#station-panel  { grid-area: stations; }
#funk-panel     { grid-area: funk; }
#fleet-panel    { grid-area: fleet; }

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 12px;
    background: var(--panel-2);
    border-bottom: 1px solid var(--line);
}
.card-head h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .07em; }
.count { color: var(--muted); font-weight: 400; }
.card-tools { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.card-body { flex: 1; min-height: 0; overflow-y: auto; margin: 0; padding: 6px 8px; list-style: none; }

.tabs { display: flex; flex-wrap: wrap; gap: 3px; }
.tabs button { padding: 2px 9px; font-size: 12px; background: transparent; border-color: var(--line); color: var(--muted); }
.tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.search {
    flex: 1;
    min-width: 120px;
    font: inherit;
    font-size: 12px;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 4px 8px;
}
.search:focus { outline: 1px solid var(--accent); }

/* ---------- Karte ---------- */
#map-wrap { padding: 0; }
#map { flex: 1; min-height: 0; background: #1a1f25; }
#map.building { cursor: crosshair; }
.map-hint {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 900;
    padding: 8px 12px;
    background: var(--panel-2);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    box-shadow: 0 6px 20px rgba(0,0,0,.45);
    white-space: nowrap;
}
.map-hint button { margin-left: 8px; padding: 2px 8px; }

/* =================================================================
   Einsätze
   ================================================================= */
#missions { display: flex; flex-direction: column; gap: 5px; }
.mi {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    border-radius: 6px;
    background: var(--panel-2);
    border-left: 4px solid var(--warn);
    cursor: pointer;
}
.mi:hover { background: var(--panel-3); }
.mi.m-arbeit { border-left-color: var(--pend); }
.mi.m-erledigt { border-left-color: var(--ok); opacity: .65; }
.mi.active { outline: 1px solid var(--accent); }
.mi .mi-text { min-width: 0; }
.mi b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mi small { color: var(--muted); }
.mi .mi-cr { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mi .mi-orgs { display: flex; gap: 2px; }
.org-dot { width: 8px; height: 22px; border-radius: 2px; }
.org-fw { background: var(--fw); }
.org-rd { background: var(--rd); }
.org-pol { background: var(--pol); }

/* =================================================================
   Wachen
   ================================================================= */
.build-wrap { position: relative; }
.dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 950;
    display: grid;
    gap: 5px;
    width: 230px;
    padding: 8px;
    background: var(--panel-3);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.dropdown button { display: flex; align-items: center; gap: 8px; text-align: left; }
.dropdown small { margin-left: auto; color: var(--muted); }

/* Panel muss das Dropdown zeigen dürfen */
#station-panel { overflow: visible; }
#station-panel > .card-head { border-radius: var(--radius) var(--radius) 0 0; }
#station-panel > .card-body { border-radius: 0 0 var(--radius) var(--radius); }

.st-row { border-bottom: 1px solid var(--line); padding: 7px 2px; }
.st-row:last-child { border-bottom: 0; }
.st-head { display: flex; align-items: center; gap: 8px; }
.st-name { flex: 1; min-width: 0; font-weight: 600; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-name:hover { color: var(--accent-2); }
.st-head button { padding: 1px 8px; font-size: 11px; }
.vchips { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 0 26px; }
.vchip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 6px 1px 2px;
    border-radius: 4px;
    background: var(--panel-3);
    font-size: 12px;
    white-space: nowrap;
}
.vchip .fms { width: 16px; height: 16px; font-size: 10px; }
.buy { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0 2px 26px; padding-top: 8px; border-top: 1px dashed var(--line); }
.buy button { padding: 3px 8px; font-size: 12px; }
.buy small { color: var(--muted); }

/* =================================================================
   Funk
   ================================================================= */
#funk { font: 12px/1.45 ui-monospace, "Cascadia Mono", Consolas, monospace; }
#funk li { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; padding: 3px 2px; border-bottom: 1px solid rgba(255,255,255,.03); }
#funk time { color: var(--muted); }
#funk .fk-text { color: var(--text); }
#funk .fk-new .fk-text { color: var(--warn); font-weight: 600; }
#funk .fk-done .fk-text { color: var(--ok); }
#funk .fms { width: 16px; height: 16px; font-size: 10px; }
#funk .fk-icon { width: 16px; text-align: center; }
#funk li.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: rgba(232,69,60,.25); } to { background: transparent; } }

/* =================================================================
   Fahrzeuge
   ================================================================= */
#fleet li {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 5px 4px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
}
#fleet li:hover { background: var(--panel-2); }
#fleet .fl-name { font-weight: 600; }
#fleet small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#fleet .fl-eta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* =================================================================
   FMS-Status
   ================================================================= */
.fms {
    display: inline-grid;
    place-items: center;
    width: 18px;
    height: 18px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 700;
    color: #111;
    flex-shrink: 0;
}
.fms-1 { background: #9ad18b; }
.fms-2 { background: #3cb371; }
.fms-3 { background: #f0c419; }
.fms-4 { background: #f08a24; }

/* =================================================================
   Karten-Marker
   ================================================================= */
.station {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 5px;
    border: 2px solid #fff;
    font-weight: 800;
    font-size: 13px;
    color: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.5);
    flex-shrink: 0;
}
.station.small { width: 18px; height: 18px; font-size: 10px; border-width: 1px; box-shadow: none; }
.st-feuerwache { background: var(--fw); }
.st-rettungswache { background: #f5f5f5; color: var(--fw); }
.st-polizeiwache { background: var(--pol); }

.mission {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #fff;
    color: #fff;
    font-weight: 900;
    box-shadow: 0 1px 6px rgba(0,0,0,.5);
    cursor: pointer;
}
.mission.m-offen { background: var(--warn); animation: pulse 1.4s infinite; }
.mission.m-arbeit { background: var(--pend); }
.mission.m-erledigt { background: var(--ok); }
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(239,107,91,.7); }
    70% { box-shadow: 0 0 0 12px rgba(239,107,91,0); }
    100% { box-shadow: 0 0 0 0 rgba(239,107,91,0); }
}

.veh {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 60px;
    height: 18px;
    padding: 0 2px 0 5px;
    white-space: nowrap;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    border: 1px solid rgba(0,0,0,.4);
    box-shadow: 0 1px 3px rgba(0,0,0,.5);
}
.veh-fw { background: var(--fw); color: #fff; }
.veh-rd { background: var(--rd); color: var(--fw); }
.veh-pol { background: var(--pol); color: #fff; }
.vfms { background: rgba(0,0,0,.35); color: #fff; border-radius: 3px; padding: 0 3px; }

/* =================================================================
   Alarmierungsfenster (über der Karte)
   ================================================================= */
.panel {
    position: absolute;
    top: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 1000;
    width: 340px;
    max-width: calc(100% - 20px);
    overflow-y: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-top: 3px solid var(--accent);
    border-radius: var(--radius);
    box-shadow: 0 8px 30px rgba(0,0,0,.55);
    padding: 12px 14px;
    height: fit-content;
    max-height: calc(100% - 20px);
}
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.panel-head h3 { margin: 0; font-size: 16px; }
#d-close { padding: 0 8px; font-size: 18px; }
.d-status { color: var(--muted); margin: 6px 0; }
.reqs { display: flex; flex-wrap: wrap; gap: 4px; }
.req { padding: 2px 6px; border-radius: 4px; background: var(--panel-2); font-size: 12px; font-weight: 600; }
.panel-actions { display: flex; gap: 6px; margin: 10px 0; }
.panel-actions button { flex: 1; }
.panel h4 { margin: 10px 0 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.dl { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.dl li { display: flex; align-items: center; gap: 6px; }
.dl label { display: flex; align-items: center; gap: 6px; cursor: pointer; width: 100%; }
.dl small { margin-left: auto; color: var(--muted); }
.dl .underway { font-style: normal; font-size: 11px; color: #9ad18b; }

/* =================================================================
   Töne
   ================================================================= */
#snd-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 1200;
    width: 290px;
    padding: 10px 12px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.snd-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 0; }
.snd-row label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.snd-row button { padding: 0 8px; font-size: 11px; }
.snd-main { font-weight: 600; border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 4px; cursor: pointer; }
.snd-vol { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; color: var(--muted); }
.snd-vol input { flex: 1; }
.snd-hint { margin: 8px 0 0; font-size: 11px; color: var(--muted); }
.snd-hint code { color: var(--text); }

/* =================================================================
   Toast
   ================================================================= */
#toast {
    position: fixed;
    left: 50%;
    bottom: 20px;
    z-index: 2000;
    transform: translate(-50%, 20px);
    opacity: 0;
    pointer-events: none;
    padding: 10px 16px;
    border-radius: 8px;
    background: var(--panel-3);
    border: 1px solid var(--line);
    transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { border-color: var(--warn); color: var(--warn); }

/* =================================================================
   Login / Registrierung
   ================================================================= */
.auth-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 16px;
    background: radial-gradient(circle at 30% 20%, #2a1416 0%, var(--bg) 60%);
}
.auth-box {
    width: 100%;
    max-width: 380px;
    padding: 28px 24px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-top: 3px solid var(--accent);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.auth-box h1 { margin: 0; font-size: 26px; }
.auth-box h1::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 10px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
    vertical-align: middle;
}
.auth-sub { margin: 6px 0 20px; color: var(--muted); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.auth-tabs button { background: none; border: 0; border-radius: 0; padding: 8px; color: var(--muted); border-bottom: 2px solid transparent; }
.auth-tabs button.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
#auth-form { display: grid; gap: 12px; }
#auth-form label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
#auth-form input {
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 9px 10px;
}
#auth-form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
#auth-form .primary { padding: 10px; margin-top: 4px; }
.auth-help { margin: 0; font-size: 12px; color: var(--muted); }
.auth-error { margin: 0; min-height: 1.2em; color: var(--warn); font-size: 13px; }

/* =================================================================
   Kleinere Bildschirme
   ================================================================= */
@media (max-width: 1200px) {
    #grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-rows: minmax(360px, 55vh) repeat(2, minmax(300px, 38vh));
        grid-template-areas:
            "map      map"
            "missions stations"
            "funk     fleet";
    }
    #app { height: auto; min-height: 100vh; }
}

@media (max-width: 760px) {
    #topbar { height: auto; flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
    .tb-stats { order: 3; width: 100%; }
    .user-btn #username { display: none; }
    .user-menu { right: -4px; }
    #grid {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: 55vh repeat(4, minmax(260px, auto));
        grid-template-areas: "map" "missions" "stations" "funk" "fleet";
        padding: 6px;
        gap: 6px;
    }
    .card-body { max-height: 50vh; }
    .panel { position: fixed; top: auto; bottom: 8px; left: 8px; right: 8px; width: auto; max-width: none; max-height: 60vh; }
    #snd-panel { right: -60px; }
}

/* =================================================================
   Wache verwalten: kaufen / verkaufen
   ================================================================= */
.manage { margin: 8px 0 2px 26px; padding-top: 8px; border-top: 1px dashed var(--line); }
.manage h5 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.manage h5 small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.manage .buy { margin: 0 0 10px; padding: 0; border: 0; }
.sell-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.sell-list li { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.sell-list li span:not(.fms) { flex: 1; }
.sell-btn { padding: 1px 8px; font-size: 11px; color: var(--warn); border-color: rgba(239,107,91,.4); background: transparent; }
.sell-btn:hover:not(:disabled) { background: rgba(239,107,91,.12); border-color: var(--warn); }
.sell-btn small { color: var(--muted); }

/* =================================================================
   Benutzermenü
   ================================================================= */
.ico { width: 20px; height: 20px; flex-shrink: 0; }
.user-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 4px 10px 4px 6px;
    background: var(--panel-2);
    font-weight: 600;
    font-size: 13px;
}
.user-btn[aria-expanded="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.ub-icon { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: rgba(255,255,255,.08); }
.ub-icon .ico { width: 17px; height: 17px; }
.caret { font-size: 10px; opacity: .7; }

.user-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 1300;
    width: 290px;
    padding: 6px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-top: 3px solid var(--accent);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(0,0,0,.55);
}
.user-menu button {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 9px 10px;
    background: none;
    border: 0;
    border-radius: 6px;
    text-align: left;
}
.user-menu button:hover, .user-menu button:focus-visible { background: var(--accent); color: #fff; outline: none; }
.user-menu button span { flex: 1; }
.user-menu em { font-style: normal; font-size: 11px; color: var(--muted); }
.user-menu button:hover em { color: rgba(255,255,255,.85); }
.user-menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }
.um-head { display: flex; align-items: center; gap: 12px; padding: 8px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.um-head .ico { width: 30px; height: 30px; color: var(--accent-2); }
.um-head b { display: block; font-size: 15px; }
.um-head small { color: var(--pend); font-size: 12px; }

/* =================================================================
   Fenster (Modal)
   ================================================================= */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1500;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(5,8,11,.65);
    backdrop-filter: blur(2px);
}
.modal-box {
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border: 1px solid var(--line);
    border-top: 3px solid var(--accent);
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 17px; }
#modal-close { padding: 0 9px; font-size: 18px; }
#modal-body { padding: 16px; overflow-y: auto; }
#modal-body h4 { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 11px; }

/* Dienstgrad */
.rk-badge { display: flex; align-items: center; gap: 14px; }
.rk-badge .ico { width: 46px; height: 46px; color: var(--pend); }
.rk-badge small { display: block; color: var(--muted); }
.rk-badge b { font-size: 19px; }
.rk-bar { height: 10px; margin: 14px 0 6px; border-radius: 99px; background: var(--panel-3); overflow: hidden; }
.rk-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--pend)); border-radius: inherit; }
.rk-next { font-size: 13px; }
.rk-next span { color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-top: 16px; }
.stats div { padding: 10px; border-radius: 6px; background: var(--panel-2); }
.stats b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.stats small { color: var(--muted); font-size: 12px; }
.rk-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: 13px; }
.rk-list li { display: flex; justify-content: space-between; padding: 5px 8px; border-radius: 4px; color: var(--muted); }
.rk-list li.done { color: var(--text); }
.rk-list li.done::before { content: '✓'; color: var(--ok); margin-right: 8px; }
.rk-list li.current { background: rgba(232,69,60,.15); color: var(--text); font-weight: 600; outline: 1px solid var(--accent); }
.rk-list li span { flex: 1; }

/* Formulare */
.form { display: grid; gap: 10px; }
.form h4 { margin: 4px 0 0 !important; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.form input, #notes-text {
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
}
.form input:focus, #notes-text:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.form-msg { margin: 0; min-height: 1.2em; font-size: 13px; color: var(--warn); }
.form-msg.ok { color: var(--ok); }

/* Notizen */
#notes-text { width: 100%; min-height: 320px; resize: vertical; line-height: 1.5; }
.notes-foot { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.notes-foot small { flex: 1; color: var(--muted); }

/* Geschwindigkeit */
.speed-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 12px; }
.speed-opt { display: grid; gap: 2px; text-align: left; padding: 12px; background: var(--panel-2); }
.speed-opt.active { border-color: var(--accent); background: rgba(232,69,60,.13); }
.speed-opt b { font-size: 15px; }
.speed-opt small { color: var(--muted); font-size: 12px; }
.sp-gauge { color: var(--accent-2); letter-spacing: 2px; font-size: 13px; }
@media (max-width: 480px) { .speed-grid { grid-template-columns: 1fr; } }

/* =================================================================
   Verband & Freunde
   ================================================================= */
.tb-ally { position: relative; }
.ally-btn { display: flex; align-items: center; gap: 6px; padding: 4px 8px; position: relative; }
.ally-btn[aria-expanded="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.ally-btn .ico { width: 19px; height: 19px; }
.ally-tag { font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--pend); }
.ally-btn[aria-expanded="true"] .ally-tag { color: #fff; }
.badge {
    display: inline-grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 99px;
    background: var(--ok);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}
.ally-btn > .badge { position: absolute; top: -7px; right: -7px; border: 2px solid #171d24; }
.user-menu button .badge { margin-left: auto; }

.atag {
    display: inline-block;
    padding: 0 5px;
    border-radius: 4px;
    background: rgba(224,168,58,.15);
    color: var(--pend);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    vertical-align: middle;
}
.online-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: #4a5563; vertical-align: middle; }
.online-dot.on { background: var(--ok); box-shadow: 0 0 6px rgba(60,179,113,.7); }

/* Fenster */
.modal-box.wide { max-width: 820px; }
.ally-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.ally-head .ico { width: 42px; height: 42px; color: var(--accent-2); flex-shrink: 0; }
.ally-head h2 { margin: 0; font-size: 19px; }
.ally-head > div:nth-child(2) { flex: 1; min-width: 0; }
.ally-desc { margin: 10px 0 0; padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--panel-2); border-radius: 0 6px 6px 0; white-space: pre-wrap; }

.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl.clickable tbody tr { cursor: pointer; }
.tbl.clickable tbody tr:hover { background: var(--panel-2); }
.tbl tr.mine { background: rgba(232,69,60,.10); }
.tbl .actions { text-align: right; white-space: nowrap; }
.tbl select { font: inherit; font-size: 12px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 2px 4px; }

.role { display: inline-block; padding: 1px 7px; border-radius: 99px; font-size: 11px; font-weight: 600; background: var(--panel-3); }
.role-leader { background: rgba(232,69,60,.2); color: var(--accent-2); }
.role-admin { background: rgba(224,168,58,.18); color: var(--pend); }
.mode { font-size: 11px; padding: 1px 7px; border-radius: 99px; white-space: nowrap; }
.mode-open { background: rgba(60,179,113,.15); color: var(--ok); }
.mode-apply { background: var(--panel-3); color: var(--muted); }

.danger-btn { padding: 2px 9px; font-size: 12px; color: var(--warn); background: transparent; border-color: rgba(239,107,91,.4); }
.danger-btn:hover:not(:disabled) { background: rgba(239,107,91,.12); border-color: var(--warn); }
.danger-zone { display: flex; gap: 8px; margin-top: 20px; padding-top: 14px; border-top: 1px dashed var(--line); }

.app-list, .fr-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.app-list li { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 9px 10px; border-radius: 6px; background: var(--panel-2); }
.app-msg { margin: 5px 0 0; color: var(--muted); font-style: italic; overflow-wrap: anywhere; }
.app-list .actions, .fr-list .actions { display: flex; gap: 5px; flex-shrink: 0; }

.finder-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.finder-bar select { font: inherit; font-size: 12px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }
.chk { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); cursor: pointer; }
.ally-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.ally-card { display: flex; flex-direction: column; gap: 6px; padding: 11px 12px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); }
.ally-card p { margin: 0; font-size: 12px; flex: 1; overflow-wrap: anywhere; }
.ac-head, .ac-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ac-foot { flex-wrap: wrap; }
.ac-foot > span { display: flex; align-items: center; gap: 8px; }

.add-friend { display: flex; gap: 8px; margin-bottom: 6px; }
.fr-list li { display: flex; align-items: center; gap: 4px; padding: 7px 9px; border-radius: 6px; background: var(--panel-2); }
.fr-name { flex: 1; min-width: 0; }
.fr-name small { display: block; }

.radio-row { display: flex; flex-wrap: wrap; gap: 14px; border: 0; margin: 0; padding: 0; }
.radio-row legend { font-size: 13px; color: var(--muted); padding: 0; margin-bottom: 4px; }
.radio-row label { display: flex !important; align-items: center; gap: 6px; color: var(--text) !important; cursor: pointer; }
.form textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; resize: vertical; }
.form textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.upper { text-transform: uppercase; }

/* Panel-Tabs (Funk / Verbandschat) */
.panel-tabs { display: flex; gap: 2px; }
.panel-tabs button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    background: none;
    border: 0;
    border-radius: 0;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
}
.panel-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.panel-tabs .badge { min-width: 10px; height: 10px; padding: 0; font-size: 0; background: var(--accent); }

/* Verbandschat */
.chat-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#chat { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; }
#chat .empty { margin: auto 0; text-align: center; }
.chat-day { align-self: center; font-size: 11px; color: var(--muted); padding: 1px 10px; border-radius: 99px; background: var(--panel-2); margin: 4px 0; }
.chat-sys { align-self: center; max-width: 90%; text-align: center; font-size: 12px; color: var(--muted); font-style: italic; }
.chat-sys time { font-style: normal; margin-right: 4px; }
.chat-msg { align-self: flex-start; max-width: 85%; padding: 6px 10px; border-radius: 10px 10px 10px 3px; background: var(--panel-2); }
.chat-msg.mine { align-self: flex-end; border-radius: 10px 10px 3px 10px; background: rgba(232,69,60,.18); }
.chat-msg div { font-size: 11px; color: var(--muted); }
.chat-msg b { color: var(--pend); }
.chat-msg.mine b { color: var(--accent-2); }
.chat-msg p { margin: 2px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.chat-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; min-width: 0; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
.chat-form input:focus { outline: 1px solid var(--accent); }

@media (max-width: 760px) {
    .ally-tag { display: none; }
    .tbl th:nth-child(4), .tbl td:nth-child(4) { display: none; }
    .app-list li { flex-direction: column; }
    #ally-menu { right: -50px; }
}

.manage h6 { margin: 8px 0 4px; font-size: 11px; font-weight: 600; color: var(--pend); }
.manage h6:first-of-type { margin-top: 0; }
.manage .buy + h6 { margin-top: 10px; }

/* Rückalarmierung */
.recall-btn {
    padding: 1px 7px;
    font-size: 11px;
    color: var(--pend);
    background: transparent;
    border-color: rgba(224,168,58,.45);
    white-space: nowrap;
    flex-shrink: 0;
}
.recall-btn:hover:not(:disabled) { background: rgba(224,168,58,.12); border-color: var(--pend); }
.dl li small + .recall-btn { margin-left: 6px; }
.dl li small { margin-left: auto; }
.fl-right { display: flex; align-items: center; gap: 6px; }

/* Wache umbenennen */
.st-head .rename-btn { padding: 0 6px; font-size: 12px; line-height: 1.5; background: transparent; border-color: transparent; color: var(--muted); }
.st-head .rename-btn:hover { color: var(--text); border-color: var(--line); background: var(--panel-2); }

/* Account bearbeiten */
.acc-section { padding: 4px 0 16px; border-bottom: 1px solid var(--line); }
.acc-section:last-child { border-bottom: 0; padding-bottom: 0; }
.acc-section > h4 { margin-top: 14px !important; }
.acc-section .form { margin-top: 10px; }
.acc-section label small { font-size: 11px; }
.confirm-pw { padding-top: 8px; border-top: 1px dashed var(--line); }
.acc-toggle { background: var(--panel-2); }
.acc-danger h4 { color: var(--warn) !important; }
.danger-solid { background: var(--warn); border-color: var(--warn); color: #fff; font-weight: 600; }
.danger-solid:hover:not(:disabled) { background: #d9503f; }

/* =================================================================
   Täglicher Login-Bonus
   ================================================================= */
.bonus-btn { display: flex; align-items: center; gap: 6px; padding: 4px 10px; font-size: 13px; color: var(--muted); }
.bonus-btn .ico { width: 18px; height: 18px; }
.bonus-btn.ready { color: #fff; background: var(--ok); border-color: var(--ok); font-weight: 600; animation: bonusGlow 1.8s infinite; }
@keyframes bonusGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(60,179,113,.6); }
    50%      { box-shadow: 0 0 0 6px rgba(60,179,113,0); }
}
.bonus-info { display: flex; gap: 14px; align-items: flex-start; padding: 12px 14px; border-radius: 8px; background: rgba(31,111,209,.12); border: 1px solid rgba(31,111,209,.35); }
.bonus-info .ico { width: 34px; height: 34px; color: #6aa8ff; flex-shrink: 0; }
.bonus-info p { margin: 0; font-size: 13px; }
.bonus-track { display: flex; flex-direction: column; align-items: center; margin: 16px auto 4px; max-width: 420px; }
.bt {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "day state" "reward state";
    align-items: center;
    gap: 0 12px;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--muted);
}
.bt-day { grid-area: day; font-weight: 700; font-size: 14px; color: var(--text); }
.bt-reward { grid-area: reward; font-variant-numeric: tabular-nums; }
.bt-reward small { font-size: 11px; }
.bt-state, .bt-claim { grid-area: state; }
.bt-state { font-size: 12px; color: var(--ok); font-weight: 600; }
.bt.done { background: rgba(60,179,113,.12); border-color: rgba(60,179,113,.35); }
.bt.done .bt-reward { color: var(--ok); }
.bt.done.today { outline: 2px solid var(--ok); outline-offset: 1px; }
.bt.ready { background: rgba(232,69,60,.16); border-color: var(--accent); box-shadow: 0 0 18px rgba(232,69,60,.25); }
.bt.ready .bt-reward { color: var(--text); font-weight: 700; font-size: 15px; }
.bt.big .bt-reward { font-size: 16px; }
.bt.big.future { border-style: dashed; border-color: var(--pend); }
.bt-star { color: var(--pend); }
.bt-claim { padding: 6px 14px; }
.bt-arrow { font-size: 10px; line-height: 1; padding: 4px 0; color: var(--line); }
.bt-arrow.on { color: var(--ok); }
.bonus-foot { text-align: center; margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.bonus-foot b { color: var(--text); }
@media (max-width: 1100px) { .bonus-label { display: none; } }

/* =================================================================
   Coins & Coin-Shop
   ================================================================= */
.coins-btn { display: flex; align-items: center; gap: 5px; padding: 3px 9px; color: #f2c94c; font-variant-numeric: tabular-nums; }
.coins-btn .ico { width: 18px; height: 18px; }
.coins-btn b { color: var(--text); }
.coin-balance { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 8px; background: rgba(242,201,76,.10); border: 1px solid rgba(242,201,76,.35); }
.coin-balance .ico { width: 40px; height: 40px; color: #f2c94c; flex-shrink: 0; }
.coin-balance b { display: block; font-size: 20px; }
.coin-balance small { font-size: 12px; }
.earn-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 6px; }
.earn-list li { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; background: var(--panel-2); font-size: 13px; }
.earn-amt { min-width: 34px; text-align: center; padding: 2px 6px; border-radius: 99px; background: rgba(242,201,76,.18); color: #f2c94c; font-weight: 700; font-size: 12px; }
.packs { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.pack { display: flex; flex-direction: column; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--panel-2); }
.pack-head { padding: 12px; background: linear-gradient(180deg, var(--panel-3), var(--panel-2)); border-bottom: 1px solid var(--line); }
.pack-head b { display: block; font-size: 16px; }
.pack-head small { color: var(--muted); font-size: 12px; }
.pack-body { display: grid; gap: 8px; padding: 12px; }
.pack-price { display: flex; align-items: center; gap: 6px; color: #f2c94c; font-weight: 700; }
.pack-price .ico { width: 18px; height: 18px; }
.pack .primary { width: 100%; background: var(--ok); border-color: var(--ok); }
.pack .primary:hover:not(:disabled) { background: #46c47e; border-color: #46c47e; }
.pack.locked { opacity: .7; }
.pack.locked .primary { background: var(--panel-3); border-color: var(--line); color: var(--muted); }
.coin-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; font-size: 13px; }
.coin-log li { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 8px; padding: 5px 8px; border-bottom: 1px solid var(--line); }
.cl-amt { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.cl-amt.plus { color: #f2c94c; }
.cl-amt.minus { color: var(--muted); }
.coin-log time { font-size: 11px; white-space: nowrap; }
.bt-coins { color: #f2c94c; font-weight: 700; font-size: 12px; }

/* Funkrufname ändern */
.sell-list .rename-btn, #fleet .rename-btn { padding: 0 6px; font-size: 12px; line-height: 1.5; background: transparent; border-color: transparent; color: var(--muted); }
.sell-list .rename-btn:hover, #fleet .rename-btn:hover { color: var(--text); border-color: var(--line); background: var(--panel-2); }
.sell-list li span small { font-size: 11px; }

/* =================================================================
   Rechtliches: Notruf-Hinweis, Fußzeilen, Impressum/Datenschutz
   ================================================================= */
.notruf {
    margin-top: 18px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(239,107,91,.45);
    background: rgba(239,107,91,.10);
    font-size: 12.5px;
    line-height: 1.5;
}
.notruf a, #app-footer a, .legal-links a, .auth-legal a, .legal a { color: var(--accent-2); }
.auth-legal { margin: 0; font-size: 11.5px; color: var(--muted); text-align: center; }
.legal-links { margin-top: 14px; text-align: center; font-size: 12px; color: var(--muted); }

#app-footer {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 4px 16px;
    padding: 0 12px 8px;
    margin-top: -2px;
    font-size: 11px;
    color: var(--muted);
}
#app-footer b { color: var(--text); }

/* Impressum & Datenschutz */
.legal-page { min-height: 100vh; padding: 32px 16px; background: var(--bg); }
.legal {
    max-width: 820px;
    margin: 0 auto;
    padding: 28px 32px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-top: 3px solid var(--accent);
    border-radius: 12px;
    line-height: 1.6;
}
.legal h1 { margin: 0 0 4px; font-size: 26px; }
.legal h2 { margin: 28px 0 8px; font-size: 17px; }
.legal h3 { margin: 18px 0 6px; font-size: 14px; color: var(--pend); }
.legal p, .legal li { color: #cfd6df; font-size: 14px; }
.legal ul { padding-left: 20px; }
.legal table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0; }
.legal th, .legal td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.legal th { color: var(--muted); font-weight: 600; font-size: 12px; }
.legal .back { display: inline-block; margin-bottom: 16px; font-size: 13px; }
.legal .stand { color: var(--muted); font-size: 12px; }
.ph { background: rgba(224,168,58,.22); color: #ffd27a; padding: 0 4px; border-radius: 3px; font-weight: 600; }
.tpl-note {
    margin: 0 0 20px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px dashed var(--pend);
    background: rgba(224,168,58,.10);
    font-size: 13px;
}
@media (max-width: 760px) {
    .legal { padding: 20px 16px; }
    #app-footer { padding: 4px 8px 8px; }
}

.brand { color: var(--text); text-decoration: none; }
.brand-sub { font-weight: 400; color: var(--muted); }
@media (max-width: 760px) { #topbar .brand-sub { display: none; } }
