:root {
    --primary: #2c5f6e;
    --bg: #f5f6f7;
    --border: #d8dcdf;
    --error: #b3261e;
    --info: #2c5f6e;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    margin: 0;
    background: var(--bg);
    color: #222;
}

.content {
    max-width: 900px;
    margin: 32px auto;
    padding: 0 16px;
}

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
}

.login-box {
    background: #fff;
    padding: 32px;
    border-radius: 8px;
    border: 1px solid var(--border);
    width: 320px;
}

.login-box h1 { margin-top: 0; color: var(--primary); }

form label {
    display: block;
    margin: 12px 0 4px;
    font-size: 14px;
}

input[type=text], input[type=password], input[type=email] {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
}

fieldset { border: 1px solid var(--border); border-radius: 4px; margin-top: 12px; }

button {
    margin-top: 16px;
    padding: 8px 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

button:hover { opacity: 0.9; }

.error { color: var(--error); }
.info { color: var(--info); font-weight: 600; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    background: #fff;
}

.data-table th, .data-table td {
    border: 1px solid var(--border);
    padding: 6px 10px;
    text-align: left;
    font-size: 14px;
    line-height: 1.3;
}

.data-table th { background: #eef1f2; }

.truncate-cell {
    display: inline-block;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.list-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 12px;
    flex-wrap: wrap;
}

.search-form { display: flex; gap: 8px; }
.search-form input { padding: 8px; border: 1px solid var(--border); border-radius: 4px; min-width: 260px; }
.search-form button { margin-top: 0; }

.btn-link {
    background: var(--primary);
    color: #fff;
    padding: 8px 14px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
}
.btn-link:hover { opacity: 0.9; }

.muted { color: #777; font-size: 14px; }

.detail-block {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px 20px;
    margin-bottom: 16px;
}

.detail-block h2 {
    margin-top: 0;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--primary);
}

.notes-text { white-space: pre-wrap; }

.inline-check {
    display: inline-block;
    margin: 4px 12px 4px 0;
    font-weight: normal;
}

.inline-form {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-top: 12px;
}
.inline-form label { margin: 0; }

textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: inherit;
}

.form-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 24px;
}
.form-grid-2col label { margin: 12px 0 4px; }

@media (max-width: 700px) {
    .form-grid-2col { grid-template-columns: 1fr; }
}

.content-wide { max-width: 1200px; }

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 16px;
}

.tab-link {
    padding: 10px 16px;
    text-decoration: none;
    color: #444;
    background: #eef1f2;
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    font-size: 14px;
}

.tab-link.active {
    background: #fff;
    color: var(--primary);
    font-weight: 600;
    border-bottom: 2px solid #fff;
    margin-bottom: -2px;
}

.tab-panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 0 6px 6px 6px;
    padding: 20px;
}

.badge {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 12px;
    margin-left: 4px;
}

.task-done { opacity: 0.55; text-decoration: line-through; }
.task-done .badge { text-decoration: none; }

/* --- Persistente Top-Navigation --- */
.topbar {
    background: var(--primary);
    color: #fff;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    height: 52px;
}

.topbar-left { display: flex; align-items: center; gap: 24px; }
.brand { font-weight: 700; font-size: 16px; letter-spacing: 0.03em; }

.main-nav { display: flex; align-items: center; gap: 4px; height: 100%; }

.main-nav > a {
    color: #dfe9ec;
    text-decoration: none;
    padding: 0 12px;
    height: 52px;
    display: flex;
    align-items: center;
    font-size: 14px;
}

.main-nav > a:hover,
.main-nav > a.active {
    color: #fff;
    background: rgba(255,255,255,0.12);
}

