*, *::before, *::after { box-sizing: border-box; }
:root {
    --bg: #f5f6f8;
    --panel: #fff;
    --border: #e6e7ec;
    --border-soft: #f0f1f4;
    --text: #0f172a;
    --muted: #6b7280;
    --accent: #0f172a;
    --primary: #2563eb;
    --primary-soft: #dbeafe;
    --status-planned: #94a3b8;
    --status-active: #3b82f6;
    --status-blocked: #f59e0b;
    --status-done: #10b981;
    --warn: #ef4444;
    --shadow-sm: 0 1px 2px rgba(15,23,42,0.04);
    --shadow: 0 1px 2px rgba(15,23,42,0.04), 0 6px 16px rgba(15,23,42,0.06);
    --shadow-lg: 0 18px 48px rgba(15,23,42,0.18);
    --radius: 8px;
    --radius-lg: 14px;
    --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; -webkit-font-smoothing: antialiased; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* LOGIN */
body.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #f5f6f8 0%, #e8ecf3 100%); }
.login-card {
    background: var(--panel); padding: 44px 40px; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); width: 360px; text-align: center;
}
.login-logo {
    font-size: 32px; line-height: 1; color: var(--primary);
    background: var(--primary-soft);
    width: 56px; height: 56px; margin: 0 auto 18px;
    border-radius: 14px; display: flex; align-items: center; justify-content: center;
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; font-weight: 600; }
.login-card p { margin: 0 0 28px; color: var(--muted); font-size: 13px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input {
    padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 15px; outline: none; transition: border-color .15s, box-shadow .15s;
    background: #fff;
}
.login-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.login-card button {
    padding: 12px; background: var(--accent); color: #fff; border: 0;
    border-radius: var(--radius); font-size: 15px; font-weight: 500;
    transition: background .15s;
}
.login-card button:hover { background: #1e293b; }
.login-card .error { color: var(--warn); min-height: 20px; font-size: 13px; }

/* TOOLBAR */
.toolbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}
.brand { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.brand-mark { color: var(--primary); font-size: 18px; }
.tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tools button {
    background: #fff; border: 1px solid var(--border); padding: 6px 12px;
    border-radius: var(--radius); font-size: 13px; color: var(--text);
    transition: all .12s;
}
.tools button:hover { background: #f9fafb; border-color: #d4d5da; }
.tools button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.tools button.primary:hover { background: #1e293b; }
.zoom-group { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.zoom-group button { border: 0; border-radius: 0; border-right: 1px solid var(--border); padding: 6px 12px; background: #fff; }
.zoom-group button:last-child { border-right: 0; }
.zoom-group button.active { background: var(--primary-soft); color: var(--primary); font-weight: 500; }

/* TIMELINE */
main#app { padding: 16px 20px 80px; }
.timeline-wrap {
    background: var(--panel); border-radius: var(--radius-lg);
    box-shadow: var(--shadow); overflow: hidden;
}
.timeline-scroll { overflow: auto; max-height: calc(100vh - 130px); }
.timeline { position: relative; user-select: none; }
.tl-header { position: sticky; top: 0; background: var(--panel); z-index: 10; border-bottom: 1px solid var(--border); }
.tl-months { display: flex; height: 30px; border-bottom: 1px solid var(--border-soft); }
.tl-month {
    border-right: 1px solid var(--border-soft); padding: 6px 10px;
    font-weight: 600; color: var(--text); font-size: 12px;
    white-space: nowrap; overflow: hidden; text-transform: capitalize;
}
.tl-days { display: flex; height: 28px; }
.tl-day {
    border-right: 1px solid var(--border-soft); text-align: center; font-size: 10px;
    color: var(--muted); display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.tl-day.weekend { background: #fafafb; }
.tl-day.today-col { background: #fef3c7; font-weight: 600; color: var(--text); }
.tl-day.month-start { border-left: 1px solid var(--border); }

.tl-density-strip {
    position: relative; height: 14px; border-bottom: 1px solid var(--border-soft);
    background: #fafbfc;
}
.density-dot {
    position: absolute; top: 5px; transform: translateX(-50%);
    width: 4px; height: 4px; border-radius: 50%;
    background: #94a3b8;
    pointer-events: none;
}

.tl-notes-row {
    position: relative; min-height: 12px; border-bottom: 1px solid var(--border-soft);
}
.tl-notes-row.has-notes { padding: 6px 0; }
.note-pill {
    position: absolute;
    transform: translateX(-50%);
    background: #fef3c7; color: #78350f;
    padding: 3px 9px; border-radius: 999px; font-size: 11px;
    max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
    border: 1px solid rgba(0,0,0,0.05);
    cursor: pointer;
    line-height: 1.3;
}
.note-pill:hover { filter: brightness(0.97); }

.bar-milestone {
    position: absolute;
    width: 12px; height: 12px;
    transform: translate(-50%, -50%) rotate(45deg);
    background: #fff;
    border: 1.5px solid #1f2937;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
    pointer-events: none;
    z-index: 3;
}
.bar-milestone.status-planned { border-color: #475569; background: #fff; }
.bar-milestone.status-active { background: #fff; border-color: #1e40af; }
.bar-milestone.status-blocked { background: #fff; border-color: #b45309; }
.bar-milestone.status-done { background: #065f46; border-color: #065f46; }

.tl-lanes { position: relative; }
.tl-lane {
    position: relative;
    border-bottom: 1px solid var(--border-soft);
}
.tl-lane:last-child { border-bottom: 0; }
.tl-lane-label {
    position: sticky; left: 0; background: linear-gradient(to right, #fff 70%, rgba(255,255,255,0));
    padding: 10px 12px 6px;
    font-weight: 600; color: var(--text); font-size: 13px;
    z-index: 5;
    display: inline-block;
}
.tl-lane-label .lane-count { color: var(--muted); font-weight: 400; margin-left: 6px; }
.tl-lane-open { background: linear-gradient(to right, #fff7ed 0%, #fff7ed 280px, transparent 480px); }
.tl-lane-open .tl-lane-label { background: linear-gradient(to right, #fff7ed 70%, rgba(255,247,237,0)); color: #9a3412; }
.lane-open-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #f97316; margin-right: 6px; vertical-align: middle; }
.tl-bar {
    position: absolute;
    height: 26px;
    border-radius: 6px;
    padding: 0 10px; font-size: 12px;
    display: flex; align-items: center; gap: 6px;
    color: #fff; cursor: grab;
    box-shadow: 0 1px 2px rgba(0,0,0,0.12);
    overflow: hidden;
    transition: filter .12s, box-shadow .12s;
    border: 1px solid transparent;
}
.tl-bar:hover { filter: brightness(1.05); box-shadow: 0 2px 6px rgba(0,0,0,0.18); }
.tl-bar.dragging { opacity: 0.9; box-shadow: 0 6px 18px rgba(0,0,0,0.25); z-index: 20; cursor: grabbing; }
.tl-bar .bar-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.tl-bar .bar-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: currentColor; opacity: 0.85; }
.tl-bar .handle {
    position: absolute; top: 0; bottom: 0; width: 6px; cursor: ew-resize; background: rgba(0,0,0,0);
}
.tl-bar .handle.left { left: 0; }
.tl-bar .handle.right { right: 0; }

.tl-bar.status-planned {
    background: #fff;
    color: #1f2937;
    border: 1px dashed #94a3b8;
    box-shadow: none;
}
.tl-bar.status-planned:hover { background: #f9fafb; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.tl-bar.status-planned .bar-dot { background: #94a3b8; opacity: 1; }

.tl-bar.status-active { background: #3b82f6; color: #fff; border-color: #2563eb; }
.tl-bar.status-active .bar-dot { background: #fff; }

.tl-bar.status-blocked {
    background-color: #f59e0b; color: #fff; border-color: #d97706;
    background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.22) 0 6px, transparent 6px 12px);
}
.tl-bar.status-blocked .bar-dot { background: #fff; }

.tl-bar.status-done {
    background: #d1fae5; color: #065f46; border-color: #6ee7b7;
}
.tl-bar.status-done .bar-text { text-decoration: line-through; text-decoration-color: rgba(6,95,70,0.4); }
.tl-bar.status-done .bar-dot { background: #10b981; opacity: 1; }

.tl-bar.end-soft {
    -webkit-mask-image: linear-gradient(to right, #000 max(55%, calc(100% - 500px)), rgba(0,0,0,0) 100%);
    mask-image: linear-gradient(to right, #000 max(55%, calc(100% - 500px)), rgba(0,0,0,0) 100%);
}

.tl-vacation {
    position: absolute;
    top: 10px;
    height: 20px;
    border-radius: 4px;
    background: #ede9fe;
    border: 1px solid #c4b5fd;
    color: #5b21b6;
    font-size: 11px;
    padding: 0 8px;
    display: flex; align-items: center; gap: 5px;
    cursor: pointer;
    overflow: hidden;
    z-index: 3;
    background-image: repeating-linear-gradient(45deg, rgba(91,33,182,0.07) 0 6px, transparent 6px 12px);
    transition: filter .12s;
}
.tl-vacation:hover { filter: brightness(0.96); }
.tl-vacation .vac-icon { flex-shrink: 0; font-size: 11px; }
.tl-vacation .vac-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }

.archive-list { display: flex; flex-direction: column; gap: 8px; }
.archive-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    border: 1px solid #e5e7eb; border-radius: 6px;
    background: #f9fafb;
}
.archive-info { flex: 1; min-width: 0; }
.archive-title { font-weight: 500; color: #111827; }
.archive-meta { font-size: 12px; color: #6b7280; margin-top: 2px; }

.tl-today-line {
    position: absolute; top: 0; bottom: 0;
    width: 1px; background: #64748b;
    pointer-events: none; z-index: 8;
    opacity: 0.55;
}
.tl-today-line::before {
    content: "Heute"; position: absolute; top: 4px; left: 4px;
    background: #475569; color: #fff; padding: 1px 6px; border-radius: 3px;
    font-size: 10px; font-weight: 600;
    opacity: 1;
}

/* EMPTY */
.empty-state {
    padding: 60px 20px; text-align: center; color: var(--muted);
}
.empty-state h3 { color: var(--text); margin: 0 0 6px; font-weight: 600; }
.empty-state p { margin: 0 0 16px; }

/* MODAL */
#modal-backdrop {
    position: fixed; inset: 0; background: rgba(15,23,42,0.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 100; padding: 20px;
    backdrop-filter: blur(2px);
}
#modal-backdrop.hidden { display: none; }
.modal {
    background: #fff; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 560px; width: 100%; max-height: 92vh; overflow-y: auto;
    animation: modal-in .15s ease-out;
}
@keyframes modal-in {
    from { transform: translateY(8px) scale(0.98); opacity: 0; }
    to { transform: none; opacity: 1; }
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); padding: 0 4px; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 24px; }
.modal-footer {
    padding: 14px 24px; border-top: 1px solid var(--border);
    display: flex; gap: 8px; justify-content: flex-end;
    background: #fafbfc;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.modal-footer .left { margin-right: auto; }

.form-row { margin-bottom: 14px; }
.form-row label {
    display: block; font-size: 11px; color: var(--muted);
    margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600;
}
.form-row input[type="text"],
.form-row input[type="date"],
.form-row input[type="url"],
.form-row select, .form-row textarea {
    width: 100%; padding: 9px 11px; border: 1px solid var(--border);
    border-radius: var(--radius); font: inherit; outline: none;
    background: #fff;
    transition: border-color .12s, box-shadow .12s;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
    border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.form-row textarea { min-height: 70px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.inline-check {
    display: flex; align-items: center; gap: 6px;
    margin-top: 6px; font-size: 12px; color: var(--muted);
    text-transform: none; letter-spacing: 0; font-weight: 400;
    cursor: pointer;
}
.inline-check input[type="checkbox"] { margin: 0; cursor: pointer; }

.swatch-group { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch-group .swatch {
    width: 28px; height: 28px; border-radius: 6px; cursor: pointer;
    border: 2px solid transparent; transition: transform .1s, border-color .1s;
}
.swatch-group .swatch:hover { transform: scale(1.1); }
.swatch-group .swatch.selected { border-color: var(--accent); }
.btn { padding: 9px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: #fff; font-size: 13px; transition: all .12s; }
.btn:hover { background: #f9fafb; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: #1e293b; }
.btn.danger { background: #fff; color: var(--warn); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }

.team-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.team-row { display: flex; gap: 6px; }
.team-row input { flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); outline: none; }
.team-row input:focus { border-color: var(--primary); }
.team-row .btn { padding: 8px 10px; }

.milestone-section { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--border); }
.milestone-section h3 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); font-weight: 600; }
.milestone-item {
    display: flex; gap: 6px; align-items: center; margin-bottom: 6px;
}
.milestone-item input[type="date"] { width: 150px; padding: 7px 8px; border: 1px solid var(--border); border-radius: var(--radius); outline: none; }
.milestone-item input[type="text"] { flex: 1; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius); outline: none; }
.milestone-item .btn { padding: 6px 10px; font-size: 12px; }
.milestone-add-btn { width: 100%; padding: 7px; margin-top: 4px; font-size: 12px; border: 1px dashed var(--border); background: #fff; }

/* TOAST */
#toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--accent); color: #fff; padding: 10px 18px;
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
    z-index: 200; font-size: 13px;
    opacity: 0; transition: opacity .2s, transform .2s;
    pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* PRINT */
@media print {
    .toolbar { display: none; }
    .timeline-scroll { max-height: none; overflow: visible; }
    main#app { padding: 0; }
}
