:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --text: #1f2933;
    --muted: #6b7280;
    --primary: #0d6efd;
    --primary-dark: #0b5ed7;
    --border: #e5e7eb;
    --success: #198754;
    --warning: #ffc107;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.app-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
}

.app-header h1 {
    margin: 0;
    font-size: 22px;
}

.app-header p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.container {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 24px;
}

.dashboard-title {
    margin-bottom: 24px;
}

.dashboard-title h2 {
    margin: 0;
    font-size: 28px;
}

.dashboard-title p {
    margin: 6px 0 0;
    color: var(--muted);
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
}

.card .label {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 8px;
}

.card .value {
    font-size: 30px;
    font-weight: bold;
}

.actions-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.action-card {
    display: block;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    text-decoration: none;
    color: var(--text);
    transition: 0.15s ease;
}

.action-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.action-card strong {
    display: block;
    margin-bottom: 6px;
}

.action-card span {
    color: var(--muted);
    font-size: 14px;
}

.footer {
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    padding: 32px 16px;
}

@media (max-width: 900px) {
    .cards-grid,
    .actions-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .app-header {
        padding: 14px 16px;
    }

    .container {
        padding: 16px;
    }

    .cards-grid,
    .actions-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-title h2 {
        font-size: 24px;
    }

    .card .value {
        font-size: 26px;
    }
}

.developer-credit {
    margin-top: 6px;
    font-size: 12px;
    opacity: 0.65;
}

.page-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.page-title h2 {
    margin: 0;
    font-size: 28px;
}

.page-title p {
    margin: 6px 0 0;
    color: var(--muted);
}

.btn-primary,
.search-form button {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 11px 16px;
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
}

.btn-primary:hover,
.search-form button:hover {
    background: var(--primary-dark);
}

.toolbar {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 18px;
}

.search-form label {
    display: block;
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 8px;
}

.search-form div {
    display: flex;
    gap: 10px;
}

.search-form input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 11px 12px;
    font-size: 14px;
}

.table-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}

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

