:root {
    --bg-0: #0b1220;
    --bg-1: #111c30;
    --card: rgba(255, 255, 255, 0.06);
    --card-border: rgba(255, 255, 255, 0.10);
    --text: #eef2f8;
    --muted: #9aa7bd;
    --accent: #4cc9f0;
    --accent-2: #7b8cff;
    --online: #34d399;
    --offline: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.12);
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    -webkit-user-select: none;
    user-select: none;
    background:
        radial-gradient(1200px 600px at 15% -10%, rgba(123, 140, 255, 0.25), transparent 60%),
        radial-gradient(1000px 500px at 110% 10%, rgba(76, 201, 240, 0.18), transparent 55%),
        linear-gradient(160deg, var(--bg-0), var(--bg-1));
    background-attachment: fixed;
}

h1 {
    margin: 0 0 0.25rem;
    font-size: clamp(1.6rem, 1.2rem + 1.8vw, 2.4rem);
    font-weight: 700;
    letter-spacing: -0.01em;
}

.muted {
    color: var(--muted);
    margin: 0;
}

/* ---------- Shell ---------- */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 0.9rem 1.5rem;
    backdrop-filter: blur(12px);
    background: rgba(11, 18, 32, 0.55);
    border-bottom: 1px solid var(--card-border);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.brand-mark {
    font-size: 1.4rem;
}

.app-main {
    flex: 1;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
}

/* ---------- Panels ---------- */
.panel,
.dashboard {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 1.75rem;
    box-shadow: var(--shadow);
}

.btn {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.55rem 1.1rem;
    border-radius: 999px;
    text-decoration: none;
    color: #0b1220;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

/* ---------- Tenant overview ---------- */
.tenant-grid {
    margin-top: 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.tenant-card {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 1.1rem 1.25rem;
    border-radius: 16px;
    text-decoration: none;
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--card-border);
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.tenant-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
    background: rgba(76, 201, 240, 0.08);
}

.tenant-name {
    font-size: 1.2rem;
    font-weight: 700;
}

.tenant-bucket {
    color: var(--muted);
    font-size: 0.85rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------- Dashboard head ---------- */
.dash-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.95rem;
    border: 1px solid transparent;
}

.badge-online {
    color: var(--online);
    background: rgba(52, 211, 153, 0.12);
    border-color: rgba(52, 211, 153, 0.35);
    box-shadow: 0 0 18px rgba(52, 211, 153, 0.25);
}

.badge-offline {
    color: var(--offline);
    background: rgba(248, 113, 113, 0.12);
    border-color: rgba(248, 113, 113, 0.35);
}

.alert {
    margin-bottom: 1.25rem;
    padding: 0.85rem 1.1rem;
    border-radius: 12px;
    color: #ffd9d9;
    background: var(--danger-bg);
    border: 1px solid rgba(248, 113, 113, 0.35);
    font-size: 0.9rem;
}

/* ---------- Metric grid ---------- */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 1rem;
}

.metric {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 1.15rem 1.25rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    overflow: hidden;
    transition: transform 0.15s ease, background 0.15s ease;
}

.metric:hover {
    transform: translateY(-3px);
    background: rgba(255, 255, 255, 0.08);
}

.metric.clickable {
    cursor: pointer;
}

.metric.clickable:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.metric-icon {
    font-size: 1.8rem;
    line-height: 1;
}

.metric-body {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.metric-label {
    color: var(--muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.metric-value {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
}

.metric-number {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
}

.metric-unit {
    color: var(--muted);
    font-size: 0.95rem;
}

.metric-empty {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--muted);
}

/* ---------- Compass ---------- */
.windrose {
    margin-left: auto;
    width: 56px;
    height: 56px;
    flex-shrink: 0;
}

.rose-ring {
    fill: rgba(0, 0, 0, 0.22);
    stroke: var(--card-border);
    stroke-width: 1;
}

.rose-tick {
    stroke: rgba(255, 255, 255, 0.25);
    stroke-width: 1;
}

.rose-card {
    fill: var(--muted);
    font-size: 8px;
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: middle;
}

.rose-n {
    fill: var(--accent);
}

.rose-needle-g {
    transform-origin: 32px 32px;
    transition: transform 0.4s ease;
}

.rose-needle {
    fill: var(--accent);
}

.rose-hub {
    fill: var(--text);
}

.refresh-hint {
    margin: 1.5rem 0 0;
    text-align: right;
    color: var(--muted);
    font-size: 0.8rem;
}

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background: rgba(4, 8, 16, 0.66);
    backdrop-filter: blur(4px);
}

.modal {
    width: min(720px, 100%);
    background: #0e1626;
    border: 1px solid var(--card-border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.modal-head h2 {
    margin: 0;
    font-size: 1.3rem;
}

.modal-close {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    cursor: pointer;
    font-size: 0.9rem;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.12);
}

.range-tabs {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 1.1rem;
}

.range-tab {
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: color 0.15s ease, background 0.15s ease;
}

.range-tab:hover {
    color: var(--text);
}

.range-tab.active {
    color: #0b1220;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent;
}

.modal-body {
    min-height: 160px;
}

/* ---------- Trend chart ---------- */
.trend {
    width: 100%;
    height: auto;
    display: block;
    overflow: visible;
}

/* Series-Pfade fangen keine Hover-Events ab – nur die Spalten-Trefferflächen. */
.trend .series {
    pointer-events: none;
}

.trend .hit {
    fill: transparent;
    pointer-events: all;
    cursor: crosshair;
}

.trend .guide,
.trend .dot,
.trend .tip {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.08s ease;
}

.trend .hover-col:hover .guide,
.trend .hover-col:hover .dot,
.trend .hover-col:hover .tip {
    opacity: 1;
}

.trend .guide {
    stroke: rgba(255, 255, 255, 0.25);
    stroke-width: 1;
    stroke-dasharray: 3 3;
}

.trend .dot {
    fill: var(--accent);
    stroke: #0e1626;
    stroke-width: 2;
}

.trend .tip rect {
    fill: rgba(8, 14, 26, 0.96);
    stroke: var(--card-border);
}

.trend .tip-val {
    fill: var(--text);
    font-size: 11px;
    font-weight: 700;
}

.trend .tip-time {
    fill: var(--muted);
    font-size: 9px;
}

.trend-meta,
.trend-axis {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
}

.trend-meta {
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

.trend-axis {
    margin-top: 0.2rem;
    font-size: 0.75rem;
}
