body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    min-height: 100vh;
}

header {
    background-color: #2c3e50;
    color: white;
    text-align: center;
    padding: 1rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

nav {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 1rem;
}

nav a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

nav a:hover, nav a.active {
    background-color: #34495e;
}

main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 2rem;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

section {
    margin-bottom: 2rem;
    padding: 2rem;
    border-radius: 8px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
}

h2 {
    color: #007bff;
}

form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

    label {
        display: block;
        margin-bottom: 0.5rem;
        font-weight: bold;
        font-size: 14px;
    }

    input, textarea {
        width: 100%;
        padding: 0.5rem;
        border: 2px solid #ced4da;
        border-radius: 5px;
        box-sizing: border-box;
        font-size: 16px;
    }

input:focus, textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 5px rgba(0,123,255,0.5);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

button {
    grid-column: span 2;
    padding: 1rem;
    background: linear-gradient(45deg, #28a745, #20c997);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

#clients-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
}

.client-card {
    background: white;
    color: #333;
    border-radius: 10px;
    width: 250px;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    text-align: center;
    padding: 1.5rem;
    border: 2px solid #e9ecef;
    position: relative;
    overflow: hidden;
}

.client-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: var(--card-color);
}

.client-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
    border-color: #007bff;
}

.client-card h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.4rem;
    color: #007bff;
}

.client-card p {
    margin: 0.25rem 0;
    font-size: 0.9rem;
    color: #666;
}

.client-card .card-info {
    width: 100%;
    text-align: left;
    margin-top: 1rem;
}

.client-card .card-info p {
    margin: 0.25rem 0;
    font-size: 0.85rem;
}

.buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

#save-btn {
    background: linear-gradient(45deg, #28a745, #20c997);
}

#delete-btn {
    background: linear-gradient(45deg, #dc3545, #fd7e14);
}

