:root {

    --color-primary: #8b5cf6;
    --bg-modal: rgba(15, 15, 15, 0.95);
    --border-subtle: rgba(255, 255, 255, 0.1);
    --input-bg: rgba(0, 0, 0, 0.4);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-modal);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    max-width: 850px;
    width: 95%;
    position: relative;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.9),
    0 0 0 1px rgba(255, 255, 255, 0.05);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.95) translateY(10px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
}

.modal-close {
    position: absolute;
    top: 1.2rem;
    right: 1.2rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    color: #ccc;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s;
    z-index: 2001;
}

.modal-close:hover {
    background: #ef4444;
    border-color: #ef4444;
    color: white;
    transform: rotate(90deg);
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 800;
    padding: 2rem 2.5rem 1rem 2.5rem;
    margin: 0;
    color: white;
    border-bottom: 1px solid var(--border-subtle);
    letter-spacing: -0.02em;
    background: linear-gradient(to right, #fff, #aaa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-body {
    padding: 0 2.5rem;
    overflow-y: auto;
    flex-grow: 1;

    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.modal-body::-webkit-scrollbar { width: 6px; }
.modal-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 10px; }

.modal-fields-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem 2rem;
    padding: 2rem 0;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.form-group label {
    font-size: 0.75rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-input {
    background: var(--input-bg);
    border: 1px solid var(--border-subtle);
    color: white;
    padding: 0.9rem 1rem;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.form-input:focus {
    outline: none;
    background: rgba(0,0,0,0.6);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15);
}

.form-group.notes-group { grid-column: 1 / span 2; }
.form-group.checkbox-group { grid-column: 3 / 4; align-self: end; margin-bottom: 0.8rem; }
.form-group.full-width { grid-column: 1 / -1; }
.notes-textarea { resize: vertical; min-height: 100px; line-height: 1.5; }

.date-group { display: flex; gap: 1.5rem; }
.date-input-pair { flex: 1; display: flex; flex-direction: column; gap: 0.6rem; }

.checkbox-group {
    flex-direction: row;
    align-items: center;
    background: rgba(255,255,255,0.02);
    padding: 0.8rem;
    border-radius: 8px;
    border: 1px solid transparent;
    transition: 0.2s;
}

.checkbox-group:hover { border-color: var(--border-subtle); }

.form-checkbox {
    width: 20px;
    height: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: transparent;
    border-radius: 5px;
    cursor: pointer;
    appearance: none;
    position: relative;
    transition: 0.2s;
}

.form-checkbox:checked {
    background: var(--color-primary);
    border-color: var(--color-primary);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.4);
}

.form-checkbox:checked::after {
    content: "✓";
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: 900;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    padding: 1.5rem 2.5rem;
    border-top: 1px solid var(--border-subtle);
    background: rgba(10, 10, 10, 0.3);
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
    backdrop-filter: blur(10px);
}

.btn-primary, .btn-secondary, .btn-danger {
    padding: 0.85rem 1.8rem;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
    filter: brightness(1.1);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: #ccc;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: white;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
    margin-right: auto;
}

.btn-danger:hover {
    background: #ef4444;
    color: white;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

@media (max-width: 768px) {
    .modal-content {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }

    .modal-title { padding: 1.5rem 1.5rem 1rem; }
    .modal-body { padding: 0 1.5rem; }
    .modal-fields-grid { display: flex; flex-direction: column; gap: 1.2rem; }

    .form-group, .form-group.notes-group,
    .form-group.checkbox-group, .form-group.full-width {
        grid-column: auto;
        width: 100%;
    }

    .date-group { flex-direction: column; gap: 1rem; }
    .modal-actions {
        flex-direction: column;
        gap: 0.8rem;
        padding: 1.5rem;
    }

    .btn-primary, .btn-secondary, .btn-danger { width: 100%; padding: 1rem; }
    .btn-primary { order: 1; }
    .btn-secondary { order: 2; }
    .btn-danger { order: 3; margin-top: 0.5rem; }
}