:root {
    --bg: #0b1220;
    --bg-elevated: #111b2e;
    --panel: #152238;
    --panel-border: rgba(148, 163, 184, 0.12);
    --text: #e5eefb;
    --muted: #94a3b8;
    --primary: #22d3ee;
    --primary-strong: #0891b2;
    --accent: #a78bfa;
    --danger: #fb7185;
    --success: #34d399;
    --warning: #fbbf24;
    --shadow: 0 20px 45px rgba(0, 0, 0, 0.35);
    --radius: 18px;
    --mobile-header-height: 52px;
    --mobile-nav-width: min(85vw, 280px);
}

* { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    height: -webkit-fill-available;
}

body {
    margin: 0;
    font-family: 'Inter', system-ui, sans-serif;
    background: radial-gradient(circle at top left, #12203a 0%, var(--bg) 45%);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

body.nav-open {
    overflow: hidden;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: #67e8f9; }

.app-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: rgba(8, 15, 30, 0.92);
    border-right: 1px solid var(--panel-border);
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    backdrop-filter: blur(12px);
    position: relative;
}

.sidebar-header {
    display: contents;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 10px;
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    background: rgba(148, 163, 184, 0.08);
    color: var(--text);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.nav-toggle-bar {
    display: block;
    width: 100%;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.sidebar.nav-open .nav-toggle-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.sidebar.nav-open .nav-toggle-bar:nth-child(2) {
    opacity: 0;
}

.sidebar.nav-open .nav-toggle-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(0, 0, 0, 0.55);
}

.sidebar-backdrop:not([hidden]) {
    display: block;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 12px;
}

a.brand,
a.brand:hover,
a.brand:focus,
a.brand:focus-visible {
    color: inherit;
    text-decoration: none;
}

.brand-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    font-size: 22px;
}

.brand small {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.app-version {
    color: var(--muted);
    font-size: 0.75em;
    font-weight: 500;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-link {
    display: block;
    padding: 12px 14px;
    border-radius: 12px;
    color: var(--text);
    font-weight: 500;
}

.nav-link:hover {
    background: rgba(34, 211, 238, 0.08);
    color: var(--primary);
}

.sidebar-footer {
    margin-top: auto;
    padding: 14px;
    border-top: 1px solid var(--panel-border);
    color: var(--muted);
    font-size: 13px;
}

.main-content {
    padding: 28px 32px 48px;
}

.page-header h1 {
    margin: 0 0 6px;
    font-size: 2rem;
}

.subtitle {
    margin: 0;
    color: var(--muted);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin: 24px 0;
}

.kpi-card {
    background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
}

.kpi-card.accent {
    border-color: rgba(34, 211, 238, 0.35);
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.12), rgba(167, 139, 250, 0.08));
}

.kpi-label {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 1.8rem;
    line-height: 1.1;
}

.kpi-value.kpi-date {
    font-size: 1.35rem;
}

.panel {
    background: rgba(21, 34, 56, 0.88);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 22px;
    box-shadow: var(--shadow);
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.panel-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.trend-help summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    list-style: none;
    user-select: none;
}

.trend-help summary::-webkit-details-marker {
    display: none;
}

.trend-help summary::before {
    content: "▸ ";
    color: var(--primary);
}

.trend-help[open] summary::before {
    content: "▾ ";
}

.trend-help p {
    margin: 12px 0 0;
}

.panel h2, .panel h3 {
    margin-top: 0;
}

.alert-panel ul {
    margin: 0;
    padding-left: 18px;
    color: var(--warning);
}

.alert-panel .alert-detail {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.info-panel h2 {
    margin-top: 0;
    font-size: 1rem;
}

.info-panel p {
    margin: 0;
    line-height: 1.5;
    font-size: 14px;
}

.meter-stats .trend-detail {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
    font-weight: 400;
}

.meter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
    gap: 18px;
}

.meter-card {
    background: var(--bg-elevated);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 18px;
}

.meter-card header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
}

.meter-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin: 16px 0;
}

.consumption-hero {
    margin: 14px 0 4px;
    padding: 16px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.1), rgba(167, 139, 250, 0.06));
    border: 1px solid rgba(34, 211, 238, 0.2);
}

.consumption-hero.muted-box {
    background: rgba(148, 163, 184, 0.06);
    border-color: var(--panel-border);
}

.consumption-label {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 6px;
}

.consumption-total {
    display: block;
    font-size: 1.75rem;
    line-height: 1.2;
    color: var(--primary);
}

.consumption-daily {
    display: block;
    font-size: 1.25rem;
    line-height: 1.2;
    color: var(--success);
    margin-bottom: 6px;
}

