/* ============================================================
   lamergamer FS25 – Stylesheet
   Bewusst durchgehend dunkles Design (Gaming-Kontext).
   ============================================================ */

:root {
    --bg:            #0e1310;
    --bg-grad:       radial-gradient(1200px 600px at 15% -10%, #1b2a1c 0%, transparent 60%),
                     radial-gradient(900px 500px at 100% 0%, #16241f 0%, transparent 55%);
    --surface:       #161d18;
    --surface-2:     #1c251e;
    --surface-3:     #232e25;
    --border:        #2b382d;
    --border-soft:   #223026;

    --text:          #e7eee8;
    --text-dim:      #a5b3a7;
    --text-faint:    #74836f;

    --accent:        #8fc84f;
    --accent-dark:   #6ea336;
    --accent-glow:   rgba(143, 200, 79, .18);

    --ok:            #63c86a;
    --warn:          #e2b24c;
    --danger:        #e2635a;
    --info:          #58aee0;

    --radius:        14px;
    --radius-sm:     9px;
    --shadow:        0 4px 24px rgba(0, 0, 0, .35);

    --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Consolas, monospace;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    background: var(--bg);
    background-image: var(--bg-grad);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #a8dc6c; text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; font-weight: 650; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

.wrap {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ---------------- Kopfbereich ---------------- */

.site-header {
    border-bottom: 1px solid var(--border-soft);
    background: linear-gradient(180deg, rgba(22, 29, 24, .92), rgba(14, 19, 16, .75));
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 40;
}

.header-top {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 0;
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    text-decoration: none;
    min-width: 0;
}
.brand:hover { text-decoration: none; color: var(--text); }

.brand-logo {
    width: 42px; height: 42px;
    flex: 0 0 42px;
    border-radius: 11px;
    background: linear-gradient(145deg, var(--accent), var(--accent-dark));
    display: grid; place-items: center;
    font-size: 22px;
    box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 4px 14px var(--accent-glow);
}

.brand-text { min-width: 0; }
.brand-title {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.brand-sub { font-size: .78rem; color: var(--text-faint); }

.header-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* ---------------- Navigation ---------------- */

.site-nav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}
.site-nav::-webkit-scrollbar { display: none; }

.site-nav a {
    padding: 10px 14px;
    color: var(--text-dim);
    font-size: .9rem;
    font-weight: 550;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}
.site-nav a:hover { color: var(--text); text-decoration: none; }
.site-nav a.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ---------------- Status-Badge ---------------- */

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px 5px 10px;
    border-radius: 999px;
    font-size: .82rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--surface-2);
    white-space: nowrap;
}
.status-pill .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--text-faint);
    flex: 0 0 8px;
}
.status-pill.is-online { border-color: rgba(99,200,106,.4); color: #9ade9f; }
.status-pill.is-online .dot {
    background: var(--ok);
    box-shadow: 0 0 0 3px rgba(99,200,106,.18);
    animation: pulse 2.4s ease-in-out infinite;
}
.status-pill.is-offline { border-color: rgba(226,99,90,.4); color: #efa19a; }
.status-pill.is-offline .dot { background: var(--danger); }

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(99,200,106,.18); }
    50%      { box-shadow: 0 0 0 6px rgba(99,200,106,.05); }
}

/* ---------------- Buttons ---------------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-size: .875rem;
    font-weight: 550;
    font-family: inherit;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover {
    background: var(--surface-3);
    border-color: #3a4a3c;
    text-decoration: none;
    color: var(--text);
}
.btn:active { transform: translateY(1px); }

.btn-primary {
    background: linear-gradient(145deg, var(--accent), var(--accent-dark));
    border-color: transparent;
    color: #10180c;
    font-weight: 650;
}
.btn-primary:hover {
    background: linear-gradient(145deg, #9bd45c, #77b03c);
    color: #10180c;
}

.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn[disabled], .btn.is-disabled {
    opacity: .45;
    cursor: not-allowed;
    pointer-events: none;
}

/* ---------------- Layout-Bausteine ---------------- */

main { padding: 26px 0 60px; }

.page-head {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.page-head p { margin: 0; color: var(--text-dim); font-size: .9rem; }
.page-head .spacer { margin-left: auto; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
}
.card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: -2px 0 14px;
}
.card-head h2, .card-head h3 { margin: 0; }
.card-head .spacer { margin-left: auto; }
.card-tight { padding: 0; overflow: hidden; }
.card-tight .card-head { padding: 16px 18px 0; margin-bottom: 12px; }

