:root {
    --navy-deep: #0a1f44;
    --navy-mid: #1a3a6b;
    --navy-light: #2c5282;
    --gold: #d4af37;
    --gold-light: #f0d674;
    --gold-dark: #b8941f;
    --white: #ffffff;
    --gray-light: #f7fafc;
    --gray-mid: #e2e8f0;
    --gray-dark: #64748b;
    --shadow-sm: 0 2px 8px rgba(10, 31, 68, 0.08);
    --shadow-md: 0 4px 20px rgba(10, 31, 68, 0.12);
    --shadow-lg: 0 8px 40px rgba(10, 31, 68, 0.16);
    --shadow-gold: 0 4px 20px rgba(212, 175, 55, 0.25);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-light);
    color: var(--navy-deep);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.logo-placeholder {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--white);
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 2rem;
    position: relative;
    z-index: 2;
}

.logo-upload {
    width: 64px;
    height: 64px;
    min-width: 64px;
    border-radius: 12px;
    border: 2px dashed rgba(212, 175, 55, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.logo-upload:hover {
    border-color: var(--gold-light);
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.05);
}

.logo-upload.has-logo {
    border-style: solid;
    border-color: var(--gold);
    background: rgba(255, 255, 255, 0.95);
}

.clinic-info-editable {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    min-width: 0;
}

.clinic-name-input {
    color: var(--white);
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    outline: none;
    border-bottom: 2px solid transparent;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.3s ease;
    min-height: 1.2em;
    line-height: 1.3;
}

.clinic-name-input:hover {
    border-bottom-color: rgba(212, 175, 55, 0.3);
}

.clinic-name-input:focus {
    border-bottom-color: var(--gold);
    background: rgba(255, 255, 255, 0.08);
}

.clinic-name-input:empty::before {
    content: attr(data-placeholder);
    color: rgba(255, 255, 255, 0.35);
    font-style: italic;
    pointer-events: none;
}

.clinic-subtitle-input {
    color: var(--gold-light);
    font-size: 0.9rem;
    font-weight: 400;
    letter-spacing: 1px;
    text-transform: uppercase;
    outline: none;
    border-bottom: 2px solid transparent;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.3s ease;
    min-height: 1.2em;
    line-height: 1.4;
}

.clinic-subtitle-input:hover {
    border-bottom-color: rgba(212, 175, 55, 0.2);
}

.clinic-subtitle-input:focus {
    border-bottom-color: var(--gold);
    background: rgba(255, 255, 255, 0.05);
}

.clinic-subtitle-input:empty::before {
    content: attr(data-placeholder);
    color: rgba(240, 214, 116, 0.35);
    font-style: italic;
    pointer-events: none;
}

/* ==================== NAVBAR ==================== */
.navbar {
    background: linear-gradient(135deg, var(--navy-deep) 0%, var(--navy-mid) 100%);
    padding: 1rem 2.5rem 0.5rem 2.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-lg);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-icon {
    font-size: 1.75rem;
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }
}

.nav-brand h1 {
    color: var(--white);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    line-height: 1.2;
}

.nav-brand small {
    color: var(--gold-light);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-badge {
    font-size: 1.5rem;
}

.user-name {
    color: var(--white);
    font-weight: 600;
    font-size: 0.95rem;
}

.btn-logout {
    padding: 0.5rem 1.25rem;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    background: transparent;
    color: var(--white);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--gold-light);
    color: var(--gold-light);
    transform: translateY(-2px);
}

/* ==================== MAIN ==================== */
.main-content {
    flex: 1;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 2.5rem;
    animation: fadeUp 0.5s ease-out;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== TOOLBAR ==================== */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
}

.toolbar-left {
    display: flex;
    align-items: baseline;
    gap: 1rem;
}

.toolbar-left h2 {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--navy-deep), var(--navy-mid));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.patient-count {
    font-size: 0.9rem;
    color: var(--gray-dark);
    font-weight: 500;
    background: var(--gray-mid);
    padding: 0.25rem 0.85rem;
    border-radius: 20px;
}

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

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 1rem;
    font-size: 1rem;
    pointer-events: none;
}

.search-box input {
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    border: 2px solid var(--gray-mid);
    border-radius: 12px;
    font-size: 0.95rem;
    font-family: inherit;
    width: 280px;
    transition: all 0.3s ease;
    background: var(--white);
}

.search-box input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.12);
    width: 340px;
}

.search-box input::placeholder {
    color: var(--gray-dark);
    opacity: 0.6;
}