.responsive-table th,
.responsive-table td {
    text-align: left;
    padding: 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.responsive-table th {
    background: #f9fafb;
    font-size: 13px;
    color: var(--muted);
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.table-actions a,
.card-actions a {
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
}

.mobile-list {
    display: none;
}

.patient-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 12px;
}

.patient-card h3 {
    margin: 4px 0 0;
    font-size: 18px;
}

.muted {
    color: var(--muted);
    font-size: 13px;
}

.patient-info p {
    margin: 8px 0;
}

.card-actions {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

@media (max-width: 700px) {
    .page-title {
        align-items: stretch;
        flex-direction: column;
    }

    .btn-primary {
        text-align: center;
    }

    .search-form div {
        flex-direction: column;
    }

    .table-card {
        display: none;
    }

    .mobile-list {
        display: block;
    }
}

.btn-secondary {
    background: #ffffff;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 11px 16px;
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
}

.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.form-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
}

.form-section {
    margin-bottom: 24px;
}

.form-section h3 {
    margin: 0 0 14px;
    font-size: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.form-field label {
    font-size: 14px;
    color: var(--muted);
}

.form-field input,
.form-field textarea,
.form-field select {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 11px 12px;
    font-size: 14px;
    width: 100%;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
    outline: none;
    border-color: var(--primary);
}

.span-2 {
    grid-column: span 2;
}

.span-3 {
    grid-column: span 3;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid var(--border);
    padding-top: 18px;
}

.errorlist {
    margin: 0;
    padding-left: 18px;
    color: #dc3545;
    font-size: 13px;
}

@media (max-width: 700px) {
    .form-card {
        padding: 16px;
    }

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

    .span-2,
    .span-3 {
        grid-column: span 1;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .btn-primary,
    .form-actions .btn-secondary {
        width: 100%;
        text-align: center;
    }
}

.page-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.profile-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.profile-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 16px;
}

.profile-card h3 {
    margin: 0 0 14px;
    font-size: 18px;
}

.info-list {
    display: grid;
    gap: 12px;
}

.info-list div {
    display: grid;
    gap: 4px;
}

.info-list span {
    color: var(--muted);
    font-size: 13px;
}

.info-list strong {
    font-size: 15px;
}

.shortcut-list {
    display: grid;
    gap: 10px;
}

.shortcut-list a {
    display: block;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 11px 12px;
    text-decoration: none;
    color: var(--text);
    background: #ffffff;
}

.shortcut-list a:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.full-width {
    width: 100%;
}

.observation-text {
    margin: 0;
    line-height: 1.5;
    color: var(--text);
}

@media (max-width: 700px) {
    .profile-grid {
        grid-template-columns: 1fr;
    }

    .page-actions {
        flex-direction: column;
    }

    .page-actions .btn-primary,
    .page-actions .btn-secondary {
        text-align: center;
    }
}

.record-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.timeline-list {
    display: grid;
    gap: 12px;
}

.timeline-list div {
    border-left: 3px solid var(--primary);
    padding-left: 12px;
}

.timeline-list strong {
    display: block;
    margin-bottom: 4px;
}

.timeline-list p {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

@media (max-width: 700px) {
    .record-grid {
        grid-template-columns: 1fr;
    }
}

.header-content {
    width: min(1180px, 100%);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.app-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.app-nav a {
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 12px;
    background: #ffffff;
}

.app-nav a:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.cards-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.dashboard-panels {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-top: 24px;
}

.dashboard-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
}

.dashboard-panel h3 {
    margin: 0 0 14px;
    font-size: 18px;
}

.compact-list {
    display: grid;
    gap: 10px;
}

.compact-list a {
    display: grid;
    gap: 4px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    text-decoration: none;
    color: var(--text);
    background: #ffffff;
}

.compact-list a:hover {
    border-color: var(--primary);
}

.compact-list span {
    color: var(--muted);
    font-size: 13px;
}

@media (max-width: 800px) {
    .header-content {
        align-items: flex-start;
        flex-direction: column;
    }

    .app-nav {
        width: 100%;
    }

    .app-nav a {
        flex: 1 1 auto;
        text-align: center;
    }

    .dashboard-panels {
        grid-template-columns: 1fr;
    }
}

.login-body {
    min-height: 100vh;
    background: var(--bg);
}

.login-wrapper {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(420px, 100%);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 28px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.login-header {
    margin-bottom: 22px;
    text-align: center;
}

.login-header h1 {
    margin: 0;
    font-size: 26px;
}

.login-header p {
    margin: 6px 0 0;
    color: var(--muted);
}

.login-button {
    width: 100%;
    margin-top: 18px;
}

.alert-error {
    background: #fff5f5;
    border: 1px solid #f5c2c7;
    color: #842029;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 18px;
    font-size: 14px;
}

.login-credit {
    text-align: center;
    margin-top: 18px;
}

.user-box {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 14px;
}

.user-box form {
    margin: 0;
}

.user-box button {
    border: 1px solid var(--border);
    background: #ffffff;
    border-radius: 999px;
    padding: 8px 12px;
    cursor: pointer;
    color: var(--text);
}

.user-box button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

@media (max-width: 800px) {
    .user-box {
        width: 100%;
        justify-content: space-between;
    }
}

.user-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 13px;
}

.user-link:hover {
    text-decoration: underline;
}

.mini-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.mini-actions a {
    font-size: 13px;
    color: var(--primary);
    text-decoration: none;
}

.mini-actions a:hover {
    text-decoration: underline;
}

.delete-card {
    background: #ffffff;
    border: 1px solid #f5c2c7;
    border-radius: 14px;
    padding: 22px;
}

.delete-card h3 {
    margin-top: 0;
    color: #842029;
}

.btn-danger {
    background: #dc3545;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    padding: 11px 16px;
    cursor: pointer;
    font-size: 14px;
}

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

.small-muted {
    color: var(--muted);
    font-size: 12px;
}

.messages-wrapper {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.app-message {
    border-radius: 12px;
    padding: 13px 15px;
    border: 1px solid var(--border);
    background: #ffffff;
    font-size: 14px;
}

.app-message-success {
    border-color: #badbcc;
    background: #f0fff4;
    color: #0f5132;
}

.app-message-error {
    border-color: #f5c2c7;
    background: #fff5f5;
    color: #842029;
}

.app-message-warning {
    border-color: #ffecb5;
    background: #fff8e1;
    color: #664d03;
}

.app-message-info {
    border-color: #b6effb;
    background: #effaff;
    color: #055160;
}

.med-card {
    border-left: 3px solid #0d6efd;
    background: #ffffff;
    padding: 10px 12px;
    margin-bottom: 12px;
    border-radius: 10px;
}

.med-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.med-card-header strong {
    color: var(--text);
}

.med-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 14px;
}

.med-grid span {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 2px;
}

.med-grid strong {
    display: block;
    font-size: 14px;
    color: var(--text);
    font-weight: 600;
}

.med-meta {
    margin-top: 8px;
}

@media (max-width: 700px) {
    .med-card-header {
        display: block;
    }

    .mini-actions {
        margin-top: 6px;
    }

    .med-grid {
        grid-template-columns: 1fr;
    }
}

.med-list {
    display: grid;
    gap: 12px;
}

.med-card {
    border-left: 3px solid #0d6efd;
    background: #ffffff;
    padding: 12px 13px;
    border-radius: 10px;
}

.med-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.med-card-header strong {
    color: var(--text);
}

.med-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px 16px;
}

.med-grid span {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 2px;
}

.med-grid strong {
    display: block;
    font-size: 14px;
    color: var(--text);
    font-weight: 600;
}

.med-meta {
    margin-top: 9px;
}

@media (max-width: 700px) {
    .med-card-header {
        display: block;
    }

    .med-card-header .mini-actions {
        margin-top: 7px;
    }

    .med-grid {
        grid-template-columns: 1fr;
    }
}

/* Ajustes finos - ações pequenas */
.mini-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    align-items: center;
}

.mini-actions a,
.mini-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--border, #d9dee8);
    background: #ffffff;
    color: var(--text, #1f2937);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.mini-actions a:hover,
.mini-actions button:hover {
    background: #f5f7fb;
}

.mini-actions a[href*="excluir"],
.mini-actions .danger-action {
    border-color: #f1b0b7;
    background: #fff5f5;
    color: #842029;
}

.mini-actions a[href*="excluir"]:hover,
.mini-actions .danger-action:hover {
    background: #ffe3e6;
}

/* Ajustes finos - botões gerais */
.btn-primary,
.btn-secondary,
.btn-danger {
    border-radius: 10px;
    font-weight: 700;
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 9px 14px;
    border: 1px solid #dc3545;
    background: #dc3545;
    color: #ffffff;
    text-decoration: none;
    cursor: pointer;
}

.btn-danger:hover {
    background: #bb2d3b;
    border-color: #bb2d3b;
}

/* Ajustes finos - cartões da ficha */
.profile-card h3 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.profile-card p:last-child {
    margin-bottom: 0;
}

/* Pequenos textos auxiliares */
.helper-text {
    color: var(--muted, #6b7280);
    font-size: 13px;
    line-height: 1.4;
}

.suggestions-box {
    margin-top: 6px;
    border: 1px solid var(--border, #d9dee8);
    border-radius: 12px;
    background: #ffffff;
    overflow: hidden;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.suggestion-item {
    display: grid;
    gap: 3px;
    padding: 11px 13px;
    text-decoration: none;
    color: var(--text, #1f2937);
    border-bottom: 1px solid var(--border, #e5e7eb);
}

.suggestion-item:last-child {
    border-bottom: 0;
}

.suggestion-item:hover {
    background: #f5f7fb;
}

.suggestion-item strong {
    font-size: 14px;
}

.suggestion-item span,
.suggestion-empty {
    font-size: 13px;
    color: var(--muted, #6b7280);
}

.suggestion-empty {
    padding: 11px 13px;
}

/* Ajuste do autocomplete de pacientes */
.suggestion-wrapper {
    position: relative;
    flex: 1 1 auto;
    min-width: 260px;
}

.suggestion-wrapper input {
    width: 100%;
}

.suggestion-wrapper .suggestions-box {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 50;
    margin-top: 0;
    max-height: 300px;
    overflow-y: auto;
}

@media (max-width: 700px) {
    .suggestion-wrapper {
        flex-basis: 100%;
        width: 100%;
    }
}

.search-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: stretch;
}

.search-row input {
    flex: 1 1 220px;
}

.filter-link {
    min-height: 44px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.search-form .helper-text {
    margin-top: 8px;
}

@media (max-width: 700px) {
    .search-row {
        display: grid;
        grid-template-columns: 1fr;
    }

    .filter-link {
        width: 100%;
    }
}


/* Cards genéricos do prontuário */
.record-list {
    display: grid;
    gap: 12px;
}

.record-card {
    border-left: 3px solid #64748b;
    background: #ffffff;
    padding: 12px 13px;
    border-radius: 10px;
}

.record-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 9px;
}

.record-label {
    display: block;
    font-size: 12px;
    color: var(--muted, #6b7280);
    margin-bottom: 2px;
}

.record-card-header strong {
    color: var(--text, #1f2937);
}

.record-body {
    margin: 0;
    color: var(--text, #1f2937);
    line-height: 1.45;
}

.record-extra {
    margin-top: 8px;
}

@media (max-width: 700px) {
    .record-card-header {
        display: block;
    }

    .record-card-header .mini-actions {
        margin-top: 7px;
    }
}

/* Ajustes finos - formulários */
.form-card {
    overflow: hidden;
}

.form-section + .form-section {
    border-top: 1px solid var(--border, #e5e7eb);
    padding-top: 18px;
    margin-top: 18px;
}

.form-section h3 {
    margin-bottom: 14px;
}

.form-actions {
    border-top: 1px solid var(--border, #e5e7eb);
    margin-top: 20px;
    padding-top: 16px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.form-field ul.errorlist,
.errorlist {
    margin: 6px 0 0;
    padding-left: 18px;
    color: #842029;
    font-size: 13px;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus,
.search-form input:focus {
    outline: none;
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.12);
}

@media (max-width: 700px) {
    .form-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .form-actions .btn-primary,
    .form-actions .btn-secondary,
    .form-actions .btn-danger,
    .form-actions button,
    .form-actions a {
        width: 100%;
    }
}

/* Busca de paciente no formulário de atendimento */
.patient-picker {
    position: relative;
}

.patient-picker-input {
    width: 100%;
}

.patient-picker .suggestions-box {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 60;
    max-height: 300px;
    overflow-y: auto;
}

.suggestion-button {
    width: 100%;
    border: 0;
    text-align: left;
    background: #ffffff;
    cursor: pointer;
}

.js-hidden-select {
    display: none;
}

/* Situação dos atendimentos */
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid var(--border, #d9dee8);
    background: #ffffff;
    color: var(--text, #1f2937);
    white-space: nowrap;
}

.status-em_aberto {
    background: #fff8e1;
    border-color: #ffecb5;
    color: #664d03;
}

.status-atendido {
    background: #f0fff4;
    border-color: #badbcc;
    color: #0f5132;
}

.status-ausente {
    background: #fff5f5;
    border-color: #f1b0b7;
    color: #842029;
}

/* =========================================================
   Polimento visual institucional - v2.0
   Ajustes apenas visuais: identidade, profundidade e leitura.
   ========================================================= */

:root {
    --brand-main: #1d4ed8;
    --brand-soft: #eff6ff;
    --brand-line: rgba(37, 99, 235, 0.22);
    --surface-border: rgba(148, 163, 184, 0.30);
    --shadow-soft: 0 12px 28px rgba(15, 23, 42, 0.075);
    --shadow-hover: 0 16px 36px rgba(15, 23, 42, 0.105);
}

body {
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.08), transparent 30rem),
        linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

.app-header {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-top: 4px solid var(--brand-main);
    border-bottom: 1px solid var(--surface-border);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.045);
}

.app-header h1 {
    color: #0f172a;
    font-weight: 800;
    letter-spacing: -0.045em;
}

.app-header p {
    color: #64748b;
    font-weight: 500;
}

.app-nav a,
.user-box a,
.user-box button {
    background: #ffffff;
    border-color: rgba(148, 163, 184, 0.35);
    transition:
        background-color 0.18s ease,
        border-color 0.18s ease,
        color 0.18s ease,
        transform 0.18s ease,
        box-shadow 0.18s ease;
}

.app-nav a:hover,
.user-box a:hover,
.user-box button:hover {
    background: var(--brand-soft);
    border-color: var(--brand-line);
    color: var(--brand-main);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.10);
}

.dashboard-title h2,
.page-title h2 {
    color: #0f172a;
    letter-spacing: -0.045em;
}

.dashboard-title p,
.page-title p {
    color: #64748b;
}

.card,
.action-card,
.dashboard-panel,
.table-card,
.patient-card,
.form-card,
.profile-card,
.delete-card,
.med-card,
.record-card,
.login-card {
    border: 1px solid var(--surface-border);
    box-shadow: var(--shadow-soft);
}

.card {
    position: relative;
    overflow: hidden;
}

.card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, var(--brand-main), #38bdf8);
}

.card .label {
    color: #64748b;
    font-weight: 500;
}

.card .value {
    color: #0f172a;
    letter-spacing: -0.05em;
}

.action-card,
.patient-card,
.med-card,
.record-card {
    transition:
        transform 0.18s ease,
        box-shadow 0.18s ease,
        border-color 0.18s ease;
}

.action-card:hover,
.patient-card:hover,
.med-card:hover,
.record-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    border-color: var(--brand-line);
}

.action-card strong,
.dashboard-panel h3,
.profile-card h3,
.table-card h3,
.med-card-header strong,
.record-card-header strong {
    color: #1e293b;
    letter-spacing: -0.02em;
}

.dashboard-panel {
    background: rgba(255, 255, 255, 0.94);
}

.dashboard-panel article,
.dashboard-panel .record-card {
    background: #ffffff;
}

.footer {
    color: #64748b;
    font-size: 0.82rem;
    padding-top: 1.6rem;
    padding-bottom: 1.6rem;
}

.footer .developer-credit {
    color: #94a3b8;
    margin-top: 0.25rem;
}

.login-card {
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.12);
}

.login-header h1 {
    letter-spacing: -0.045em;
}

.login-button {
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.18);
}

@media (max-width: 720px) {
    .app-header {
        border-top-width: 3px;
    }

    .app-header h1 {
        font-size: 1.55rem;
    }

    .card::before {
        height: 3px;
    }

    .action-card:hover,
    .patient-card:hover,
    .med-card:hover,
    .record-card:hover {
        transform: none;
    }
}

/* =========================================================
   Tema suave institucional
   Degradês sutis e aparência mais tranquila.
   ========================================================= */

:root {
    --bg-main: #f8fbff;
    --bg-soft: #f3f8ff;
    --bg-mint: #eefaf7;
    --surface: rgba(255, 255, 255, 0.92);
    --surface-border-soft: rgba(148, 163, 184, 0.22);
    --shadow-soft-theme: 0 10px 30px rgba(15, 23, 42, 0.06);
    --shadow-card-theme: 0 4px 14px rgba(15, 23, 42, 0.05);
    --text-main-theme: #1e293b;
    --text-soft-theme: #64748b;
}

body {
    color: var(--text-main-theme);
    background:
        linear-gradient(180deg, rgba(219, 234, 254, 0.34) 0%, rgba(248, 251, 255, 0.96) 26%, rgba(236, 254, 255, 0.45) 100%),
        linear-gradient(135deg, #f8fbff 0%, #eef6ff 52%, #eefaf7 100%);
}

.app-header {
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.20);
    box-shadow: 0 2px 20px rgba(15, 23, 42, 0.03);
}

.dashboard-title,
.page-title {
    background: linear-gradient(135deg, rgba(219, 234, 254, 0.55) 0%, rgba(224, 242, 254, 0.38) 45%, rgba(236, 254, 255, 0.45) 100%);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 20px;
    padding: 1.4rem 1.5rem;
    box-shadow: var(--shadow-soft-theme);
    margin-bottom: 1.25rem;
}

.card,
.action-card,
.dashboard-panel,
.table-card,
.patient-card,
.form-card,
.profile-card,
.delete-card,
.med-card,
.record-card {
    background: var(--surface);
    border: 1px solid var(--surface-border-soft);
    box-shadow: var(--shadow-card-theme);
}

.cards-grid .card {
    position: relative;
    overflow: hidden;
}

.cards-grid .card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, #93c5fd 0%, #7dd3fc 50%, #99f6e4 100%);
}

@media (max-width: 720px) {
    .dashboard-title,
    .page-title {
        border-radius: 16px;
        padding: 1.1rem 1rem;
    }
}


/* =========================================================
   Auditoria legível - v2.0 alpha.22
   Ajustes visuais para reduzir aparência técnica da auditoria.
   ========================================================= */

.audit-activity {
    color: #0f172a;
    font-weight: 700;
}

.audit-patient {
    color: #0f172a;
    font-weight: 700;
}

.audit-empty {
    color: #94a3b8;
}

.audit-detail-cell {
    line-height: 1.35;
}

.audit-detail {
    color: #475569;
    font-size: 0.92rem;
}

@media (max-width: 720px) {
    .audit-detail {
        display: inline-block;
        margin-top: 0.15rem;
    }
}


/* =========================================================
   Ajuste visual claro - v2.0 alpha.24
   Recupera a faixa superior dos cards e suaviza os fundos.
   ========================================================= */

body {
    background:
        linear-gradient(180deg, rgba(248, 251, 255, 0.98) 0%, rgba(245, 249, 255, 0.96) 46%, rgba(250, 253, 255, 0.98) 100%),
        linear-gradient(135deg, #f8fbff 0%, #f3f8ff 52%, #f7fcff 100%);
}

.dashboard-title,
.page-title {
    background: linear-gradient(135deg, rgba(239, 246, 255, 0.78) 0%, rgba(248, 252, 255, 0.90) 54%, rgba(240, 253, 250, 0.54) 100%);
    border-color: rgba(191, 219, 254, 0.34);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.045);
}

.cards-grid .card::before,
.card::before {
    height: 4px;
    background: linear-gradient(90deg, var(--brand-main), #38bdf8);
}

@media (max-width: 720px) {
    .cards-grid .card::before,
    .card::before {
        height: 3px;
    }
}

/* =========================================================
   Auditoria - paciente com ID discreto
   ========================================================= */

.audit-patient {
    display: block;
}

.audit-patient-id {
    display: block;
    margin-top: 0.15rem;
    color: #64748b;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.25;
}

/* =========================================================
   Medicações - ordenação visual
   ========================================================= */

.med-section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.med-section-header h3 {
    margin-bottom: 0.25rem;
}

.med-order-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.med-order-link {
    display: inline-flex;
    align-items: center;
    min-height: 2rem;
    padding: 0.35rem 0.7rem;
    border: 1px solid #dbe3ef;
    border-radius: 999px;
    background: #ffffff;
    color: #334155;
    font-size: 0.86rem;
    font-weight: 700;
    text-decoration: none;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.med-order-link:hover {
    border-color: #93c5fd;
    color: #1d4ed8;
}

.med-order-link.active {
    border-color: #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
}

@media (max-width: 720px) {
    .med-section-header {
        flex-direction: column;
        align-items: stretch;
    }

    .med-order-actions {
        justify-content: flex-start;
    }
}

/* =========================================================
   Alpha.25 - fila de atendimento e ordenação de medicações
   ========================================================= */

.queue-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.2rem;
}

.queue-summary-card {
    padding: 1rem;
    border: 1px solid #dbe3ef;
    border-radius: 1rem;
    background: #ffffff;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.045);
}

.queue-summary-card span {
    display: block;
    color: #64748b;
    font-size: 0.88rem;
    margin-bottom: 0.35rem;
}

.queue-summary-card strong {
    color: #0f172a;
    font-size: 1.65rem;
    line-height: 1;
}

.attendance-section {
    margin-bottom: 1.3rem;
}

.attendance-section-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin: 0 0 0.65rem;
}

.attendance-section-header h3 {
    margin: 0 0 0.2rem;
}

.status-em_aberto {
    border-color: #fcd34d;
    background: #fffbeb;
    color: #92400e;
}

.status-em_atendimento {
    border-color: #93c5fd;
    background: #eff6ff;
    color: #1d4ed8;
}

.med-section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.med-section-header h3 {
    margin-bottom: 0.25rem;
}

.med-order-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.med-order-link {
    display: inline-flex;
    align-items: center;
    min-height: 2rem;
    padding: 0.35rem 0.7rem;
    border: 1px solid #dbe3ef;
    border-radius: 999px;
    background: #ffffff;
    color: #334155;
    font-size: 0.86rem;
    font-weight: 700;
    text-decoration: none;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.med-order-link:hover {
    border-color: #93c5fd;
    color: #1d4ed8;
}

.med-order-link.active {
    border-color: #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
}

@media (max-width: 900px) {
    .queue-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .queue-summary-grid {
        grid-template-columns: 1fr;
    }

    .attendance-section {
        display: none;
    }

    .med-section-header {
        flex-direction: column;
        align-items: stretch;
    }

    .med-order-actions {
        justify-content: flex-start;
    }
}