/* ---------------- Kennzahlen ---------------- */

.stat {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: relative;
    overflow: hidden;
}
.stat::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--accent);
    opacity: .55;
}
.stat-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-faint);
    font-weight: 650;
}
.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
}
.stat-value small { font-size: .95rem; color: var(--text-faint); font-weight: 500; }
.stat-hint { font-size: .78rem; color: var(--text-dim); }

/* ---------------- Verbindungsdaten ---------------- */

.connect-box {
    display: grid;
    gap: 10px;
}
.connect-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
}
.connect-row .label {
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-faint);
    font-weight: 650;
    flex: 0 0 84px;
}
.connect-row code {
    font-family: var(--mono);
    font-size: .9rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.connect-row .spacer { margin-left: auto; }

.copy-btn {
    border: 1px solid var(--border);
    background: var(--surface-3);
    color: var(--text-dim);
    border-radius: 7px;
    padding: 3px 9px;
    font-size: .75rem;
    cursor: pointer;
    font-family: inherit;
    flex: 0 0 auto;
}
.copy-btn:hover { color: var(--text); border-color: #3f5140; }
.copy-btn.copied { color: var(--ok); border-color: rgba(99,200,106,.5); }

/* ---------------- Tabellen ---------------- */

.table-scroll { overflow-x: auto; }

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}
table.data th {
    text-align: left;
    padding: 10px 14px;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-faint);
    font-weight: 650;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
}
table.data td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: rgba(255, 255, 255, .022); }
table.data .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
table.data .shrink { width: 1%; white-space: nowrap; }

.mod-name {
    font-weight: 600;
    display: block;
    overflow-wrap: anywhere;
}
.mod-id {
    font-family: var(--mono);
    font-size: .76rem;
    color: var(--text-faint);
    overflow-wrap: anywhere;
}

