/**
 * INDASOL - Portal de Comunidades
 * Stylesheet
 */

/* ===================================
   CSS Variables
   =================================== */
:root {
    --portal-primary: #2F5D8C;
    --portal-primary-dark: #1e3f5e;
    --portal-primary-light: #3d7ab8;
    --portal-accent: #4A90D9;
    --portal-sidebar-bg: #1a2332;
    --portal-sidebar-hover: #243447;
    --portal-sidebar-active: #2F5D8C;
    --portal-topbar-bg: #ffffff;
    --portal-body-bg: #f0f4f8;
    --portal-card-bg: #ffffff;
    --portal-text: #2c3e50;
    --portal-text-light: #7f8c9b;
    --portal-border: #e2e8f0;
    --portal-success: #27ae60;
    --portal-warning: #f39c12;
    --portal-danger: #e74c3c;
    --portal-info: #3498db;
    --portal-radius: 12px;
    --portal-radius-sm: 8px;
    --portal-shadow: 0 2px 12px rgba(0,0,0,0.08);
    --portal-shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --portal-transition: 0.25s ease;
    --sidebar-width: 260px;
}

/* ===================================
   Reset & Base
   =================================== */
.portal-body {
    display: flex;
    min-height: 100vh;
    background: var(--portal-body-bg);
    font-family: 'Inter', 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--portal-text);
    margin: 0;
    padding: 0;
}

.portal-body *,
.portal-body *::before,
.portal-body *::after {
    box-sizing: border-box;
}

/* ===================================
   Sidebar
   =================================== */
.portal-sidebar {
    width: var(--sidebar-width);
    background: var(--portal-sidebar-bg);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--portal-transition);
    overflow-y: auto;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #fff;
}

.sidebar-logo img {
    height: 36px;
    width: auto;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
}

.sidebar-close svg {
    width: 20px;
    height: 20px;
}

.sidebar-user {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--portal-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
}

.sidebar-user-name {
    font-size: 14px;
    font-weight: 600;
    color: #e2e8f0;
}

.sidebar-user-role {
    font-size: 12px;
    color: #64748b;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 0;
}

.sidebar-nav-section {
    margin-bottom: 4px;
}

.sidebar-nav-label {
    display: block;
    padding: 12px 20px 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #64748b;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--portal-transition);
    border-left: 3px solid transparent;
    position: relative;
}

.sidebar-link:hover {
    color: #e2e8f0;
    background: var(--portal-sidebar-hover);
}

.sidebar-link.active {
    color: #ffffff;
    background: var(--portal-sidebar-active);
    border-left-color: var(--portal-accent);
}

.sidebar-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-badge {
    margin-left: auto;
    background: var(--portal-danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 0;
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* ===================================
   Community Switcher
   =================================== */
.sidebar-community-switcher {
    padding: 8px 12px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-community-switcher .sidebar-nav-label {
    padding: 4px 8px 6px;
}

.community-selector {
    position: relative;
}

.community-selector-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.community-selector-btn:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.18);
}

.community-selector-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: #94a3b8;
}

.community-selector-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.community-selector-arrow {
    transition: transform 0.25s ease;
}

.community-selector.open .community-selector-arrow {
    transform: rotate(180deg);
}

.community-selector.open .community-selector-btn {
    background: rgba(255,255,255,0.1);
    border-color: var(--portal-accent);
}

.community-selector-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #1e2d3d;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    padding: 4px;
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    max-height: 240px;
    overflow-y: auto;
    animation: commDropdownIn 0.2s ease;
}

.community-selector.open .community-selector-dropdown {
    display: block;
}

@keyframes commDropdownIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.community-option-form {
    margin: 0;
}

.community-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    background: none;
    border: none;
    border-radius: 6px;
    color: #94a3b8;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
}

.community-option:hover {
    background: rgba(255,255,255,0.08);
    color: #e2e8f0;
}

.community-option.active {
    color: #fff;
    background: var(--portal-sidebar-active);
}

.community-option svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: var(--portal-accent);
}

.community-option-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #475569;
    margin: 0 4px;
    flex-shrink: 0;
}

/* Single community (no dropdown) */
.community-single {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: #cbd5e1;
    font-size: 13px;
    font-weight: 500;
    background: rgba(255,255,255,0.04);
    border-radius: 8px;
}

.community-single svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: #64748b;
}

.sidebar-footer .sidebar-link {
    border-left: none;
    color: #64748b;
}

.sidebar-footer .sidebar-link:hover {
    color: #e2e8f0;
    background: var(--portal-sidebar-hover);
}

/* ===================================
   Main Content
   =================================== */
.portal-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    overflow-x: hidden;
}

/* ===================================
   Top Bar
   =================================== */
.portal-topbar {
    background: var(--portal-topbar-bg);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--portal-border);
    position: sticky;
    top: 0;
    z-index: 220;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.portal-page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--portal-text);
    margin: 0;
    flex: 1;
}

.portal-topbar-title-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.portal-topbar-title-group .portal-page-title {
    flex: unset;
}

.portal-topbar-community {
    font-size: 12px;
    font-weight: 500;
    color: var(--portal-text-light);
    display: flex;
    align-items: center;
    gap: 5px;
}

.portal-topbar-community::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--portal-success);
    flex-shrink: 0;
}

.portal-topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.portal-topbar-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    color: var(--portal-text-light);
    transition: all var(--portal-transition);
    text-decoration: none;
}

.portal-topbar-link:hover {
    background: rgba(47, 93, 140, 0.08);
    color: var(--portal-primary);
}

.portal-topbar-link svg {
    width: 20px;
    height: 20px;
}

.portal-menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--portal-text);
    position: relative;
    z-index: 221;
    pointer-events: auto;
    touch-action: manipulation;
}

.portal-menu-toggle svg {
    width: 24px;
    height: 24px;
}

/* ===================================
   Content Area
   =================================== */
.portal-content {
    padding: 32px;
    flex: 1;
    max-width: 100%;
    overflow-x: hidden;
}

/* ===================================
   Cards
   =================================== */
.portal-card {
    background: var(--portal-card-bg);
    border-radius: var(--portal-radius);
    box-shadow: var(--portal-shadow);
    margin-bottom: 24px;
    overflow: hidden;
    max-width: 100%;
    box-sizing: border-box;
}

.portal-card-header {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--portal-border);
}

.portal-card-header h2 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    color: var(--portal-text);
}

.portal-card-body {
    padding: 24px;
    min-width: 0;
}

/* ===================================
   Stats Grid
   =================================== */
.portal-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.portal-stat-card {
    background: var(--portal-card-bg);
    border-radius: var(--portal-radius);
    padding: 24px;
    box-shadow: var(--portal-shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform var(--portal-transition), box-shadow var(--portal-transition);
}

.portal-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--portal-shadow-lg);
}

a.portal-stat-card-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

/* ===================================
   Panel General (dashboard global) — ver también el bloque ampliado
   "Panel General v2" al final de este archivo.
   =================================== */
.panel-general-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.panel-general-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--portal-text);
}

.panel-general-date {
    font-size: 14px;
    font-weight: 600;
    color: var(--portal-text-light);
    text-transform: capitalize;
}


.portal-stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.portal-stat-icon svg {
    width: 24px;
    height: 24px;
}

.portal-stat-icon.blue { background: rgba(47, 93, 140, 0.1); color: var(--portal-primary); }
.portal-stat-icon.green { background: rgba(39, 174, 96, 0.1); color: var(--portal-success); }
.portal-stat-icon.orange { background: rgba(243, 156, 18, 0.1); color: var(--portal-warning); }
.portal-stat-icon.red { background: rgba(231, 76, 60, 0.1); color: var(--portal-danger); }

.portal-stat-info h3 {
    font-size: 28px;
    font-weight: 800;
    margin: 0 0 4px 0;
    color: var(--portal-text);
    line-height: 1;
}

.portal-stat-info p {
    font-size: 13px;
    color: var(--portal-text-light);
    margin: 0;
    font-weight: 500;
}

.portal-stat-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    word-break: normal;
    overflow-wrap: anywhere;
}

.portal-stat-number {
    font-size: 28px;
    font-weight: 800;
    color: var(--portal-text);
    line-height: 1;
}

.portal-stat-label {
    font-size: 13px;
    color: var(--portal-primary);
    margin-top: 6px;
    font-weight: 600;
    line-height: 1.35;
    word-break: normal;
    overflow-wrap: anywhere;
    text-wrap: balance;
}

.portal-stat-line1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--portal-text);
    line-height: 1.2;
}

.portal-stat-line1 .portal-stat-number {
    font-size: inherit;
    font-weight: inherit;
}

.portal-stat-line2 {
    font-size: 13px;
    color: var(--portal-text-light);
    font-weight: 500;
    line-height: 1.3;
}

/* ===================================
   Dashboard Lists
   =================================== */
.portal-list {
    display: flex;
    flex-direction: column;
}

.portal-list-item {
    display: flex;
    align-items: flex-start;
    padding: 14px 0;
    border-bottom: 1px solid var(--portal-border);
}

.portal-list-item:last-child {
    border-bottom: none;
}

a.portal-list-item-link {
    text-decoration: none;
    color: inherit;
    padding: 14px 12px;
    margin: 0 -12px;
    border-radius: var(--portal-radius-sm);
    transition: background var(--portal-transition);
}

a.portal-list-item-link:hover {
    background: #f1f5f9;
}

.portal-list-item-content {
    flex: 1;
    min-width: 0;
}

.portal-list-item-content h4 {
    margin: 4px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--portal-text);
    line-height: 1.4;
}

a.portal-list-item-link:hover h4 {
    color: var(--portal-primary);
}

.portal-list-item-content p {
    margin: 0;
    font-size: 13px;
    color: var(--portal-text-light);
    line-height: 1.5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.portal-list-item-top {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}

.portal-list-meta {
    font-size: 12px;
    color: var(--portal-text-light);
    margin-left: auto;
}

.portal-list-item.unread {
    position: relative;
}

.portal-list-item.unread::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--portal-primary);
}

.portal-list-item.unread h4 {
    font-weight: 700;
}

/* ===================================
   Tables
   =================================== */
.portal-table-wrapper {
    overflow-x: auto;
}

.portal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.portal-table thead th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--portal-text-light);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--portal-border);
    white-space: nowrap;
}

.portal-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--portal-border);
    vertical-align: middle;
}

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

.portal-table tbody tr:hover {
    background: rgba(47, 93, 140, 0.03);
}

/* ===================================
   Badges
   =================================== */
.portal-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

