/**
 * Vision4Insights Daily Summary Dashboard
 * Official Theme Stylesheet
 * Subdomain: dashboard.vision4insights.com
 */

:root {
    --v4i-primary: #173F63;
    --v4i-primary-dark: #0F2A42;
    --v4i-primary-light: #235B8D;
    --v4i-secondary: #EAF4FB;
    --v4i-secondary-hover: #D8ECF9;
    --v4i-accent: #13B8D1;
    --v4i-accent-hover: #0EA5E9;
    --v4i-bg: #F8FAFC;
    --v4i-card-bg: #FFFFFF;
    --v4i-border: #E2E8F0;
    --v4i-border-focus: #13B8D1;
    --v4i-text-main: #1E293B;
    --v4i-text-muted: #64748B;
    --v4i-text-light: #94A3B8;

    --v4i-status-completed: #10B981;
    --v4i-status-terminated: #EF4444;
    --v4i-status-quota: #3B82F6;
    --v4i-status-security: #F59E0B;
    --v4i-status-pending: #13B8D1;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 3px rgba(23, 63, 99, 0.05);
    --shadow-md: 0 4px 12px rgba(23, 63, 99, 0.06);
    --shadow-lg: 0 12px 28px rgba(23, 63, 99, 0.12);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--v4i-bg);
    color: var(--v4i-text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* App Shell Layout */
.app-container {
    max-width: 1540px;
    margin: 0 auto;
    padding: 20px 24px 60px;
}

/* Top Navigation Bar */
.top-navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #FFFFFF;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    border: 1px solid var(--v4i-border);
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}
.brand-logo-img {
    height: 42px;
    width: 42px;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 2px 6px rgba(23, 63, 99, 0.18);
}
.brand-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--v4i-primary);
    line-height: 1.1;
    display: block;
    letter-spacing: -0.02em;
}
.brand-subtitle {
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--v4i-accent);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: block;
}

.nav-menu {
    display: flex;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
}
.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--v4i-text-muted);
    text-decoration: none;
    transition: all 0.2s ease;
}
.nav-link:hover {
    color: var(--v4i-primary);
    background: var(--v4i-secondary);
}
.nav-link.active {
    color: #FFFFFF;
    background: var(--v4i-primary);
    box-shadow: 0 2px 8px rgba(23, 63, 99, 0.25);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}
.profile-dropdown-wrapper {
    position: relative;
    display: inline-block;
}
.profile-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px;
    background: var(--v4i-secondary);
    border-radius: 20px;
    border: 1px solid #BFDBFE;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}
.profile-pill:hover,
.profile-dropdown-wrapper:focus-within .profile-pill {
    background: #DBEAFE;
    border-color: #93C5FD;
}
.profile-dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 240px;
    background: #FFFFFF;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.2), 0 8px 10px -6px rgba(15, 23, 42, 0.1);
    border: 1px solid var(--v4i-border);
    padding: 10px 0;
    z-index: 1000;
    display: none;
}
.profile-dropdown-wrapper:hover .profile-dropdown-menu,
.profile-dropdown-wrapper:focus-within .profile-dropdown-menu {
    display: block;
    animation: v4iFadeDown 0.18s ease forwards;
}
@keyframes v4iFadeDown {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}
.profile-menu-header {
    padding: 4px 16px 10px 16px;
    border-bottom: 1px solid var(--v4i-border);
}
.profile-menu-header strong {
    display: block;
    font-size: 0.88rem;
    color: var(--v4i-primary);
}
.profile-menu-header span {
    font-size: 0.74rem;
    color: var(--v4i-text-muted);
}
.profile-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--v4i-text-main);
    text-decoration: none;
    transition: background 0.15s ease;
}
.profile-menu-item:hover {
    background: var(--v4i-secondary);
    color: var(--v4i-primary);
}
.profile-menu-divider {
    height: 1px;
    background: var(--v4i-border);
    margin: 6px 0;
}
.profile-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--v4i-primary);
    color: #FFFFFF;
    font-size: 0.8rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}
.profile-info strong {
    font-size: 0.82rem;
    color: var(--v4i-primary);
    display: block;
    line-height: 1.1;
}
.profile-info small {
    font-size: 0.68rem;
    color: var(--v4i-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 700;
    color: #DC2626;
    background: #FEE2E2;
    border: 1px solid #FCA5A5;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s ease;
}
.btn-logout:hover {
    background: #DC2626;
    color: #FFFFFF;
}

/* Dashboard Header Block */
.dash-header-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #FFFFFF;
    padding: 20px 24px;
    border-radius: var(--radius-md);
    border: 1px solid var(--v4i-border);
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}
.header-title-wrap h1 {
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--v4i-primary);
    margin: 0 0 6px 0;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 10px;
}
.header-meta-row {
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 0.82rem;
    color: var(--v4i-text-muted);
    flex-wrap: wrap;
}
.meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.header-actions-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Live Feed Status Badge */
.live-feed-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    background: #DCFCE7;
    color: #166534;
    border: 1px solid #86EFAC;
    transition: all 0.3s ease;
}
.live-feed-badge.reconnecting {
    background: #FEF3C7;
    color: #92400E;
    border-color: #FCD34D;
}
.live-feed-badge.offline {
    background: #FEE2E2;
    color: #991B1B;
    border-color: #FCA5A5;
}
.live-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #16A34A;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.25);
    animation: v4iPulse 2s infinite;
}
.live-feed-badge.reconnecting .live-pulse-dot {
    background: #D97706;
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.25);
}
.live-feed-badge.offline .live-pulse-dot {
    background: #DC2626;
    box-shadow: none;
    animation: none;
}
@keyframes v4iPulse {
    0% { transform: scale(0.95); opacity: 0.85; }
    50% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.85; }
}

