/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --red: #dc2626;
    --red-bg: #fef2f2;
    --red-border: #fca5a5;
    --orange: #d97706;
    --orange-bg: #fffbeb;
    --orange-border: #fcd34d;
    --green: #16a34a;
    --green-bg: #f0fdf4;
    --green-border: #86efac;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --white: #ffffff;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.5;
    min-height: 100vh;
}

/* === Navbar === */
.navbar {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 0 1.5rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand a {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--gray-900);
    text-decoration: none;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-user {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.nav-logout { display: inline; }

/* === Nav Dropdown === */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle {
    cursor: pointer;
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.25rem;
    min-width: 220px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    z-index: 200;
    padding: 0.25rem 0;
}

.nav-dropdown-menu a {
    display: block;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: var(--gray-700);
    text-decoration: none;
}

.nav-dropdown-menu a:hover {
    background: var(--gray-100);
}

.nav-dropdown.open .nav-dropdown-menu {
    display: block;
}

/* === Container === */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--gray-700);
    font-size: 0.875rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}
.btn:hover { background: var(--gray-100); }
.btn-primary { background: var(--gray-900); color: var(--white); border-color: var(--gray-900); }
.btn-primary:hover { background: var(--gray-700); }
.btn-ghost { border: none; background: transparent; }
.btn-ghost:hover { background: var(--gray-100); }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }

/* === Auth Pages === */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
}

.auth-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-md);
}

.auth-card h1 {
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 0.25rem;
}

.auth-subtitle {
    text-align: center;
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

/* === Forms === */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--gray-700);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.875rem;
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--gray-900);
    box-shadow: 0 0 0 1px var(--gray-900);
}

/* === TOTP === */
.totp-qr {
    text-align: center;
    margin: 1.5rem 0;
}
.totp-qr img { max-width: 200px; border-radius: var(--radius); }

.totp-manual {
    margin-bottom: 1.5rem;
    font-size: 0.8rem;
    text-align: center;
}
.totp-secret {
    display: block;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: var(--gray-100);
    border-radius: 4px;
    word-break: break-all;
    font-size: 0.75rem;
}

/* === Alerts === */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}
.alert-error { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }
.alert-warning { background: var(--orange-bg); color: var(--orange); border: 1px solid var(--orange-border); }
.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }

/* === Dashboard === */
.dashboard h1 { margin-bottom: 0.25rem; }
.dashboard-subtitle { color: var(--gray-500); font-size: 0.875rem; margin-bottom: 1.5rem; }

.ampel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.ampel-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--gray-900);
    transition: all 0.15s;
    border-left: 4px solid var(--gray-300);
}
.ampel-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.ampel-red { border-left-color: var(--red); background: #fecaca; }
.ampel-orange { border-left-color: var(--orange); background: #fed7aa; }
.ampel-green { border-left-color: var(--green); }
.ampel-gray { border-left-color: var(--gray-300); background: var(--gray-100); }

.ampel-indicator { flex-shrink: 0; }

.ampel-dot {
    display: block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--gray-300);
}
.ampel-dot-red { background: var(--red); box-shadow: 0 0 8px rgba(220,38,38,0.4); }
.ampel-dot-orange { background: var(--orange); box-shadow: 0 0 8px rgba(217,119,6,0.4); }
.ampel-dot-green { background: var(--green); }
.ampel-dot-gray { background: var(--gray-300); }

.count-gray { color: var(--gray-500); }

.ampel-content { flex: 1; }
.ampel-content h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.25rem; }

.ampel-counts { font-size: 0.8rem; }
.count-red { color: var(--red); font-weight: 500; }
.count-orange { color: var(--orange); font-weight: 500; }
.count-green { color: var(--green); }

.ampel-total {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-500);
    flex-shrink: 0;
    min-width: 2rem;
    text-align: center;
}

/* === Issues List === */
.page-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.page-header h1 { flex: 1; }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-count { background: var(--gray-200); color: var(--gray-700); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-green { background: var(--green-bg); color: var(--green); }

.issues-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.issue-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--gray-900);
    transition: all 0.15s;
}
.issue-row:hover { box-shadow: var(--shadow); }

.issue-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.issue-dot-red { background: var(--red); }
.issue-dot-orange { background: var(--orange); }
.issue-dot-green { background: var(--green); }

.issue-info { flex: 1; }
.issue-title { font-weight: 500; }
.issue-meta { font-size: 0.8rem; color: var(--gray-500); margin-top: 0.2rem; }
.issue-locked { color: var(--orange); font-weight: 500; }
.issue-plenty-link { color: var(--gray-700); font-weight: 500; cursor: pointer; text-decoration: underline; }
.issue-plenty-link:hover { color: var(--gray-900); }
.issue-severity { font-size: 0.8rem; font-weight: 500; color: var(--gray-500); }
.detail-plenty { margin-bottom: 0.5rem; }

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--gray-500);
}

/* === Issue Detail === */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
    .detail-grid { grid-template-columns: 1fr; }
    .ampel-grid { grid-template-columns: 1fr; }
}

.detail-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}
.detail-card h2 { font-size: 1.1rem; margin-bottom: 1rem; }
.detail-card h3 { font-size: 0.95rem; margin: 1rem 0 0.5rem; }

.detail-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 1rem;
    font-size: 0.875rem;
}
.detail-list dt { color: var(--gray-500); font-weight: 500; }
.detail-list dd { color: var(--gray-900); }

.detail-description { font-size: 0.875rem; line-height: 1.6; }

.detail-source { margin-top: 1rem; font-size: 0.8rem; }
.detail-source pre {
    background: var(--gray-100);
    padding: 0.75rem;
    border-radius: var(--radius);
    overflow-x: auto;
    font-size: 0.75rem;
    margin-top: 0.5rem;
}

/* AI Card */
.ai-card { border-left: 4px solid #8b5cf6; }
.ai-analysis { font-size: 0.875rem; line-height: 1.6; }

.ai-suggestions { display: flex; flex-direction: column; gap: 0.5rem; }
.suggestion-card {
    padding: 0.75rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}
.suggestion-title { font-weight: 600; font-size: 0.875rem; }
.suggestion-description { font-size: 0.8rem; color: var(--gray-500); margin: 0.25rem 0; }

.text-muted { color: var(--gray-500); font-size: 0.875rem; }

/* === Action Area === */
.action-area {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}
.action-area h2 { font-size: 1.1rem; margin-bottom: 1rem; }

.action-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}