/* ==================== BUTTONS ==================== */
.btn-primary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    color: var(--white);
    box-shadow: var(--shadow-gold);
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    box-shadow: 0 6px 30px rgba(212, 175, 55, 0.4);
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-cancel {
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--gray-mid);
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    background: var(--white);
    color: var(--navy-deep);
    transition: all 0.3s ease;
}

.btn-cancel:hover {
    border-color: var(--navy-mid);
    background: var(--gray-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

/* ==================== TABLE ==================== */
.table-container {
    background: var(--white);
    border-radius: 20px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.patients-table {
    width: 100%;
    border-collapse: collapse;
}

.patients-table thead {
    background: linear-gradient(135deg, var(--navy-deep), var(--navy-mid));
}

.patients-table th {
    padding: 1rem 1.25rem;
    color: var(--white);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
}

.patients-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-mid);
    font-size: 0.95rem;
    vertical-align: middle;
}

.patients-table tbody tr {
    transition: all 0.2s ease;
}

.patients-table tbody tr:hover {
    background: linear-gradient(to right, rgba(212, 175, 55, 0.04), transparent);
}

.patients-table tbody tr:last-child td {
    border-bottom: none;
}

/* Patient name cell */
.patient-name-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.patient-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--navy-light), var(--navy-mid));
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.patient-name {
    font-weight: 600;
    color: var(--navy-deep);
}

.cpf-cell {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: var(--gray-dark);
}

.btn-anamnese {
    padding: 0.5rem 1.25rem;
    border: 2px solid var(--gold);
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    background: transparent;
    color: var(--gold-dark);
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-anamnese:hover {
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    color: var(--white);
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: var(--shadow-gold);
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-icon {
    font-size: 3.5rem;
    display: block;
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.3rem;
    color: var(--navy-mid);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--gray-dark);
    font-size: 0.95rem;
}

/* ==================== MODAL ==================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 31, 68, 0.55);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--white);
    border-radius: 24px;
    width: 95%;
    max-width: 620px;
    box-shadow: 0 20px 60px rgba(10, 31, 68, 0.3);
    transform: translateY(30px) scale(0.96);
    transition: transform 0.35s ease;
    overflow: hidden;
}

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

.modal-header {
    background: linear-gradient(135deg, var(--navy-deep), var(--navy-mid));
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 {
    color: var(--white);
    font-size: 1.25rem;
    font-weight: 700;
}

.modal-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: var(--white);
    font-size: 1.25rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-family: inherit;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg);
}

.modal-form {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-row .full {
    grid-column: 1 / -1;
}

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

.form-group label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--navy-deep);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-group input,
.form-group textarea {
    padding: 0.8rem 1rem;
    border: 2px solid var(--gray-mid);
    border-radius: 12px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.3s ease;
    background: var(--white);
    color: var(--navy-deep);
    resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.12);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--gray-dark);
    opacity: 0.5;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding-top: 0.5rem;
}

/* ==================== FOOTER ==================== */
.page-footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--gray-dark);
    font-size: 0.85rem;
}

/* ==================== NOTIFICATION ==================== */
.notification {
    position: fixed;
    top: 80px;
    right: 20px;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    color: var(--white);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(212, 175, 55, 0.35);
    font-weight: 600;
    font-size: 0.95rem;
    z-index: 2000;
    animation: notifIn 0.35s ease-out;
}

.notification.error {
    background: linear-gradient(135deg, #e53e3e, #fc8181);
}

@keyframes notifIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes notifOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 968px) {
    .navbar {
        padding: 1rem 1.5rem;
    }

    .main-content {
        padding: 1.5rem 1rem;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-right {
        flex-direction: column;
    }

    .search-box input {
        width: 100%;
    }

    .search-box input:focus {
        width: 100%;
    }

    .btn-primary {
        justify-content: center;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    /* Card layout for mobile */
    .patients-table thead {
        display: none;
    }

    .patients-table,
    .patients-table tbody,
    .patients-table tr,
    .patients-table td {
        display: block;
    }

    .patients-table tr {
        padding: 1rem;
        border-bottom: 2px solid var(--gray-mid);
        position: relative;
    }

    .patients-table td {
        padding: 0.35rem 1rem;
        border-bottom: none;
        text-align: left;
    }

    .patients-table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        color: var(--gray-dark);
        display: block;
        margin-bottom: 0.15rem;
    }

    .patients-table td:last-child {
        padding-top: 0.75rem;
    }
}

@media (max-width: 480px) {
    .nav-brand h1 {
        font-size: 1rem;
    }

    .user-name {
        display: none;
    }

    .modal {
        width: 98%;
        border-radius: 16px;
    }

    .modal-form {
        padding: 1.25rem;
    }
}

/* Accessibility */
*:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 2px;
}