/* Buttons */
.btn-v4i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 38px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-decoration: none;
}
.btn-v4i-primary {
    background: var(--v4i-primary);
    color: #FFFFFF;
}
.btn-v4i-primary:hover {
    background: var(--v4i-primary-dark);
    box-shadow: 0 4px 10px rgba(23, 63, 99, 0.2);
}
.btn-v4i-secondary {
    background: #FFFFFF;
    color: var(--v4i-primary);
    border-color: var(--v4i-border);
}
.btn-v4i-secondary:hover {
    background: var(--v4i-secondary);
    border-color: #BFDBFE;
}
.btn-v4i-accent {
    background: var(--v4i-accent);
    color: #FFFFFF;
}
.btn-v4i-accent:hover {
    background: #0EA5E9;
    box-shadow: 0 4px 10px rgba(19, 184, 209, 0.25);
}
.btn-v4i-simulate {
    background: #EAF4FB;
    color: var(--v4i-primary);
    border: 1px dashed #3B82F6;
    font-size: 0.8rem;
}
.btn-v4i-simulate:hover {
    background: #DBEAFE;
    color: #1D4ED8;
}

/* Advanced Filter Panel */
.filter-panel-card {
    background: #FFFFFF;
    padding: 20px 24px;
    border-radius: var(--radius-md);
    border: 1px solid var(--v4i-border);
    margin-bottom: 22px;
    box-shadow: var(--shadow-sm);
}
.filter-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--v4i-border);
}
.filter-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--v4i-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    align-items: end;
}
.filter-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.filter-field label {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--v4i-primary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin: 0;
}
.form-control-v4i {
    height: 38px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--v4i-border);
    background: #FFFFFF;
    color: var(--v4i-text-main);
    font-size: 0.85rem;
    outline: none;
    transition: all 0.2s ease;
    width: 100%;
}
.form-control-v4i:focus {
    border-color: var(--v4i-accent);
    box-shadow: 0 0 0 3px rgba(19, 184, 209, 0.15);
}
.filter-action-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* 10 Live Summary Cards Grid */
.summary-cards-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    margin-bottom: 22px;
}
.metric-card {
    background: #FFFFFF;
    border-radius: var(--radius-md);
    padding: 16px;
    border: 1px solid var(--v4i-border);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--v4i-primary);
}
.metric-card.card-completed::before { background: var(--v4i-status-completed); }
.metric-card.card-terminated::before { background: var(--v4i-status-terminated); }
.metric-card.card-quota::before { background: var(--v4i-status-quota); }
.metric-card.card-security::before { background: var(--v4i-status-security); }
.metric-card.card-pending::before { background: var(--v4i-status-pending); }