.daily-label {
    margin-top: 10px;
}

.daily-days {
    display: block;
    font-size: 11px;
    margin-top: 2px;
}

.meter-kind {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.sparkline-label {
    margin: 0 0 6px;
    font-size: 12px;
    color: var(--muted);
}

.trend-badge-stigende {
    background: rgba(251, 113, 133, 0.15);
    color: var(--danger);
}

.trend-badge-faldende {
    background: rgba(52, 211, 153, 0.15);
    color: var(--success);
}

.trend-badge-stabil {
    background: rgba(148, 163, 184, 0.12);
    color: var(--muted);
}

.kpi-card.alert-kpi {
    border-color: rgba(251, 191, 36, 0.35);
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.1), rgba(251, 113, 133, 0.06));
}

.dashboard-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.meter-stats small {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.meter-stats strong {
    font-size: 1rem;
}

.sparkline {
    height: 90px !important;
    margin-bottom: 12px;
}

.trend-stigende { border-color: rgba(251, 113, 133, 0.35); }
.trend-faldende { border-color: rgba(52, 211, 153, 0.35); }
.trend-stabil { border-color: rgba(148, 163, 184, 0.25); }

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(34, 211, 238, 0.12);
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #042f3a;
}

.btn-ghost {
    background: rgba(148, 163, 184, 0.08);
    color: var(--text);
    border: 1px solid var(--panel-border);
}

.btn-danger {
    background: rgba(251, 113, 133, 0.15);
    color: var(--danger);
    border: 1px solid rgba(251, 113, 133, 0.35);
}

.toolbar, .inline-form {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
    padding: 0 4px;
}

.data-table th,
.data-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--panel-border);
    text-align: left;
}