.portal-badge-info { background: rgba(52, 152, 219, 0.1); color: #2980b9; }
.portal-badge-success, .portal-badge-confirmed { background: rgba(39, 174, 96, 0.1); color: #27ae60; }
.portal-badge-warning { background: rgba(243, 156, 18, 0.1); color: #e67e22; }
.portal-badge-danger, .portal-badge-cancelled { background: rgba(231, 76, 60, 0.1); color: #c0392b; }
.portal-badge-open { background: rgba(231, 76, 60, 0.1); color: #e74c3c; }
.portal-badge-acknowledged { background: rgba(52, 152, 219, 0.1); color: #3498db; }
.portal-badge-in_progress { background: rgba(243, 156, 18, 0.1); color: #f39c12; }
.portal-badge-resolved { background: rgba(39, 174, 96, 0.1); color: #27ae60; }
.portal-badge-closed { background: rgba(149, 165, 166, 0.1); color: #7f8c8d; }
.portal-badge-pending { background: rgba(234, 179, 8, 0.1); color: #ca8a04; }
.portal-badge-reviewed { background: rgba(59, 130, 246, 0.1); color: #2563eb; }
.portal-badge-answered { background: rgba(16, 185, 129, 0.1); color: #059669; }
.portal-badge-primary { background: rgba(47, 93, 140, 0.1); color: var(--portal-primary); }
.portal-badge-priority-low { background: rgba(149, 165, 166, 0.1); color: #7f8c8d; }
.portal-badge-priority-medium { background: rgba(52, 152, 219, 0.1); color: #2980b9; }
.portal-badge-priority-high { background: rgba(243, 156, 18, 0.1); color: #e67e22; }
.portal-badge-priority-urgent { background: rgba(231, 76, 60, 0.15); color: #c0392b; font-weight: 700; }

/* ===================================
   Forms
   =================================== */
.portal-form {
    max-width: 680px;
}

.portal-form-group {
    margin-bottom: 20px;
}

.portal-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--portal-text);
    margin-bottom: 6px;
}

.portal-form-group input[type="text"],
.portal-form-group input[type="email"],
.portal-form-group input[type="password"],
.portal-form-group input[type="tel"],
.portal-form-group input[type="number"],
.portal-form-group input[type="date"],
.portal-form-group input[type="time"],
.portal-form-group input[type="file"],
.portal-form-group select,
.portal-form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--portal-border);
    border-radius: var(--portal-radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--portal-text);
    background: #fff;
    transition: border-color var(--portal-transition), box-shadow var(--portal-transition);
    box-sizing: border-box;
    max-width: 100%;
}

.portal-form-group input:focus,
.portal-form-group select:focus,
.portal-form-group textarea:focus {
    outline: none;
    border-color: var(--portal-primary);
    box-shadow: 0 0 0 3px rgba(47, 93, 140, 0.12);
}

.portal-form-group textarea {
    resize: vertical;
    min-height: 100px;
}

/* Show/hide password toggle (eye icon) */
input.has-pw-toggle {
    padding-right: 42px !important;
}

.pw-toggle-btn {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    margin: 0;
    border: none;
    background: none;
    color: #9ca3af;
    cursor: pointer;
    z-index: 3;
    transition: color 0.2s ease;
}

.pw-toggle-btn:hover,
.pw-toggle-btn:focus-visible {
    color: #2F5D8C;
}

.pw-toggle-btn svg {
    width: 18px;
    height: 18px;
    pointer-events: none;
}

.portal-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.portal-form-check label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
}

.portal-form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--portal-primary);
}

/* ===================================
   Buttons
   =================================== */
.portal-body .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--portal-radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--portal-transition);
    line-height: 1.4;
}

.portal-body .btn-primary {
    background: var(--portal-primary);
    color: #fff;
}

.portal-body .btn-primary:hover {
    background: var(--portal-primary-dark);
    box-shadow: 0 4px 12px rgba(47, 93, 140, 0.3);
}

.portal-body .btn-sm {
    padding: 7px 14px;
    font-size: 13px;
}

.portal-action-link {
    background: none;
    border: none;
    color: var(--portal-primary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background var(--portal-transition);
    text-decoration: none;
}

.portal-action-link:hover {
    background: rgba(47, 93, 140, 0.08);
}

.portal-action-danger {
    color: var(--portal-danger);
}

.portal-action-danger:hover {
    background: rgba(231, 76, 60, 0.08);
}

/* ===================================
   Alerts
   =================================== */
.portal-alert {
    padding: 14px 20px;
    border-radius: var(--portal-radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
}

.portal-alert-success {
    background: rgba(39, 174, 96, 0.1);
    color: #1e8449;
    border: 1px solid rgba(39, 174, 96, 0.2);
}

.portal-alert-error {
    background: rgba(231, 76, 60, 0.1);
    color: #c0392b;
    border: 1px solid rgba(231, 76, 60, 0.2);
}

/* ===================================
   Empty States
   =================================== */
.portal-empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--portal-text-light);
}

.portal-empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.portal-empty-state h3 {
    font-size: 18px;
    margin: 0 0 8px;
    color: var(--portal-text);
}

.portal-empty-state p {
    margin: 0 0 20px;
    font-size: 14px;
}

.portal-empty {
    text-align: center;
    padding: 32px;
    color: var(--portal-text-light);
    font-size: 14px;
}

.portal-text-muted {
    color: var(--portal-text-light);
    font-size: 14px;
    line-height: 1.6;
    margin: 4px 0 12px;
}

.portal-card-link {
    color: var(--portal-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: color var(--portal-transition);
}

.portal-card-link:hover {
    color: var(--portal-primary-dark);
}

/* ===================================
   Back Link
   =================================== */
.portal-back-link {
    color: var(--portal-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: color var(--portal-transition);
}

.portal-back-link:hover {
    color: var(--portal-primary-dark);
}

/* ===================================
   Filter Bar
   =================================== */
.portal-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--portal-border);
}

.portal-filter-tag {
    display: inline-flex;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    color: var(--portal-text-light);
    background: rgba(0,0,0,0.04);
    transition: all var(--portal-transition);
}

.portal-filter-tag:hover {
    background: rgba(47, 93, 140, 0.08);
    color: var(--portal-primary);
}

.portal-filter-tag.active {
    background: var(--portal-primary);
    color: #fff;
}

/* ===================================
   Document year groups (contratos)
   =================================== */
.portal-year-group {
    margin-bottom: 12px;
    border: 1px solid var(--portal-border);
    border-radius: 8px;
    overflow: hidden;
}

.portal-year-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--portal-bg);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    list-style: none;
    user-select: none;
    border-bottom: 1px solid transparent;
}

.portal-year-group[open] > .portal-year-group-header {
    border-bottom-color: var(--portal-border);
}

.portal-year-group-header::-webkit-details-marker { display: none; }

.portal-year-group-header::before {
    content: '▶';
    font-size: 0.7rem;
    margin-right: 10px;
    transition: transform 0.2s;
    color: var(--portal-primary);
}

.portal-year-group[open] > .portal-year-group-header::before {
    transform: rotate(90deg);
}

.portal-year-group-count {
    background: var(--portal-primary);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: auto;
}

.portal-year-group .portal-table-wrapper {
    border-radius: 0;
    border: none;
}


.portal-comm-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.portal-comm-item {
    display: flex;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--portal-border);
    cursor: pointer;
    transition: background var(--portal-transition);
}

.portal-comm-item:last-child {
    border-bottom: none;
}

.portal-comm-item:hover {
    background: rgba(47, 93, 140, 0.02);
}

.portal-comm-item.unread {
    position: relative;
}

.portal-comm-item.unread::before {
    content: '';
    position: absolute;
    left: -24px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--portal-primary);
}

.portal-comm-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--portal-text-light);
}

.portal-comm-detail {
    max-width: 800px;
}

.portal-comm-detail h2 {
    font-size: 22px;
    margin: 0 0 8px;
}

.portal-comm-detail .portal-comm-meta {
    margin-bottom: 24px;
}

.portal-comm-detail .portal-comm-body {
    font-size: 15px;
    line-height: 1.7;
    color: var(--portal-text);
}

.portal-comm-detail .portal-comm-body p {
    margin-bottom: 16px;
}

.comm-attachment {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    padding: 12px 16px;
    background: var(--portal-bg);
    border: 1px solid var(--portal-border);
    border-radius: 10px;
}
.comm-attachment svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--portal-primary);
}
.comm-attachment a {
    color: var(--portal-primary);
    font-weight: 500;
    font-size: 14px;
    text-decoration: none;
}
.comm-attachment a:hover {
    text-decoration: underline;
}

/* ===================================
   Incidents
   =================================== */
.portal-incident-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.portal-incident-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--portal-border);
    gap: 12px;
}

.portal-incident-item:last-child {
    border-bottom: none;
}

.portal-incident-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.portal-incident-title a {
    color: var(--portal-text);
    text-decoration: none;
}

.portal-incident-title a:hover {
    color: var(--portal-primary);
}

/* Two-column incident detail */
.portal-incident-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.portal-incident-sidebar .portal-card {
    position: sticky;
    top: 80px;
}

/* Comments & Incident Detail */
.incident-detail h2 {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 12px;
    color: var(--portal-text);
}

.incident-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    font-size: 14px;
}

.incident-body {
    font-size: 15px;
    line-height: 1.7;
    color: #374151;
    padding: 16px 0;
    border-bottom: 1px solid var(--portal-border);
}

.incident-image {
    margin-top: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--portal-border);
}

.incident-image img {
    max-width: 100%;
    border-radius: var(--portal-radius-sm);
    box-shadow: var(--portal-shadow);
    height: auto;
}

.incident-comments {
    margin-top: 28px;
}

.incident-comments h3 {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--portal-border);
    color: var(--portal-text);
}

.incident-comment {
    display: flex;
    flex-direction: column;
    padding: 14px 16px;
    margin-bottom: 12px;
    background: #f8fafc;
    border-radius: var(--portal-radius-sm);
    border: 1px solid var(--portal-border);
    transition: background var(--portal-transition);
}

.incident-comment.admin-comment {
    background: rgba(47, 93, 140, 0.05);
    border-left: 3px solid var(--portal-primary);
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.comment-header strong {
    font-size: 13px;
    color: var(--portal-text);
}

.comment-date {
    font-size: 12px;
    color: var(--portal-text-light);
    margin-left: auto;
}

.incident-comment p {
    margin: 0;
    font-size: 14px;
    line-height: 1.65;
    color: #4b5563;
}

.comment-form {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid var(--portal-border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.comment-form textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius-sm);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    transition: border-color var(--portal-transition), box-shadow var(--portal-transition);
    background: #fff;
    color: var(--portal-text);
    box-sizing: border-box;
    max-width: 100%;
}

.comment-form textarea:focus {
    outline: none;
    border-color: var(--portal-primary);
    box-shadow: 0 0 0 3px rgba(47, 93, 140, 0.1);
}

.comment-form .btn {
    align-self: flex-end;
}

.comments-empty {
    text-align: center;
    color: var(--portal-text-light);
    font-size: 14px;
    padding: 20px 0;
    font-style: italic;
    margin: 0;
}

/* Legacy comment classes (used by portal-comment-list widget) */
.portal-comment-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.portal-comment {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: #f8fafc;
    border-radius: var(--portal-radius-sm);
}

.portal-comment.admin-comment {
    background: rgba(47, 93, 140, 0.06);
    border-left: 3px solid var(--portal-primary);
}

.portal-comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--portal-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.portal-comment-content {
    flex: 1;
}

.portal-comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.portal-comment-name {
    font-weight: 600;
    font-size: 13px;
}

.portal-comment-date {
    font-size: 12px;
    color: var(--portal-text-light);
}

.portal-comment-text {
    font-size: 14px;
    line-height: 1.6;
}

/* ===================================
   Reservations - Facilities & Slots
   =================================== */
.portal-facilities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.portal-facility-card {
    display: flex;
    flex-direction: column;
    border-radius: var(--portal-radius);
    overflow: hidden;
    background: var(--portal-card-bg);
    border: 1px solid var(--portal-border);
    text-decoration: none;
    color: inherit;
    transition: transform var(--portal-transition), box-shadow var(--portal-transition);
}

.portal-facility-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--portal-shadow-lg);
}

