/* ===== Variables ===== */
:root {
    --color-bg: #0f0f12;
    --color-surface: #18181c;
    --color-border: #2a2a30;
    --color-text: #e4e4e7;
    --color-text-muted: #a1a1aa;
    --color-primary: #6366f1;
    --color-primary-hover: #818cf8;
    --color-accent: #22d3ee;
    --color-success: #34d399;
    --color-danger: #f87171;
    --font-sans: 'DM Sans', 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;
    --radius: 12px;
    --shadow: 0 4px 24px rgba(0,0,0,0.25);
}

/* ===== Base ===== */
html {
    font-size: 16px; /* verhindert iOS-Zoom bei Input-Focus */
    -webkit-text-size-adjust: 100%;
}
html, body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
}
@media (max-width: 1199px) {
    html, body { overflow-x: hidden; }
    .app-page { min-width: 0; width: 100%; }
    .app-main { width: 100%; box-sizing: border-box; }
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    margin-top: 0;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-hover); }

/* ===== App shell ===== */
.app-page {
    display: flex;
    min-height: 100vh;
}

.app-topbar {
    display: none;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0.75rem 1rem;
}
.app-topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1400px;
    margin: 0 auto;
}
.app-brand {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--color-text);
}
.app-toggler {
    background: none;
    border: none;
    color: var(--color-text);
    padding: 0.75rem;
    margin: -0.25rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 8px;
    -webkit-tap-highlight-color: transparent;
}
.app-toggler span {
    width: 22px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
}

.app-sidebar {
    width: 240px;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    padding: 1rem 0;
    flex-shrink: 0;
}
.app-sidebar.collapse {
    display: none;
}
@media (min-width: 1200px) {
    .app-sidebar.collapse {
        display: block;
    }
}
.app-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.app-nav-link {
    padding: 0.6rem 1rem;
    color: var(--color-text-muted);
    border-radius: var(--radius);
    margin: 0 0.5rem;
    transition: background .15s, color .15s;
}
.app-nav-link:hover, .app-nav-link.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--color-primary);
}
.app-nav-icon {
    opacity: 0.8;
    margin-right: 0.5rem;
    font-size: 0.85em;
}

.app-main {
    flex: 1;
    min-width: 0;
    padding: 1.5rem;
}
.app-content {
    max-width: 1000px;
    margin: 0 auto;
}

/* ===== Mobile / Tablet: Topbar + Overlay-Menü (Sidebar nimmt keinen Platz weg) ===== */
.app-sidebar-backdrop {
    display: none;
}
@media (max-width: 1199px) {
    .app-topbar {
        display: flex;
        align-items: center;
        min-height: 52px;
        padding: 0.75rem 1rem;
        padding-top: max(0.75rem, env(safe-area-inset-top));
    }
    .app-topbar-inner { width: 100%; }
    .app-brand { font-size: 1.1rem; }
    .app-sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.45);
        z-index: 99;
        -webkit-tap-highlight-color: transparent;
    }
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 52px;
        top: calc(52px + env(safe-area-inset-top));
        bottom: 0;
        z-index: 100;
        box-shadow: var(--shadow);
        width: min(260px, 78vw);
        padding: 0.5rem 0;
        overflow-y: auto;
    }
    .app-sidebar.collapse { display: none; }
    .app-nav-link {
        padding: 0.85rem 1rem;
        min-height: 48px;
        display: flex;
        align-items: center;
        font-size: 1rem;
    }
    .app-nav-icon { font-size: 1.1em; }
    .app-main {
        padding: 1rem;
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
    .app-content { max-width: 100%; }
    /* Tabellen: horizontales Scrollen nur wo keine Karten-Ansicht */
    .app-main .table-wrapper:not(.table-responsive-cards) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }
    .app-main .table-wrapper:not(.table-responsive-cards) .table {
        min-width: 520px;
    }
    .app-main .table th,
    .app-main .table td {
        padding: 0.65rem 0.5rem;
        font-size: 0.9375rem;
    }
    /* Touch-freundliche Buttons */
    .app-main .btn,
    .app-main .btn-sm {
        min-height: 44px;
        padding: 0.6rem 1rem;
        font-size: 1rem;
    }
    .app-main .btn-sm { min-height: 40px; padding: 0.5rem 0.85rem; }
    /* Formulare */
    .app-main .form-control {
        min-height: 48px;
        font-size: 16px; /* verhindert Zoom auf iOS */
        padding: 0.65rem 0.85rem;
    }
    .app-main .form-label { font-size: 0.9375rem; }
    /* Cards & Abstände */
    .app-main .card-body { padding: 1rem; }
    .app-main h1 { font-size: 1.5rem; }
    .app-main h2, .app-main h3 { font-size: 1.35rem; }
    .mb-3, .mt-4 { margin-bottom: 1rem; margin-top: 1rem; }
    /* Sprach-Umschalter größer */
    .lang-toggle .btn {
        min-height: 40px;
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .app-main { padding: 0.75rem; }
    .app-main .table-wrapper { margin: 0 -0.75rem; padding: 0 0.75rem; }
    .app-main .table-responsive-cards .table { min-width: 0; }
    .app-sidebar { width: min(260px, 82vw); }
}

