/* ===================================
   FINAL VIEW STYLES - GRID LAYOUT & COCKPIT
   =================================== */

:root {
    --card-bg: white;
    --card-border: #e2e8f0;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --primary-bg: #f1f5f9;
}

body {
    background-color: var(--primary-bg);
    overflow: hidden;
    /* NO MAIN PAGE SCROLL */
    height: 100vh;
}

/* Header - Premium Design */
.header {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
    border-bottom: none;
    display: flex;
    flex-direction: column;
    padding: 0;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.3);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 20% 50%, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 50%, rgba(99, 102, 241, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    position: relative;
    z-index: 1;
    max-width: none;
    width: 100%;
    margin: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    animation: pulse-glow 3s ease-in-out infinite;
}

.logo-img {
    height: 50px;
    width: auto;
    border-radius: 8px;
    background: white;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    }

    50% {
        box-shadow: 0 4px 20px rgba(59, 130, 246, 0.6);
    }
}

.logo>div:last-child {
    color: white;
}

.logo>div:last-child>div:first-child {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.logo>div:last-child>div:last-child {
    font-size: 0.75rem;
    opacity: 0.8;
    margin-top: 2px;
}

#saveIndicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    margin-left: 8px;
    transition: all 0.3s ease;
}

#saveIndicator.saved {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

#saveIndicator.saving {
    background: rgba(234, 179, 8, 0.2);
    color: #facc15;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-bar {
    position: relative;
}