.portal-facility-img {
    position: relative;
    width: 100%;
    height: 180px;
    overflow: hidden;
    background: linear-gradient(135deg, #e8eef5, #dce5f0);
}

.portal-facility-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.portal-facility-card:hover .portal-facility-img img {
    transform: scale(1.05);
}

.portal-facility-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--portal-primary);
    opacity: 0.4;
}

.portal-facility-info {
    padding: 16px 18px 12px;
    flex: 1;
}

.portal-facility-info h4 {
    font-size: 17px;
    font-weight: 700;
    margin: 0 0 6px;
    color: var(--portal-text);
}

.portal-facility-desc {
    font-size: 13px;
    color: var(--portal-text-light);
    margin: 0 0 10px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.portal-facility-meta {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--portal-text-light);
    font-weight: 500;
}

.portal-facility-meta span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.portal-facility-meta svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.portal-facility-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-top: 1px solid var(--portal-border);
    font-size: 14px;
    font-weight: 600;
    color: var(--portal-primary);
    background: rgba(47, 93, 140, 0.03);
    transition: background var(--portal-transition);
}

.portal-facility-card:hover .portal-facility-action {
    background: rgba(47, 93, 140, 0.08);
}

.portal-facility-hero {
    width: 100%;
    max-height: 220px;
    overflow: hidden;
}

.portal-facility-hero img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    display: block;
}

.portal-slots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
}

.portal-slot {
    text-align: center;
    padding: 10px 8px;
    border-radius: var(--portal-radius-sm);
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all var(--portal-transition);
    font-family: inherit;
}

.portal-slot.available {
    background: rgba(39, 174, 96, 0.1);
    color: var(--portal-success);
    border: 1.5px solid rgba(39, 174, 96, 0.3);
}

.portal-slot.available:hover {
    background: var(--portal-success);
    color: #fff;
    transform: scale(1.05);
}

.portal-slot.booked {
    background: rgba(231, 76, 60, 0.08);
    color: #bbb;
    cursor: not-allowed;
    text-decoration: line-through;
}

.portal-slot.past {
    background: #f5f5f5;
    color: #ccc;
    cursor: not-allowed;
}

.portal-date-picker {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.portal-date-picker label {
    font-weight: 600;
    font-size: 14px;
}

.portal-date-picker input[type="date"] {
    padding: 8px 14px;
    border: 1.5px solid var(--portal-border);
    border-radius: var(--portal-radius-sm);
    font-size: 14px;
    font-family: inherit;
}

/* ===================================
   Reservations List
   =================================== */
.portal-reservations-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.portal-reservations-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--portal-border);
    font-size: 14px;
}

.portal-reservations-list li:last-child {
    border-bottom: none;
}

/* ===================================
   Activity Log
   =================================== */
.portal-activity-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.portal-activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--portal-border);
    font-size: 13px;
}

.portal-activity-item:last-child {
    border-bottom: none;
}

.portal-activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--portal-primary);
    flex-shrink: 0;
}

.portal-activity-time {
    color: var(--portal-text-light);
    font-size: 12px;
    margin-left: auto;
    white-space: nowrap;
}

/* ===================================
   Mobile Overlay
   =================================== */
.portal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}

.portal-overlay.active {
    display: block;
}

/* ===================================
   Login Page
   =================================== */
.portal-login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f1923 0%, #1a2f44 30%, #2F5D8C 70%, #3d7ab8 100%);
    padding: 20px;
    font-family: 'Montserrat', 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    position: relative;
    overflow: hidden;
    margin: 0;
}

/* Decorative background shapes */
.login-bg-shapes {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.login-bg-shape {
    position: absolute;
    border-radius: 50%;
    opacity: 0.07;
    background: #fff;
}

.login-bg-shape--1 {
    width: 600px;
    height: 600px;
    top: -200px;
    right: -150px;
    animation: loginFloat 20s ease-in-out infinite;
}

.login-bg-shape--2 {
    width: 400px;
    height: 400px;
    bottom: -100px;
    left: -100px;
    animation: loginFloat 15s ease-in-out infinite reverse;
}

.login-bg-shape--3 {
    width: 200px;
    height: 200px;
    top: 50%;
    left: 60%;
    animation: loginFloat 12s ease-in-out infinite 3s;
}

@keyframes loginFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.05); }
    66% { transform: translate(-20px, 20px) scale(0.95); }
}

.portal-login-wrapper {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 440px;
}

.portal-login-card {
    background: rgba(255, 255, 255, 0.97);
    border-radius: 20px;
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    padding: 48px 40px 40px;
    width: 100%;
    backdrop-filter: blur(20px);
    animation: loginCardAppear 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Prevent any SVG inside login card from rendering huge */
.portal-login-card svg {
    flex-shrink: 0;
    overflow: visible;
}

@keyframes loginCardAppear {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header */
.portal-login-header {
    text-align: center;
    margin-bottom: 40px;
}

.portal-login-logo-link {
    display: inline-block;
    transition: transform 0.3s ease;
}

.portal-login-logo-link:hover {
    transform: scale(1.05);
}

.portal-login-logo {
    height: 56px;
    width: auto;
    margin-bottom: 20px;
}

.portal-login-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 22px;
    font-weight: 800;
    color: #1a2332;
    margin: 0 0 8px;
    letter-spacing: -0.3px;
}

.portal-login-subtitle {
    color: #94a3b8;
    font-size: 14.5px;
    font-weight: 400;
    margin: 4px 0 0;
    font-family: 'Poppins', sans-serif;
}

/* Form */
.portal-login-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.portal-login-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.portal-login-field label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    letter-spacing: 0.2px;
    font-family: 'Montserrat', sans-serif;
}

.portal-login-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.portal-login-input-icon {
    position: absolute;
    left: 14px;
    width: 18px !important;
    height: 18px !important;
    max-width: 18px;
    max-height: 18px;
    min-width: 0;
    min-height: 0;
    color: #9ca3af;
    pointer-events: none;
    transition: color 0.25s ease;
    z-index: 1;
    top: 50%;
    transform: translateY(-50%);
    flex-shrink: 0;
    overflow: visible;
}

.portal-login-input-wrap input {
    width: 100%;
    padding: 13px 16px 13px 44px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 15px;
    font-family: 'Poppins', sans-serif;
    color: #1a2332;
    background: #f8fafc;
    transition: all 0.25s ease;
    outline: none;
}

.portal-login-input-wrap input::placeholder {
    color: #b0bec5;
    font-weight: 300;
}

.portal-login-input-wrap input:hover {
    border-color: #cbd5e1;
    background: #fff;
}

.portal-login-input-wrap input:focus {
    border-color: #2F5D8C;
    background: #fff;
    box-shadow: 0 0 0 3.5px rgba(47, 93, 140, 0.12);
}

.portal-login-input-wrap input:focus ~ .portal-login-input-icon,
.portal-login-input-wrap:focus-within .portal-login-input-icon {
    color: #2F5D8C;
}

/* Submit Button */
.portal-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px 28px;
    margin-top: 12px;
    background: linear-gradient(135deg, #2F5D8C 0%, #3d7ab8 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-family: 'Montserrat', sans-serif;
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(47, 93, 140, 0.25);
}

.portal-login-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0) 50%);
    opacity: 0;
    transition: opacity 0.35s ease;
}

.portal-login-btn:hover::before {
    opacity: 1;
}

.portal-login-btn svg {
    width: 18px;
    height: 18px;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.portal-login-btn:hover {
    background: linear-gradient(135deg, #1e3f5e 0%, #2F5D8C 100%);
    box-shadow: 0 8px 30px rgba(47, 93, 140, 0.4);
    transform: translateY(-2px);
}

.portal-login-btn:hover svg {
    transform: translateX(4px);
}

.portal-login-btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(47, 93, 140, 0.3);
    transition-duration: 0.1s;
}

/* Error Alert */
.portal-login-error {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    color: #b91c1c;
    padding: 13px 16px;
    border-radius: 10px;
    margin-bottom: 24px;
    font-size: 13.5px;
    font-weight: 500;
    border: 1px solid #fecaca;
    animation: loginShake 0.5s ease;
}

.portal-login-error svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

@keyframes loginShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

/* Back Link */
.portal-login-back {
    text-align: center;
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid #f1f5f9;
}

.portal-login-back a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #7f8c9b;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.25s ease;
    font-family: 'Poppins', sans-serif;
}

.portal-login-back a svg {
    width: 16px;
    height: 16px;
    transition: transform 0.25s ease;
}

.portal-login-back a:hover {
    color: #2F5D8C;
}

.portal-login-back a:hover svg {
    transform: translateX(-3px);
}

/* Brand footer */
.portal-login-brand {
    margin-top: 24px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
    font-family: 'Poppins', sans-serif;
    letter-spacing: 0.3px;
    animation: loginCardAppear 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}

/* ===================================
   Responsive
   =================================== */
@media (max-width: 1024px) {
    .portal-incident-grid {
        grid-template-columns: 1fr;
    }
    
    .portal-incident-sidebar .portal-card {
        position: static;
    }
}