/* Hochformat / schmale Viewports: Tabellen als Karten (lesbar ohne Quer-Scroll) */
@media (max-width: 767px) {
    .app-main .table-responsive-cards .table,
    .app-main .table-responsive-cards thead,
    .app-main .table-responsive-cards tbody,
    .app-main .table-responsive-cards tr,
    .app-main .table-responsive-cards th,
    .app-main .table-responsive-cards td {
        display: block;
    }
    .app-main .table-responsive-cards thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0,0,0,0);
        border: 0;
    }
    .app-main .table-responsive-cards tbody tr {
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius);
        margin-bottom: 0.75rem;
        padding: 0.75rem 1rem;
        box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    }
    .app-main .table-responsive-cards tbody td {
        border: none;
        padding: 0.35rem 0;
        font-size: 0.9375rem;
        line-height: 1.45;
    }
    .app-main .table-responsive-cards tbody td::before {
        content: attr(data-label);
        display: inline-block;
        min-width: 6.5em;
        font-weight: 600;
        color: var(--color-text-muted);
        font-size: 0.8125rem;
        margin-right: 0.5rem;
    }
    .app-main .table-responsive-cards tbody td:last-child {
        margin-top: 0.5rem;
        padding-top: 0.5rem;
        border-top: 1px solid var(--color-border);
    }
    .app-main .table-responsive-cards tbody td:last-child::before {
        display: none;
    }
    .app-main .table-wrapper.table-responsive-cards {
        overflow-x: visible;
        margin: 0;
        padding: 0;
    }
    .app-main .table-responsive-cards .table {
        min-width: 0;
    }
}

/* Portrait: etwas mehr Lesbarkeit */
@media (max-width: 767px) and (orientation: portrait) {
    .app-main { padding: 0.85rem 1rem; }
    .app-main h1 { font-size: 1.35rem; }
    .app-main h2, .app-main h3 { font-size: 1.25rem; }
    .app-main .table-responsive-cards tbody td { font-size: 1rem; }
}

/* Lange URLs / Code auf kleinen Screens umbrechen */
.app-main code {
    word-break: break-all;
    overflow-wrap: break-word;
}