.card-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.card-label {
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--v4i-text-muted);
}
.card-icon-badge {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    background: var(--v4i-secondary);
    color: var(--v4i-primary);
}
.card-completed .card-icon-badge { background: #DCFCE7; color: #16A34A; }
.card-terminated .card-icon-badge { background: #FEE2E2; color: #DC2626; }
.card-quota .card-icon-badge { background: #DBEAFE; color: #2563EB; }
.card-security .card-icon-badge { background: #FEF3C7; color: #D97706; }
.card-pending .card-icon-badge { background: #E0F2FE; color: #0284C7; }

.card-number {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--v4i-text-main);
    line-height: 1.1;
    margin-bottom: 8px;
}
.card-bottom-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--v4i-text-muted);
}
.pill-badge {
    padding: 2px 7px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.72rem;
}
.pill-completed { background: #DCFCE7; color: #166534; }
.pill-terminated { background: #FEE2E2; color: #991B1B; }
.pill-quota { background: #DBEAFE; color: #1E40AF; }
.pill-security { background: #FEF3C7; color: #92400E; }
.pill-neutral { background: var(--v4i-secondary); color: var(--v4i-primary); }

/* Analytics Charts Section */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 22px;
}
.chart-box {
    background: #FFFFFF;
    border-radius: var(--radius-md);
    padding: 18px 20px;
    border: 1px solid var(--v4i-border);
    box-shadow: var(--shadow-sm);
}
.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--v4i-border);
    font-size: 0.94rem;
    font-weight: 700;
    color: var(--v4i-primary);
}
.chart-render-target {
    min-height: 280px;
}

/* Data Table Card */
.table-card {
    background: #FFFFFF;
    border-radius: var(--radius-md);
    border: 1px solid var(--v4i-border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.table-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px;
    border-bottom: 1px solid var(--v4i-border);
}
.table-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--v4i-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.table-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}
.table-scroll-wrap {
    overflow-x: auto;
    width: 100%;
}
.v4i-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
    text-align: left;
}
.v4i-table th {
    background: #F8FAFC;
    color: var(--v4i-primary);
    font-weight: 700;
    padding: 12px 14px;
    border-bottom: 1px solid var(--v4i-border);
    white-space: nowrap;
    text-transform: uppercase;
    font-size: 0.74rem;
    letter-spacing: 0.04em;
}
.v4i-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #F1F5F9;
    color: var(--v4i-text-main);
    vertical-align: middle;
}
.v4i-table tbody tr:hover {
    background: #F8FBFF;
}

/* Status Badges */
.badge-status {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.74rem;
    font-weight: 700;
}
.badge-success { background: #DCFCE7; color: #166534; border: 1px solid #86EFAC; }
.badge-danger { background: #FEE2E2; color: #991B1B; border: 1px solid #FCA5A5; }
.badge-primary { background: #DBEAFE; color: #1E40AF; border: 1px solid #93C5FD; }
.badge-warning { background: #FEF3C7; color: #92400E; border: 1px solid #FCD34D; }
.badge-info { background: #E0F2FE; color: #0369A1; border: 1px solid #7DD3FC; }
.badge-secondary { background: #F1F5F9; color: #475569; border: 1px solid #CBD5E1; }

/* Risk Badges */
.risk-pill-low {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    background: #DCFCE7;
    color: #166534;
    font-weight: 700;
    font-size: 0.72rem;
}
.risk-pill-medium {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    background: #FEF3C7;
    color: #92400E;
    font-weight: 700;
    font-size: 0.72rem;
}
.risk-pill-high {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    background: #FEE2E2;
    color: #991B1B;
    font-weight: 700;
    font-size: 0.72rem;
}

.table-btn-action {
    padding: 5px 10px;
    font-size: 0.76rem;
    font-weight: 700;
    border-radius: 6px;
    background: var(--v4i-secondary);
    color: var(--v4i-primary);
    border: 1px solid #BFDBFE;
    cursor: pointer;
    transition: all 0.15s ease;
}
.table-btn-action:hover {
    background: var(--v4i-primary);
    color: #FFFFFF;
}
.copy-trigger {
    cursor: pointer;
    margin-left: 5px;
    color: #94A3B8;
}
.copy-trigger:hover {
    color: var(--v4i-primary);
}

/* Pagination Footer */
.table-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 22px;
    background: #F8FAFC;
    border-top: 1px solid var(--v4i-border);
    font-size: 0.82rem;
    color: var(--v4i-text-muted);
}
.pagination-wrap {
    display: flex;
    gap: 4px;
}
.pagination-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid var(--v4i-border);
    background: #FFFFFF;
    color: var(--v4i-text-main);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}
.pagination-btn:hover:not(:disabled) {
    background: var(--v4i-secondary);
    border-color: #BFDBFE;
    color: var(--v4i-primary);
}
.pagination-btn.active {
    background: var(--v4i-primary);
    border-color: var(--v4i-primary);
    color: #FFFFFF;
}
.pagination-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Modal Overlay & Card */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.show {
    display: flex;
}
.modal-card {
    background: #FFFFFF;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--v4i-border);
}
.modal-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--v4i-border);
}
.modal-card-body {
    padding: 20px 24px;
}
.modal-card-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--v4i-border);
    display: flex;
    justify-content: flex-end;
    background: #F8FAFC;
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
.detail-item {
    background: #F8FAFC;
    border: 1px solid var(--v4i-border);
    border-radius: 8px;
    padding: 10px 12px;
}
.detail-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--v4i-text-muted);
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}
.detail-val {
    font-size: 0.85rem;
    color: var(--v4i-text-main);
}

/* Toasts */
.toast-shelf {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast-msg {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: var(--v4i-primary);
    color: #FFFFFF;
    border-radius: 8px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
    font-size: 0.85rem;
    font-weight: 600;
    animation: v4iSlideIn 0.3s ease;
}
.toast-msg.toast-success { background: #166534; }
.toast-msg.toast-error { background: #991B1B; }
.toast-msg.toast-info { background: #173F63; }
@keyframes v4iSlideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.spin {
    animation: spinAnim 1s infinite linear;
    display: inline-block;
}
@keyframes spinAnim {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 1200px) {
    .summary-cards-grid { grid-template-columns: repeat(3, 1fr); }
    .charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .summary-cards-grid { grid-template-columns: repeat(2, 1fr); }
    .dash-header-card { flex-direction: column; align-items: flex-start; gap: 14px; }
    .header-actions-wrap { width: 100%; justify-content: space-between; }
    .top-navbar { flex-direction: column; align-items: flex-start; gap: 12px; }
    .nav-actions { width: 100%; justify-content: space-between; }
}
@media (max-width: 480px) {
    .summary-cards-grid { grid-template-columns: 1fr; }
}
