:root {
    --color-bg: #f6f5f3;
    --color-sidebar-bg: #ffffff;
    --color-accent: #d9bb8d;
    --color-accent-dark: #c9a876;
    --color-text: #2b2b2b;
    --color-text-muted: #9a9a9a;
    --color-card-bg: #ffffff;
    --color-border: #ececea;
    --color-active-bg: #f4ead9;
}

* { box-sizing: border-box; }
body {
    font-family: -apple-system, Segoe UI, Roboto, sans-serif;
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
}

/* Einheitliche goldene Umrandung bei Hover/Fokus für alle Formularelemente */
input, select, textarea { transition: border-color 0.15s ease; }
input:hover, select:hover, textarea:hover,
input:focus, select:focus, textarea:focus { border-color: var(--color-accent) !important; outline: none; }

/* --- Sidebar --- */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 230px;
    background: var(--color-sidebar-bg);
    border-right: 1px solid var(--color-border);
    padding: 1.75rem 1.25rem;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.sidebar-logo img { width: 110px; margin-bottom: 1.75rem; }
.sidebar-greeting { font-weight: 600; margin-bottom: 1.5rem; font-size: 0.92rem; }
.sidebar-nav { display: flex; flex-direction: column; gap: 0.2rem; flex-grow: 1; }
.sidebar-nav a {
    display: block;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.88rem;
}
.sidebar-nav a:hover { background: var(--color-bg); }
.sidebar-nav a.active { background: var(--color-active-bg); color: var(--color-accent-dark); font-weight: 600; }
.sidebar-logout {
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.82rem;
    padding: 0.55rem 0.75rem;
}
.sidebar-logout:hover { color: var(--color-text); }

.main-content { flex-grow: 1; min-width: 0; padding: 2.25rem 2.5rem; overflow-x: auto; }
.page-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.75rem; flex-wrap: wrap; }
.page-header h1 { font-size: 1.5rem; margin: 0; font-weight: 700; letter-spacing: -0.02em; }
.total-count { color: var(--color-text-muted); font-weight: 500; font-size: 1.1rem; }

.company-switch { display: flex; gap: 0.5rem; }

/* --- Zeitregler --- */
.period-picker { position: relative; display: flex; align-items: center; gap: 0.4rem; }
.period-arrow {
    width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--color-border);
    background: #fff; color: var(--color-text-muted); cursor: pointer; font-size: 0.9rem;
    display: flex; align-items: center; justify-content: center;
}
.period-arrow:hover { border-color: var(--color-accent); color: var(--color-accent-dark); }
.period-toggle {
    background: #fff; border: 1px solid var(--color-border); border-radius: 20px;
    padding: 0.5rem 1.1rem; font-size: 0.88rem; font-weight: 700; cursor: pointer;
    display: flex; align-items: center; gap: 0.4rem; color: var(--color-text); white-space: nowrap;
}
.period-toggle:hover { border-color: var(--color-accent); }
.period-chevron { font-size: 0.7rem; color: var(--color-text-muted); }

.period-dropdown {
    position: absolute; top: 110%; left: 50%; transform: translateX(-50%);
    background: #fff; border: 1px solid var(--color-border); border-radius: 14px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.1); padding: 1rem; z-index: 50; width: 300px;
}
.period-year-tabs { display: flex; gap: 0.3rem; margin-bottom: 0.85rem; flex-wrap: wrap; }
.period-year-tab {
    background: none; border: none; padding: 0.35rem 0.65rem; border-radius: 8px;
    font-size: 0.82rem; color: var(--color-text-muted); cursor: pointer; font-weight: 600;
}
.period-year-tab:hover { background: var(--color-bg); }
.period-year-tab.active { background: var(--color-active-bg); color: var(--color-accent-dark); }
.period-year-tab.active-year { box-shadow: inset 0 -2px 0 var(--color-accent); }

.period-month-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }
.period-month-btn {
    background: var(--color-bg); border: none; border-radius: 8px; padding: 0.5rem 0;
    font-size: 0.82rem; font-weight: 600; color: var(--color-text); cursor: pointer;
}
.period-month-btn:hover { background: var(--color-active-bg); }
.period-month-btn.active { background: var(--color-accent); color: #fff; }
.period-month-btn.no-data { color: var(--color-text-muted); font-weight: 500; }

.company-switch select {
    padding: 0.55rem 0.9rem;
    border-radius: 10px;
    border: 1px solid var(--color-border);
    background: #fff;
    color: var(--color-text);
    font-size: 0.87rem;
}

.search-wrap { position: relative; flex-grow: 1; max-width: 340px; }
.search-icon {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--color-text-muted); font-size: 0.95rem; pointer-events: none;
}
.search-input {
    width: 100%;
    padding: 0.55rem 0.9rem 0.55rem 2.1rem;
    border-radius: 10px;
    border: 1px solid var(--color-border);
    background: #fff;
    font-size: 0.87rem;
}
.search-input:focus { outline: none; border-color: var(--color-accent); }