/* ===== Forms & buttons (app) ===== */
.btn-primary {
    background: var(--color-primary);
    border: none;
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
}
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-secondary, .btn-outline-secondary {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
}
.btn-secondary:hover, .btn-outline-secondary:hover {
    background: var(--color-surface);
    border-color: var(--color-text-muted);
}
.form-control {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    width: 100%;
}
.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}
.form-label { color: var(--color-text-muted); margin-bottom: 0.25rem; display: block; }
.alert-danger { background: rgba(248,113,113,0.15); color: var(--color-danger); border: 1px solid var(--color-danger); border-radius: var(--radius); padding: 0.75rem; }
.alert-success { background: rgba(52,211,153,0.15); color: var(--color-success); border-radius: var(--radius); padding: 0.75rem; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 0.6rem; text-align: left; border-bottom: 1px solid var(--color-border); }
.table th { color: var(--color-text-muted); font-weight: 500; }
.table-striped tbody tr:nth-child(odd) { background: rgba(255,255,255,0.02); }
/* Tabellen im Dark-Theme: kein weißer Hintergrund */
.app-main .table,
.app-main .table th,
.app-main .table td,
.app-main .table thead,
.app-main .table tbody,
.app-main .table tbody tr {
    background: transparent !important;
    background-color: transparent !important;
    color: var(--color-text) !important;
    border-color: var(--color-border) !important;
}
.app-main .table {
    background: var(--color-surface) !important;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}
.app-main .table thead th {
    background: rgba(0,0,0,0.2) !important;
    color: var(--color-text-muted) !important;
    font-weight: 500;
    border-bottom: 1px solid var(--color-border);
}
.app-main .table tbody td {
    border-bottom: 1px solid var(--color-border);
}
.app-main .table-striped tbody tr:nth-child(odd) {
    background: rgba(255,255,255,0.03) !important;
}
.app-main .table-striped tbody tr:nth-child(even) {
    background: transparent !important;
}
.app-main .table tbody tr:hover {
    background: rgba(99, 102, 241, 0.08) !important;
}
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); }
.card-body { padding: 1.25rem; }
.card-title { color: var(--color-text) !important; }
.card-text { color: var(--color-text) !important; }
/* Billing & App-Inhalte: Lesbarkeit auf dunklem Hintergrund */
.app-main,
.app-content {
    color: var(--color-text);
}
.app-main h1,
.app-main h2,
.app-main h3,
.app-main h4,
.app-main h5,
.app-main h6 { color: var(--color-text) !important; }
.app-main .card,
.app-main .card-body,
.app-main .card-title,
.app-main .card-text,
.app-main p,
.app-main li { color: var(--color-text); }
.app-main .text-muted,
.app-main .small,
.app-main small { color: var(--color-text-muted) !important; }
.app-main .text-success { color: var(--color-success) !important; }
.app-main .text-warning { color: #fbbf24 !important; }
/* Dashboard: Buttons in Tabellen – gut lesbar, kein heller Hintergrund */
.app-main .btn-outline-secondary {
    background: transparent !important;
    border: 1px solid var(--color-text-muted) !important;
    color: var(--color-text) !important;
}
.app-main .btn-outline-secondary:hover {
    background: var(--color-surface) !important;
    border-color: var(--color-primary) !important;
    color: var(--color-primary) !important;
}
.text-muted { color: var(--color-text-muted); }
.small, small { font-size: 0.875rem; }
code { background: var(--color-surface); padding: 0.2em 0.4em; border-radius: 4px; font-family: var(--font-mono); font-size: 0.9em; color: var(--color-text); }

/* DNS-Hinweis (White-Label): lesbar im Dark-Theme */
.dns-hint {
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}
.dns-hint strong { color: var(--color-text); }
.dns-hint ul { color: var(--color-text-muted); }
.dns-hint ul strong { color: var(--color-text); }
.dns-hint code {
    background: rgba(99, 102, 241, 0.15);
    color: var(--color-accent);
    padding: 0.2em 0.45em;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.9em;
}

/* ===== Landing layout ===== */
.landing-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(160deg, #0f0f12 0%, #1a1a24 50%, #0d0d12 100%);
}
.landing-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.landing-header-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.landing-header .brand {
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--color-text);
    letter-spacing: -0.02em;
}
.landing-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.landing-nav a {
    color: var(--color-text-muted);
    font-weight: 500;
}
.landing-nav a:hover { color: var(--color-text); }
.landing-main { flex: 1; }
.landing-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.06);
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}
.landing-footer-inner { max-width: 1100px; margin: 0 auto; }
.landing-footer a { color: var(--color-text-muted); text-decoration: none; }
.landing-footer a:hover { color: var(--color-text); text-decoration: underline; }

