:root {
    --color-bg: #f4f5f7;
    --color-surface: #ffffff;
    --color-border: #e2e4e9;
    --color-text: #1f2430;
    --color-text-muted: #6b7280;
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;

    --status-erfasst: #64748b;
    --status-in_bearbeitung: #2563eb;
    --status-erledigt: #16a34a;
    --status-onhold: #ea580c;

    --step-none-bg: #ffffff;
    --step-none-border: #d1d5db;
    --step-angefragt-bg: #fde68a;
    --step-angefragt-border: #d97706;
    --step-erhalten-bg: #bbf7d0;
    --step-erhalten-border: #16a34a;
    --step-abgelehnt-bg: #fecaca;
    --step-abgelehnt-border: #dc2626;

    --radius: 8px;
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow-lg: 0 10px 30px rgba(16, 24, 40, 0.18);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 14px;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Topbar */
.topbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.topbar h1 { font-size: 18px; margin: 0; }
.topbar h1 a { color: var(--color-text); }
.topbar-nav { display: flex; align-items: center; gap: 18px; color: var(--color-text-muted); }

.page { padding: 24px; max-width: 1600px; margin: 0 auto; }

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.toolbar-filters { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.search-input {
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    min-width: 220px;
    font-size: 14px;
}

.status-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    cursor: pointer;
    font-size: 13px;
    color: var(--color-text-muted);
    user-select: none;
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; }
.status-pill.active {
    color: #fff;
    border-color: transparent;
}
.status-pill.active .dot { background: #fff; }

/* Buttons */
.btn {
    padding: 8px 16px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-secondary { background: var(--color-surface); border-color: var(--color-border); color: var(--color-text); }
.btn-secondary:hover { background: var(--color-bg); }
.btn-small { padding: 5px 12px; font-size: 13px; }

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    font-size: 14px;
    line-height: 1;
    padding: 4px;
}
.icon-btn:hover { color: var(--color-text); }

/* Table */
.table-wrapper {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
    border: 1px solid var(--color-border);
}
.loading, .empty-state { padding: 40px; text-align: center; color: var(--color-text-muted); }

table.projects-table {
    border-collapse: collapse;
    width: 100%;
    min-width: 1100px;
}
table.projects-table th, table.projects-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    vertical-align: middle;
}
table.projects-table thead th {
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: var(--color-surface);
    position: sticky;
    top: 0;
    z-index: 2;
}
table.projects-table tbody tr:hover { background: #fafbfc; }

.col-name {
    position: sticky;
    left: 0;
    background: var(--color-surface);
    z-index: 1;
    min-width: 220px;
    max-width: 280px;
    box-shadow: 2px 0 4px rgba(0,0,0,0.03);
}
table.projects-table tbody tr:hover .col-name { background: #fafbfc; }

.name-cell-inner { display: flex; align-items: center; gap: 4px; }

.project-name {
    font-weight: 600;
    background: none;
    border: none;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: text;
    flex: 1;
    min-width: 0;
    font-size: 14px;
    color: var(--color-text);
}
.project-name:hover, .project-name:focus { background: var(--color-bg); outline: none; }

.project-note-btn {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-muted);
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.5;
}
.project-note-btn:hover { opacity: 1; }
.project-note-btn.has-note {
    background: #fef3c7;
    border-color: #d97706;
    color: #92400e;
    opacity: 1;
}

.project-dropbox-btn {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-muted);
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.5;
}
.project-dropbox-btn:hover { opacity: 1; }
.project-dropbox-btn.has-link {
    background: #dbeafe;
    border-color: #2563eb;
    color: #1d4ed8;
    opacity: 1;
}

.col-step { text-align: center; width: 46px; }
.step-header-label {
    display: inline-block;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    white-space: nowrap;
    font-size: 11px;
    max-height: 140px;
}

.col-status { min-width: 150px; }
.col-lastmod { min-width: 130px; color: var(--color-text-muted); white-space: nowrap; }
.col-actions { width: 40px; text-align: center; }

.status-select {
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 22px;
}

/* Step cell */
.step-cell { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.step-btn {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1.5px solid var(--step-none-border);
    background: var(--step-none-bg);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: transparent;
    padding: 0;
}
.step-btn[data-value="angefragt"] { background: var(--step-angefragt-bg); border-color: var(--step-angefragt-border); }
.step-btn[data-value="erhalten"] { background: var(--step-erhalten-bg); border-color: var(--step-erhalten-border); color: #14532d; }
.step-btn[data-value="abgelehnt"] { background: var(--step-abgelehnt-bg); border-color: var(--step-abgelehnt-border); color: #991b1b; }
.step-btn[data-value="erhalten"]::after { content: "✓"; }
.step-btn[data-value="angefragt"]::after { content: "?"; color: #92400e; }
.step-btn[data-value="abgelehnt"]::after { content: "✕"; color: #991b1b; }

.note-indicator {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #f59e0b;
    border: 2px solid var(--color-surface);
    display: none;
    cursor: pointer;
}
.note-indicator.has-note { display: block; }

.note-add-trigger {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 9px;
    line-height: 12px;
    text-align: center;
    cursor: pointer;
    opacity: 0;
}
.step-cell:hover .note-add-trigger { opacity: 1; }
.note-indicator.has-note ~ .note-add-trigger { display: none; }

.delete-btn { color: #dc2626; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}
.modal-overlay.hidden { display: none; }
.modal {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 24px;
    width: 100%;
    max-width: 420px;
}
.modal h2 { margin-top: 0; }
.modal form label { display: block; margin-bottom: 14px; font-weight: 500; }
.modal form input {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 14px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* Popover */
.popover {
    position: absolute;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 12px;
    width: 260px;
    z-index: 60;
}
.popover.hidden { display: none; }
.popover-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.popover textarea, .popover input[type="url"] {
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 8px;
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
}
.popover-actions { display: flex; justify-content: flex-end; margin-top: 8px; gap: 8px; }
.popover-actions-split { justify-content: space-between; }
.popover-actions-split .btn-secondary.disabled {
    pointer-events: none;
    opacity: 0.4;
}

/* Auth pages */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--color-bg);
}
.auth-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px;
    width: 100%;
    max-width: 360px;
}
.auth-card h1 { margin: 0 0 4px; font-size: 20px; }
.auth-subtitle { color: var(--color-text-muted); margin-top: 0; margin-bottom: 20px; }
.auth-form label { display: block; margin-bottom: 14px; font-weight: 500; font-size: 13px; }
.auth-form input {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 9px 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 14px;
}
.auth-form .btn { width: 100%; margin-top: 6px; }

.alert { padding: 10px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }

/* Simple table (users page) */
.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 24px; background: var(--color-surface); padding: 16px; border-radius: var(--radius); border: 1px solid var(--color-border); }
.inline-form label { font-size: 13px; font-weight: 500; }
.inline-form input { display: block; margin-top: 4px; padding: 7px 10px; border: 1px solid var(--color-border); border-radius: 6px; }
.simple-table { width: 100%; border-collapse: collapse; background: var(--color-surface); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--color-border); }
.simple-table th, .simple-table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--color-border); }
.simple-table thead { background: var(--color-bg); }

@media (max-width: 700px) {
    .page { padding: 12px; }
    .toolbar { flex-direction: column; align-items: stretch; }
}