@media (max-width: 768px) {
    .portal-sidebar {
        transform: translateX(-100%);
    }
    
    .portal-sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-close {
        display: block;
    }
    
    .portal-main {
        margin-left: 0;
    }
    
    .portal-menu-toggle {
        display: block;
    }
    
    .portal-topbar {
        padding: 12px 16px;
    }
    
    .portal-page-title {
        font-size: 18px;
    }
    
    .portal-content {
        padding: 20px 16px;
    }
    
    .portal-stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .portal-stat-card {
        padding: 14px;
        gap: 12px;
    }
    
    .portal-stat-info h3 {
        font-size: 20px;
    }

    .portal-stat-line1 {
        font-size: 15px;
    }

    .portal-stat-line2 {
        font-size: 12px;
    }
    
    .portal-form-row {
        grid-template-columns: 1fr;
    }
    
    .portal-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 16px;
    }
    
    .portal-card-body {
        padding: 16px;
    }

    a.portal-list-item-link {
        margin: 0 -8px;
        padding: 12px 8px;
    }

    .portal-list-item-content p {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        word-break: break-word;
    }

    .portal-list-item-top {
        gap: 6px;
    }

    .portal-list-meta {
        margin-left: 0;
        width: 100%;
        margin-top: 2px;
    }

    .incident-detail h2 {
        font-size: 18px;
        word-break: break-word;
    }

    .incident-meta {
        gap: 8px;
        font-size: 13px;
    }

    .incident-body {
        font-size: 14px;
    }

    .comment-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .comment-date {
        margin-left: 0;
    }

    .comment-form textarea {
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    .portal-slots-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    }

    .portal-facilities-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .portal-facility-img {
        height: 160px;
    }

    .portal-facility-hero {
        max-height: 180px;
    }

    .portal-facility-hero img {
        height: 180px;
    }

    .portal-date-picker {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .portal-date-picker input[type="date"] {
        width: 100%;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .portal-stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .portal-stat-card {
        padding: 16px 12px;
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 10px;
    }

    .portal-stat-icon {
        width: 44px;
        height: 44px;
        border-radius: 12px;
    }

    .portal-stat-icon svg {
        width: 22px;
        height: 22px;
    }

    .portal-stat-info {
        align-items: center;
    }

    .portal-stat-number {
        font-size: 24px;
    }

    .portal-stat-label {
        text-align: center;
        font-size: 12px;
        margin-top: 4px;
    }

    .portal-stat-line1 {
        font-size: 15px;
        font-weight: 700;
        text-align: center;
    }

    .portal-stat-line2 {
        font-size: 12px;
        text-align: center;
    }

    .portal-login-card {
        padding: 36px 24px 32px;
        border-radius: 16px;
    }
    
    .portal-login-logo {
        height: 48px;
    }

    .portal-login-title {
        font-size: 19px;
    }

    .login-bg-shape--1 {
        width: 300px;
        height: 300px;
    }

    .login-bg-shape--2 {
        width: 200px;
        height: 200px;
    }

    .login-bg-shape--3 {
        display: none;
    }
}

/* ===================================
   Language Switcher (Portal)
   =================================== */
.portal-lang-selector {
    position: relative;
}

.portal-lang-selector-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    border-radius: 20px;
    background: var(--portal-body-bg);
    color: var(--portal-text);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    letter-spacing: 0.2px;
    cursor: pointer;
    transition: all var(--portal-transition);
    border: 1px solid var(--portal-border);
}

.portal-lang-selector-btn:hover {
    background: var(--portal-primary);
    color: #fff;
    border-color: var(--portal-primary);
}

.portal-lang-flag {
    font-size: 16px;
    line-height: 1;
}

.portal-lang-arrow {
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.portal-lang-selector.open .portal-lang-arrow {
    transform: rotate(180deg);
}

.portal-lang-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 160px;
    background: #fff;
    border: 1px solid var(--portal-border);
    border-radius: 10px;
    padding: 4px;
    z-index: 230;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.portal-lang-selector.open .portal-lang-dropdown {
    display: block;
}

.portal-lang-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border-radius: 6px;
    color: var(--portal-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: background var(--portal-transition);
}

.portal-lang-option:hover {
    background: var(--portal-body-bg);
}

.portal-lang-option.active {
    color: var(--portal-primary);
    font-weight: 600;
}

.portal-lang-option svg {
    width: 14px;
    height: 14px;
    margin-left: auto;
    flex-shrink: 0;
    color: var(--portal-primary);
}

/* Notification Toggle */
.portal-notif-toggle {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--portal-body-bg);
    color: var(--portal-text-light);
    cursor: pointer;
    transition: all var(--portal-transition);
}

.portal-notif-toggle:hover {
    background: rgba(47, 93, 140, 0.08);
    color: var(--portal-primary);
}

.portal-notif-toggle.active {
    background: rgba(39, 174, 96, 0.1);
    color: var(--portal-success);
}

.portal-notif-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--portal-success);
    border: 2px solid var(--portal-topbar-bg);
}

/* ===================================
   Providers
   =================================== */
.provider-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.provider-detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.provider-detail-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--portal-text-light);
}

.provider-detail-item a {
    color: var(--portal-primary);
    text-decoration: none;
}

.provider-detail-item a:hover {
    text-decoration: underline;
}

.provider-incident-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--portal-border);
}

.provider-incident-item:last-child {
    border-bottom: none;
}

.provider-incident-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.provider-incident-info a {
    color: var(--portal-text);
    text-decoration: none;
}

.provider-incident-info a:hover {
    color: var(--portal-primary);
}

.provider-incident-info small {
    color: var(--portal-text-light);
    font-size: 12px;
}

.provider-assigned-info {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--portal-border);
}

.provider-assigned-info strong {
    display: block;
    margin-bottom: 4px;
}

.provider-assigned-info p {
    margin: 4px 0;
    font-size: 13px;
}

.provider-assigned-info a {
    color: var(--portal-primary);
    text-decoration: none;
}

.provider-assigned-info a:hover {
    text-decoration: underline;
}

.row-inactive {
    opacity: 0.5;
}

.text-muted {
    color: var(--portal-text-light);
}

@media (max-width: 600px) {
    .provider-detail-grid {
        grid-template-columns: 1fr;
    }
}

/* ===================================
   Install App Page
   =================================== */
.install-page {
    max-width: 1040px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.install-hero {
    padding: 24px;
    border-radius: 20px;
    background: linear-gradient(145deg, #f8fbff 0%, #edf4fb 100%);
    border: 1px solid #d9e7f6;
    box-shadow: var(--portal-shadow);
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 20px;
    align-items: center;
    animation: installFadeIn 320ms ease-out;
}

.install-hero-brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.install-hero-icon {
    width: 96px;
    height: 96px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    box-shadow: 0 10px 24px rgba(26, 35, 50, 0.12);
}

.install-hero-icon img {
    width: 88px;
    height: 88px;
    border-radius: 20px;
    object-fit: cover;
}

.install-hero-texts h2 {
    font-size: 30px;
    line-height: 1.2;
    margin: 0 0 10px;
    color: var(--portal-text);
}

.install-hero-texts p {
    margin: 0;
    color: var(--portal-text-light);
    line-height: 1.6;
    max-width: 640px;
}

.install-hero-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
    justify-content: center;
}

.install-device-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.install-primary-btn {
    min-height: 46px;
    padding: 12px 22px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
}

.install-open-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 12px 20px;
    border-radius: 12px;
    border: 1px solid var(--portal-primary);
    color: var(--portal-primary);
    background: #fff;
    text-decoration: none;
    font-weight: 700;
}

.install-open-btn:hover,
.install-open-btn:focus {
    background: #f2f8ff;
}

.install-hero-note {
    margin: 0;
    min-height: 22px;
    font-size: 14px;
    color: var(--portal-text-light);
}