.search-input {
    width: 260px;
    padding: 10px 16px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: white;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.search-input:focus {
    outline: none;
    border-color: rgba(59, 130, 246, 0.6);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.btn {
    padding: 10px 18px;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.header-title {
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Stats Bar as Filters */
.stats-bar {
    height: 48px;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 10px;
    overflow-x: auto;
}

.stat-item {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #64748b;
    transition: all 0.2s;
    white-space: nowrap;
}

.stat-item:hover {
    background: #e2e8f0;
    transform: translateY(-1px);
}

.stat-item.active {
    background: #0f172a;
    color: white;
    border-color: #0f172a;
}

/* Color Coding for Stats */
.stat-item.risk-high {
    color: #991b1b;
    background: #fef2f2;
    border-color: #fca5a5;
}

.stat-item.risk-high.active {
    background: #991b1b;
    color: white;
}

.stat-item.risk-med {
    color: #92400e;
    background: #fffbeb;
    border-color: #fcd34d;
}

.stat-item.risk-med.active {
    background: #92400e;
    color: white;
}

.stat-item.status-good {
    color: #166534;
    background: #dcfce7;
    border-color: #86efac;
}

.stat-item.status-good.active {
    background: #166534;
    color: white;
}

.stat-item.status-wait {
    color: #0369a1;
    background: #e0f2fe;
    border-color: #7dd3fc;
}

.stat-item.status-wait.active {
    background: #0369a1;
    color: white;
}


/* ===================================
   GRID LAYOUT (Patient Rows)
   =================================== */
.main-layout {
    height: calc(100vh - 130px);
    overflow-y: auto;
    padding: 16px;
    max-width: 100%;
    /* Full width */
    margin: 0;
}

.patient-grid-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Row-Base Card Styling */
.patient-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    display: grid;
    /* Grid: Strip | Identity | Clinical | Conduct | Status */
    grid-template-columns: 8px 220px 1.5fr 1fr 180px;
    min-height: 120px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    padding: 0;
    /* Align internally */
    overflow: hidden;
    /* For strip */
}

.patient-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #94a3b8;
}

/* 1. VISUAL STRIP */
.pc-strip {
    height: 100%;
    width: 100%;
    border-right: 1px solid #e2e8f0;
}

.patient-card[data-gravity="unstable"] .pc-strip {
    background: #991b1b;
}

.patient-card[data-gravity="alert"] .pc-strip {
    background: #ea580c;
}

.patient-card[data-gravity="stable"] .pc-strip {
    background: #166534;
}


/* 2. IDENTITY COL */
.pc-col-identity {
    padding: 12px;
    border-right: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.pc-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
}

.pc-meta {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 2px;
}

.pc-leito-val {
    font-size: 0.85rem;
    font-weight: 700;
    color: #3b82f6;
    margin-top: 4px;
    background: #eff6ff;
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
    width: fit-content;
}

.alergia-badge {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 8px;
    background: #fee2e2;
    color: #dc2626;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 4px;
    border: 1px solid #fca5a5;
}


/* 3. CLINICAL & 4. CONDUCT COLS */
.pc-col {
    padding: 12px;
    border-right: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    gap: 6px;
    justify-content: center;
}

.info-lbl {
    font-size: 0.7rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.info-val {
    font-size: 0.9rem;
    color: #334155;
    line-height: 1.4;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

/* 5. STATUS COL */
.pc-col-status {
    padding: 10px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    border-left: 1px solid #e2e8f0;
}

.badge-risk {
    width: 100%;
    padding: 4px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    background: #e2e8f0;
    color: #475569;
}

.patient-card[data-gravity="unstable"] .badge-risk {
    background: #fee2e2;
    color: #991b1b;
}

.patient-card[data-gravity="alert"] .badge-risk {
    background: #fff7ed;
    color: #9a3412;
}

.patient-card[data-gravity="stable"] .badge-risk {
    background: #dcfce7;
    color: #166534;
}

.systems-row {
    font-size: 0.7rem;
    font-weight: 700;
    color: #dc2626;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}

/* Night Evolution Button */
.night-evo-btn {
    width: 100%;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 6px;
    border: 1px solid #e2e8f0;
}

.night-evo-btn:hover {
    transform: scale(1.02);
}

.night-evo-icon {
    font-size: 0.9rem;
}

.night-evo-label {
    color: #64748b;
}

.night-evo-status {
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Yes State */
.night-evo-btn.night-evo-yes {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border-color: #f59e0b;
}

.night-evo-btn.night-evo-yes .night-evo-status {
    background: #f59e0b;
    color: white;
}

.night-evo-btn.night-evo-yes .night-evo-label {
    color: #92400e;
}

/* No State */
.night-evo-btn.night-evo-no {
    background: #f8fafc;
    border-color: #e2e8f0;
}

.night-evo-btn.night-evo-no .night-evo-status {
    background: #94a3b8;
    color: white;
}

/* ===================================
   RESPONSIVE DESIGN
   =================================== */

/* Header Mobile */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 12px;
        padding: 12px 16px;
    }

    .logo {
        width: 100%;
        justify-content: flex-start;
    }

    .logo-img {
        height: 40px;
    }

    .logo>div:last-child>div:first-child {
        font-size: 1rem;
    }

    .logo>div:last-child>div:last-child {
        font-size: 0.65rem;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
        gap: 8px;
    }

    .search-input {
        width: 100%;
        flex: 1;
        min-width: 120px;
    }

    .btn {
        padding: 8px 12px;
        font-size: 0.75rem;
    }

    .btn span {
        display: none;
    }

    /* Stats Bar Mobile */
    .stats-bar {
        height: auto;
        padding: 8px 12px;
        flex-wrap: wrap;
        gap: 6px;
    }

    .stat-item {
        font-size: 0.7rem;
        padding: 4px 8px;
    }

    /* Main Layout Mobile */
    .main-layout {
        height: calc(100vh - 180px);
        padding: 10px;
    }

    /* Patient Cards Mobile - Vertical Layout */
    .patient-card {
        grid-template-columns: 6px 1fr;
        grid-template-rows: auto auto auto auto;
        min-height: auto;
    }

    .pc-strip {
        grid-row: 1 / -1;
        width: 6px;
    }

    .pc-col-identity {
        grid-column: 2;
        border-right: none;
        border-bottom: 1px solid #f1f5f9;
        padding: 10px 12px;
    }

    .pc-leito-val {
        font-size: 1.1rem;
    }

    .pc-name {
        font-size: 0.9rem;
    }

    .pc-meta {
        font-size: 0.75rem;
    }

    .pc-col {
        grid-column: 2;
        border-right: none;
        border-bottom: 1px solid #f1f5f9;
        padding: 8px 12px;
    }

    .info-lbl {
        font-size: 0.65rem;
    }

    .info-val {
        font-size: 0.8rem;
        -webkit-line-clamp: 4;
    }

    .pc-col-status {
        grid-column: 2;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 8px;
        padding: 10px 12px;
        background: #f8fafc;
        border-left: none;
    }

    .badge-risk {
        width: auto;
        padding: 4px 10px;
    }

    .night-evo-btn {
        width: auto;
        flex: 1;
        min-width: 120px;
        margin-top: 0;
    }

    .systems-row {
        width: 100%;
    }
}

/* Tablet breakpoint */
@media (max-width: 1200px) and (min-width: 769px) {
    .patient-card {
        grid-template-columns: 8px 200px 1fr 180px;
    }

    .pc-col:nth-child(4) {
        display: none;
    }

    .search-input {
        width: 200px;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .header-content {
        padding: 10px 12px;
    }

    .logo {
        gap: 10px;
    }

    .logo-img {
        height: 36px;
    }

    .logo>div:last-child>div:first-child {
        font-size: 0.9rem;
    }

    #saveIndicator {
        display: none;
    }

    .header-actions {
        flex-wrap: wrap;
    }

    .search-bar {
        width: 100%;
        order: 3;
        margin-top: 4px;
    }

    .search-input {
        width: 100%;
    }

    .btn {
        flex: 1;
        justify-content: center;
    }

    .main-layout {
        height: calc(100vh - 220px);
        padding: 8px;
    }

    .patient-grid-container {
        gap: 8px;
    }

    .pc-col-identity {
        padding: 8px 10px;
    }

    .pc-leito-val {
        font-size: 1rem;
    }

    .pc-col {
        padding: 6px 10px;
    }

    .info-val {
        font-size: 0.75rem;
    }

    /* Cockpit Mobile */
    .cockpit-body {
        grid-template-columns: 1fr;
        padding: 10px;
        gap: 10px;
    }

    .cockpit-header {
        height: auto;
        padding: 10px 12px;
        flex-wrap: wrap;
    }

    .ch-info {
        flex-direction: column;
        gap: 6px;
    }

    .ch-name {
        font-size: 0.9rem;
    }

    .ch-meta {
        font-size: 0.7rem;
        flex-wrap: wrap;
    }

    .c-section {
        padding: 8px;
    }

    .c-input,
    .c-textarea {
        font-size: 0.85rem;
    }
}


/* ===================================
   FULL SCREEN COCKPIT (THE DASHBOARD)
   =================================== */

.cockpit-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f8fafc;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    overflow: hidden;
}

.cockpit-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Cockpit Header */
.cockpit-header {
    height: 45px;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    flex-shrink: 0;
}

.ch-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.ch-name {
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
}

.ch-meta {
    font-size: 0.8rem;
    color: #64748b;
    display: flex;
    gap: 12px;
}

.ch-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.highlight-pc {
    color: var(--primary-blue);
    font-weight: 800;
    background: #eff6ff;
    padding: 2px 6px;
    border-radius: 4px;
}

.btn-close {
    background: #f1f5f9;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close:hover {
    background: #e2e8f0;
    color: #ef4444;
}

/* Cockpit Grid */
.cockpit-body {
    flex: 1;
    padding: 12px;
    display: grid;
    grid-template-columns: 28% 44% 28%;
    /* Wider center */
    gap: 12px;
    background: #f1f5f9;
    overflow-y: auto;
    align-items: start;
}

.cockpit-col {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Sections */
.c-section {
    background: white;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.c-title {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: #94a3b8;
    font-weight: 800;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

/* Form Elements */
.input-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    flex-shrink: 0;
}

.compact-label {
    font-size: 0.65rem;
    color: #64748b;
    font-weight: 600;
    margin-bottom: 2px;
}

.c-input,
.c-textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    background: #f8fafc;
    transition: all 0.2s;
}

.c-textarea {
    resize: none;
    overflow-y: hidden;
    display: block;
    min-height: 80px;
}

/* Helpers */
.form-group-row {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
}

.form-group-row.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.form-group-row.three-col {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr;
}

.mt-xs {
    margin-top: 4px;
}

.mb-xs {
    margin-bottom: 4px;
}

.mt-sm {
    margin-top: 8px;
}

.h-100 {
    height: 100%;
}

.flex-col {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.flex-h {
    flex: 1;
}

.row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    height: 100%;
}

/* Status Toggles */
.status-pill-group {
    display: flex;
    background: white;
    padding: 2px;
    width: 100%;
    gap: 4px;
}

.status-pill {
    flex: 1;
    text-align: center;
    padding: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    border-radius: 4px;
    color: #64748b;
    font-weight: 600;
    border: 1px solid #e2e8f0;
}

.status-pill.active {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
    color: white;
}

.status-pill.active.risk {
    background: var(--error-red);
    border-color: var(--error-red);
}

/* Compact Checkboxes */
.compact-check {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.badge-stable {
    background: #dcfce7;
    color: #166534;
}

.badge-alert {
    background: #fef3c7;
    color: #92400e;
}

.badge-unstable {
    background: #fee2e2;
    color: #991b1b;
}

/* Status Badges */
.status-dest {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-top: 4px;
    text-transform: uppercase;
}

.status-alta {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.status-aguarda {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.status-internacao {
    background: #ffedd5;
    color: #c2410c;
    /* Laranja escuro para alerta "Vai Internar" */
    border: 1px solid #fed7aa;
}

.status-cedida {
    background: #fdf2f8;
    color: #be185d;
    border: 1px solid #fbcfe8;
}

@media (max-width: 1024px) {
    .cockpit-body {
        grid-template-columns: 1fr;
        overflow-y: auto;
        padding-bottom: 40px;
    }

    .cockpit-col {
        height: auto;
        overflow: visible;
    }

    .c-section.flex-grow {
        min-height: 150px;
    }
}

/* ===================================
   NEW BADGE STYLES (UNIFIED)
   =================================== */

/* Gravidade Unificada */
.badge-unstable {
    background: #fee2e2;
    color: #991b1b;
    border-top: 4px solid #ef4444;
    padding: 6px;
    border-radius: 4px;
    font-weight: 800;
}

.badge-alert {
    background: #fff7ed;
    color: #9a3412;
    border-top: 4px solid #f97316;
    padding: 6px;
    border-radius: 4px;
    font-weight: 800;
}

.badge-stable {
    background: #dcfce7;
    color: #166534;
    border-top: 4px solid #22c55e;
    padding: 6px;
    border-radius: 4px;
    font-weight: 800;
}

/* Status Badges */
.status-dest {
    display: inline-block;
    border-radius: 4px;
    font-weight: 700;
}

.status-alta {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #6ee7b7;
    padding: 6px;
}

.status-aguarda {
    background: #eff6ff;
    color: #0369a1;
    border: 1px solid #7dd3fc;
    padding: 6px;
}

.status-internacao {
    background: #faf5ff;
    /* Roxo */
    color: #6b21a8;
    /* Roxo */
    border: 1px solid #d8b4fe;
    padding: 6px;
}

.status-cedida {
    background: #fdf2f8;
    /* Rosa */
    color: #be185d;
    border: 1px solid #f9a8d4;
    padding: 6px;
}

/* ===================================
   PORTA VIEW (MOCKUP STYLES)
   =================================== */

.porta-grid-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 40px;
}

.porta-card {
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    display: grid;
    /* Grid: Col1(ID,AP,QP - maior) | Col2(Atendido) | Col3(Checklist) */
    grid-template-columns: 1fr 180px 180px;
    min-height: 180px;
    padding: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* COL 1: Info */
.porta-col-info {
    padding: 10px;
    border-right: 1px solid #cbd5e1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
}

.porta-id-row {
    margin-bottom: 4px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 4px;
}

.porta-name {
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
}

.porta-meta {
    font-size: 0.8rem;
    color: #64748b;
}

.porta-text-group {
    display: flex;
    flex-direction: column;
}

.porta-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
}

.porta-val {
    font-size: 0.85rem;
    color: #334155;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* COL 2: Atendido Por (Full Textarea) */
.porta-col-atendido {
    display: flex;
    flex-direction: column;
    border-right: 1px solid #cbd5e1;
    height: 100%;
    background: #f8fafc;
}

.porta-col-atendido .porta-label {
    padding: 6px 10px;
    border-bottom: 1px solid #e2e8f0;
    background: #e2e8f0;
    color: #475569;
}

.porta-textarea {
    flex: 1;
    width: 100%;
    border: none;
    padding: 10px;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    resize: none;
    min-height: 40px;
    outline: none;
    background: transparent;
    color: #0f172a;
}

.porta-textarea:focus {
    background: #fff;
}

/* COL 3: Checklist */
.porta-col-checks {
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    background: #fff;
}

.porta-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #334155;
    cursor: pointer;
    line-height: 1.2;
    padding: 2px 0;
}

.porta-check input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #0f172a;
}

/* Porta Editable Inputs */
.porta-input-name {
    width: 100%;
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 2px 4px;
    margin-bottom: 2px;
}

.porta-input-name:focus {
    border-color: #3b82f6;
    background: #eff6ff;
    outline: none;
}

.porta-meta-row {
    font-size: 0.8rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 4px;
}

.porta-input-meta {
    font-size: 0.8rem;
    color: #64748b;
    border: 1px solid #e2e8f0;
    /* Slight border for visibility */
    border-radius: 4px;
    padding: 1px 4px;
    text-align: center;
}

.porta-input-meta:focus {
    border-color: #3b82f6;
    background: #eff6ff;
    outline: none;
}

.porta-textarea-small {
    width: 100%;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    color: #334155;
    border: 1px solid transparent;
    /* Hidden unless focused or hovered */
    border-radius: 4px;
    padding: 4px 6px;
    resize: none;
    /* Allow manual resize */
    min-height: 30px;
    max-height: none;
    /* No max height - show all content */
    background: transparent;
    line-height: 1.4;
    overflow-y: auto;
    /* Scroll only if really needed */
}

.porta-textarea-small:hover {
    background: #f8fafc;
}

.porta-textarea-small:focus {
    border-color: #3b82f6;
    background: #fff;
    outline: none;
}

.btn-delete-porta {
    position: absolute;
    top: 6px;
    right: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    opacity: 0.2;
    transition: opacity 0.2s;
    font-size: 0.9rem;
}

.porta-card {
    position: relative;
    /* For absolute positioning of delete button */
}

.porta-card:hover .btn-delete-porta {
    opacity: 1;
}

.btn-delete-porta:hover {
    transform: scale(1.1);
    color: #dc2626;
}

/* Divider for checklist */
.porta-divider {
    height: 1px;
    background: #e2e8f0;
    margin: 4px 0;
}

.porta-check-special {
    background: #f1f5f9;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
}

/* Document Action Buttons (Retaguarda) */
.btn-doc-action {
    flex: 1;
    background: white;
    border: 1px solid #cbd5e1;
    color: #64748b;
    border-radius: 4px;
    padding: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.btn-doc-action:hover {
    background: #f0f9ff;
    border-color: #3b82f6;
    color: #0369a1;
}

.btn-doc-action.done {
    background: #ecfdf5;
    border-color: #10b981;
    color: #047857;
}

/* ===================================
   DOCUMENT POPUP STYLES
   =================================== */

.doc-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    backdrop-filter: blur(4px);
    pointer-events: auto;
}

.doc-popup {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.doc-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #2563eb, #1e40af);
    color: white;
}

.doc-popup-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
}

.doc-popup-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.doc-popup-close:hover {
    opacity: 0.8;
}

.doc-popup-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.doc-popup-patient {
    padding: 10px 14px;
    background: #f1f5f9;
    border-radius: 6px;
    font-size: 0.95rem;
}

.doc-popup-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.doc-popup-field label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
}

.doc-popup-textarea {
    width: 100%;
    min-height: 80px;
    padding: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    resize: vertical;
    outline: none;
}

.doc-popup-textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.doc-popup-result {
    min-height: 200px;
    background: #f8fafc;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}

.doc-popup-btn-generate {
    align-self: flex-start;
    padding: 10px 20px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.doc-popup-btn-generate:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.doc-popup-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

.doc-popup-btn-cancel {
    padding: 10px 20px;
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    color: #64748b;
}

.doc-popup-btn-cancel:hover {
    background: #f1f5f9;
}

.doc-popup-btn-save {
    padding: 10px 24px;
    background: linear-gradient(135deg, #2563eb, #1e40af);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.doc-popup-btn-save:hover {
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}