#print-reports-btn {
    background: linear-gradient(45deg, #6c757d, #495057);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-top: 2rem;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

#print-reports-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

/* Reports page */
.report-cards {
    display: flex;
    justify-content: space-around;
    margin-bottom: 2rem;
}

.report-card {
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    text-align: center;
    width: 200px;
}

.report-card:nth-child(1) {
    border-top: 5px solid #28a745; /* Green for Total */
}

.report-card:nth-child(2) {
    border-top: 5px solid #007bff; /* Blue for Renovações Mês */
}

.report-card:nth-child(3) {
    border-top: 5px solid #dc3545; /* Red for Atrasados */
}

.report-card:nth-child(4) {
    border-top: 5px solid #ffc107; /* Yellow for Renovados */
}

.report-card h3 {
    margin: 0 0 1rem 0;
    color: #007bff;
}

.report-card p {
    font-size: 2rem;
    font-weight: bold;
    color: #333;
    margin: 0;
}

.report-details h3 {
    margin-top: 2rem;
}

.report-details h3:nth-of-type(1) {
    color: #007bff; /* Blue for Renovações Este Mês */
}

.report-details h3:nth-of-type(2) {
    color: #dc3545; /* Red for Atrasados */
}

.report-details ul {
    list-style: none;
    padding: 0;
}

.report-details ul:nth-of-type(1) li {
    background: #f8f9fa;
    margin: 0.5rem 0;
    padding: 0.5rem;
    border-radius: 5px;
    border-left: 4px solid #007bff; /* Blue */
    color: #007bff;
}

.report-details ul:nth-of-type(2) li {
    background: #f8f9fa;
    margin: 0.5rem 0;
    padding: 0.5rem;
    border-radius: 5px;
    border-left: 4px solid #dc3545; /* Red */
    color: #dc3545;
}

@media print {
    @page { margin: 12mm; size: A4; }

    /* keep exact colors when printing (user still may need "background graphics" enabled) */
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; color-adjust: exact !important; }

    html, body { width: 100% !important; margin: 0 !important; padding: 0 !important; background: white !important; }

    /* hide UI not needed on print */
    header, nav, footer, #print-reports-btn, .modal, .modal-content, button { display: none !important; }

    main { width: 100% !important; max-width: 100% !important; margin: 0 auto !important; padding: 10mm 12mm !important; background: white !important; border-radius: 0 !important; box-shadow: none !important; }

    section { width: 100% !important; margin: 0 !important; padding: 0 !important; background: white !important; border: none !important; }

    #reports { width: 100% !important; margin: 0 !important; padding: 0 !important; }

    /* title same as screen */
    #reports h2 { color: #007bff !important; margin: 0 0 22px 0 !important; font-size: 22pt !important; font-weight: 700 !important; }

    /* Use floats for print to guarantee horizontal placement */
    .report-cards { display: block !important; width: 100% !important; margin-bottom: 18px !important; page-break-inside: avoid !important; }
    .report-cards::after { content: "" !important; display: table !important; clear: both !important; }

    /* floated cards sized by percentage so four fit in portrait A4 */
    .report-card {
        float: left !important;
        width: 22% !important; /* four cards + gaps fit within printable area */
        box-sizing: border-box !important;
        background: white !important;
        border-radius: 8px !important;
        padding: 18px 12px !important;
        box-shadow: 0 6px 18px rgba(0,0,0,0.06) !important;
        text-align: center !important;
        border-top: 5px solid !important;
        margin-right: 2% !important;
        page-break-inside: avoid !important;
        min-width: 0 !important;
    }
    .report-card:nth-of-type(4) { margin-right: 0 !important; }

    .report-card:nth-child(1) { border-top-color: #28a745 !important; }
    .report-card:nth-child(2) { border-top-color: #007bff !important; }
    .report-card:nth-child(3) { border-top-color: #dc3545 !important; }
    .report-card:nth-child(4) { border-top-color: #ffc107 !important; }

    .report-card h3 { margin: 0 0 16px 0 !important; color: #007bff !important; font-size: 14pt !important; font-weight: 700 !important; }
    .report-card p { font-size: 32pt !important; font-weight: 700 !important; color: #333 !important; margin: 0 !important; line-height: 1 !important; }

    /* details below cards keep normal spacing */
    .report-details { width: 100% !important; margin-top: 18px !important; page-break-inside: avoid !important; clear: both !important; }
    .report-details h3 { margin: 18px 0 10px 0 !important; font-size: 12pt !important; font-weight: 700 !important; color: #007bff !important; }
    .report-details h3:nth-of-type(2) { color: #dc3545 !important; }
    .report-details ul { list-style: none !important; padding: 0 !important; margin: 0 0 12px 0 !important; }
    .report-details li { background: #f8f9fa !important; margin: 6px 0 !important; padding: 8px 10px !important; border-radius: 4px !important; border-left: 4px solid !important; font-size: 10pt !important; }
    .report-details ul:nth-of-type(1) li { border-left-color: #007bff !important; color: #007bff !important; }
    .report-details ul:nth-of-type(2) li { border-left-color: #dc3545 !important; color: #dc3545 !important; }
}

/* Selector page */
#selector {
    text-align: center;
    padding: 3rem;
}

.selector-buttons {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 2rem;
}

.selector-btn {
    display: inline-block;
    padding: 1.5rem 3rem;
    background: linear-gradient(45deg, #007bff, #6610f2);
    color: white;
    text-decoration: none;
    border-radius: 10px;
    font-size: 1.2rem;
    font-weight: bold;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.selector-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

@media (max-width: 768px) {
    .selector-buttons {
        flex-direction: column;
        align-items: center;
    }

    /* Header mobile */
    header {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.5rem;
        text-align: center;
    }

    header nav {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }

    header nav a {
        font-size: 0.9rem;
        padding: 0.5rem 1rem;
    }

    /* Forms mobile */
    form {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    input, textarea, button {
        font-size: 16px;
    }

    button {
        grid-column: span 1;
    }

    /* Client cards mobile */
    .client-card {
        width: 90%;
        min-height: auto;
        padding: 1rem;
    }

    .client-card h3 {
        font-size: 1.2rem;
    }

    .client-card p {
        font-size: 0.85rem;
    }

    /* Buttons mobile */
    .buttons {
        flex-direction: column;
        gap: 0.5rem;
        align-items: center;
    }

    .buttons button {
        width: 100%;
        max-width: 250px;
    }

    /* Reports mobile */
    .report-cards {
        flex-direction: column;
        align-items: center;
    }

    .report-card {
        width: 90%;
        margin-bottom: 1rem;
    }

    .report-details h3 {
        font-size: 1rem;
    }

    .report-details ul {
        padding-left: 1rem;
    }

    #print-reports-btn {
        width: 90%;
        max-width: 300px;
    }

    /* Client detail mobile */
    #client-detail h2 {
        font-size: 1.3rem;
    }

    main {
        padding: 1rem;
    }

    /* Modal mobile */
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }

    #modal-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 30px;
    border-radius: 10px;
    width: 80%;
    max-width: 400px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease;
    text-align: center;
}

.close {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: black;
}

#modal-title {
    margin-top: 0;
    color: #333;
    margin-bottom: 10px;
}

#modal-message {
    margin: 20px 0;
    line-height: 1.5;
}

#modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

#modal-ok, #modal-cancel, #modal-confirm {
    background: linear-gradient(45deg, #007bff, #6610f2);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: transform 0.2s ease;
}

#modal-cancel {
    background: linear-gradient(45deg, #6c757d, #495057);
}

#modal-confirm {
    background: linear-gradient(45deg, #dc3545, #fd7e14);
}

#modal-ok:hover, #modal-cancel:hover, #modal-confirm:hover {
    transform: translateY(-2px);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }