* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.5;
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.header {
    background: #333;
    color: #fff;
    padding: 1.03rem 2.06rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 1.29rem;
    font-weight: 500;
}

.header h1 span {
    color: #888;
    font-weight: 400;
}

.header-nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.header-nav a {
    color: #ccc;
    text-decoration: none;
}

.header-nav a:hover {
    color: #fff;
}

.header-user {
    color: #999;
    font-size: 0.93rem;
}

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

.menu-wrapper {
    position: relative;
}

.menu-toggle {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.55rem;
    cursor: pointer;
    padding: 0.26rem 0.52rem;
    line-height: 1;
}

.menu-toggle:hover {
    color: #ccc;
}

.menu-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: #fff;
    border-radius: 12px;
    min-width: 180px;
    margin-top: 0.5rem;
    z-index: 200;
}

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

.menu-dropdown a {
    display: block;
    padding: 0.75rem 1rem;
    color: #333;
    text-decoration: none;
    border-bottom: 1px solid #eee;
}

.menu-dropdown a:last-child {
    border-bottom: none;
}

.menu-dropdown a:hover {
    background: #f5f5f5;
}

.menu-dropdown #admin-links a {
    border-bottom: 1px solid #eee;
}

/* Cards */
.card {
    background: #fff;
    border-radius: 12px;
    margin-bottom: 1rem;
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-body {
    padding: 1.5rem;
}

/* Project List */
.project-item {
    padding: 1.5rem;
    margin-bottom: 0.5rem;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.project-item:hover {
    background: #fafafa;
}

.project-item:last-child {
    margin-bottom: 0;
}

.project-item .project-content {
    flex: 1;
}

.project-item.draggable {
    cursor: default;
}

.project-item.dragging {
    opacity: 0.5;
    background: #f0f0f0;
}

.project-item.drag-over {
    outline: 2px dashed #007bff;
    background: #f0f7ff;
}

.project-item .drag-handle {
    cursor: grab;
    color: #999;
    font-size: 1rem;
    padding: 0.25rem;
    user-select: none;
    letter-spacing: -2px;
}

.project-item .drag-handle:hover {
    color: #333;
}

.project-item .drag-handle:active {
    cursor: grabbing;
}

.project-name {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.project-desc {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* Status Bar */
.status-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: #eee;
    margin-bottom: 0.5rem;
}

.status-bar .draft {
    background: #ffd700;
}

.status-bar .approved {
    background: #4a90d9;
}

.status-bar .implemented {
    background: #5cb85c;
}

.status-labels {
    display: flex;
    gap: 1.5rem;
    font-size: 0.8rem;
    color: #666;
}

.status-labels span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.draft { background: #ffd700; }
.status-dot.approved { background: #4a90d9; }
.status-dot.implemented { background: #5cb85c; }

/* Page Content (for split views) */
.page-content {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 54px);
}

.page-content .sub-header {
    position: relative;
    top: 0;
}

/* Sub-Header (sticky) */
.sub-header {
    background: #fff;
    padding: 1.5rem 2rem;
    position: sticky;
    top: 54px;
    z-index: 90;
}

.sub-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.add-module-container {
    display: flex;
}

.add-module-btn {
    /* gleiche Größe wie btn-small */
}

.add-module-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.add-module-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.add-module-input {
    padding: 0.25rem 1.5rem 0.25rem 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.75rem;
    width: 140px;
}

.add-module-input:focus {
    outline: none;
    border-color: #28a745;
}

.add-module-clear {
    position: absolute;
    right: 4px;
    color: #999;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
}

.add-module-clear:hover {
    color: #666;
}

.sub-header-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.breadcrumb a {
    color: #666;
    text-decoration: none;
}

.breadcrumb a:hover {
    color: #333;
}

.breadcrumb span {
    color: #999;
}

.sub-header-meta {
    color: #666;
    font-size: 0.9rem;
}

/* Modules */
.module-item {
    border-radius: 12px;
    margin-bottom: 0.5rem;
    background: #fff;
}

.module-item.open .module-row {
    position: sticky;
    top: 154px;
    z-index: 80;
    background: #fff;
    border-radius: 12px 12px 0 0;
}

/* Drag and Drop */
.module-item.draggable {
    cursor: default;
}

.module-item.dragging {
    opacity: 0.5;
    background: #f0f0f0;
}

.module-item.drag-over {
    border: 2px dashed #007bff;
    background: #f0f7ff;
}

.drag-handle {
    cursor: grab;
    color: #999;
    font-size: 1rem;
    padding: 0 0.5rem 0 0;
    user-select: none;
    letter-spacing: -2px;
}

.drag-handle:hover {
    color: #333;
}

.drag-handle:active {
    cursor: grabbing;
}

.module-row {
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.module-row:hover {
    background: #fafafa;
    border-radius: 12px;
}

.module-name {
    font-weight: 500;
    cursor: pointer;
}

.module-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.module-version {
    font-family: monospace;
}

.module-status {
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 0.65rem;
    text-transform: uppercase;
}

.module-status.draft { background: #fff3cd; color: #856404; }
.module-status.approved { background: #cce5ff; color: #004085; }
.module-status.implemented { background: #d4edda; color: #155724; }

.module-content {
    display: none;
    padding: 1.5rem;
    background: #fafafa;
    border-radius: 0 0 12px 12px;
}

.module-content.open {
    display: block;
}

.module-content pre,
#module-content {
    white-space: pre-wrap;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
}

.module-text-scroll {
    max-height: calc(100vh - 350px);
    overflow-y: auto;
}

.btn.btn-small {
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    min-width: 5.5rem;
    text-align: center;
}

/* Split View */
.split-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.split-top {
    flex: 2;
    overflow-y: auto;
    background: #f5f5f5;
}

.split-bottom {
    flex: 1;
    background: #f0f0f0;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.split-bottom textarea {
    flex: 1;
    width: 100%;
    padding: 1rem;
    font-family: inherit;
    font-size: 1rem;
    border: none;
    border-radius: 12px;
    resize: none;
    background: #fff;
}

.split-bottom textarea:focus {
    outline: none;
}

.split-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    justify-content: flex-end;
    align-items: center;
}

.save-timestamp {
    color: #888;
    font-size: 0.75rem;
    margin-right: auto;
    font-family: 'Courier New', 'Courier', serif;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.15s;
}

.btn-primary {
    background: #4a90d9;
    color: #fff;
}

.btn-primary:hover {
    background: #3a7bc8;
}

.btn-success {
    background: #28a745;
    color: #fff;
}

.btn-success:hover {
    background: #218838;
}

.btn-secondary {
    background: #6c757d;
    color: #fff;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-success {
    background: #5cb85c;
    color: #fff;
}

.btn-success:hover {
    background: #4cae4c;
}

.btn-danger {
    background: #d9534f;
    color: #fff;
}

.btn-danger:hover {
    background: #c9302c;
}

.btn-outline {
    background: transparent;
    color: #333;
}

.btn-outline:hover {
    background: #f5f5f5;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    background: #f0f0f0;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    background: #e8e8e8;
}

.form-hint {
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.25rem;
}

.form-error {
    color: #d9534f;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.form-success {
    color: #155724;
    background: #d4edda;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

.checkbox-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* Login */
.login-container {
    max-width: 400px;
    margin: 4rem auto;
    padding: 2rem;
}

.login-title {
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 2rem;
}

.login-title span {
    color: #888;
    font-weight: 400;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.table th {
    background: #f5f5f5;
    font-weight: 500;
}

.table tr:hover td {
    background: #fafafa;
}

/* Version Dropdown */
.version-select {
    padding: 0.2rem 0.4rem;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 4px;
    font-size: 0.7rem;
    font-family: inherit;
    font-weight: normal;
    background: transparent;
    cursor: pointer;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #cce5ff; color: #004085; }

/* Utilities */
.text-muted { color: #666; }
.text-small { font-size: 0.85rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* Back Link */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: #666;
    text-decoration: none;
    margin-bottom: 1rem;
}

.back-link:hover {
    color: #333;
}

/* Comments */
.comment-item {
    padding: 1rem;
    border-bottom: 1px solid #eee;
}

.comment-item:last-child {
    border-bottom: none;
}

.comment-meta {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.comment-content {
    white-space: pre-wrap;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: #666;
}

/* Accordion Arrow */
.accordion-arrow {
    transition: transform 0.2s;
    font-size: 0.75rem;
}

.accordion-arrow.open {
    transform: rotate(90deg);
}

/* ===========================================
   RESPONSIVE - Tablet (max 1024px)
   =========================================== */
@media (max-width: 1024px) {
    .container {
        padding: 1.5rem;
    }

    .sub-header {
        padding: 1rem 1.5rem;
    }

    .status-labels {
        gap: 1rem;
    }
}

/* ===========================================
   RESPONSIVE - Phone (max 768px)
   =========================================== */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .header {
        padding: 0.75rem 1rem;
    }

    .header h1 {
        font-size: 1.1rem;
    }

    .header-user {
        display: none;
    }

    .sub-header {
        padding: 1rem;
        top: 46px;
    }

    .sub-header-title {
        font-size: 1.25rem;
    }

    .breadcrumb {
        font-size: 0.8rem;
    }

    /* Form rows to columns on mobile */
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    /* Tables responsive */
    .table {
        font-size: 0.85rem;
    }

    .table th,
    .table td {
        padding: 0.5rem;
    }

    /* Hide less important columns on mobile */
    .table th:nth-child(4),
    .table td:nth-child(4) {
        display: none;
    }

    /* Module row stack on mobile */
    .module-row {
        flex-wrap: wrap;
        padding: 0.75rem 1rem;
    }

    .module-name {
        flex-basis: 100%;
        order: -1;
        margin-bottom: 0.5rem;
    }

    .module-actions {
        margin-left: 0;
        width: 100%;
        justify-content: flex-start;
        margin-top: 0.5rem;
    }

    /* Buttons larger for touch */
    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.95rem;
    }

    .btn.btn-small {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }

    /* Split view adjustments */
    .split-container {
        flex-direction: column;
    }

    .split-top {
        flex: 1;
        max-height: 50vh;
    }

    .split-bottom {
        flex: 1;
        padding: 1rem;
    }

    .split-bottom textarea {
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    /* Card padding */
    .card-body {
        padding: 1rem;
    }

    /* Project items */
    .project-item {
        padding: 1rem;
    }

    /* Status labels wrap */
    .status-labels {
        flex-wrap: wrap;
        gap: 0.5rem 1rem;
    }

    /* Login container */
    .login-container {
        margin: 2rem auto;
        padding: 1.5rem;
    }

    /* Comments */
    .comment-item {
        padding: 0.75rem;
    }

    /* Menu dropdown */
    .menu-dropdown {
        min-width: 160px;
    }

    /* Version select larger */
    .version-select {
        padding: 0.3rem 0.5rem;
        font-size: 0.8rem;
    }

    /* Module content */
    .module-content {
        padding: 1rem;
    }

    .module-item.open .module-row {
        top: 110px;
    }

    /* Form inputs larger for touch */
    .form-group input,
    .form-group select {
        padding: 0.85rem;
        font-size: 16px; /* Prevents iOS zoom */
    }
}

/* ===========================================
   RESPONSIVE - Small Phone (max 480px)
   =========================================== */
@media (max-width: 480px) {
    .header h1 span {
        display: none;
    }

    .sub-header-title {
        font-size: 1.1rem;
    }

    .status-labels {
        font-size: 0.75rem;
    }

    /* Stack buttons on very small screens */
    .split-actions {
        flex-direction: column;
    }

    .split-actions .btn {
        width: 100%;
    }

    /* Table scroll horizontal */
    .card {
        overflow-x: auto;
    }

    .table {
        min-width: 500px;
    }
}