.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-right a { color: #fff; text-decoration: underline; }

.dropdown { position: relative; height: 100%; }

.dropdown-toggle {
    color: #dfe9ec;
    text-decoration: none;
    padding: 0 12px;
    height: 52px;
    display: flex;
    align-items: center;
    font-size: 14px;
}
.dropdown-toggle:hover, .dropdown-toggle.active { color: #fff; background: rgba(255,255,255,0.12); }

.dropdown-menu {
    display: none;
    position: absolute;
    top: 52px;
    left: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 0 0 6px 6px;
    min-width: 200px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.12);
    z-index: 10;
}

.dropdown:hover .dropdown-menu,
.dropdown:focus-within .dropdown-menu { display: block; }

.dropdown-menu a {
    display: block;
    padding: 10px 16px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
}
.dropdown-menu a:hover { background: #eef1f2; }

.page-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

/* --- Notizen (mehrere pro Kontakt) --- */
.note-entry {
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
}
.note-entry:last-of-type { border-bottom: none; }
.note-meta { font-size: 12px; color: #777; margin-bottom: 4px; }
.note-text { white-space: pre-wrap; }

/* --- Aufgaben-Priorität --- */
.priority-flag {
    color: #c0392b;
    font-weight: 700;
    font-size: 13px;
    white-space: nowrap;
}
.priority-text { color: #c0392b; font-weight: 600; }

/* --- Custom-Field-Checkboxen im Raster --- */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px 20px;
}
.checkbox-grid-view span { font-size: 14px; }
.cf-checked { color: #222; font-weight: 600; }
.cf-unchecked { color: #999; }

@media (max-width: 900px) {
    .checkbox-grid { grid-template-columns: repeat(2, 1fr); }
}

/* --- Custom-Field-Übersicht (Admin) und gruppierte Anzeige (Kontakt) --- */
.cf-overview, .cf-grouped {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-top: 12px;
}
.cf-overview-col h3, .cf-grouped-col h3 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
    margin: 0 0 8px;
}
.cf-overview-col ul { margin: 0; padding-left: 18px; font-size: 14px; }
.cf-overview-col li { margin-bottom: 3px; }
.cf-grouped-col label { display: block; margin-bottom: 6px; font-weight: normal; }
.cf-grouped-col .cf-checked, .cf-grouped-col .cf-unchecked { display: block; margin-bottom: 6px; }

@media (max-width: 640px) {
    .cf-overview, .cf-grouped { grid-template-columns: repeat(2, 1fr); }
}

/* --- Erweiterte Filter (Kontaktliste) --- */
.filter-details {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 16px;
    padding: 4px 16px;
}
.filter-details summary {
    cursor: pointer;
    padding: 10px 0;
    font-weight: 600;
    color: var(--primary);
    list-style: none;
}
.filter-details summary::-webkit-details-marker { display: none; }
.filter-details summary::before { content: '▸ '; }
.filter-details[open] summary::before { content: '▾ '; }

.filter-panel { padding: 8px 0 16px; }
.filter-section { margin-bottom: 20px; }
.filter-section h3 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--primary);
    margin: 0 0 8px;
}
.inline-check-list { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.filter-actions { display: flex; gap: 12px; align-items: center; }

/* --- Gruppen-Farb-Chips --- */
.group-chip {
    display: inline-block;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    margin: 1px 3px 1px 0;
    white-space: nowrap;
    text-shadow: 0 1px 1px rgba(0,0,0,0.25);
}
.color-swatch {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.15);
    vertical-align: middle;
}

.sync-success-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #e6f4ea;
    border: 1px solid #34a853;
    border-radius: 6px;
    padding: 14px 18px;
    margin-bottom: 16px;
    color: #1e4620;
}
.sync-success-icon {
    background: #34a853;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    flex-shrink: 0;
}

/* --- Kompaktes Kontakt-Profil (Main-Tab) --- */
.profile-header { margin-bottom: 20px; }
.profile-name { font-size: 26px; margin: 0 0 6px; }
.profile-contact-line { display: flex; gap: 20px; margin-bottom: 8px; font-size: 15px; }
.profile-contact-line a { color: var(--primary); text-decoration: none; }
.profile-contact-line a:hover { text-decoration: underline; }
.profile-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.category-chip {
    display: inline-block;
    background: #eef1f2;
    color: #444;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    margin: 1px 3px 1px 0;
}
.profile-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}
.profile-box {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px 20px;
    margin-bottom: 16px;
}
.profile-box h3 {
    margin-top: 0;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--primary);
}
.compact-list { margin: 0 0 10px; padding-left: 18px; font-size: 14px; }
.compact-list li { margin-bottom: 4px; }
@media (max-width: 900px) {
    .profile-grid { grid-template-columns: 1fr; }
}