/* ===== Hero ===== */
.hero {
    padding: 4rem 1.5rem 5rem;
    text-align: center;
}
.hero-content { max-width: 680px; margin: 0 auto; }
.hero-title {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.03em;
    margin-bottom: 1.25rem;
    background: linear-gradient(135deg, #fff 0%, #a1a1aa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero-subtitle {
    font-size: 1.125rem;
    color: var(--color-text-muted);
    margin-bottom: 2rem;
    line-height: 1.7;
}
.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
}
.btn-hero-primary {
    display: inline-block;
    background: var(--color-primary);
    color: #fff !important;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
    -webkit-text-fill-color: #fff;
}
.btn-hero-primary:hover { background: var(--color-primary-hover); }
.btn-hero-secondary {
    display: inline-block;
    background: transparent;
    color: var(--color-text) !important;
    border: 1px solid var(--color-border);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 500;
    -webkit-text-fill-color: var(--color-text);
}
.btn-hero-secondary:hover { border-color: var(--color-text-muted); background: rgba(255,255,255,0.05); }

/* ===== Features ===== */
.features {
    padding: 4rem 1.5rem;
    background: rgba(0,0,0,0.2);
}
.features-inner { max-width: 1100px; margin: 0 auto; }
.features h2 {
    text-align: center;
    font-size: 1.75rem;
    margin-bottom: 2.5rem;
    color: var(--color-text);
}
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
}
.feature-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: border-color .2s, transform .2s;
}
.feature-card:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
}
.feature-icon { font-size: 2rem; margin-bottom: 0.75rem; }
.feature-card h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.feature-card p { color: var(--color-text-muted); font-size: 0.95rem; margin: 0; }

/* ===== CTA ===== */
.cta {
    padding: 4rem 1.5rem;
    text-align: center;
}
.cta-inner { max-width: 560px; margin: 0 auto; }
.cta h2 { font-size: 1.5rem; margin-bottom: 0.75rem; }
.cta p { color: var(--color-text-muted); margin-bottom: 1.5rem; }

/* ===== Auth pages in app layout ===== */
.container { max-width: 520px; margin-left: auto; margin-right: auto; padding: 0 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mt-3 { margin-top: 1rem; }
.mt-2 { margin-top: 0.5rem; }
.me-1 { margin-right: 0.25rem; }
.me-2 { margin-right: 0.5rem; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.875rem; }
.btn-link { background: none; border: none; color: var(--color-primary); cursor: pointer; padding: 0; }
.form-check { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }
.form-check-input { width: 1.25rem; height: 1.25rem; accent-color: var(--color-primary); }
.list-unstyled { list-style: none; padding: 0; margin: 0; }

/* ===== Blazor / loading ===== */
h1:focus { outline: none; }
.content { padding-top: 1rem; }
.valid.modified:not([type=checkbox]) { outline: 1px solid var(--color-success); }
.invalid { outline: 1px solid var(--color-danger); }
.validation-message { color: var(--color-danger); }
#blazor-error-ui {
    background: rgba(248,113,113,0.2);
    color: var(--color-danger);
    bottom: 0;
    padding: 0.6rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    display: none;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
.blazor-error-boundary { padding: 1rem; color: white; background: var(--color-danger); }
.loading-progress { display: block; width: 8rem; height: 8rem; margin: 20vh auto 1rem auto; }
.loading-progress circle { fill: none; stroke: var(--color-border); stroke-width: 0.6rem; transform: rotate(-90deg); }
.loading-progress circle:last-child { stroke: var(--color-primary); stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%; }
.loading-progress-text { text-align: center; font-weight: bold; margin-top: 1rem; }