.install-btn-disabled,
.install-primary-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.install-adaptive {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.install-card {
    background: var(--portal-card-bg);
    border-radius: 16px;
    box-shadow: var(--portal-shadow);
    padding: 22px;
    border: 1px solid var(--portal-border);
    animation: installFadeIn 280ms ease-out;
}

.install-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.install-card-header h3 {
    margin: 0;
    font-size: 22px;
    line-height: 1.3;
}

.install-card p {
    margin: 0 0 14px;
    color: var(--portal-text-light);
    line-height: 1.6;
}

.install-card-done {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    background: linear-gradient(135deg, #d1fae5, #ecfdf5);
    border-color: var(--portal-success);
}

.install-card-body h3 {
    margin: 0 0 8px;
    font-size: 24px;
}

.install-card-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.install-card-icon-android {
    background: #d1fae5;
    color: #059669;
}

.install-card-icon-ios {
    background: #f3f4f6;
    color: #374151;
}

.install-card-icon-auto {
    background: var(--portal-primary);
    color: #fff;
}

.install-card-icon-success {
    background: var(--portal-success);
    color: #fff;
}

.install-alert {
    margin: 0 0 14px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid #facc15;
    background: #fef9c3;
    color: #713f12;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.install-alert-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f59e0b;
    color: #fff;
    font-weight: 800;
    box-shadow: 0 6px 14px rgba(245, 158, 11, 0.3);
}

.install-alert-warning {
    border-color: #fdba74;
    background: #fff7ed;
    color: #9a3412;
}

.install-mini-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.install-mini-step {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid var(--portal-border);
}

.install-mini-step strong {
    color: var(--portal-primary);
    min-width: 28px;
}

.install-steps-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.install-step-card {
    border-radius: 14px;
    border: 1px solid var(--portal-border);
    background: #fff;
    padding: 14px;
    box-shadow: 0 4px 12px rgba(16, 24, 40, 0.04);
}

.install-step-card-num {
    display: inline-flex;
    font-size: 28px;
    font-weight: 800;
    color: var(--portal-primary);
    letter-spacing: 0.02em;
    margin-bottom: 8px;
}

.install-step-card h4 {
    margin: 0 0 8px;
    font-size: 16px;
}

.install-step-card p {
    margin: 0;
    color: var(--portal-text-light);
    font-size: 14px;
    line-height: 1.5;
}

.install-steps-grid-generic {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.install-steps-grid-ios {
    grid-template-columns: 1fr;
    gap: 14px;
}

.install-step-card-visual {
    display: grid;
    grid-template-columns: minmax(210px, 300px) 1fr;
    gap: 16px;
    align-items: center;
    padding: 0;
    overflow: hidden;
    min-height: 184px;
}

.install-step-card-visual-media {
    position: relative;
    min-height: 184px;
    background: linear-gradient(160deg, #f2f7ff 0%, #e7f0fb 100%);
    border-right: 1px solid var(--portal-border);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.install-step-card-visual .install-step-card-num {
    position: absolute;
    left: 12px;
    top: 12px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #2f5d8c;
    color: #fff;
    font-size: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    box-shadow: 0 8px 18px rgba(47, 93, 140, 0.28);
}

.install-step-icon-badge {
    position: absolute;
    top: 20px;
    right: 14px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
}

.install-step-icon-badge-safari {
    color: #0ea5e9;
}

.install-step-icon-badge-share {
    color: #2563eb;
}

.install-step-icon-badge-add {
    color: #1d4ed8;
}

.install-step-asset {
    display: block;
    max-width: 100%;
    object-fit: contain;
    border-radius: 12px;
}

.install-step-asset-icon {
    width: 96px;
    height: 96px;
    border-radius: 22px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
}

.install-step-asset-share {
    width: 80px;
    height: auto;
    filter: drop-shadow(0 6px 14px rgba(37, 99, 235, 0.25));
}

.install-step-asset-menu {
    width: 200px;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
    border: 1px solid #e2e8f0;
    background: #fff;
}

.install-step-card-copy {
    padding: 16px;
}

.install-step-card-visual h4 {
    font-size: 22px;
    margin: 0 0 8px;
}

.install-step-card-visual p {
    font-size: 15px;
    margin: 0;
}

.install-step-add-cta {
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #2f5d8c;
}

.install-step-add-cta svg {
    width: 84px;
    height: 28px;
}

.install-step-add-cta span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 96px;
    min-height: 38px;
    padding: 8px 14px;
    border-radius: 12px;
    background: linear-gradient(180deg, #4f86d9 0%, #2f5d8c 100%);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 8px 18px rgba(47, 93, 140, 0.28);
}

.install-ios-open-card {
    margin-top: 14px;
    border: 1px solid var(--portal-border);
    border-radius: 14px;
    padding: 18px;
    background: #fff;
    text-align: center;
}

.install-ios-open-card h4 {
    margin: 0 0 8px;
    font-size: 28px;
}

.install-ios-open-card p {
    margin: 0 0 14px;
}

.install-benefits,
.install-guided-steps,
.install-help {
    background: #fff;
    border-radius: 16px;
    border: 1px solid var(--portal-border);
    box-shadow: var(--portal-shadow);
    padding: 20px;
}

.install-benefits h3,
.install-guided-steps h3,
.install-help h3 {
    margin: 0 0 14px;
    font-size: 22px;
}

.install-benefits-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.install-benefit-card {
    border: 1px solid var(--portal-border);
    border-radius: 12px;
    padding: 14px;
    background: #fbfdff;
}

.install-benefit-card h4 {
    margin: 0 0 8px;
    font-size: 16px;
}

.install-benefit-card p {
    margin: 0;
    color: var(--portal-text-light);
    line-height: 1.5;
}

.install-qr-block {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
}

.install-qr-block img {
    width: min(260px, 100%);
    height: auto;
    border-radius: 14px;
    border: 1px solid var(--portal-border);
    background: #fff;
    padding: 10px;
}

.install-qr-title {
    margin: 2px 0 0;
    font-weight: 700;
    color: var(--portal-text);
}

.install-qr-note {
    margin: 0;
    color: var(--portal-text-light);
}

.install-help p {
    margin: 0 0 12px;
    color: var(--portal-text-light);
}

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

@keyframes installFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 920px) {
    .install-hero {
        grid-template-columns: 1fr;
    }

    .install-steps-grid,
    .install-steps-grid-generic {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .install-page {
        gap: 14px;
    }

    .install-hero {
        padding: 18px;
        border-radius: 14px;
    }

    .install-hero-brand {
        align-items: flex-start;
        gap: 12px;
    }

    .install-hero-icon {
        width: 72px;
        height: 72px;
        border-radius: 16px;
    }

    .install-hero-icon img {
        width: 64px;
        height: 64px;
        border-radius: 14px;
    }

    .install-hero-texts h2 {
        font-size: 24px;
    }

    .install-primary-btn,
    .install-open-btn {
        width: 100%;
        justify-content: center;
    }

    .install-hero-actions {
        align-items: stretch;
    }

    .install-benefits,
    .install-guided-steps,
    .install-help,
    .install-card {
        padding: 16px;
        border-radius: 14px;
    }

    .install-benefits-grid,
    .install-steps-grid,
    .install-steps-grid-generic {
        grid-template-columns: 1fr;
    }

    .install-step-card-visual {
        grid-template-columns: minmax(150px, 220px) 1fr;
    }

    .install-step-card-visual-media {
        border-right: 1px solid var(--portal-border);
        border-bottom: none;
        min-height: 168px;
    }

    .install-step-card-copy {
        padding: 14px;
    }

    .install-step-card-visual h4 {
        font-size: 19px;
    }

    .install-ios-open-card h4 {
        font-size: 24px;
    }

    .install-card-header h3 {
        font-size: 20px;
    }
}

@media (max-width: 540px) {
    .install-step-card-visual {
        grid-template-columns: 1fr;
    }

    .install-step-card-visual-media {
        border-right: none;
        border-bottom: 1px solid var(--portal-border);
        min-height: 150px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .install-hero,
    .install-card {
        animation: none;
    }
}

/* ===================================
   Residents: Search, Import, Extended
   =================================== */
.portal-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.residents-search-form {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 20px;
}

.residents-search-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius-sm);
    font-size: 14px;
    background: var(--portal-body-bg);
    transition: border-color 0.2s;
}

.residents-search-input:focus {
    outline: none;
    border-color: var(--portal-primary);
    box-shadow: 0 0 0 3px rgba(47, 93, 140, 0.1);
}

.table-actions {
    white-space: nowrap;
    text-align: right;
}

.table-actions .portal-action-link,
.table-actions form {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

.table-actions button.portal-action-link {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    font-size: 16px;
    line-height: 1;
}

.portal-table-hover tbody tr:hover {
    background: rgba(47, 93, 140, 0.04);
}

.portal-table-sm th,
.portal-table-sm td {
    padding: 8px 10px;
    font-size: 13px;
}

.text-muted {
    color: var(--portal-text-light);
}

/* Import Summary */
.import-summary {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--portal-body-bg);
    border-radius: var(--portal-radius-sm);
    flex-wrap: wrap;
}

.import-stat {
    font-size: 14px;
}

.import-stat-new {
    color: var(--portal-success);
}

.import-stat-existing {
    color: var(--portal-warning);
}

.import-row-new {
    background: rgba(39, 174, 96, 0.05);
}

.import-row-exists {
    background: rgba(243, 156, 18, 0.05);
}

.import-description {
    color: var(--portal-text-light);
    margin-bottom: 16px;
}

.import-format-info {
    background: var(--portal-body-bg);
    padding: 16px;
    border-radius: var(--portal-radius-sm);
    border-left: 4px solid var(--portal-primary);
}

.import-format-info h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 600;
}

.import-format-example {
    display: block;
    font-size: 12px;
    word-break: break-all;
    color: var(--portal-text-light);
    background: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    margin-top: 8px;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #f1f5f9;
    color: var(--portal-text);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
    border-radius: var(--portal-radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

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

.portal-badge-warning {
    background: rgba(243, 156, 18, 0.1);
    color: #b7791f;
}

/* Responsive: residents page */
@media (max-width: 768px) {
    .portal-header-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .residents-search-form {
        flex-wrap: wrap;
    }
    
    .residents-search-input {
        width: 100%;
    }
    
    .import-summary {
        flex-direction: column;
        gap: 8px;
    }
    
    .portal-form-row {
        flex-direction: column;
    }
}

/* ═══════════════════════════════════════════
   SUGGESTIONS  /  CONSULTAS · PROPUESTAS · QUEJAS
   ═══════════════════════════════════════════ */

/* ── Type icons ── */
.sug-type-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f1f5f9;
    flex-shrink: 0;
}
.sug-type-query  { background: #dbeafe; }
.sug-type-proposal { background: #fef9c3; }
.sug-type-complaint { background: #fee2e2; }

/* ── Detail view ── */
.sug-detail-type {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.sug-detail h2 {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 8px;
    color: var(--portal-text);
}
.sug-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--portal-text-light);
    margin-bottom: 16px;
}
.sug-body {
    font-size: 15px;
    line-height: 1.7;
    color: #374151;
    padding: 16px 0;
    border-bottom: 1px solid var(--portal-border);
}

/* ── Attachment ── */
.sug-attachment {
    margin-top: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--portal-border);
}
.sug-attachment-img {
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--portal-radius-sm);
    box-shadow: var(--portal-shadow);
    display: block;
    margin-bottom: 10px;
}
.sug-attachment-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    color: var(--portal-primary);
    text-decoration: none;
    font-weight: 500;
}
.sug-attachment-link:hover {
    text-decoration: underline;
}

/* ── Admin response card ── */
.sug-response {
    margin-top: 20px;
    padding: 16px;
    background: rgba(47, 93, 140, 0.05);
    border-left: 4px solid var(--portal-primary);
    border-radius: var(--portal-radius-sm);
}
.sug-response-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.sug-response-date {
    font-size: 12px;
    color: var(--portal-text-light);
    margin-left: auto;
}
.sug-response-body {
    font-size: 14px;
    line-height: 1.65;
    color: #374151;
}

/* ── Respond form ── */
.sug-respond-form h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--portal-text);
}

/* ── Suggestion list table highlight ── */
.sug-row-pending {
    background: rgba(234, 179, 8, 0.04);
}
.sug-row-pending td:first-child {
    position: relative;
}
.sug-row-pending td:first-child::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: #eab308;
    border-radius: 2px;
}