.data-table th {
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.input, select {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 10px 12px;
    min-width: 0;
    max-width: 100%;
    font-size: 16px;
}

.input, select, .btn {
    min-height: 44px;
}

.form-panel .form-grid {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 14px 18px;
    align-items: center;
    max-width: 640px;
}

.form-actions {
    margin-top: 18px;
    display: flex;
    gap: 10px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.form-hint {
    margin: 0 0 8px;
    font-size: 13px;
    max-width: 640px;
}

.auth-body {
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.auth-shell {
    width: 100%;
    max-width: 420px;
}

.auth-card {
    padding: 28px 24px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.auth-brand strong {
    display: block;
    font-size: 1.1rem;
}

.auth-brand small {
    color: var(--muted);
}

.auth-title {
    margin: 0 0 8px;
    font-size: 1.5rem;
}

.auth-lead {
    margin: 0 0 20px;
}

.auth-form {
    display: grid;
    gap: 12px;
}

.auth-form label {
    font-size: 14px;
    color: var(--muted);
}

.auth-submit {
    margin-top: 8px;
    width: 100%;
}

.auth-switch {
    margin: 20px 0 0;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

.sidebar-footer .logout-link {
    display: inline-block;
    margin-top: 8px;
    font-size: 13px;
    color: var(--muted);
}

.sidebar-footer .logout-link:hover {
    color: var(--primary);
}

.role-badge {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.input-compact {
    min-height: 36px;
    padding: 6px 10px;
    font-size: 14px;
}

.auth-flash {
    margin-bottom: 16px;
    padding: 12px 14px;
}

.badge-reset {
    margin-left: 6px;
    background: rgba(251, 191, 36, 0.15);
    color: var(--warning);
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    gap: 18px;
}

.chart-grid canvas {
    min-height: 260px;
}

.analytics-page .compact-panel {
    margin-bottom: 14px;
    padding: 16px 18px;
}

.analytics-page .analytics-kpi {
    margin: 14px 0;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.analytics-page .analytics-kpi .kpi-value {
    font-size: 1.35rem;
}

.analytics-page .analytics-chart-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.analytics-page .chart-cell {
    height: 220px;
    display: flex;
    flex-direction: column;
}

.analytics-page .chart-cell h3 {
    margin: 0 0 8px;
    font-size: 0.95rem;
}

.analytics-page .chart-cell canvas {
    flex: 1;
    min-height: 0 !important;
    max-height: 180px !important;
    height: 180px !important;
}

.analytics-page .chart-note {
    margin: 10px 0 0;
    font-size: 12px;
}

.analytics-toolbar {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.analytics-filter-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.analytics-date-range {
    flex-wrap: wrap;
}

.analytics-date-range .input-date {
    min-width: 150px;
}

.filter-note {
    margin: 0;
    font-size: 13px;
}

.filter-note strong {
    color: var(--text);
}

.meter-edit-form {
    flex-wrap: wrap;
}

@media (min-width: 641px) {
    .input, select {
        min-width: 180px;
    }

    .input-unit {
        min-width: 110px;
        max-width: 140px;
    }
}

.validation-summary {
    color: var(--danger);
    margin-bottom: 12px;
}

.field-error {
    color: var(--danger);
    font-size: 13px;
}

/* Tablet */
@media (max-width: 1100px) {
    .analytics-page .analytics-chart-grid {
        grid-template-columns: 1fr;
    }

    .analytics-page .analytics-kpi {
        grid-template-columns: repeat(2, minmax(140px, 1fr));
    }
}

/* Mobile */
@media (max-width: 960px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 100;
        padding: 8px 12px;
        gap: 0;
        border-right: none;
        border-bottom: 1px solid var(--panel-border);
        background: rgba(8, 15, 30, 0.98);
    }

    .sidebar-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        min-height: var(--mobile-header-height);
        position: relative;
        z-index: 130;
    }

    .brand {
        padding: 0;
        min-width: 0;
        gap: 10px;
        flex: 1 1 auto;
    }

    .brand-icon {
        width: 34px;
        height: 34px;
        font-size: 17px;
        border-radius: 10px;
        flex-shrink: 0;
    }

    .brand strong {
        font-size: 0.95rem;
        line-height: 1.2;
    }

    .brand small {
        display: none;
    }

    .nav-toggle {
        display: inline-flex;
        flex-shrink: 0;
        position: relative;
        z-index: 131;
    }

    .sidebar nav {
        display: flex;
        flex-direction: column;
        gap: 4px;
        position: fixed;
        top: var(--mobile-header-height);
        left: 0;
        bottom: 0;
        width: var(--mobile-nav-width);
        max-width: 280px;
        margin: 0;
        padding: 12px 10px calc(130px + env(safe-area-inset-bottom, 0px));
        background: rgba(8, 15, 30, 0.98);
        border-right: 1px solid var(--panel-border);
        box-shadow: var(--shadow);
        transform: translateX(-105%);
        transition: transform 0.2s ease;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        z-index: 120;
        pointer-events: none;
        visibility: hidden;
    }

    .sidebar.nav-open nav {
        transform: translateX(0);
        pointer-events: auto;
        visibility: visible;
    }

    .nav-link {
        padding: 12px 14px;
        font-size: 1rem;
        border-radius: 10px;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .sidebar-footer {
        display: block;
        position: fixed;
        left: 0;
        bottom: 0;
        width: var(--mobile-nav-width);
        max-width: 280px;
        margin: 0;
        padding: 14px 12px calc(14px + env(safe-area-inset-bottom, 0px));
        background: rgba(8, 15, 30, 0.98);
        border-top: 1px solid var(--panel-border);
        border-right: 1px solid var(--panel-border);
        transform: translateX(-105%);
        transition: transform 0.2s ease;
        z-index: 120;
        pointer-events: none;
        visibility: hidden;
    }

    .sidebar.nav-open .sidebar-footer {
        transform: translateX(0);
        pointer-events: auto;
        visibility: visible;
    }

    .sidebar-backdrop:not([hidden]) {
        display: block;
        touch-action: none;
    }

    .main-content {
        padding: 12px 12px 28px;
    }

    .page-header {
        margin-bottom: 12px;
    }

    .page-header h1 {
        font-size: 1.2rem;
        line-height: 1.25;
    }

    .subtitle {
        font-size: 0.85rem;
        line-height: 1.35;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .panel {
        padding: 14px;
        margin-bottom: 14px;
    }

    .kpi-value {
        font-size: 1.35rem;
    }

    .kpi-value.kpi-date {
        font-size: 1rem;
    }

    .consumption-total {
        font-size: 1.35rem;
    }

    .dashboard-toolbar,
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .dashboard-toolbar .btn,
    .toolbar > .btn {
        width: 100%;
        text-align: center;
    }

    .inline-form {
        width: 100%;
    }

    .inline-form label {
        flex: 0 0 auto;
    }

    .inline-form select,
    .inline-form .input,
    .inline-form .btn {
        flex: 1 1 auto;
        width: 100%;
    }

    .analytics-filter-form .inline-form {
        flex-direction: column;
        align-items: stretch;
    }

    .analytics-date-range .input-date {
        width: 100%;
    }

    .chart-grid {
        grid-template-columns: 1fr;
    }

    .meter-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .auth-body {
        align-items: flex-start;
        justify-content: flex-start;
        padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(24px, env(safe-area-inset-bottom, 0px));
    }

    .auth-card {
        padding: 20px 16px;
    }

    .auth-title {
        font-size: 1.25rem;
    }

    .auth-brand strong {
        font-size: 1rem;
    }

    .auth-switch {
        font-size: 15px;
    }

    .meter-stats {
        grid-template-columns: 1fr 1fr;
    }

    .kpi-grid,
    .analytics-page .analytics-kpi {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .form-panel .form-grid {
        grid-template-columns: 1fr;
        gap: 8px;
        max-width: none;
    }

    .form-panel .form-grid label {
        margin-bottom: 2px;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }

    .actions {
        flex-direction: column;
        align-items: stretch;
    }

    .actions .btn,
    .actions .inline-form {
        width: 100%;
    }

    .actions .inline-form .btn {
        width: 100%;
    }

    .data-table.responsive-table {
        border: 0;
    }

    .data-table.responsive-table thead {
        display: none;
    }

    .data-table.responsive-table tbody tr {
        display: block;
        margin-bottom: 14px;
        padding: 14px;
        border: 1px solid var(--panel-border);
        border-radius: 14px;
        background: var(--bg-elevated);
    }

    .data-table.responsive-table tbody tr:last-child {
        margin-bottom: 0;
    }

    .data-table.responsive-table td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        padding: 8px 0;
        border-bottom: 1px solid var(--panel-border);
        text-align: right;
    }

    .data-table.responsive-table td:last-child {
        border-bottom: 0;
        padding-bottom: 0;
    }

    .data-table.responsive-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--muted);
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        text-align: left;
        flex: 0 0 42%;
    }

    .data-table.responsive-table td.actions {
        flex-direction: column;
        align-items: stretch;
    }

    .data-table.responsive-table td.actions::before {
        margin-bottom: 4px;
    }

    .data-table.responsive-table td[colspan] {
        display: block;
        text-align: center;
    }

    .data-table.responsive-table td[colspan]::before {
        display: none;
    }

    .meter-card .btn {
        width: 100%;
    }

    .meter-edit-form {
        flex-direction: column;
        align-items: stretch;
    }

    .meter-edit-form .input,
    .meter-edit-form .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .kpi-grid,
    .analytics-page .analytics-kpi,
    .meter-stats {
        grid-template-columns: 1fr;
    }

    .page-header h1 {
        font-size: 1.1rem;
    }

    .subtitle {
        -webkit-line-clamp: 1;
    }
}

.sort-link {
    color: inherit;
    font-weight: 600;
    text-decoration: none;
}

.sort-link:hover {
    color: var(--primary);
}

.sortable-table th {
    white-space: nowrap;
}

.flash {
    padding: 14px 18px;
}

.flash p {
    margin: 0;
}

.flash-success {
    border-color: rgba(52, 211, 153, 0.35);
    background: rgba(52, 211, 153, 0.08);
}

.flash-error {
    border-color: rgba(251, 113, 133, 0.35);
    background: rgba(251, 113, 133, 0.08);
}

.flash-info {
    border-color: rgba(34, 211, 238, 0.25);
    background: rgba(34, 211, 238, 0.06);
}

.auth-switch a {
    display: inline-block;
    padding: 6px 2px;
    min-height: 44px;
    line-height: 32px;
}

.impersonation-banner {
    margin-bottom: 16px;
}

.impersonation-banner p {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    align-items: center;
}

.impersonation-link {
    color: var(--primary);
    font-weight: 600;
}

.muted { color: var(--muted); }

/* Front-page shortcuts. Hidden at 768px and above so desktop stays unchanged. */
.mobile-shortcuts {
    display: none;
}

@media (max-width: 767px) {
    .mobile-shortcuts {
        display: flex;
        flex-direction: column;
        gap: 12px;
        margin: 0 0 18px;
    }

    .mobile-shortcut {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        min-height: 72px;
        padding: 18px 16px;
        border-radius: 16px;
        border: 1px solid rgba(34, 211, 238, 0.35);
        background: linear-gradient(135deg, rgba(34, 211, 238, 0.18), rgba(167, 139, 250, 0.14));
        color: var(--text);
        font-family: inherit;
        font-size: 1.35rem;
        font-weight: 700;
        line-height: 1.2;
        text-align: center;
        text-decoration: none;
        box-shadow: var(--shadow);
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-shortcut:hover,
    .mobile-shortcut:focus-visible {
        color: #042f3a;
        background: linear-gradient(135deg, var(--primary), var(--primary-strong));
        border-color: transparent;
    }
}

.app-footer {
    margin-top: 28px;
    color: var(--muted);
    font-size: 13px;
}

.auth-footer {
    text-align: center;
    margin-top: 16px;
}

/* Subpage mobile layout. Hidden from 768px up so desktop stays unchanged. */
.mobile-back,
.mobile-cards,
.mobile-only {
    display: none;
}

@media (max-width: 767px) {
    .mobile-back {
        display: block;
        margin: 0 0 16px;
    }

    .mobile-back-link {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        min-height: 72px;
        padding: 18px 16px;
        border-radius: 16px;
        border: 1px solid rgba(148, 163, 184, 0.35);
        background: rgba(148, 163, 184, 0.12);
        color: var(--text);
        font-family: inherit;
        font-size: 1.35rem;
        font-weight: 700;
        line-height: 1.2;
        text-align: center;
        text-decoration: none;
        box-shadow: var(--shadow);
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-back-link:hover,
    .mobile-back-link:focus-visible {
        color: #042f3a;
        background: linear-gradient(135deg, var(--primary), var(--primary-strong));
        border-color: transparent;
    }

    .mobile-cards {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .desktop-table {
        display: none !important;
    }

    .mobile-only {
        display: block;
    }

    .mobile-card {
        border: 1px solid var(--panel-border);
        border-radius: 16px;
        background: var(--bg-elevated);
        padding: 16px;
    }

    .mobile-card-field {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        padding: 10px 0;
        border-bottom: 1px solid var(--panel-border);
    }

    .mobile-card-field-edit {
        flex-direction: column;
        align-items: stretch;
    }

    .mobile-card-label {
        color: var(--muted);
        font-size: 12px;
        font-weight: 600;
        letter-spacing: 0.04em;
        text-transform: uppercase;
    }

    .mobile-card-value {
        min-width: 0;
        font-size: 18px;
        font-weight: 600;
        text-align: right;
        overflow-wrap: anywhere;
    }

    .mobile-card-actions,
    .mobile-card-action-forms {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .mobile-card-actions {
        margin-top: 14px;
    }

    .mobile-card-actions .inline-form,
    .mobile-card-actions .btn,
    .mobile-card-action-forms .inline-form,
    .mobile-card-action-forms .btn {
        width: 100%;
    }

    .mobile-card-actions .btn,
    .mobile-card-action-forms .btn {
        min-height: 48px;
        font-size: 18px;
    }

    .mobile-card .input,
    .mobile-card select,
    .mobile-card-field-edit .input,
    .mobile-card-field-edit select,
    .mobile-card-field-edit .inline-form {
        width: 100%;
        min-width: 0;
        max-width: none;
        min-height: 48px;
        font-size: 18px;
    }

    .mobile-card-field-edit .inline-form {
        min-height: 0;
        font-size: inherit;
    }

    .reading-form .form-grid {
        grid-template-columns: 1fr;
        max-width: none;
    }

    .reading-form .form-grid > span:empty {
        display: none;
    }

    .reading-form .input,
    .reading-form select {
        width: 100%;
        min-width: 0;
        max-width: none;
        min-height: 48px;
        font-size: 18px;
    }

    .reading-form .checkbox-row {
        min-height: 48px;
        font-size: 18px;
    }

    .reading-form .checkbox-row input[type="checkbox"] {
        width: 22px;
        height: 22px;
    }

    .reading-form .form-actions {
        flex-direction: column;
    }

    .reading-form .form-actions .btn {
        width: 100%;
    }

    .reading-form .btn-primary {
        min-height: 64px;
        font-size: 1.25rem;
        font-weight: 700;
    }

    .kpi-grid.forbrug-kpis {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .forbrug-kpis .kpi-card {
        min-height: 96px;
        padding: 20px 18px;
    }

    .forbrug-kpis .kpi-label {
        font-size: 15px;
    }

    .forbrug-kpis .kpi-value {
        font-size: 2rem;
    }

    .forbrug-kpis .kpi-value.kpi-date {
        font-size: 1.6rem;
    }

    .forbrug-charts .consumption-total {
        font-size: 2rem;
    }

    .forbrug-charts .sparkline {
        display: block;
        width: 100% !important;
        max-width: 100%;
        height: 200px !important;
    }

    .mobile-table-details > .mobile-table-toggle {
        display: flex;
        width: 100%;
        min-height: 56px;
        margin-top: 4px;
        font-size: 18px;
        list-style: none;
        cursor: pointer;
    }

    .mobile-table-details > .mobile-table-toggle::-webkit-details-marker {
        display: none;
    }

    .mobile-table-details[open] > .mobile-table-toggle {
        margin-bottom: 14px;
    }
}
