/* ===== Dashboard — Corporate SaaS ===== */

/* Nav */
.nav-dashboard {
    background: #0f172a;
    border-bottom: 1px solid #1e293b;
}

.nav-dashboard .nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-plan-pill {
    display: flex;
    align-items: center;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 12px;
    color: #94a3b8;
    white-space: nowrap;
}

.nav-upgrade-link {
    font-size: 13px;
    font-weight: 600;
    color: #10b981 !important;
    text-decoration: none;
    margin-right: 8px;
}

.nav-upgrade-link:hover {
    color: #34d399 !important;
}

.nav-dashboard .nav-links a {
    color: #cbd5e1;
}

.nav-dashboard .nav-links a:hover,
.nav-dashboard .nav-links a.active {
    color: white;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: 12px;
    padding-left: 12px;
    border-left: 1px solid #334155;
}

.nav-user span {
    color: #cbd5e1;
    font-size: 13px;
}

/* ===== Main Layout ===== */
.dashboard-main {
    min-height: 100vh;
    padding-top: 80px;
    padding-bottom: 60px;
    background: #f8fafc;
}

.dashboard-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ===== Header ===== */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 28px 0 4px;
}

.dashboard-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.3px;
    margin-bottom: 2px;
}

.header-sub {
    color: #64748b;
    font-size: 13px;
}

.dashboard-header .btn {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

/* ===== KPI Row ===== */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-top: 20px;
}

.kpi-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #e2e8f0;
}

.kpi-card:nth-child(1)::before { background: #3b82f6; }
.kpi-card:nth-child(2)::before { background: #f59e0b; }
.kpi-card:nth-child(3)::before { background: #10b981; }
.kpi-card:nth-child(4)::before { background: #8b5cf6; }

.kpi-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.kpi-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.kpi-value.kpi-best-name {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0;
}

.kpi-value.kpi-attention.has-attention {
    color: #dc6b09;
}

.kpi-sub {
    display: block;
    font-size: 12px;
    color: #94a3b8;
    margin-top: 6px;
    line-height: 1.4;
}

.kpi-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 3px;
    position: relative;
    top: -1px;
}

.kpi-dot.safe { background: #10b981; }
.kpi-dot.watch { background: #f59e0b; }
.kpi-dot.danger { background: #ef4444; }

@media (max-width: 900px) {
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 500px) {
    .kpi-row { grid-template-columns: 1fr; }
}

/* ===== Alert Banner ===== */
.alert-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fffbeb;
    border: 1px solid #fbbf24;
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
    padding: 12px 16px;
    margin-top: 16px;
    font-size: 13px;
    color: #92400e;
}

.alert-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: #f59e0b;
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.alert-text {
    flex: 1;
    line-height: 1.4;
}

.alert-link {
    color: #92400e;
    font-weight: 600;
    text-decoration: underline;
    white-space: nowrap;
    flex-shrink: 0;
}

.alert-link:hover {
    color: #78350f;
}

/* ===== Reports Section ===== */
.reports-section {
    margin-top: 24px;
}

.reports-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.reports-toolbar h2 {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}

/* Filter Chips */
.filter-chips {
    display: flex;
    gap: 6px;
}

.chip {
    padding: 6px 16px;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s;
}

.chip:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.chip.active {
    background: #0f172a;
    color: white;
    border-color: #0f172a;
}

.chip-danger.active {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

.chip-watch.active {
    background: #fffbeb;
    color: #d97706;
    border-color: #fde68a;
}

.chip-safe.active {
    background: #f0fdf4;
    color: #16a34a;
    border-color: #bbf7d0;
}

/* ===== Table ===== */
.reports-table-wrap {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    overflow-x: auto;
}

.reports-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}

.reports-table thead {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.reports-table th {
    text-align: left;
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.reports-table th:last-child {
    text-align: right;
}

.reports-table td {
    padding: 14px 16px;
    font-size: 14px;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

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

.reports-table tbody tr {
    transition: background 0.1s;
}

.reports-table tbody tr:hover td {
    background: #f8fafc;
}

.reports-table td:last-child {
    text-align: right;
}

.report-name-cell {
    font-weight: 600;
    color: #0f172a;
    font-size: 14px;
    line-height: 1.3;
}

.report-industry {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 1px;
}

.period-cell {
    font-size: 13px;
    color: #64748b;
    white-space: nowrap;
}

/* Health Badge */
.health-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    white-space: nowrap;
}

.health-badge::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.health-badge.danger {
    background: #fef2f2;
    color: #dc2626;
}
.health-badge.danger::before { background: #ef4444; }

.health-badge.watch {
    background: #fffbeb;
    color: #d97706;
}
.health-badge.watch::before { background: #f59e0b; }

.health-badge.safe {
    background: #f0fdf4;
    color: #16a34a;
}
.health-badge.safe::before { background: #22c55e; }

/* Metrics */
.metric-positive { color: #059669; }
.metric-negative { color: #dc2626; }

/* Runway */
.runway-cell {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.runway-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.runway-dot.dot-danger { background: #ef4444; }
.runway-dot.dot-watch { background: #f59e0b; }
.runway-dot.dot-safe { background: #22c55e; }

/* Table Actions */
.table-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    align-items: center;
}

.table-actions .btn {
    padding: 5px 14px;
    font-size: 12px;
}

.btn-icon-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 6px;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-icon-delete:hover {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

.empty-filter {
    text-align: center;
    color: #94a3b8;
    padding: 40px 20px !important;
    font-size: 14px;
}

/* ===== States ===== */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 60px 20px;
    color: #64748b;
}

.loading-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-state {
    text-align: center;
    padding: 56px 20px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    margin-top: 20px;
}

.empty-icon {
    margin-bottom: 16px;
    color: #cbd5e1;
}

.empty-state h2 {
    font-size: 18px;
    color: #0f172a;
    margin-bottom: 6px;
}

.empty-state p {
    color: #64748b;
    margin-bottom: 20px;
    font-size: 14px;
}

.error-message {
    text-align: center;
    color: #dc2626;
    padding: 32px 20px !important;
}

.btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== Trends (Collapsible) ===== */
.trends-section {
    background: white;
    border-radius: 10px;
    margin-top: 20px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.trends-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.trends-toggle:hover {
    background: #f8fafc;
}

.trends-toggle h2 {
    font-size: 14px;
    font-weight: 600;
    color: #334155;
    margin: 0;
}

.trends-toggle-icon {
    width: 20px;
    height: 20px;
    color: #94a3b8;
    transition: transform 0.2s;
}

.trends-section.expanded .trends-toggle-icon {
    transform: rotate(180deg);
}

.trends-body {
    display: none;
    padding: 0 20px 20px;
}

.trends-section.expanded .trends-body {
    display: block;
}

.trends-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.trend-card {
    background: #f8fafc;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.trend-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 4px;
}

.trend-value {
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
}

.trend-value.positive { color: #10b981; }
.trend-value.negative { color: #ef4444; }

.trends-chart-container {
    height: 200px;
}

@media (max-width: 640px) {
    .trends-summary { grid-template-columns: 1fr; }
}


/* ===== Responsive ===== */
@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .reports-toolbar {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .filter-chips {
        flex-wrap: wrap;
    }

    .nav-user span,
    .nav-plan-pill {
        display: none;
    }

    .nav-right {
        gap: 4px;
    }

    .alert-banner {
        flex-wrap: wrap;
    }
}