/* ── Resident list cards ── */
.sug-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.sug-list-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius-sm);
    transition: all var(--portal-transition);
    text-decoration: none;
    color: inherit;
}
.sug-list-item:hover {
    border-color: var(--portal-primary);
    box-shadow: var(--portal-shadow);
}
.sug-list-item-body {
    flex: 1;
    min-width: 0;
}
.sug-list-item-subject {
    font-weight: 600;
    font-size: 15px;
    color: var(--portal-text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sug-list-item-preview {
    font-size: 13px;
    color: var(--portal-text-light);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.sug-list-item-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--portal-text-light);
}

/* ── Awaiting / Has response indicator ── */
.sug-awaiting { color: #eab308; font-weight: 500; }
.sug-answered  { color: var(--portal-success); font-weight: 500; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .sug-list-item { flex-direction: column; }
    .sug-type-icon { width: 28px; height: 28px; font-size: 16px; }
    .sug-detail h2 { font-size: 18px; }
    .sug-respond-form textarea { font-size: 14px; }
}


/* ═══════════════════════════════════════════
   ADMIN CALENDAR
   ═══════════════════════════════════════════ */

.cal-container { max-width: 100%; }

/* ── Toolbar ── */
.cal-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}
.cal-toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}
.cal-toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.cal-month-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--portal-text);
    min-width: 180px;
    text-align: center;
}
.cal-nav-btn {
    background: var(--portal-card-bg);
    border: 1px solid var(--portal-border);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: var(--portal-text);
}
.cal-nav-btn:hover { background: #f1f5f9; }
.cal-nav-btn svg { width: 18px; height: 18px; }
.cal-today-btn {
    background: #f1f5f9;
    border: 1px solid var(--portal-border);
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.cal-today-btn:hover { background: #e2e8f0; }

/* ── View Tabs ── */
.cal-view-tabs {
    display: flex;
    background: #f1f5f9;
    border-radius: 8px;
    padding: 3px;
}
.cal-tab {
    border: none;
    background: none;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    color: var(--portal-text-light);
    transition: all 0.2s;
}
.cal-tab.active {
    background: #fff;
    color: var(--portal-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ── Calendar Grid ── */
.cal-grid {
    background: var(--portal-card-bg);
    border-radius: 12px;
    border: 1px solid var(--portal-border);
    overflow: hidden;
}
.cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #f8fafc;
    border-bottom: 1px solid var(--portal-border);
}
.cal-weekdays > div {
    padding: 10px 8px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--portal-text-light);
    letter-spacing: 0.5px;
}
.cal-weekdays .cal-weekend { color: #94a3b8; }

.cal-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}
.cal-day {
    min-height: 100px;
    border-right: 1px solid #f1f5f9;
    border-bottom: 1px solid #f1f5f9;
    padding: 4px;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
    overflow: hidden;
}
.cal-day:nth-child(7n) { border-right: none; }
.cal-day:hover { background: #f8fafc; }
.cal-day-outside { background: #fafbfc; }
.cal-day-outside .cal-day-num { color: #cbd5e1; }
.cal-day-today {
    background: #eff6ff;
}
.cal-day-today .cal-day-num {
    background: var(--portal-primary);
    color: #fff;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cal-day-selected { background: #e8f0fe; }
.cal-day-num {
    font-size: 13px;
    font-weight: 500;
    color: var(--portal-text);
    padding: 2px 4px;
    display: inline-flex;
    margin-bottom: 2px;
}

/* ── Event Pills ── */
.cal-day-events { display: flex; flex-direction: column; gap: 2px; }
.cal-event-pill {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    background: #f0f4ff;
    border-left: 3px solid #2F5D8C;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1.4;
    color: var(--portal-text);
}
.cal-event-pill:hover { background: #e0e8f5; transform: translateX(1px); }
.cal-event-pill.completed { opacity: 0.5; text-decoration: line-through; }
a.cal-event-pill { display: block; text-decoration: none; }
.cal-event-icon { font-size: 10px; }
.cal-event-time { font-weight: 600; color: var(--portal-primary); font-size: 10px; }
.cal-event-more {
    font-size: 11px;
    color: var(--portal-primary);
    padding: 1px 6px;
    cursor: pointer;
    font-weight: 500;
}

/* ── Agenda Panel ── */
.cal-agenda {
    margin-top: 16px;
    background: var(--portal-card-bg);
    border-radius: 12px;
    border: 1px solid var(--portal-border);
    overflow: hidden;
    animation: calSlideIn 0.3s ease;
}
@keyframes calSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.cal-agenda-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--portal-border);
    background: #f8fafc;
}
.cal-agenda-header h3 {
    font-size: 16px;
    font-weight: 600;
    text-transform: capitalize;
}
.cal-close-btn {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--portal-text-light);
    line-height: 1;
    padding: 4px;
}
.cal-close-btn:hover { color: var(--portal-text); }

.cal-agenda-list { padding: 8px; }
.cal-agenda-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    transition: background 0.15s;
}
.cal-agenda-item:hover { background: #f8fafc; }
.cal-agenda-item.completed .cal-agenda-title { text-decoration: line-through; opacity: 0.5; }
.cal-agenda-color {
    width: 4px;
    border-radius: 2px;
    min-height: 36px;
    flex-shrink: 0;
    align-self: stretch;
}
.cal-agenda-content { flex: 1; min-width: 0; }
.cal-agenda-top {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}
.cal-agenda-type { font-size: 14px; }
.cal-agenda-time {
    font-size: 12px;
    font-weight: 600;
    color: var(--portal-primary);
}
.cal-agenda-badge {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 4px;
    background: #f1f5f9;
}
.cal-agenda-badge.personal { background: #fef3c7; }
.cal-agenda-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--portal-text);
}
.cal-agenda-desc {
    font-size: 12px;
    color: var(--portal-text-light);
    margin-top: 2px;
    white-space: pre-line;
}
.cal-agenda-meta {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 2px;
}
.cal-agenda-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.cal-agenda-actions button {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: background 0.15s;
}
.cal-agenda-actions button:hover { background: #f1f5f9; }
.cal-agenda-add {
    width: 100%;
    padding: 10px;
    background: none;
    border: 2px dashed #e2e8f0;
    border-radius: 8px;
    color: var(--portal-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 4px;
    transition: all 0.2s;
}
.cal-agenda-add:hover { border-color: var(--portal-primary); background: #f8fafc; }

/* ── Modal ── */
.cal-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: calFadeIn 0.2s ease;
}
@keyframes calFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.cal-modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    animation: calModalIn 0.3s ease;
}
@keyframes calModalIn {
    from { transform: translateY(20px) scale(0.95); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}
.cal-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--portal-border);
}
.cal-modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}
.cal-modal-body {
    padding: 20px;
}
.cal-form-group {
    margin-bottom: 14px;
}
.cal-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--portal-text);
    margin-bottom: 5px;
}
.cal-form-group input[type="text"],
.cal-form-group input[type="date"],
.cal-form-group input[type="time"],
.cal-form-group select,
.cal-form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--portal-border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
    outline: none;
    box-sizing: border-box;
}
.cal-form-group input:focus,
.cal-form-group select:focus,
.cal-form-group textarea:focus {
    border-color: var(--portal-primary);
}
.cal-form-group textarea { resize: vertical; }
.cal-form-group small {
    display: block;
    font-size: 11px;
    color: var(--portal-text-light);
    margin-top: 3px;
}
.cal-form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}
.cal-form-check label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-weight: 400;
}
.cal-form-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--portal-primary);
}

/* ── Color Picker ── */
.cal-color-options {
    display: flex;
    gap: 6px;
    padding-top: 4px;
}
.cal-color-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}
.cal-color-btn:hover { transform: scale(1.15); }
.cal-color-btn.active { border-color: var(--portal-text); box-shadow: 0 0 0 2px #fff inset; }

/* ── Modal Actions ── */
.cal-modal-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid var(--portal-border);
    margin-top: 8px;
}
.cal-modal-actions-right {
    display: flex;
    gap: 8px;
}

/* ── Global Reminder Toast (with snooze) ── */
.reminder-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
    border-left: 5px solid #ea580c;
    z-index: 10000;
    max-width: 370px;
    width: calc(100vw - 40px);
    animation: reminderToastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}
