/* ============================================================
   mb-portal - Energie-Monitor  (Design-System: Inter, #2563eb,
   1px Rahmen, 8-10px Radius, dezente Schatten, keine Gradients)
   ============================================================ */
@font-face {
    font-family: 'Inter';
    src: url('/assets/fonts/Inter-Variable.woff2') format('woff2');
    font-weight: 100 900;
    font-display: swap;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --bg: #f9fafb;
    --card: #ffffff;
    --border: #e5e7eb;
    --text: #111827;
    --text-2: #6b7280;
    --text-3: #9ca3af;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* ---------- Topbar ---------- */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
    padding: 14px 20px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
}
.topbar-left { display: flex; align-items: baseline; gap: 12px; }
.brand { font-weight: 700; font-size: 1.05rem; }
.device { color: var(--text-2); font-size: .85rem; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.last-update { color: var(--text-3); font-size: .8rem; font-variant-numeric: tabular-nums; }

.badge {
    font-size: .78rem; font-weight: 600; padding: 4px 10px;
    border-radius: 999px; border: 1px solid transparent;
}
.badge-ok { color: var(--success); background: rgba(5, 150, 105, .08); border-color: rgba(5, 150, 105, .2); }
.badge-stale { color: var(--warning); background: rgba(217, 119, 6, .08); border-color: rgba(217, 119, 6, .2); }
.badge-off { color: var(--danger); background: rgba(220, 38, 38, .08); border-color: rgba(220, 38, 38, .2); }
.badge-muted { color: var(--text-3); background: var(--bg); border-color: var(--border); }

/* ---------- Layout ---------- */
.wrap { max-width: 1160px; margin: 0 auto; padding: 20px; }

.tiles {
    display: grid; gap: 14px; margin-bottom: 16px;
    grid-template-columns: repeat(4, 1fr);
}
.tile {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.tile-accent { border-color: var(--primary); }
.tile-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.tile-label { color: var(--text-2); font-size: .82rem; }
.tile-ic { width: 18px; height: 18px; color: var(--text-3); }
.tile-accent .tile-ic { color: var(--primary); }
.tile-value { font-size: 1.9rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.tile-accent .tile-value { color: var(--primary); }
.tile-value .unit { font-size: .95rem; font-weight: 600; color: var(--text-2); margin-left: 4px; }
.tile-foot { color: var(--text-3); font-size: .78rem; margin-top: 8px; }

.phases {
    display: grid; gap: 14px; margin-bottom: 16px;
    grid-template-columns: repeat(3, 1fr);
}
.phase-card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.phase-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.phase-name { font-weight: 700; font-size: 1.05rem; }
.phase-power { font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
.phase-metrics { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.phase-metrics dt { color: var(--text-2); font-size: .78rem; }
.phase-metrics dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }

.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 16px 18px; margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 1rem; font-weight: 700; }
.chart-box { position: relative; height: 320px; }

.range-picker { display: inline-flex; gap: 4px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 3px; }
.range-picker button {
    border: 0; background: transparent; color: var(--text-2);
    font: inherit; font-size: .82rem; font-weight: 600;
    padding: 5px 12px; border-radius: 6px; cursor: pointer;
}
.range-picker button.active { background: var(--primary); color: #fff; }

.foot { color: var(--text-3); font-size: .78rem; text-align: center; padding: 8px 0 24px; }

/* ---------- Buttons ---------- */
.btn-primary {
    width: 100%; border: 0; background: var(--primary); color: #fff;
    font: inherit; font-weight: 600; padding: 11px 16px; border-radius: 8px; cursor: pointer;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--text-2); text-decoration: none; font-size: .85rem; font-weight: 600;
    padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px;
}
.btn-ghost:hover { background: var(--bg); }

/* ---------- Icons ---------- */
.ic { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic-fill { fill: currentColor; stroke: currentColor; }
.brand-icon { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 7px; background: var(--primary); }
.brand-icon .ic { width: 15px; height: 15px; color: #fff; }
.brand { display: inline-flex; align-items: center; gap: 9px; }

/* ---------- Benutzerdefinierter Zeitraum ---------- */
.btn-custom { display: inline-flex !important; align-items: center; gap: 5px; }
.btn-custom .ic { width: 14px; height: 14px; }
.custom-range {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    margin: 0 0 14px; padding: 12px 14px;
    background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
}
.custom-range[hidden] { display: none; }
.custom-range label { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 600; color: var(--text-2); }
.custom-range input[type=datetime-local] {
    font: inherit; font-size: .85rem; padding: 6px 8px;
    border: 1px solid var(--border); border-radius: 6px; background: var(--card); color: var(--text);
}
.btn-small {
    border: 0; background: var(--primary); color: #fff; font: inherit; font-weight: 600;
    font-size: .82rem; padding: 7px 14px; border-radius: 6px; cursor: pointer;
}
.btn-small:hover { background: var(--primary-dark); }
.cr-error { color: var(--danger); font-size: .8rem; font-weight: 600; }

/* ---------- Login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 32px 28px; width: 100%; max-width: 360px; text-align: center;
}
.login-logo { display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 13px; background: var(--primary); }
.login-logo .ic { width: 28px; height: 28px; color: #fff; }
.login-card h1 { margin: 6px 0 2px; font-size: 1.35rem; }
.login-sub { color: var(--text-2); font-size: .85rem; margin: 0 0 20px; }
.login-card label { display: block; text-align: left; font-size: .82rem; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.login-card input[type=password] {
    width: 100%; padding: 11px 12px; border: 1px solid var(--border);
    border-radius: 8px; font: inherit; margin-bottom: 16px;
}
.login-card input[type=password]:focus { outline: 2px solid rgba(37, 99, 235, .35); border-color: var(--primary); }
.alert { border-radius: 8px; padding: 10px 12px; font-size: .85rem; margin-bottom: 16px; text-align: left; }
.alert-error { color: var(--danger); background: rgba(220, 38, 38, .08); border: 1px solid rgba(220, 38, 38, .2); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .tiles { grid-template-columns: repeat(2, 1fr); }
    .phases { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
    .tiles { grid-template-columns: 1fr; }
    .chart-box { height: 260px; }
    .device { display: none; }
}
