/**
 * 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: 50;
    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);
}

.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;
}

.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: break-word;
}

.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); }

/* ===================================
   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;
}

.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-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-switch {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    background: var(--portal-body-bg);
    color: var(--portal-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    transition: all var(--portal-transition);
    border: 1px solid var(--portal-border);
}

.portal-lang-switch:hover {
    background: var(--portal-primary);
    color: #fff;
    border-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);
}

.portal-lang-switch svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ===================================
   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: 640px;
    margin: 0 auto;
}

.install-hero {
    text-align: center;
    padding: 32px 20px;
}

.install-hero-icon {
    margin: 0 auto 16px;
    width: 80px;
    height: 80px;
}

.install-hero-icon img {
    width: 80px;
    height: 80px;
    border-radius: 18px;
    box-shadow: var(--portal-shadow-lg);
}

.install-hero h2 {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 8px;
    color: var(--portal-text);
}

.install-hero p {
    font-size: 15px;
    color: var(--portal-text-light);
    line-height: 1.6;
    margin: 0;
}

.install-card {
    background: var(--portal-card-bg);
    border-radius: var(--portal-radius);
    box-shadow: var(--portal-shadow);
    margin-bottom: 20px;
    padding: 24px;
    border: 2px solid transparent;
    transition: border-color var(--portal-transition);
}

.install-card-highlight {
    border-color: var(--portal-primary);
    order: -1;
}

.install-card-secondary {
    opacity: 0.6;
    order: 1;
}

.install-card-secondary:hover {
    opacity: 1;
}

.install-card-auto {
    display: flex;
    align-items: center;
    gap: 20px;
    background: linear-gradient(135deg, #e0f2fe, #dbeafe);
    border-color: var(--portal-accent);
    margin-bottom: 28px;
}

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

.install-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--portal-border);
}

.install-card-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
}

.install-card-body h3 {
    margin: 0 0 6px;
    font-size: 17px;
    font-weight: 700;
}

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

.install-card-icon {
    width: 44px;
    height: 44px;
    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 {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--portal-primary);
    color: #fff;
}

.install-card-icon-success {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--portal-success);
    color: #fff;
}

.install-btn {
    font-size: 15px;
    padding: 12px 28px;
    border-radius: 10px;
}

.install-steps {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.install-step {
    display: flex;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--portal-border);
}

.install-step:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.install-step:first-child {
    padding-top: 0;
}

.install-step-num {
    width: 30px;
    height: 30px;
    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;
}

.install-step-content {
    flex: 1;
    padding-top: 4px;
}

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

.install-step-icon-hint {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #f1f5f9;
    border-radius: 8px;
    font-size: 13px;
    color: var(--portal-text-light);
}

.install-step-icon-hint svg {
    color: var(--portal-text);
    flex-shrink: 0;
}

.install-instructions {
    display: flex;
    flex-direction: column;
}

/* ===================================
   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;
}
.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; }
.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: 13px;
    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;
    }
}