@keyframes reminderToastIn {
    from { transform: translateX(100%) scale(0.9); opacity: 0; }
    to { transform: translateX(0) scale(1); opacity: 1; }
}
@keyframes reminderToastOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(110%); opacity: 0; }
}
.reminder-toast-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px 6px;
}
.reminder-toast-icon { font-size: 22px; flex-shrink: 0; }
.reminder-toast-title {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: var(--portal-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.reminder-toast-dismiss {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #94a3b8;
    padding: 2px 4px;
    line-height: 1;
    border-radius: 4px;
    transition: all 0.15s;
}
.reminder-toast-dismiss:hover { color: #64748b; background: #f1f5f9; }
.reminder-toast-body {
    padding: 0 14px 8px;
    font-size: 13px;
    color: #64748b;
}
.reminder-toast-actions {
    display: flex;
    border-top: 1px solid #f1f5f9;
}
.reminder-snooze-btn,
.reminder-open-btn {
    flex: 1;
    background: none;
    border: none;
    border-right: 1px solid #f1f5f9;
    padding: 10px 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    color: var(--portal-text);
    transition: background 0.15s;
}
.reminder-snooze-btn:hover { background: #fff7ed; color: #ea580c; }
.reminder-open-btn {
    border-right: none;
    color: var(--portal-primary);
}
.reminder-open-btn:hover { background: #eff6ff; }
.reminder-snooze-btn:disabled {
    opacity: 0.5;
    cursor: default;
}
/* Pulse animation for the toast border */
.reminder-toast::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 0;
    bottom: 0;
    width: 5px;
    background: #ea580c;
    animation: reminderPulse 2s ease-in-out infinite;
}
@keyframes reminderPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ── Permission Banner ── */
.reminder-permission-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 1px solid #fbbf24;
    border-radius: 12px;
    padding: 14px 18px;
    margin-bottom: 16px;
    animation: reminderBannerIn 0.4s ease;
}
@keyframes reminderBannerIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes reminderBannerOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-10px); }
}
.reminder-banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}
.reminder-banner-icon { font-size: 28px; flex-shrink: 0; }
.reminder-banner-text strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #92400e;
}
.reminder-banner-text span {
    font-size: 13px;
    color: #a16207;
}
.reminder-banner-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.reminder-banner-enable {
    background: #f59e0b;
    color: #fff;
    border: none;
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.reminder-banner-enable:hover { background: #d97706; }
.reminder-banner-later {
    background: none;
    border: 1px solid #d4a34a;
    color: #92400e;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}
.reminder-banner-later:hover { background: rgba(0,0,0,0.05); }
.reminder-banner-denied {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border-color: #fca5a5;
}
.reminder-banner-denied .reminder-banner-text strong { color: #991b1b; }
.reminder-banner-denied .reminder-banner-text span { color: #b91c1c; }
.reminder-banner-denied .reminder-banner-later { border-color: #e7a0a0; color: #991b1b; }

@media (max-width: 480px) {
    .reminder-permission-banner { flex-direction: column; text-align: center; }
    .reminder-banner-content { flex-direction: column; }
    .reminder-banner-actions { width: 100%; justify-content: center; }
}

/* ── Calendar Responsive ── */
@media (max-width: 768px) {
    .cal-toolbar { flex-direction: column; align-items: stretch; }
    .cal-toolbar-left { justify-content: center; }
    .cal-toolbar-right { justify-content: center; }
    .cal-month-title { font-size: 17px; min-width: auto; }
    .cal-day { min-height: 64px; }
    .cal-event-pill { font-size: 10px; padding: 1px 4px; }
    .cal-event-time { display: none; }
    .cal-day-num { font-size: 12px; }
    .cal-modal { max-width: 100%; margin: 0; border-radius: 12px; }
    .cal-form-row { grid-template-columns: 1fr; }
    /* Toast responsive */
    .reminder-toast { right: 10px; max-width: calc(100vw - 20px); }
}

@media (max-width: 480px) {
    .cal-day { min-height: 48px; padding: 2px; }
    .cal-day-events .cal-event-pill { display: none; }
    .cal-day-events .cal-event-more { display: none; }
    .cal-day-num { font-size: 11px; }
    /* Show a colored dot indicator instead */
    .cal-day-events {
        display: flex;
        flex-direction: row;
        gap: 2px;
        justify-content: center;
        flex-wrap: wrap;
    }
    .cal-day-events::before { display: none; }
    .cal-day.has-events::after {
        content: '';
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--portal-primary);
        display: block;
        margin: 2px auto 0;
    }
}

/* ═══════════════════════════════════════════
   AI CHAT WIDGET
   ═══════════════════════════════════════════ */

/* ── Floating Action Button ── */
.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2F5D8C, #1a3d5c);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(47, 93, 140, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(47, 93, 140, 0.5);
}
.chat-fab-icon {
    width: 24px;
    height: 24px;
    transition: all 0.3s ease;
    position: absolute;
}
.chat-fab-icon-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}
.chat-fab-active .chat-fab-icon-open {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}
.chat-fab-active .chat-fab-icon-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* ── Chat Panel ── */
.chat-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.08);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.chat-panel-open {
    display: flex;
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ── Header ── */
.chat-header {
    background: linear-gradient(135deg, #2F5D8C, #1a3d5c);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.chat-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    overflow: hidden;
    position: relative;
}
.chat-avatar img {
    width: 36px;
    height: 36px;
    max-width: 36px;
    max-height: 36px;
    object-fit: cover;
    display: block;
}
.chat-header-name {
    font-weight: 600;
    font-size: 14px;
}
.chat-header-status {
    font-size: 11px;
    opacity: 0.8;
}
.chat-header-actions {
    display: flex;
    gap: 4px;
}
.chat-header-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.chat-header-btn:hover {
    background: rgba(255,255,255,0.25);
}
.chat-header-btn svg {
    width: 16px;
    height: 16px;
}

/* ── Messages Area ── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
}
.chat-messages::-webkit-scrollbar {
    width: 5px;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* Welcome screen */
.chat-welcome {
    text-align: center;
    padding: 20px 10px;
}
.chat-welcome-icon {
    font-size: 40px;
    margin-bottom: 8px;
}
.chat-welcome h4 {
    font-size: 16px;
    color: #1e293b;
    margin-bottom: 4px;
}
.chat-welcome p {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 16px;
}
.chat-suggestions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.chat-suggestion-btn {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 8px;
}
.chat-suggestion-btn:hover {
    background: #f0f4ff;
    border-color: #93b4d8;
    transform: translateX(4px);
}

/* ── Message Bubbles ── */
.chat-msg {
    display: flex;
    gap: 8px;
    max-width: 90%;
    animation: chatMsgIn 0.3s ease;
}
@keyframes chatMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.chat-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.chat-msg-assistant {
    align-self: flex-start;
}
.chat-msg-avatar {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    border-radius: 50%;
    background: #e8f0fe;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 2px;
    overflow: hidden;
    position: relative;
}
.chat-msg-avatar img {
    width: 28px;
    height: 28px;
    max-width: 28px;
    max-height: 28px;
    object-fit: cover;
    display: block;
}
.chat-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
}
.chat-msg-user .chat-msg-bubble {
    background: #2F5D8C;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg-assistant .chat-msg-bubble {
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}
.chat-msg-bubble strong { font-weight: 600; }
.chat-msg-bubble code {
    background: rgba(0,0,0,0.06);
    padding: 1px 4px;
    border-radius: 4px;
    font-size: 12px;
}
.chat-msg-image {
    max-width: 200px;
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    display: block;
}
.chat-msg-time {
    display: block;
    font-size: 10px;
    opacity: 0.5;
    margin-top: 4px;
    text-align: right;
}

/* ── Typing indicator ── */
.chat-typing .chat-typing-dots {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}
.chat-typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94a3b8;
    animation: chatTypingBounce 1.4s infinite ease-in-out;
}
.chat-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatTypingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ── Image Preview ── */
.chat-image-preview {
    padding: 8px 16px;
    background: #f1f5f9;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.chat-image-preview img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
}
.chat-image-remove {
    background: #fee2e2;
    color: #b91c1c;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Input Area ── */
.chat-input-area {
    padding: 12px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #fff;
    flex-shrink: 0;
}
.chat-attach-btn {
    cursor: pointer;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    transition: all 0.2s;
    flex-shrink: 0;
}
.chat-attach-btn:hover {
    background: #f1f5f9;
    color: #2F5D8C;
}
.chat-attach-btn svg {
    width: 18px;
    height: 18px;
}
.chat-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 16px; /* ≥16px evita el zoom automático en iOS */
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 56px;
    overflow-y: auto;
    line-height: 1.4;
    transition: border-color 0.2s;
}
.chat-input:focus {
    border-color: #2F5D8C;
}
.chat-send-btn {
    background: #2F5D8C;
    color: #fff;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.chat-send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}
.chat-send-btn:not(:disabled):hover {
    background: #1a3d5c;
    transform: scale(1.05);
}
.chat-send-btn svg {
    width: 16px;
    height: 16px;
}

/* ── Mobile responsive ── */
@media (max-width: 480px) {
    .chat-panel {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        max-width: 100vw;
        border-radius: 0;
    }
    .chat-panel-open ~ .chat-fab {
        display: none !important;
    }
    .chat-fab {
        bottom: 16px;
        right: 16px;
    }
}

/* ===================================
   Tareas (Tasks module)
   =================================== */
.portal-badge-task-high { background: rgba(231, 76, 60, 0.12); color: #c0392b; }
.portal-badge-task-medium { background: rgba(230, 126, 34, 0.12); color: #d35400; }
.portal-badge-task-low { background: rgba(52, 152, 219, 0.12); color: #2980b9; }
.portal-badge-waiting { background: rgba(148, 163, 184, 0.16); color: #475569; }
.portal-badge-secondary { background: rgba(100, 116, 139, 0.12); color: #475569; }

.portal-stat-sublabel {
    font-size: 11px;
    color: var(--portal-text-light);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dashboard-task-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.dashboard-task-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 8px;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}
.dashboard-task-item:hover { background: #f8fafc; }
.dashboard-task-dot { font-size: 12px; margin-top: 3px; flex-shrink: 0; }
.dashboard-task-content { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.dashboard-task-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--portal-text);
}
.dashboard-task-meta {
    font-size: 12px;
    color: var(--portal-text-light);
    margin-top: 2px;
}

.task-more-summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--portal-primary);
    margin: 4px 0 14px;
    list-style: none;
}
.task-more-summary::-webkit-details-marker { display: none; }
.task-more-summary::before {
    content: '▸ ';
}
#taskMoreOptions[open] > .task-more-summary::before {
    content: '▾ ';
}

.task-filters-form {
    background: #f8fafc;
    border: 1px solid var(--portal-border);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 16px;
}
.task-filters-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

/* Mobile: convert the tasks table into stacked cards */
@media (max-width: 768px) {
    .portal-table.task-table thead { display: none; }
    .portal-table.task-table,
    .portal-table.task-table tbody,
    .portal-table.task-table tr,
    .portal-table.task-table td {
        display: block;
        width: 100%;
    }
    .portal-table.task-table tr {
        margin-bottom: 12px;
        border: 1px solid var(--portal-border);
        border-radius: 10px;
        padding: 10px 14px;
        box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    }
    .portal-table.task-table td {
        border-bottom: none;
        padding: 6px 0;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 10px;
        text-align: right;
    }
    .portal-table.task-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--portal-text-light);
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.4px;
        flex-shrink: 0;
        text-align: left;
    }
}

/* Sidebar "new feature" tag next to Tareas (kept for future reuse, not
   currently displayed - see includes/portal-header.php). */
.sidebar-badge-new {
    margin-left: auto;
    background: rgba(34, 197, 94, 0.18);
    color: #4ade80;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 2px 7px;
    border-radius: 10px;
}

/* View switcher (list / calendar / board) */
.task-view-switcher {
    display: flex;
    gap: 4px;
    background: var(--portal-bg);
    border: 1px solid var(--portal-border);
    border-radius: 8px;
    padding: 3px;
}
.task-view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 15px;
    color: var(--portal-text-light);
    transition: all 0.15s;
}
.task-view-btn:hover { background: rgba(47, 93, 140, 0.08); }
.task-view-btn.active { background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.08); color: var(--portal-primary); }

/* Priority segmented control (create/edit modal) */
.task-priority-options {
    display: flex;
    gap: 8px;
}
.task-priority-btn {
    flex: 1;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1.5px solid var(--portal-border);
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--portal-text-light);
    transition: all 0.15s;
}
.task-priority-btn:hover { border-color: var(--portal-primary); }
.task-priority-btn.active.task-priority-high { background: rgba(231, 76, 60, 0.12); border-color: #c0392b; color: #c0392b; }
.task-priority-btn.active.task-priority-medium { background: rgba(230, 126, 34, 0.12); border-color: #d35400; color: #d35400; }
.task-priority-btn.active.task-priority-low { background: rgba(52, 152, 219, 0.12); border-color: #2980b9; color: #2980b9; }

/* Priority dot (list view) */
.task-priority-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}
.task-priority-dot-high { background: #e74c3c; }
.task-priority-dot-medium { background: #e67e22; }
.task-priority-dot-low { background: #3498db; }

/* Assignee avatar */
.task-assignee {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.task-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--portal-primary);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
}

/* Mobile floating "+ Nueva tarea" button, scoped to the Tareas page only.
   Positioned above the global chat FAB (bottom:16px/right:16px on mobile)
   so the two never overlap. */
.task-fab { display: none; }
@media (max-width: 768px) {
    .task-fab {
        display: flex;
        position: fixed;
        bottom: 90px;
        right: 20px;
        width: 52px;
        height: 52px;
        border-radius: 50%;
        background: var(--portal-primary);
        color: #fff;
        border: none;
        align-items: center;
        justify-content: center;
        box-shadow: 0 6px 18px rgba(47, 93, 140, 0.35);
        z-index: 500;
        cursor: pointer;
    }
    .task-fab svg { width: 24px; height: 24px; }
}

/* ===================================
   Tareas: Board (Kanban) view
   =================================== */
.task-board {
    display: grid;
    grid-template-columns: repeat(4, minmax(230px, 1fr));
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 4px;
}
.task-board-column {
    background: var(--portal-bg);
    border: 1px solid var(--portal-border);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.task-board-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    font-size: 13px;
    font-weight: 700;
    color: var(--portal-text);
    border-bottom: 1px solid var(--portal-border);
}
.task-board-column-count {
    background: #fff;
    border: 1px solid var(--portal-border);
    color: var(--portal-text-light);
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
}
.task-board-column-body {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}
.task-board-card {
    background: #fff;
    border: 1px solid var(--portal-border);
    border-radius: 8px;
    padding: 10px 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.task-board-card-top {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}
.task-board-card-top strong {
    flex: 1;
    font-size: 13px;
    line-height: 1.35;
    color: var(--portal-text);
}
.task-board-card-menu {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    padding: 2px 4px;
    border-radius: 4px;
    flex-shrink: 0;
}
.task-board-card-menu:hover { background: rgba(0,0,0,0.05); }
.task-board-card-meta {
    font-size: 11px;
    color: var(--portal-text-light);
    margin: 6px 0 0 14px;
}
.task-board-flag.overdue { color: #c0392b; font-weight: 600; }
.task-board-flag.today { color: #d35400; font-weight: 600; }
.task-board-card-related {
    font-size: 11px;
    color: var(--portal-text-light);
    margin: 6px 0 0 14px;
}
.task-board-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
}
.task-board-status-select {
    font-size: 11px;
    padding: 4px 6px;
    border: 1px solid var(--portal-border);
    border-radius: 6px;
    background: #fff;
    max-width: 130px;
}
.task-board-add-btn {
    width: 100%;
    padding: 8px;
    background: none;
    border: 2px dashed var(--portal-border);
    border-radius: 8px;
    color: var(--portal-primary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.task-board-add-btn:hover { border-color: var(--portal-primary); background: #fff; }

@media (max-width: 900px) {
    .task-board { grid-template-columns: repeat(4, minmax(220px, 1fr)); }
}

/* ===================================
   Tareas: Calendar view (scoped to this module only,
   independent from admin/calendar.php)
   =================================== */
.task-calendar-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}
.task-calendar-toolbar h3 {
    flex: 1;
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    text-transform: capitalize;
    margin: 0;
}
.task-calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 700;
    color: var(--portal-text-light);
    text-transform: uppercase;
    text-align: center;
}
.task-calendar-weekdays .weekend { color: #cbd5e1; }
.task-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}
.task-calendar-cell {
    min-height: 84px;
    border: 1px solid var(--portal-border);
    border-radius: 8px;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.task-calendar-cell.empty { border: none; background: none; }
.task-calendar-cell.today { border-color: var(--portal-primary); background: rgba(47, 93, 140, 0.04); }
.task-calendar-daynum {
    font-size: 11px;
    font-weight: 700;
    color: var(--portal-text-light);
}
.task-calendar-cell.today .task-calendar-daynum { color: var(--portal-primary); }
.task-calendar-chip {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.task-calendar-chip.task-calendar-chip-high { background: #e74c3c; }
.task-calendar-chip.task-calendar-chip-medium { background: #e67e22; }
.task-calendar-chip.task-calendar-chip-low { background: #3498db; }
.task-calendar-more {
    font-size: 10px;
    color: var(--portal-text-light);
    padding-left: 2px;
}

@media (max-width: 768px) {
    .task-calendar-cell { min-height: 56px; font-size: 10px; }
    .task-calendar-chip { display: none; }
    .task-calendar-cell.today::after {
        content: '';
        display: block;
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--portal-primary);
    }
}

/* ===================================
   Documents page (admin/documents.php)
   =================================== */
.portal-card-subtitle {
    margin: 2px 0 0;
    font-size: 13px;
    color: var(--portal-text-light);
    font-weight: 400;
}

.portal-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ─── Filter toolbar: year + search ─── */
.portal-doc-toolbar {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 16px;
}

.portal-doc-field-year {
    flex: 0 0 140px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.portal-doc-field-year label {
    font-size: 12px;
    font-weight: 600;
    color: var(--portal-text-light);
}

.portal-doc-field-year select {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid var(--portal-border);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: var(--portal-text);
}

.portal-doc-field-search {
    flex: 1 1 auto;
    min-width: 0;
}

.portal-doc-search-box {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--portal-border);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.portal-doc-search-box input[type="search"] {
    flex: 1 1 auto;
    min-width: 0;
    border: none;
    padding: 9px 12px;
    font-size: 14px;
    outline: none;
    background: transparent;
}

.portal-doc-search-box input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

.portal-doc-search-btn {
    flex: 0 0 auto;
    border: none;
    border-left: 1px solid var(--portal-border);
    background: var(--portal-bg);
    padding: 0 14px;
    cursor: pointer;
    font-size: 14px;
}

.portal-doc-search-btn:hover {
    background: rgba(47, 93, 140, 0.08);
}

@media (max-width: 640px) {
    .portal-doc-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .portal-doc-field-year {
        flex-basis: auto;
    }
}

/* ─── Results bar ─── */
.portal-doc-results-bar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin: 4px 0 12px;
    font-size: 13px;
}

.portal-doc-results-count {
    font-weight: 700;
    color: var(--portal-text);
}

.portal-doc-results-sort {
    color: var(--portal-text-light);
}

/* ─── Empty / no-match states ─── */
.portal-doc-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--portal-text-light);
}

.portal-doc-empty p {
    margin-bottom: 12px;
}

/* ─── Document rows ─── */
.portal-doc-list {
    display: flex;
    flex-direction: column;
}

.portal-doc-row {
    border-bottom: 1px solid var(--portal-border);
}

.portal-doc-row:last-child {
    border-bottom: none;
}

.portal-doc-row-view {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 4px;
}

.portal-doc-row-view[hidden] {
    display: none;
}

.portal-doc-icon {
    flex: 0 0 auto;
    font-size: 22px;
    width: 32px;
    text-align: center;
}

.portal-doc-main {
    flex: 1 1 auto;
    min-width: 0;
}

.portal-doc-title {
    font-weight: 600;
    color: var(--portal-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.portal-doc-subtext {
    font-size: 12px;
    color: var(--portal-text-light);
    margin-top: 2px;
}

.portal-doc-date {
    flex: 0 0 auto;
    font-size: 13px;
    color: var(--portal-text-light);
    white-space: nowrap;
}

/* ─── Actions (⋮) menu ─── */
.portal-doc-actions {
    position: relative;
    flex: 0 0 auto;
}

.portal-doc-actions-btn {
    border: none;
    background: transparent;
    font-size: 18px;
    line-height: 1;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--portal-text-light);
}

.portal-doc-actions-btn:hover,
.portal-doc-actions-btn[aria-expanded="true"] {
    background: rgba(47, 93, 140, 0.08);
    color: var(--portal-primary);
}

.portal-doc-actions-menu {
    position: fixed;
    z-index: 9999;
    background: #fff;
    border: 1px solid var(--portal-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    min-width: 160px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.portal-doc-actions-menu[hidden] {
    display: none;
}

.portal-doc-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--portal-text);
    text-decoration: none;
    cursor: pointer;
}

.portal-doc-menu-item:hover,
.portal-doc-menu-item:focus {
    background: var(--portal-bg);
    outline: none;
}

.portal-doc-menu-form {
    margin: 0;
}

.portal-doc-menu-danger {
    color: #c0392b;
}

.portal-doc-menu-danger:hover,
.portal-doc-menu-danger:focus {
    background: rgba(231, 76, 60, 0.08);
}

/* ─── Inline rename ─── */
.portal-doc-row-edit {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 4px;
    flex-wrap: wrap;
}

.portal-doc-row-edit[hidden] {
    display: none;
}

.portal-doc-row-edit input[type="text"] {
    flex: 1 1 260px;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid var(--portal-border);
    border-radius: 8px;
    font-size: 14px;
}

@media (max-width: 640px) {
    .portal-doc-row-view {
        align-items: flex-start;
    }
    .portal-doc-date {
        display: none;
    }
}

/* ===================================
   Panel General v2 (rediseño compacto)
   =================================== */

/* Contraste local de textos secundarios: se redefine la variable solo
   dentro de esta página (no afecta al resto del sitio, que sigue usando
   --portal-text-light tal cual). */
.panel-general {
    --portal-text-light: #5b6b7c;
}

.panel-general .portal-stats-grid {
    margin-bottom: 20px;
}

.panel-general .portal-stat-card {
    padding: 18px;
}

.panel-general .portal-card {
    margin-bottom: 20px;
}

.panel-general .portal-card-header {
    padding: 16px 20px;
}

.panel-general .portal-card-body {
    padding: 16px 20px 18px;
}

.panel-general .portal-card-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pg-header-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--portal-primary);
}

/* Dos columnas: ~60% alertas / ~40% agenda */
.pg-columns {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: 20px;
    align-items: start;
    margin-bottom: 20px;
}

.pg-columns .portal-card {
    margin-bottom: 0;
}

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

/* ─── Pestañas "Requiere tu atención" ─── */
.pg-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    border-bottom: 1px solid var(--portal-border);
    margin-bottom: 14px;
}

.pg-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 8px 12px;
    margin-bottom: -1px;
    font-size: 13px;
    font-weight: 600;
    color: var(--portal-text-light);
    cursor: pointer;
    font-family: inherit;
    transition: color var(--portal-transition), border-color var(--portal-transition);
}

.pg-tab:hover {
    color: var(--portal-primary);
}

.pg-tab.active,
.pg-tab[aria-selected="true"] {
    color: var(--portal-primary);
    border-bottom-color: var(--portal-primary);
}

.pg-tab:focus-visible {
    outline: 2px solid var(--portal-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

.pg-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.06);
    color: var(--portal-text-light);
    font-size: 11px;
    font-weight: 700;
}

.pg-tab.active .pg-tab-count,
.pg-tab[aria-selected="true"] .pg-tab-count {
    background: rgba(47, 93, 140, 0.12);
    color: var(--portal-primary);
}

.pg-tabpanel[hidden] {
    display: none;
}

.pg-view-all,
.pg-view-more {
    display: inline-block;
    margin-top: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--portal-primary);
    text-decoration: none;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}

.pg-view-all:hover,
.pg-view-more:hover {
    text-decoration: underline;
}

/* Puntos de prioridad (sustituyen a los emojis de color) */
.pg-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 6px;
}

.pg-dot-urgent { background: var(--portal-danger); }
.pg-dot-high { background: #e67e22; }
.pg-dot-medium { background: var(--portal-info); }
.pg-dot-low { background: #95a5a6; }

/* ─── Agenda de próximos eventos ─── */
.pg-agenda-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 4px;
}

.pg-agenda-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}

.pg-agenda-item:hover {
    background: #f8fafc;
}

.pg-agenda-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 8px;
    background: rgba(47, 93, 140, 0.08);
}

.pg-agenda-date-month {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.4px;
    color: var(--portal-primary);
}

.pg-agenda-date-day {
    font-size: 16px;
    font-weight: 700;
    color: var(--portal-primary);
    line-height: 1.1;
}

.pg-agenda-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.pg-agenda-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--portal-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pg-agenda-meta {
    font-size: 12px;
    color: var(--portal-text-light);
    margin-top: 2px;
}

.pg-comms-strip {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #fffbeb;
    color: #92400e;
    font-size: 13px;
    text-decoration: none;
}

.pg-comms-strip svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.pg-comms-strip:not(.pg-comms-strip-empty):hover {
    background: #fef3c7;
}

.pg-comms-strip-empty {
    background: var(--portal-body-bg);
    color: var(--portal-text-light);
}

/* ─── Tabla "Estado de comunidades" ─── */
.pg-comm-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.pg-comm-search {
    flex: 1 1 220px;
    min-width: 180px;
    padding: 8px 12px;
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius-sm);
    font-size: 14px;
    font-family: inherit;
}

.pg-comm-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pg-comm-filter {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--portal-border);
    background: #fff;
    font-size: 13px;
    font-weight: 500;
    color: var(--portal-text-light);
    cursor: pointer;
    font-family: inherit;
    transition: all var(--portal-transition);
}

.pg-comm-filter:hover {
    color: var(--portal-primary);
    border-color: var(--portal-primary);
}

.pg-comm-filter.active {
    background: var(--portal-primary);
    border-color: var(--portal-primary);
    color: #fff;
}

.pg-comm-filter:focus-visible {
    outline: 2px solid var(--portal-primary);
    outline-offset: 2px;
}

.pg-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.pg-reason {
    display: block;
    font-size: 11px;
    color: var(--portal-text-light);
    margin-top: 3px;
}

.pg-comm-pagination {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

.pg-comm-remaining {
    font-size: 12px;
    color: var(--portal-text-light);
}

@media (max-width: 768px) {
    .pg-comm-search {
        flex-basis: 100%;
    }

    /* La tabla de comunidades se convierte en tarjetas apiladas, igual que
       la de tareas (.portal-table.task-table), para no desbordar la página. */
    .portal-table.pg-comm-table thead {
        display: none;
    }
    .portal-table.pg-comm-table,
    .portal-table.pg-comm-table tbody,
    .portal-table.pg-comm-table tr,
    .portal-table.pg-comm-table td {
        display: block;
        width: 100%;
    }
    .portal-table.pg-comm-table tr {
        margin-bottom: 12px;
        border: 1px solid var(--portal-border);
        border-radius: 10px;
        padding: 10px 14px;
        box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    }
    .portal-table.pg-comm-table td {
        border-bottom: none;
        padding: 6px 0;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 10px;
        text-align: right;
    }
    .portal-table.pg-comm-table td.pg-num {
        text-align: right;
    }
    .portal-table.pg-comm-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--portal-text-light);
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.4px;
        flex-shrink: 0;
        text-align: left;
    }
}