/* ---------------- Badges & Tags ---------------- */

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: .72rem;
    font-weight: 600;
    background: var(--surface-3);
    color: var(--text-dim);
    border: 1px solid var(--border-soft);
    white-space: nowrap;
}
.tag-ok     { color: #9ade9f; border-color: rgba(99,200,106,.35); background: rgba(99,200,106,.08); }
.tag-warn   { color: #efd28a; border-color: rgba(226,178,76,.35); background: rgba(226,178,76,.08); }
.tag-danger { color: #efa19a; border-color: rgba(226,99,90,.35); background: rgba(226,99,90,.08); }
.tag-info   { color: #9bd0ef; border-color: rgba(88,174,224,.35); background: rgba(88,174,224,.08); }
.tag-accent { color: #b9e483; border-color: rgba(143,200,79,.4);  background: rgba(143,200,79,.10); }

.admin-star { color: var(--warn); }

/* ---------------- Suchleiste ---------------- */

.toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 16px;
}
.field {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 12px;
    flex: 1 1 260px;
    min-width: 0;
}
.field:focus-within { border-color: var(--accent-dark); }
.field input {
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font: inherit;
    padding: 9px 0;
    width: 100%;
    min-width: 0;
}
.field input::placeholder { color: var(--text-faint); }
.field .icon { color: var(--text-faint); flex: 0 0 auto; }

select.input {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font: inherit;
    cursor: pointer;
}

/* ---------------- Fortschritt / Balken ---------------- */

.bar {
    height: 7px;
    border-radius: 99px;
    background: var(--surface-3);
    overflow: hidden;
}
.bar > span {
    display: block;
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--accent-dark), var(--accent));
    transition: width .4s ease;
}
.bar.warn > span  { background: linear-gradient(90deg, #b98b2a, var(--warn)); }
.bar.danger > span { background: linear-gradient(90deg, #b8483f, var(--danger)); }

/* ---------------- Verlaufs-Graph ---------------- */

.spark {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 62px;
    padding-top: 6px;
}
.spark-bar {
    flex: 1 1 0;
    min-width: 2px;
    background: var(--surface-3);
    border-radius: 2px 2px 0 0;
    position: relative;
    transition: background .15s;
}
.spark-bar[data-on="1"] { background: linear-gradient(180deg, var(--accent), var(--accent-dark)); }
.spark-bar[data-on="0"] { background: rgba(226,99,90,.28); }
.spark-bar:hover { background: #b9e483; }
.spark-axis {
    display: flex;
    justify-content: space-between;
    font-size: .7rem;
    color: var(--text-faint);
    margin-top: 6px;
}

/* ---------------- Map ---------------- */

.map-box {
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-soft);
    background: var(--surface-2);
    aspect-ratio: 1 / 1;
    display: grid;
    place-items: center;
}
.map-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.map-box .placeholder {
    color: var(--text-faint);
    font-size: .82rem;
    text-align: center;
    padding: 20px;
}

/* ---------------- Meldungen ---------------- */

.notice {
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: .875rem;
    border: 1px solid var(--border);
    background: var(--surface-2);
    margin-bottom: 18px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.notice .icon { flex: 0 0 auto; }
.notice-warn   { border-color: rgba(226,178,76,.4); background: rgba(226,178,76,.07); }
.notice-danger { border-color: rgba(226,99,90,.4);  background: rgba(226,99,90,.07); }
.notice-info   { border-color: rgba(88,174,224,.4); background: rgba(88,174,224,.07); }
.notice code { font-family: var(--mono); font-size: .84em; }

.empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-faint);
    font-size: .9rem;
}
.empty .big { font-size: 2rem; display: block; margin-bottom: 8px; opacity: .6; }

/* ---------------- Definitionslisten ---------------- */

dl.kv { margin: 0; display: grid; gap: 0; }
dl.kv > div {
    display: flex;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border-soft);
    font-size: .88rem;
}
dl.kv > div:last-child { border-bottom: none; }
dl.kv dt { color: var(--text-dim); flex: 1 1 auto; margin: 0; }
dl.kv dd {
    margin: 0;
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

/* ---------------- Fusszeile ---------------- */

.site-footer {
    border-top: 1px solid var(--border-soft);
    padding: 22px 0 40px;
    color: var(--text-faint);
    font-size: .82rem;
}
.footer-inner {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    align-items: center;
}
.footer-inner .spacer { margin-left: auto; }

/* ---------------- Hilfsklassen ---------------- */

.muted  { color: var(--text-dim); }
.faint  { color: var(--text-faint); }
.mono   { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.small  { font-size: .82rem; }
.center { text-align: center; }
.mt-0 { margin-top: 0; } .mt-3 { margin-top: 18px; } .mt-4 { margin-top: 26px; }
.mb-0 { margin-bottom: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.updating { opacity: .55; transition: opacity .2s; }

@media (max-width: 620px) {
    .stat-value { font-size: 1.35rem; }
    .brand-sub { display: none; }
    h1 { font-size: 1.35rem; }
    .connect-row .label { flex-basis: 68px; font-size: .68rem; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

/* ============================================================
   Interaktive Karte
   ============================================================ */

.map-layout {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(250px, 1fr);
    gap: 16px;
    align-items: start;
}
.map-side { display: grid; gap: 16px; align-content: start; }

@media (max-width: 900px) {
    .map-layout { grid-template-columns: 1fr; }
}

/* ---- Werkzeugleiste ---- */

.map-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.layer-toggles { display: flex; gap: 6px; flex-wrap: wrap; }

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 999px;
    font-size: .8rem;
    color: var(--text-dim);
    cursor: pointer;
    user-select: none;
}
.toggle:hover { color: var(--text); border-color: #3f5140; }
.toggle input { accent-color: var(--accent); margin: 0; cursor: pointer; }
.toggle:has(input:checked) {
    color: var(--text);
    border-color: rgba(143, 200, 79, .5);
    background: rgba(143, 200, 79, .09);
}

.zoom-controls {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
}
.zoom-btn {
    width: 28px; height: 26px;
    border: none;
    background: none;
    color: var(--text-dim);
    font-size: 1rem;
    font-family: inherit;
    border-radius: 6px;
    cursor: pointer;
    line-height: 1;
}
.zoom-btn:hover { background: var(--surface-3); color: var(--text); }
.zoom-level {
    font-size: .74rem;
    font-family: var(--mono);
    color: var(--text-faint);
    min-width: 44px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* ---- Ansichtsfenster ---- */

.map-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    cursor: grab;
    touch-action: none;
    outline: none;
}
.map-viewport:focus-visible { border-color: var(--accent-dark); }
.map-viewport.is-dragging { cursor: grabbing; }

.map-stage {
    position: absolute;
    inset: 0;
    transform-origin: 0 0;
    /* Wird per JS gesetzt und von den Markern gegenskaliert */
    --marker-scale: 1;
    will-change: transform;
}

.map-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}
.map-placeholder {
    background: repeating-linear-gradient(45deg,
        var(--surface-2) 0 12px, var(--surface-3) 12px 24px);
}

.map-layer { position: absolute; inset: 0; }

.map-hint {
    position: absolute;
    left: 10px; bottom: 10px;
    font-size: .7rem;
    color: rgba(255, 255, 255, .75);
    background: rgba(0, 0, 0, .55);
    padding: 3px 9px;
    border-radius: 999px;
    pointer-events: none;
    transition: opacity .3s;
}
.map-viewport.is-zoomed .map-hint { opacity: 0; }

/* ---- Marker ---- */

.marker {
    position: absolute;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    transform: translate(-50%, -50%);
    transition: left .9s linear, top .9s linear;
    font-family: inherit;
}

/* Der innere Teil skaliert gegen den Kartenzoom, damit Marker bei
   starkem Zoom nicht riesig werden. */
.marker-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    transform: scale(var(--marker-scale));
    transform-origin: center;
}

.marker-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--text-faint);
    box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .6);
    display: block;
}

.marker-label {
    font-size: .64rem;
    font-weight: 650;
    color: #fff;
    background: rgba(0, 0, 0, .68);
    padding: 0 4px;
    border-radius: 4px;
    white-space: nowrap;
    line-height: 1.55;
    display: none;
}
.map-stage.show-labels .marker-label:not(:empty) { display: block; }

/* Fahrernamen immer zeigen - das ist der interessanteste Teil */
.marker-vehicle.is-driven .marker-label:not(:empty) { display: block; }

.marker-vehicle { z-index: 3; }
.marker-vehicle.is-driven { z-index: 6; }
.marker-vehicle.is-driven .marker-dot {
    width: 13px; height: 13px;
    box-shadow: 0 0 0 2px #fff, 0 0 10px 3px rgba(143, 200, 79, .8);
    animation: markerPulse 2s ease-in-out infinite;
}
.marker:hover { z-index: 9; }
.marker:hover .marker-dot { box-shadow: 0 0 0 2px #fff; }

@keyframes markerPulse {
    0%, 100% { box-shadow: 0 0 0 2px #fff, 0 0 10px 3px rgba(143, 200, 79, .8); }
    50%      { box-shadow: 0 0 0 2px #fff, 0 0 16px 6px rgba(143, 200, 79, .35); }
}

/* ---- Feldmarker ---- */

.marker-field { z-index: 2; transition: none; }

.field-box {
    min-width: 17px;
    height: 15px;
    padding: 0 3px;
    border-radius: 3px;
    font-size: .58rem;
    font-weight: 700;
    color: rgba(0, 0, 0, .78);
    display: grid;
    place-items: center;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .5);
    font-variant-numeric: tabular-nums;
}
.marker-field.is-owned .field-box {
    box-shadow: 0 0 0 1.5px #fff, 0 0 0 2.5px rgba(0, 0, 0, .45);
}
.marker-field:hover .field-box { transform: scale(1.25); }

/* ---- Legende ---- */

.legend-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex: 0 0 10px;
    box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .5);
}
.legend-dot.is-square { border-radius: 3px; }
.legend-dot.is-driven {
    background: var(--accent);
    box-shadow: 0 0 0 2px #fff, 0 0 8px 2px rgba(143, 200, 79, .7);
}

/* ---- Kalibrier-Werkzeug ---- */

.cal-controls {
    display: grid;
    gap: 8px;
}
.cal-controls .toggle { justify-content: flex-start; }

.cal-num {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: .8rem;
    color: var(--text-dim);
}
.cal-num span { flex: 0 0 62px; font-family: var(--mono); }
.cal-num input {
    flex: 1 1 auto;
    min-width: 0;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 7px;
    padding: 5px 9px;
    font: inherit;
    font-variant-numeric: tabular-nums;
}
.cal-num input:focus { outline: none; border-color: var(--accent-dark); }

.cal-snippet-box { display: grid; gap: 8px; }

.cal-snippet {
    margin: 0;
    background: var(--bg);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-family: var(--mono);
    font-size: .74rem;
    line-height: 1.5;
    color: var(--text-dim);
    overflow-x: auto;
    white-space: pre;
}

/* ---- Kalibrier-Assistent ---- */

.cal-wizard {
    margin-top: 14px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    display: grid;
    gap: 8px;
}
.cal-wizard-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .85rem;
}
.cal-wizard-points {
    font-family: var(--mono);
    font-size: .72rem;
    line-height: 1.6;
    border-top: 1px solid var(--border-soft);
    padding-top: 7px;
}

/* Im Assistentenmodus ist der Zeiger ein Kreuz und Marker nehmen
   keine Klicks an – der Klick gehört der Positionsauswahl. */
.map-viewport.is-picking { cursor: crosshair; }
.map-viewport.is-picking .marker { pointer-events: none; }
.map-viewport.is-picking::after {
    content: "";
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 0 2px rgba(143, 200, 79, .7);
    pointer-events: none;
}

/* ---- Kalibriergitter ---- */

.map-grid { position: absolute; inset: 0; pointer-events: none; }

.grid-line { position: absolute; }
.grid-line.vertical   { top: 0; bottom: 0; border-left: 1px dashed rgba(255,255,255,.28); }
.grid-line.horizontal { left: 0; right: 0; border-top: 1px dashed rgba(255,255,255,.28); }
.grid-line.origin     { border-color: rgba(226, 99, 90, .9); border-style: solid; }

.grid-line span {
    position: absolute;
    font-size: .6rem;
    font-family: var(--mono);
    color: #fff;
    background: rgba(0, 0, 0, .6);
    padding: 0 3px;
    border-radius: 3px;
}
.grid-line.vertical span   { top: 2px; left: 2px; }
.grid-line.horizontal span { left: 2px; top: 2px; }

/* ---------------- Wetter ---------------- */

.weather-now {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 14px;
}
.weather-now-icon { font-size: 2.1rem; line-height: 1; }
.weather-now-label { font-weight: 650; font-size: 1.05rem; }

.forecast {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
}
.forecast-item {
    flex: 0 0 82px;
    text-align: center;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 9px 6px;
}
.forecast-item.is-today {
    border-color: rgba(143, 200, 79, .45);
    background: rgba(143, 200, 79, .07);
}
.forecast-day {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-faint);
    font-weight: 650;
}
.forecast-icon { font-size: 1.5rem; line-height: 1.3; }
.forecast-label { font-size: .76rem; font-weight: 600; }
.forecast-time { font-size: .68rem; color: var(--text-faint); font-family: var(--mono); }

/* ---------------- Frucht-Chips (Felder) ---------------- */

.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }

.chip {
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 999px;
    padding: 5px 13px;
    font-size: .8rem;
    color: var(--text-dim);
    text-decoration: none;
}
.chip:hover { color: var(--text); border-color: #3f5140; text-decoration: none; }
.chip.is-active { border-color: var(--accent); color: var(--text); }

.chip-bar {
    position: absolute;
    inset: 0 auto 0 0;
    background: rgba(143, 200, 79, .16);
    pointer-events: none;
}
.chip-text { position: relative; display: inline-flex; gap: 6px; align-items: baseline; }
.chip-text strong { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------------- Grosse Nachfrage ---------------- */

.demand {
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 13px 15px;
    display: grid;
    gap: 4px;
}
.demand.is-running {
    border-color: rgba(143, 200, 79, .5);
    background: rgba(143, 200, 79, .07);
}
.demand-mult {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -.02em;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

/* Laufende Periode im Preisverlauf hervorheben */
.spark-bar.is-now {
    background: linear-gradient(180deg, #cdf08c, var(--accent)) !important;
    box-shadow: 0 0 0 1px rgba(205, 240, 140, .5);
}

/* ============================================================
   Adminbereich
   ============================================================ */

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.login-card {
    width: 100%;
    max-width: 380px;
}
.login-logo {
    width: 52px; height: 52px;
    margin: 0 auto 12px;
    border-radius: 14px;
    background: linear-gradient(145deg, var(--accent), var(--accent-dark));
    display: grid; place-items: center;
    font-size: 24px;
    box-shadow: 0 4px 18px var(--accent-glow);
}

.admin-input {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 7px;
    padding: 7px 10px;
    font: inherit;
    font-variant-numeric: tabular-nums;
    text-align: right;
}
.admin-input:focus {
    outline: none;
    border-color: var(--accent-dark);
    background: var(--surface-3);
}
.admin-input::placeholder { color: var(--text-faint); font-style: italic; }
.admin-input:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.admin-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px 18px;
    border-top: 1px solid var(--border-soft);
    background: var(--surface-2);
}
.admin-actions .btn-primary { margin-left: auto; }

/* Aufklappbare Diagnose im Adminbereich */
.diag {
    margin-top: 12px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    background: var(--bg);
    padding: 0 12px;
}
.diag > summary {
    cursor: pointer;
    padding: 9px 0;
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-dim);
}
.diag > summary:hover { color: var(--text); }
.diag[open] > summary { border-bottom: 1px solid var(--border-soft); margin-bottom: 8px; }
.diag dl.kv { margin-bottom: 10px; }
.diag dl.kv dt { flex: 0 0 auto; min-width: 170px; }

/* ---- AutoDrive-Routen ---- */

.map-routes {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}
/* Fuer SVG greift das UA-Stylesheet fuer [hidden] nicht zuverlaessig */
.map-routes[hidden] { display: none; }

.map-routes path {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    /* Strichbreite vom Kartenzoom entkoppeln */
    vector-effect: non-scaling-stroke;
}

.route-builder-points { z-index: 4; }
.route-builder-point {
    position: absolute;
    width: 22px;
    height: 22px;
    margin: -11px 0 0 -11px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #e26d5a;
    color: #fff;
    font: 700 .7rem/18px system-ui, sans-serif;
    text-align: center;
    box-shadow: 0 1px 5px rgba(0,0,0,.55);
    pointer-events: none;
}
.route-builder-line { stroke: #e26d5a; stroke-width: 3px; }
.map-viewport.is-route-building { cursor: crosshair; }
.route-builder-controls { display: grid; gap: 8px; }

/* Kontur als zweiter, breiterer Pfad statt drop-shadow: ein Filter ueber
   tausende Teilstrecken muss der Browser als eine riesige Region rastern
   und kann dabei still scheitern. */
.route-halo {
    stroke: rgba(0, 0, 0, .55);
    stroke-width: 3.2px;
}
.route-line {
    stroke: #58aee0;
    stroke-width: 1.4px;
}

.marker-dest { z-index: 4; transition: none; }

.dest-dot {
    width: 0; height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 9px solid #58aee0;
    filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, .9));
    display: block;
}
.marker-dest .marker-label {
    display: block;
    background: rgba(20, 40, 55, .82);
    color: #cfe9f8;
    font-size: .6rem;
}
.marker-dest:hover .dest-dot { transform: scale(1.35); }

/* ---- Vermögensübersicht ---- */

a.wealth-card {
    color: inherit;
    text-decoration: none;
    transition: border-color .15s, transform .08s;
}
a.wealth-card:hover {
    border-color: var(--accent-dark);
    text-decoration: none;
    color: inherit;
}
a.wealth-card:active { transform: translateY(1px); }

.wealth-total {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
    color: #b9e483;
    margin-bottom: 10px;
}
.wealth-total.is-negative { color: #efa19a; }

/* Summenzeile in Tabellen */
table.data tfoot th {
    position: static;
    background: var(--surface-3);
    border-top: 1px solid var(--border);
    border-bottom: none;
    color: var(--text);
    font-size: .82rem;
    text-transform: none;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
}
table.data tfoot th.num { text-align: right; }

/* ---- Wartungsaufgaben im Adminbereich ---- */

.task-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 10px;
}

.task {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 12px 14px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.task.is-danger { border-color: rgba(226, 99, 90, .4); }

.task-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: .9rem;
}
.task-desc { margin: 0; flex: 1 1 auto; line-height: 1.45; }
.task .btn { align-self: flex-start; }

/* ---- Ausgabe der Skripte ---- */

.cli-output {
    margin: 0;
    padding: 14px 18px;
    background: var(--bg);
    border-top: 1px solid var(--border-soft);
    font-family: var(--mono);
    font-size: .76rem;
    line-height: 1.55;
    color: var(--text-dim);
    max-height: 560px;
    overflow: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.cli-output span { display: block; }
.cli-output .is-ok    { color: #9ade9f; }
.cli-output .is-bad   { color: #efa19a; font-weight: 600; }
.cli-output .is-warn  { color: #efd28a; }
.cli-output .is-muted { color: var(--text-faint); }
