:root {
    --bg-body: #f3f4f6;
    --bg-header: #1f2937;
    --bg-sidebar: #111827;
    --bg-card: #ffffff;
    --bg-tab: #e5e7eb;
    --bg-tab-active: #ffffff;
    --border-soft: #d1d5db;
    --primary: #2563eb;
    --primary-soft: #dbeafe;
    --text-main: #111827;
    --text-muted: #6b7280;
    --text-inverted: #f9fafb;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top left, #e5e7eb, #f9fafb);
    color: var(--text-main);
}

/* ---------------- HEADER ---------------- */

header.app-header {
    background: linear-gradient(to right, #111827, #1f2937);
    color: var(--text-inverted);
    padding: 16px 24px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.header-left {
    display: flex;
    align-items: center;
}

.client-logo-box {
    border-radius: 999px;
    background: radial-gradient(circle at 30% 30%, #60a5fa, #1d4ed8);
    padding: 3px;
    box-shadow: 0 4px 14px rgba(15,23,42,0.45);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.client-logo-inner {
    background: rgba(255,255,255,0.92);
    border-radius: 999px;
    padding: 8px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.client-logo-inner img {
    height: 46px;
    width: auto;
    display: block;
}

.client-logo-box img {
    height: 42px;
    width: auto;
    display: block;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: right;
}

.header-title h1 {
    margin: 0;
    font-size: 20px;
    letter-spacing: 0.02em;
}

.header-title p {
    margin: 2px 0 0;
    font-size: 13px;
    color: #9ca3af;
}

.app-logo {
    width: 48px;
    height: 48px;
    border-radius: 999px;
    background: radial-gradient(circle at 30% 30%, #60a5fa, #1d4ed8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 22px;
    color: white;
    box-shadow: 0 8px 24px rgba(37,99,235,0.6);
}

/* ---------------- LAYOUT ---------------- */

.layout {
    max-width: 1200px;
    margin: 16px auto 32px;
    padding: 0 16px;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 20px;
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ---------------- SIDEBAR ---------------- */

.sidebar {
    background: var(--bg-sidebar);
    border-radius: var(--radius-xl);
    padding: 16px 14px;
    color: var(--text-inverted);
    box-shadow: 0 12px 30px rgba(15,23,42,0.7);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.sidebar-info {
    font-size: 12px;
    color: #9ca3af;
    margin-bottom: 16px;
}

.sidebar-info div {
    margin-bottom: 2px;
}

.sidebar-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #9ca3af;
    margin-bottom: 8px;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0 0 20px 0;
}

.sidebar-menu li + li {
    margin-top: 4px;
}

.sidebar-menu a,
.sidebar-menu span {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 999px;
    text-decoration: none;
    font-size: 14px;
    color: inherit;
    transition: background 0.15s, transform 0.1s;
}

.sidebar-menu a:hover {
    background: rgba(55,65,81,0.9);
    transform: translateY(-1px);
}

.sidebar-badge {
    margin-left: auto;
    background: #1f2937;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    color: #9ca3af;
}

/* ---------------- MAIN CARD ---------------- */

.main-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 18px 20px 22px;
    box-shadow: 0 20px 35px rgba(15,23,42,0.12);
    border: 1px solid #e5e7eb;
}

.main-header-line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.main-header-line h2 {
    margin: 0;
    font-size: 18px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: #1d4ed8;
    font-size: 11px;
    font-weight: 500;
}

.pill span {
    font-size: 10px;
    text-transform: uppercase;
}

.subinfo {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 14px;
}

/* ---------------- TABS ---------------- */

.tabs {
    margin-top: 8px;
}

.tab-list {
    display: flex;
    gap: 6px;
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: 4px;
}

.tab-btn {
    border: 0;
    background: transparent;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s, color 0.15s, transform 0.1s;
}

.tab-btn[data-active="true"] {
    background: var(--primary-soft);
    color: #1d4ed8;
    transform: translateY(-1px);
}

.tab-badge {
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(37,99,235,0.08);
}

.tab-panels {
    margin-top: 12px;
}

.tab-panel {
    display: none;
}

.tab-panel[data-active="true"] {
    display: block;
}

/* ---------------- FIELDS ---------------- */

.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px 16px;
    margin-top: 8px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
}

.field label {
    font-size: 12px;
    color: var(--text-muted);
}

.field input,
.field textarea,
.field select {
    border-radius: 10px;
    border: 1px solid var(--border-soft);
    padding: 6px 8px;
    font-size: 13px;
    font-family: inherit;
}

.field textarea {
    min-height: 70px;
    resize: vertical;
}

.textarea-autoresize {
    overflow: hidden;
    resize: none;
}

.section-legend {
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #374151;
    margin-top: 18px;
    margin-bottom: 6px;
}

.muted-box {
    border-radius: 10px;
    border: 1px dashed #d1d5db;
    padding: 10px;
    background: #f9fafb;
    font-size: 13px;
    color: #6b7280;
}

/* ---------------- IMAGENS EXAME ---------------- */

.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 8px;
}

.image-card {
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    padding: 8px;
    color: #111827;
}

.image-thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 8px;
    overflow: hidden;
    background: #f9fafb;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e5e7eb;
}

.image-thumb img {
    max-width: 100%;
    max-height: 100%;
    display: block;
}

.image-name {
    margin-top: 4px;
    font-size: 11px;
    color: #4b5563;
    word-break: break-all;
}

.image-actions {
    margin-top: 6px;
    display: flex;
    gap: 4px;
    justify-content: space-between;
}

.btn-xs {
    padding: 4px 8px;
    font-size: 11px;
}

.btn-danger {
    background: #b91c1c;
    color: #ffffff;
}

/* ---------------- ACTIONS ---------------- */

.actions {
    margin-top: 40px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn {
    border-radius: 999px;
    padding: 8px 14px;
    border: 0;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: linear-gradient(to right, #2563eb, #1d4ed8);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid #d1d5db;
    color: #374151;
}

.btn-secondary {
    background: #f3f4f6;
    color: #111827;
}

.btn:hover {
    filter: brightness(1.05);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.actions-note {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Destaque forte para campos obrigatórios no parecer médico */
.required-highlight {
    border-color: #dc2626 !important;              /* vermelho forte */
    background-color: #fef2f2;                     /* fundo levemente rosado */
    box-shadow: 0 0 0 1px rgba(220,38,38,0.7);     /* contorno mais intenso */
}

.required-highlight textarea,
.required-highlight input,
.required-highlight select {
    border-color: #dc2626 !important;
}

.required-highlight:focus {
    outline: none;
    border-color: #b91c1c !important;
    box-shadow: 0 0 0 2px rgba(220,38,38,0.9);
    background-color: #fee2e2;
}

/* REMOVE qualquer highlight aplicado na div inteira */
.q-item.required-highlight {
    border: none !important;
    background: transparent !important;
}

/* APLICAR highlight apenas ao textarea */
.q-item textarea.required-highlight {
    border: 2px solid #d93025 !important;
    background: #ffecec !important;
}

/* highlight apenas no campo */
textarea.required-highlight,
input.required-highlight,
select.required-highlight {
    border-color: #dc2626;
    box-shadow: 0 0 0 1px rgba(220,38,38,.4);
}

/* se por acaso a div ganhar a classe, não desenhar borda nela */
.q-item.required-highlight {
    border: none;
    box-shadow: none;
}


.alert-flash {
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}
.alert-flash-success {
    background-color: #ecfdf3;
    border: 1px solid #16a34a33;
    color: #166534;
}

#flash-msg.flash-focus {
    outline: 2px solid #1d4ed8;
}

.alert-flash {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.95rem;
}

.alert-flash-success {
    background: #dcfce7;
    border: 1px solid #22c55e;
    color: #166534;
}

.alert-flash-visible {
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.4);
    /* animação leve de entrada */
    animation: flash-pop 0.25s ease-out;
}

@keyframes flash-pop {
    from {
        transform: translateY(-4px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-validacao {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.modal-validacao.is-open {
    display: flex;
}

.modal-validacao-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.modal-validacao-dialog {
    position: relative;
    background: #ffffff;
    border-radius: 8px;
    max-width: 640px;
    width: 90%;
    padding: 16px 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.25);
    z-index: 1000;
}

.modal-validacao-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.modal-validacao-close {
    border: none;
    background: transparent;
    font-size: 20px;
    cursor: pointer;
}

.modal-validacao-body {
    font-size: 0.95rem;
    margin: 8px 0 12px;
}

.modal-validacao-footer {
    text-align: right;
}