/* --- Login --- */
.login-page { display: flex; align-items: center; justify-content: center; height: 100vh; background: var(--color-bg); }
.login-box { background: #fff; padding: 2.75rem; border-radius: 16px; box-shadow: 0 8px 30px rgba(0,0,0,0.06); width: 320px; text-align: center; }
.login-box img { width: 100px; margin-bottom: 1.5rem; }
.login-box label { display: block; margin-bottom: 1rem; font-size: 0.83rem; text-align: left; }
.login-box input {
    width: 100%; padding: 0.6rem 0.8rem; margin-top: 0.3rem;
    border: 1px solid var(--color-border); border-radius: 10px; font-size: 0.9rem;
}
.login-box input:focus { outline: none; border-color: var(--color-accent); }
.login-box button, .admin-main button, .stage-form button {
    background: var(--color-accent); color: #fff; border: none;
    padding: 0.65rem 1.3rem; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 0.88rem;
}
.login-box button:hover, .admin-main button:hover { background: var(--color-accent-dark); }
.error { color: #c0392b; font-size: 0.85rem; }
.success { color: #3d8f5b; padding: 0.5rem 0; font-size: 0.85rem; }

/* --- Funnel-Filter-Tabs --- */
.funnel-tabs { display: flex; gap: 0.4rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.funnel-tab {
    background: #fff; border: 1px solid var(--color-border); border-radius: 20px;
    padding: 0.4rem 1rem; font-size: 0.82rem; cursor: pointer; color: var(--color-text-muted);
}
.funnel-tab:hover { border-color: var(--color-accent); }
.funnel-tab.active { background: var(--color-active-bg); color: var(--color-accent-dark); border-color: var(--color-active-bg); font-weight: 600; }

/* --- Kanban-Board --- */
.board { display: flex; gap: 1.25rem; overflow-x: auto; padding-bottom: 1.1rem; align-items: flex-start; }
.board::-webkit-scrollbar { height: 10px; }
.board::-webkit-scrollbar-track { background: var(--color-bg); border-radius: 10px; }
.board::-webkit-scrollbar-thumb { background: var(--color-accent); border-radius: 10px; }
.board::-webkit-scrollbar-thumb:hover { background: var(--color-accent-dark); }
.board { scrollbar-width: thin; scrollbar-color: var(--color-accent) var(--color-bg); }
.column { background: transparent; border-radius: 14px; padding: 0 0.25rem; min-width: 290px; flex-shrink: 0; }
.column h2 { font-size: 0.85rem; margin: 0 0 1rem; display: flex; align-items: center; justify-content: space-between; font-weight: 500; }
.stage-pill-wrap { display: flex; align-items: center; gap: 0.3rem; }
.stage-pill { padding: 4px 12px; border-radius: 20px; font-size: 0.76rem; font-weight: 600; }
.count { color: var(--color-text-muted); font-weight: 500; font-size: 0.82rem; }

.stage-edit-btn, .stage-delete-btn {
    background: none; border: none; cursor: pointer; color: var(--color-text-muted);
    font-size: 0.8rem; padding: 2px 4px; border-radius: 4px; opacity: 0; transition: opacity 0.15s;
}
.column:hover .stage-edit-btn, .column:hover .stage-delete-btn { opacity: 1; }
.stage-edit-btn:hover { color: var(--color-accent-dark); }
.stage-delete-btn:hover { color: #c0392b; }

.lead-list { min-height: 40px; border-radius: 10px; transition: background 0.15s; }
.lead-list.drag-over { background: var(--color-active-bg); }

.add-column { display: flex; align-items: flex-start; padding-top: 0.1rem; }
.add-stage-btn {
    background: #fff; border: 1.5px dashed var(--color-border); border-radius: 10px;
    color: var(--color-text-muted); padding: 0.6rem 1rem; font-size: 0.82rem; cursor: pointer;
    width: 100%; min-width: 200px;
}
.add-stage-btn:hover { border-color: var(--color-accent); color: var(--color-accent-dark); }

.card {
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.85rem;
    font-size: 0.85rem;
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.card:hover { box-shadow: 0 6px 18px rgba(0,0,0,0.08); border-color: var(--color-accent); }
.card { cursor: grab; }
.card.dragging { opacity: 0.4; }

.card-header { display: flex; align-items: center; gap: 0.55rem; margin-bottom: 0.5rem; }
.card-avatar {
    width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--color-accent-dark); font-size: 0.78rem; font-weight: 700;
}
.card-line { color: var(--color-text); font-size: 0.82rem; margin-bottom: 0.15rem; }

.card-footer-row { display: flex; align-items: center; justify-content: space-between; margin: 0.6rem 0; }
.funnel-tag {
    display: inline-block; background: var(--color-active-bg); color: var(--color-accent-dark);
    font-size: 0.7rem; padding: 3px 10px; border-radius: 20px; font-weight: 600;
}
.meta { color: var(--color-text-muted); font-size: 0.74rem; }

.stage-select {
    width: 100%; margin-top: 0.25rem; padding: 0.4rem 0.5rem; border-radius: 8px;
    border: 1px solid var(--color-border); font-size: 0.8rem; background: var(--color-bg); color: var(--color-text);
}

.card-bottom-row { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.6rem; }

.comment-indicator {
    display: inline-flex; align-items: center; gap: 3px;
    color: var(--color-text-muted); font-size: 0.74rem; cursor: default; position: relative; flex-shrink: 0;
}
.comment-tooltip {
    display: none;
    position: absolute; left: 0; bottom: 100%; z-index: 20;
    background: #2b2b2b; color: #fff; padding: 0.6rem 0.75rem; border-radius: 10px;
    font-size: 0.76rem; width: 220px; margin-bottom: 6px; box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    white-space: pre-wrap;
}
.comment-indicator:hover .comment-tooltip { display: block; }

.comment-form { display: flex; gap: 0.35rem; flex-grow: 1; }
.comment-form input {
    flex-grow: 1; padding: 0.32rem 0.55rem; border-radius: 8px; border: 1px solid var(--color-border); font-size: 0.76rem;
    background: var(--color-bg);
}
.comment-form input:focus { outline: none; border-color: var(--color-accent); }
.comment-form button {
    background: var(--color-accent); color: #fff; border: none; border-radius: 8px;
    width: 26px; height: 26px; font-size: 0.85rem; cursor: pointer; flex-shrink: 0;
}
.comment-form button:hover { background: var(--color-accent-dark); }

/* --- Admin --- */
.admin-main section { background: var(--color-card-bg); border: 1px solid var(--color-border); border-radius: 14px; padding: 1.5rem; margin-bottom: 1.5rem; transition: border-color 0.15s ease; }
.admin-main section:hover { border-color: var(--color-accent); }
.admin-main h2 { font-size: 1rem; margin-top: 0; font-weight: 700; }
.admin-main h3 { font-weight: 600; }
.admin-main table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.admin-main th, .admin-main td { text-align: left; padding: 0.5rem 0.4rem; border-bottom: 1px solid var(--color-border); font-size: 0.84rem; }
.admin-main form { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.admin-main input, .admin-main select { padding: 0.5rem 0.7rem; border: 1px solid var(--color-border); border-radius: 8px; font-size: 0.85rem; }
code { font-size: 0.72rem; background: var(--color-bg); padding: 3px 6px; border-radius: 6px; }

.stage-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0; border-bottom: 1px solid var(--color-border); font-size: 0.85rem; }
.stage-row .stage-name { flex-grow: 1; }
.stage-row input[type=number] { width: 60px; }
.stage-row input[type=color] { width: 40px; height: 32px; padding: 2px; border-radius: 6px; }
.stage-row .delete-btn { background: none; border: none; color: #c0392b; cursor: pointer; font-size: 0.8rem; }

/* --- Detail-Modal --- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(20,18,15,0.45);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 4vh 1rem; z-index: 100; overflow-y: auto;
}
.modal-box {
    background: #fff; border-radius: 16px; width: 100%; max-width: 560px;
    padding: 1.75rem; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    max-height: 92vh; overflow-y: auto; box-sizing: border-box;
}
@media (max-width: 640px) {
    .modal-overlay { padding: 0; align-items: stretch; }
    .modal-box { max-width: 100%; max-height: 100vh; border-radius: 0; min-height: 100vh; }
}
.modal-close {
    position: absolute; top: 1rem; right: 1.1rem; background: none; border: none;
    font-size: 1.4rem; color: var(--color-text-muted); cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--color-text); }
.modal-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.25rem; }
.modal-header h2 { margin: 0; font-size: 1.15rem; }
.modal-header .card-avatar { width: 42px; height: 42px; font-size: 1rem; }
.modal-subhead { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted); margin: 1.25rem 0 0.5rem; }
.modal-section { border-top: 1px solid var(--color-border); padding-top: 0.75rem; }
.modal-section:first-of-type { border-top: none; padding-top: 0; }

.detail-row { display: flex; gap: 0.75rem; padding: 0.35rem 0; font-size: 0.84rem; border-bottom: 1px solid #f5f3f0; }
.detail-label { color: var(--color-text-muted); min-width: 40%; flex-shrink: 0; }
.detail-value { color: var(--color-text); word-break: break-word; }
@media (max-width: 640px) {
    .detail-row { flex-direction: column; gap: 0.15rem; }
    .detail-label { min-width: 0; font-size: 0.76rem; }
}

.note-item { padding: 0.6rem 0; border-bottom: 1px solid #f5f3f0; font-size: 0.84rem; }
.note-item:last-child { border-bottom: none; }
.note-meta { color: var(--color-text-muted); font-size: 0.72rem; margin-bottom: 0.15rem; }
