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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    background: #f4f6f9;
    color: #333;
    padding-top: 48px;
}

/* Nav */
nav {
    background: #0078d4;
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    padding: 0 12px;
    min-height: 48px;
}
.nav-brand {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    color: #fff;
    padding-right: 16px;
    flex-shrink: 0;
    text-decoration: none;
}
.nav-brand:hover { opacity: 0.85; }
.nav-version {
    font-size: 11px;
    font-weight: 400;
    opacity: 0.65;
    margin-left: 5px;
}
.nav-links {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex: 1;
}
.nav-links::-webkit-scrollbar { display: none; }
nav ul { list-style: none; display: flex; gap: 2px; }
nav a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 4px;
    transition: background 0.15s;
    white-space: nowrap;
    display: block;
    font-size: 13px;
}
nav a:hover { background: rgba(255,255,255,0.15); }
nav a.active { background: rgba(255,255,255,0.25); color: #fff; font-weight: 600; }
nav a.nav-planned { opacity: 0.45; cursor: default; }
nav a.nav-planned:hover { background: none; }
.nav-sub-tab.nav-planned { opacity: 0.4; cursor: default; color: #94a3b8; }
.nav-sub-tab.nav-planned:hover { color: #94a3b8; }
.nav-planned-badge { font-size: 9px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; background: rgba(255,255,255,0.25); border-radius: 3px; padding: 1px 4px; margin-left: 4px; vertical-align: middle; }
.nav-sub-tab .nav-planned-badge { background: #e2e8f0; color: #94a3b8; }

/* Sub-tabs (Signaturen: Vorlagen / Vorschau) */
.nav-sub-tabs {
    list-style: none;
    display: flex;
    gap: 0;
    padding: 0;
    margin: 0 0 24px;
    border-bottom: 2px solid #e2e8f0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    white-space: nowrap;
    flex-wrap: nowrap;
}
.nav-sub-tabs::-webkit-scrollbar { display: none; }
.nav-sub-tab {
    display: block;
    padding: 9px 20px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    color: #64748b;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}
.nav-sub-tab:hover { color: #2563eb; }
.nav-sub-tab.active { color: #2563eb; border-bottom-color: #2563eb; }

/* Hamburger toggle — hidden on wide screens */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px 6px;
    margin-left: auto;
    flex-direction: column;
    gap: 5px;
    flex-shrink: 0;
}
.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: rgba(255,255,255,0.9);
    border-radius: 2px;
}
.nav-toggle:hover span { background: #fff; }

@media (max-width: 600px) {
    .nav-toggle { display: flex; }
    .nav-links {
        display: none;
        position: absolute;
        top: 48px;
        left: 0;
        right: 0;
        background: #0068c0;
        padding: 6px 8px 10px;
        box-shadow: 0 6px 16px rgba(0,0,0,0.25);
        border-top: 1px solid rgba(255,255,255,0.15);
    }
    .nav-links.open { display: block; }
    nav ul { flex-direction: column; gap: 2px; }
    nav a { padding: 10px 12px; font-size: 14px; border-radius: 6px; }
}

/* Main */
main { max-width: 960px; margin: 32px auto; padding: 0 24px; }
@media (max-width: 600px) {
    main { margin: 12px auto; padding: 0 10px; }
    h1 { font-size: 18px; margin-bottom: 16px; }
    .preview-form { flex-direction: column; align-items: flex-start; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    /* Override inline width styles that cause horizontal overflow */
    select, input[type="text"], input[type="email"], input[type="url"],
    input[type="password"], input[type="number"], textarea {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }
}
@media (max-width: 380px) {
    .stats-grid { grid-template-columns: 1fr; }
}
h1 { font-size: 22px; font-weight: 600; margin-bottom: 24px; }
h2 { font-size: 16px; font-weight: 600; margin: 24px 0 12px; }
h3 { font-size: 13px; font-weight: 600; margin: 16px 0 8px; color: #555; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.stat-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    border-top: 4px solid #0078d4;
}
.stat-card.warn { border-top-color: #f59e0b; }
.stat-card.error { border-top-color: #ef4444; }
.stat-value { font-size: 36px; font-weight: 700; color: #0078d4; }
.stat-card.warn .stat-value { color: #f59e0b; }
.stat-card.error .stat-value { color: #ef4444; }
.stat-label { margin-top: 6px; color: #666; font-size: 13px; }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 13px;
}
.alert.success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert.error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert.warn    { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* Forms / Editor */
.editor-section { margin-bottom: 20px; }
label { display: block; margin-bottom: 6px; font-weight: 500; }
textarea {
    width: 100%;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 12px;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fafafa;
    resize: vertical;
    line-height: 1.5;
}
textarea:focus { outline: none; border-color: #0078d4; box-shadow: 0 0 0 2px rgba(0,120,212,0.15); }

input[type="email"], input[type="text"] {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    width: 320px;
    max-width: 100%;
}
input:focus { outline: none; border-color: #0078d4; }

.preview-form { display: flex; gap: 12px; align-items: center; margin-bottom: 24px; }
.preview-form label { margin: 0; white-space: nowrap; }

/* Buttons */
.actions { display: flex; gap: 12px; margin-top: 8px; }
.btn {
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    border: none;
    display: inline-block;
}
.btn.primary { background: #0078d4; color: #fff; }
.btn.primary:hover { background: #106ebe; }
.btn.secondary { background: #e5e7eb; color: #333; }
.btn.secondary:hover { background: #d1d5db; }

/* Preview */
.preview-frame {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 24px;
    margin-bottom: 16px;
}

/* Code block */
.code-block {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 16px;
    border-radius: 6px;
    font-size: 12px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Config table */
.config-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; border: 1px solid #e0e0e0; }
.config-table th { background: #f1f5f9; text-align: left; padding: 10px 16px; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: #666; }
.config-table td { padding: 10px 16px; border-top: 1px solid #f0f0f0; }
.config-table tr:hover td { background: #f8fafc; }
.config-table code { background: #eef2f7; padding: 2px 6px; border-radius: 4px; font-size: 12px; }

/* Hint */
.hint { color: #666; font-size: 12px; margin-top: 4px; }
.hint code { background: #eef2f7; padding: 2px 6px; border-radius: 4px; }

/* S/MIME user card header */
.user-hdr {
    background: #f8fafc;
    padding: 9px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 6px 6px 0 0;
    flex-wrap: wrap;
}
.user-hdr-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}
.user-hdr-actions {
    display: flex;
    gap: 7px;
    align-items: center;
    flex-wrap: wrap;
    flex-shrink: 0;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}
@media (max-width: 600px) {
    .user-hdr-actions { width: 100%; }
}

/* Settings */
.settings-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 20px;
}
.settings-card h2 { margin: 0 0 16px; font-size: 15px; color: #0078d4; }
.settings-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.settings-row label:first-child {
    min-width: 200px;
    font-weight: 500;
    padding-top: 6px;
    flex-shrink: 0;
}
.settings-control { display: flex; flex-direction: column; gap: 4px; }
.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    font-weight: 400 !important;
    padding-top: 0 !important;
    min-width: unset !important;
    cursor: pointer;
}
input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: #0078d4;
    cursor: pointer;
    flex-shrink: 0;
}
select {
    padding: 7px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    min-width: 140px;
}
select:focus { outline: none; border-color: #0078d4; }
input[type="number"] {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    width: 100px;
}

/* Key-value table */
.kv-table { width: 100%; border-collapse: collapse; margin-bottom: 4px; }
.kv-table th {
    text-align: left; padding: 6px 8px;
    font-size: 11px; text-transform: uppercase;
    color: #888; font-weight: 600; letter-spacing: 0.04em;
}
.kv-table td { padding: 4px 6px 4px 0; }
.kv-table input { width: 100%; }

/* Small button */
.btn-sm { padding: 4px 10px; font-size: 12px; }

@media (max-width: 600px) {
    .settings-row { flex-direction: column; }
    .settings-row label:first-child { min-width: unset; padding-top: 0; }
}

/* ── Log viewer ────────────────────────────────────────────────────────────── */
.log-wrap {
    background: #0d1117;
    border-radius: 8px;
    border: 1px solid #30363d;
    min-height: 300px;
    overflow-y: auto;
    overflow-x: auto;
}
.log-pre {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 12px;
    line-height: 1.55;
    color: #c9d1d9;
    padding: 12px 16px;
    margin: 0;
    white-space: pre;
    min-height: 100%;
}
.log-pre .log-error    { color: #ff7b72; }
.log-pre .log-critical { color: #ff7b72; font-weight: 700; }
.log-pre .log-warn     { color: #e3b341; }
.log-pre .log-debug    { color: #8b949e; }
.log-status {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
}
.log-status.live       { background: #dcfce7; color: #16a34a; }
.log-status.connecting { background: #fef3c7; color: #b45309; }

/* ── Setup Wizard ──────────────────────────────────────────────────────────── */
.wizard-step {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 16px;
    overflow: hidden;
    transition: border-color 0.2s;
}
.wizard-step.done {
    border-left: 4px solid #22c55e;
}
.wizard-step:not(.done) {
    border-left: 4px solid #e0e0e0;
}

.step-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #f0f0f0;
    flex-wrap: wrap;
}
.wizard-step.done .step-header {
    background: #f0fdf4;
}

.step-badge {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #0078d4;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.wizard-step.done .step-badge {
    background: #22c55e;
}

.step-title {
    font-size: 14px;
    font-weight: 600;
    color: #222;
    flex: 1;
}

.step-status {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 500;
    white-space: nowrap;
}
.step-status.done    { background: #dcfce7; color: #16a34a; }
.step-status.pending { background: #fef3c7; color: #b45309; }
.step-status.waiting { background: #f1f5f9; color: #64748b; }

.step-body {
    padding: 16px 20px 20px;
}
.step-body .hint { color: #666; font-size: 13px; }
.step-body ul { color: #555; font-size: 13px; }
.step-body .alert { margin-bottom: 0; }

/* password strength nag */
input[type="password"] {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    width: 260px;
    max-width: 100%;
}
input[type="password"]:focus { outline: none; border-color: #0078d4; }

/* Email address in user card — truncate with ellipsis rather than overflow */
.user-hdr-info strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-hdr-info span { flex-shrink: 0; }

/* Pill toggle buttons (log controls) */
.btn-toggle {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid #d1d5db;
    background: #f3f4f6;
    color: #555;
    white-space: nowrap;
    line-height: 1.4;
}
.btn-toggle.active {
    background: #0078d4;
    color: #fff;
    border-color: #0078d4;
}
.btn-toggle:hover:not(.active) { background: #e5e7eb; }

/* Mobile overrides that must come after component definitions to win the cascade */
@media (max-width: 600px) {
    .settings-card { padding: 14px 12px; }
    .config-table { font-size: 12px; }
    .config-table th, .config-table td { padding: 8px 10px; }
    .nav-online-text { display: none; }
}
