/* ============================================================
   sercon v0.5.0 — responsive Stylesheet
============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #1a1d23;
    color: #d8dde5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
}

/* ============================================================
   Topbar
============================================================ */

.topbar {
    background: #232830;
    border-bottom: 1px solid #3a3f48;
}

.topbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
}

.brand {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    line-height: 1.1;
}

.brand strong {
    font-size: 1.5rem;
    color: #4a9eff;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.brand .tagline {
    color: #6b7280;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 0.1rem;
}

.nav-toggle {
    display: none;
    background: none;
    border: 1px solid #3a3f48;
    color: #d8dde5;
    font-size: 1.3rem;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    cursor: pointer;
    line-height: 1;
}

.topbar-collapse {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem 0.75rem;
    gap: 1rem;
}

.nav {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.nav a {
    color: #b0b8c4;
    text-decoration: none;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.nav a:hover {
    background: #2c3138;
    color: #fff;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
    flex-shrink: 0;
}

.user-email {
    color: #b0b8c4;
    font-size: 0.85rem;
    text-decoration: none;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    white-space: nowrap;
}

.user-email:hover {
    background: #2c3138;
    color: #fff;
}

.logout-link {
    color: #b0b8c4;
    text-decoration: none;
    font-size: 0.85rem;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    border: 1px solid #3a3f48;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.logout-link:hover {
    background: #3a1e1e;
    color: #fca5a5;
    border-color: #7f1d1d;
}

/* ============================================================
   Content
============================================================ */

.content {
    flex: 1;
    padding: 2rem 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.content h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: #fff;
    font-weight: 600;
}

.content h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: #4a9eff;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.lead { color: #b0b8c4; margin-bottom: 1.5rem; }

code { background: #1a1d23; padding: 0.15rem 0.4rem; border-radius: 4px; font-size: 0.9em; }

.small { font-size: 0.8rem; color: #6b7280; }

/* ============================================================
   Footer
============================================================ */

.bottombar {
    background: #232830;
    border-top: 1px solid #3a3f48;
    padding: 1rem 1.5rem;
    text-align: center;
    color: #6b7280;
    font-size: 0.85rem;
}

/* ============================================================
   Dashboard: Info-Grid + Status
============================================================ */

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.card {
    background: #232830;
    border: 1px solid #3a3f48;
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
}

.stat-line { color: #d8dde5; margin-top: 0.5rem; font-size: 0.9rem; }
.stat-line strong { color: #fff; font-size: 1.1rem; }

.bar { background: #1a1d23; border-radius: 6px; height: 8px; overflow: hidden; margin-top: 0.5rem; }
.bar-fill { background: #4a9eff; height: 100%; transition: width 0.3s; }
.bar-fill.warn { background: #f59e0b; }

.load-row { display: flex; justify-content: space-between; gap: 0.75rem; margin-top: 0.25rem; }
.load-row > div { flex: 1; text-align: center; padding: 0.5rem; background: #1a1d23; border-radius: 6px; }
.load-row strong { display: block; color: #fff; font-size: 1.25rem; }
.load-row .small { display: block; color: #6b7280; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }

.service-list { list-style: none; margin-top: 0.5rem; }
.service-list li { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0; border-bottom: 1px solid #2c3138; font-size: 0.9rem; }
.service-list li:last-child { border-bottom: none; }

/* ============================================================
   Badges
============================================================ */

.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge.ok   { background: #1e3a2e; color: #4ade80; }
.badge.err  { background: #3a1e1e; color: #f87171; }
.badge.warn { background: #3a2e1e; color: #fbbf24; }

/* ============================================================
   Datentabellen
============================================================ */

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #232830;
    border: 1px solid #3a3f48;
    border-radius: 8px;
    overflow: hidden;
}

.data-table thead { background: #1a1d23; }

.data-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    color: #9ca3af;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #3a3f48;
    white-space: nowrap;
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #2c3138;
    vertical-align: top;
    font-size: 0.85rem;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover { background: #2c3138; }
.data-table code { color: #4a9eff; background: #1a1d23; }
.data-table .actions { display: flex; gap: 0.4rem; flex-wrap: wrap; white-space: nowrap; }
.data-table .actions form { display: inline; margin: 0; }
.err-text { color: #fca5a5; }

/* ============================================================
   Buttons
============================================================ */

.btn-primary, .btn-small, .btn-danger, .btn-cancel {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid #3a3f48;
    background: #2c3138;
    color: #d8dde5;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}

.btn-small { padding: 0.3rem 0.6rem; font-size: 0.75rem; }
.btn-primary { background: #4a9eff; color: #fff; border-color: #4a9eff; }
.btn-primary:hover { background: #2563eb; border-color: #2563eb; }
.btn-danger { background: #3a1e1e; color: #fca5a5; border-color: #7f1d1d; }
.btn-danger:hover { background: #7f1d1d; color: #fff; }
.btn-cancel { background: transparent; color: #9ca3af; }
.btn-cancel:hover { color: #fff; background: #2c3138; }

.toolbar { margin: 1.5rem 0 1rem; display: flex; gap: 0.75rem; flex-wrap: wrap; }

.empty-state {
    background: #232830;
    border: 1px dashed #3a3f48;
    border-radius: 8px;
    padding: 2.5rem 1.5rem;
    text-align: center;
    color: #9ca3af;
    margin-top: 1rem;
}

/* ============================================================
   Tabs
============================================================ */

.tab-bar { display: flex; gap: 0; border-bottom: 2px solid #3a3f48; margin: 1.5rem 0 0; overflow-x: auto; }
.tab {
    background: none; border: none; color: #9ca3af;
    padding: 0.65rem 1rem; cursor: pointer;
    border-bottom: 2px solid transparent; margin-bottom: -2px;
    font-size: 0.85rem; font-weight: 500; font-family: inherit;
    transition: color 0.15s, border-color 0.15s; white-space: nowrap;
}
.tab:hover { color: #d8dde5; }
.tab.active { color: #4a9eff; border-bottom-color: #4a9eff; }
.tab-content { display: none; padding-top: 1.5rem; }
.tab-content.active { display: block; }

/* ============================================================
   Forms
============================================================ */

.form-card {
    background: #232830;
    border: 1px solid #3a3f48;
    border-radius: 12px;
    padding: 1.75rem;
    max-width: 500px;
    margin-top: 1rem;
}

.form-card h3 { margin-bottom: 1rem; }

.form-card form { display: flex; flex-direction: column; gap: 0.85rem; }

.form-card label {
    font-size: 0.85rem;
    color: #b0b8c4;
    margin-bottom: -0.4rem;
}

.form-card input[type="email"],
.form-card input[type="password"],
.form-card input[type="text"],
.form-card select {
    background: #1a1d23;
    border: 1px solid #3a3f48;
    color: #e0e6ed;
    padding: 0.7rem 0.9rem;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.15s;
    width: 100%;
}

.form-card input:focus, .form-card select:focus {
    outline: none;
    border-color: #4a9eff;
}

.form-card button {
    background: #4a9eff;
    color: #fff;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 0.25rem;
    transition: background 0.15s;
}

.form-card button:hover { background: #2563eb; }
.form-card .small { color: #6b7280; font-size: 0.8rem; margin-top: -0.4rem; }
.form-actions { display: flex; gap: 0.75rem; margin-top: 0.5rem; align-items: center; flex-wrap: wrap; }

.checkbox-row {
    display: flex; align-items: center; gap: 0.5rem;
    color: #d8dde5; font-size: 0.9rem; margin-top: 0.5rem;
}
.checkbox-row input[type="checkbox"] { width: 1.1rem; height: 1.1rem; accent-color: #4a9eff; }

/* ============================================================
   Messages
============================================================ */

.error-box {
    background: #3a1e1e; color: #fca5a5; border: 1px solid #7f1d1d;
    padding: 0.75rem 1rem; border-radius: 6px; font-size: 0.9rem; margin-bottom: 1rem;
}

.success-box {
    background: #1e3a2e; color: #86efac; border: 1px solid #14532d;
    padding: 0.75rem 1rem; border-radius: 6px; font-size: 0.9rem; margin-bottom: 1rem;
}

/* ============================================================
   Auth (Login / Verify)
============================================================ */

.auth-body { background: #1a1d23; min-height: 100vh; display: flex; flex-direction: column; }
.auth-wrapper { flex: 1; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }

.auth-card {
    background: #232830; border: 1px solid #3a3f48; border-radius: 12px;
    padding: 2rem; width: 100%; max-width: 400px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand strong { font-size: 1.75rem; color: #4a9eff; letter-spacing: -0.02em; display: block; }
.auth-brand .tagline { display: block; color: #6b7280; font-size: 0.7rem; margin-top: 0.15rem; text-transform: uppercase; letter-spacing: 0.1em; }
.auth-card h2 { text-align: center; color: #fff; margin-bottom: 1.5rem; font-size: 1.25rem; font-weight: 600; }
.auth-card form { display: flex; flex-direction: column; gap: 0.85rem; }
.auth-card label { font-size: 0.85rem; color: #b0b8c4; margin-bottom: -0.4rem; }
.auth-card input[type="email"],
.auth-card input[type="password"],
.auth-card input[type="text"] {
    background: #1a1d23; border: 1px solid #3a3f48; color: #e0e6ed;
    padding: 0.7rem 0.9rem; border-radius: 6px; font-size: 1rem; font-family: inherit;
    transition: border-color 0.15s; width: 100%;
}
.auth-card input:focus { outline: none; border-color: #4a9eff; }
.auth-card button {
    background: #4a9eff; color: #fff; border: none;
    padding: 0.75rem 1rem; border-radius: 6px; font-size: 1rem;
    font-weight: 600; cursor: pointer; margin-top: 0.5rem; transition: background 0.15s;
}
.auth-card button:hover { background: #2563eb; }

/* ============================================================
   Export / Code-Blocks
============================================================ */

.code-block {
    background: #0f1115; border: 1px solid #3a3f48; border-radius: 6px;
    padding: 1rem 1.25rem; color: #d8dde5;
    font-family: "SF Mono", Monaco, Consolas, "Courier New", monospace;
    font-size: 0.8rem; line-height: 1.5; overflow-x: auto;
    white-space: pre; margin: 0.5rem 0; user-select: all;
}

.export-section {
    background: #232830; border: 1px solid #3a3f48; border-radius: 8px;
    padding: 1.25rem 1.5rem; margin: 1rem 0;
}
.export-section h3 { margin-bottom: 0.75rem; color: #4a9eff; }
.export-user { border-top: 1px solid #2c3138; padding-top: 1rem; margin-top: 1rem; }
.export-user:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.export-user h4 { color: #fff; font-size: 1rem; margin-bottom: 0.5rem; }
.export-section details { margin-top: 0.5rem; }
.export-section details summary { cursor: pointer; color: #4a9eff; padding: 0.25rem 0; }
.export-section ol { margin-left: 1.5rem; color: #d8dde5; line-height: 1.8; }
.export-section ol code { background: #1a1d23; padding: 0.15rem 0.4rem; }

/* ============================================================
   Responsive: Mobile (<768px)
============================================================ */

@media (max-width: 768px) {
    /* Topbar: Hamburger sichtbar, Collapse versteckt */
    .nav-toggle { display: block; }

    .topbar-collapse {
        display: none;
        flex-direction: column;
        padding: 0 1.5rem 1rem;
        gap: 0.5rem;
    }

    .topbar.nav-open .topbar-collapse {
        display: flex;
    }

    .nav {
        flex-direction: column;
        gap: 0;
    }

    .nav a {
        padding: 0.65rem 0.75rem;
        border-radius: 6px;
        font-size: 0.95rem;
    }

    .user-menu {
        margin-left: 0;
        padding-top: 0.5rem;
        border-top: 1px solid #3a3f48;
        width: 100%;
        justify-content: space-between;
    }

    .user-email { max-width: none; }

    /* Content */
    .content { padding: 1.25rem 1rem; }
    .content h2 { font-size: 1.3rem; }

    /* Dashboard */
    .info-grid { grid-template-columns: 1fr; }

    /* Tables: horizontal scroll */
    .data-table { display: block; overflow-x: auto; }
    .data-table .actions { flex-direction: column; gap: 0.3rem; }

    /* Forms */
    .form-card { max-width: 100%; padding: 1.25rem; }
    .auth-card { padding: 1.5rem; }

    /* Tabs: scrollbar statt Umbruch */
    .tab-bar { -webkit-overflow-scrolling: touch; }

    /* Toolbar */
    .toolbar { flex-direction: column; }
    .toolbar .btn-primary { text-align: center; }

    /* Export code blocks */
    .code-block { font-size: 0.7rem; padding: 0.75rem; }
    .export-section { padding: 1rem; }
}

/* ============================================================
   Responsive: Tablet (768px - 1024px)
============================================================ */

@media (min-width: 769px) and (max-width: 1024px) {
    .info-grid { grid-template-columns: repeat(2, 1fr); }
    .user-email { max-width: 160px; }
}
