/* ============================================
   DATA HEALTH DASHBOARD — Grosvenor Solutions
   ============================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --green: #16a34a;
    --green-bg: #f0fdf4;
    --green-border: #bbf7d0;
    --amber: #d97706;
    --amber-bg: #fffbeb;
    --amber-border: #fde68a;
    --red: #dc2626;
    --red-bg: #fef2f2;
    --red-border: #fecaca;
    --blue: #2563eb;
    --blue-bg: #eff6ff;
    --grey-50: #f9fafb;
    --grey-100: #f3f4f6;
    --grey-200: #e5e7eb;
    --grey-300: #d1d5db;
    --grey-400: #9ca3af;
    --grey-500: #6b7280;
    --grey-600: #4b5563;
    --grey-700: #374151;
    --grey-800: #1f2937;
    --grey-900: #111827;
    --white: #ffffff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --radius: 8px;
    --radius-lg: 12px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --transition: 0.2s ease;
}

body {
    font-family: var(--font);
    background: var(--grey-50);
    color: var(--grey-800);
    line-height: 1.5;
    min-height: 100vh;
}

/* -- Header -- */
.header {
    background: var(--white);
    border-bottom: 1px solid var(--grey-200);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}
.header-left { display: flex; align-items: baseline; gap: 12px; }
.header-title { font-size: 20px; font-weight: 700; color: var(--grey-900); }
.header-subtitle { font-size: 13px; color: var(--grey-400); font-weight: 400; }
.header-right { display: flex; align-items: center; gap: 12px; }
.last-run { font-size: 12px; color: var(--grey-400); }

/* -- Buttons -- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--grey-300);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    background: var(--white);
    color: var(--grey-700);
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn:hover { background: var(--grey-50); border-color: var(--grey-400); }
.btn-primary { background: var(--blue); color: var(--white); border-color: var(--blue); }
.btn-primary:hover { background: #1d4ed8; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--grey-100); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-back { border: none; background: none; color: var(--blue); font-weight: 600; padding: 4px 0; }
.btn-back:hover { color: #1d4ed8; background: none; border: none; }
.btn-icon { font-size: 10px; }
.btn-accept { background: var(--amber); color: var(--white); border-color: var(--amber); }
.btn-accept:hover { background: #b45309; }
.btn-suppress { background: var(--grey-600); color: var(--white); border-color: var(--grey-600); }
.btn-suppress:hover { background: var(--grey-700); }

.action-btn {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid;
    background: var(--white);
    transition: all var(--transition);
    margin: 2px;
}
.action-btn.ack { color: var(--blue); border-color: #bfdbfe; }
.action-btn.ack:hover { background: var(--blue-bg); }
.action-btn.accept { color: var(--amber); border-color: var(--amber-border); }
.action-btn.accept:hover { background: var(--amber-bg); }
.action-btn.suppress { color: var(--grey-500); border-color: var(--grey-300); }
.action-btn.suppress:hover { background: var(--grey-100); }
.action-btn.detail { color: var(--grey-500); border-color: var(--grey-200); }
.action-btn.detail:hover { background: var(--grey-100); }
.action-btn.remove { color: var(--red); border-color: var(--red-border); }
.action-btn.remove:hover { background: var(--red-bg); }

/* -- Sections -- */
.section { padding: 24px 32px; max-width: 1400px; margin: 0 auto; }
.section-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.section-header h2 { font-size: 18px; font-weight: 700; color: var(--grey-900); }

/* -- Client Cards -- */
.client-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}
.client-card {
    background: var(--white);
    border: 1px solid var(--grey-200);
    border-radius: var(--radius-lg);
    padding: 20px;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
    display: flex;
    gap: 16px;
    align-items: flex-start;
}
.client-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--grey-300);
    transform: translateY(-1px);
}
.client-card.status-green { border-left: 4px solid var(--green); }
.client-card.status-amber { border-left: 4px solid var(--amber); }
.client-card.status-red { border-left: 4px solid var(--red); }
.client-card.status-unknown { border-left: 4px solid var(--grey-300); }

.card-score {
    width: 56px; height: 56px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; font-weight: 800;
    flex-shrink: 0; color: var(--white);
}
.card-score.green { background: var(--green); }
.card-score.amber { background: var(--amber); }
.card-score.red { background: var(--red); }
.card-score.unknown { background: var(--grey-300); }

.card-info { flex: 1; min-width: 0; }
.card-name {
    font-size: 15px; font-weight: 700; color: var(--grey-900);
    margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-stats { display: flex; gap: 12px; font-size: 12px; color: var(--grey-500); margin-bottom: 6px; }
.card-stat { display: flex; align-items: center; gap: 4px; }
.card-stat .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.fail { background: var(--red); }
.dot.warning { background: var(--amber); }
.dot.pass { background: var(--green); }
.card-last-run { font-size: 11px; color: var(--grey-400); }

/* -- Score Card -- */
.score-card {
    background: var(--white);
    border: 1px solid var(--grey-200);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex; gap: 24px; align-items: center;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
}
.score-circle {
    width: 90px; height: 90px;
    border-radius: 50%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    flex-shrink: 0; color: var(--white);
}
.score-circle.green { background: var(--green); }
.score-circle.amber { background: var(--amber); }
.score-circle.red { background: var(--red); }
.score-number { font-size: 28px; font-weight: 800; line-height: 1; }
.score-label { font-size: 11px; opacity: 0.85; }
.score-details { flex-shrink: 0; }
.score-status { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.score-counts { display: flex; gap: 12px; font-size: 13px; }
.count-fail { color: var(--red); font-weight: 600; }
.count-warning { color: var(--amber); font-weight: 600; }
.count-pass { color: var(--green); font-weight: 600; }

.category-bars {
    flex: 1; min-width: 280px;
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px;
}
.cat-bar { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.cat-bar-label {
    width: 110px; color: var(--grey-500); text-align: right; flex-shrink: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cat-bar-track { flex: 1; height: 8px; background: var(--grey-100); border-radius: 4px; overflow: hidden; }
.cat-bar-fill { height: 100%; border-radius: 4px; transition: width 0.6s ease; }
.cat-bar-fill.green { background: var(--green); }
.cat-bar-fill.amber { background: var(--amber); }
.cat-bar-fill.red { background: var(--red); }
.cat-bar-value { width: 30px; text-align: right; font-weight: 600; color: var(--grey-700); }

/* -- Detail Header -- */
.detail-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.detail-title { font-size: 20px; font-weight: 700; flex: 1; }

/* -- Tabs -- */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--grey-200); margin-bottom: 20px; }
.tab {
    padding: 10px 20px; border: none; background: none;
    font-size: 14px; font-weight: 500; color: var(--grey-500);
    cursor: pointer; border-bottom: 2px solid transparent;
    margin-bottom: -2px; transition: all var(--transition);
}
.tab:hover { color: var(--grey-700); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }
.tab-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 10px; background: var(--grey-200); color: var(--grey-600);
    font-size: 11px; font-weight: 700; margin-left: 4px;
}
.tab.active .tab-count { background: var(--blue-bg); color: var(--blue); }

/* -- Findings Table -- */
.findings-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.findings-table thead th {
    text-align: left; padding: 10px 12px;
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--grey-400); border-bottom: 1px solid var(--grey-200); white-space: nowrap;
}
.findings-table tbody tr { border-bottom: 1px solid var(--grey-100); transition: background var(--transition); }
.findings-table tbody tr:hover { background: var(--grey-50); }
.findings-table td { padding: 12px 12px; vertical-align: top; }

.col-severity { width: 80px; }
.col-category { width: 130px; }
.col-check { width: 160px; }
.col-summary { min-width: 200px; }
.col-amount { width: 100px; text-align: right; }
.col-age { width: 70px; }
.col-actions { width: 180px; }

/* -- Badges -- */
.badge {
    display: inline-flex; align-items: center;
    padding: 2px 10px; border-radius: 10px;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
}
.badge-fail { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }
.badge-warning { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-border); }
.badge-pass { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.badge-neutral { background: var(--grey-100); color: var(--grey-500); }

.category-label {
    font-size: 11px; color: var(--grey-500); background: var(--grey-100);
    padding: 2px 8px; border-radius: 4px; white-space: nowrap;
}
.check-name { font-weight: 600; color: var(--grey-800); }
.finding-summary { color: var(--grey-600); line-height: 1.4; }
.finding-amount { font-weight: 600; color: var(--grey-800); text-align: right; white-space: nowrap; }
.finding-age { font-size: 12px; color: var(--grey-400); white-space: nowrap; }

/* -- Empty State -- */
.empty-state { text-align: center; padding: 48px 24px; color: var(--grey-400); font-size: 14px; }

/* -- Modal -- */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}
.modal {
    background: var(--white); border-radius: var(--radius-lg);
    width: 480px; max-width: 90vw; box-shadow: var(--shadow-lg);
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--grey-200);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
    background: none; border: none; font-size: 22px;
    color: var(--grey-400); cursor: pointer; line-height: 1; padding: 4px;
}
.modal-close:hover { color: var(--grey-700); }
.modal-body { padding: 20px; }
.modal-body label {
    display: block; font-size: 13px; font-weight: 600;
    color: var(--grey-700); margin: 12px 0 6px;
}
.modal-body textarea, .modal-body select {
    width: 100%; padding: 8px 12px;
    border: 1px solid var(--grey-300); border-radius: 6px;
    font-size: 13px; font-family: var(--font); resize: vertical;
}
.modal-body textarea:focus, .modal-body select:focus {
    outline: none; border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.modal-finding-summary {
    background: var(--grey-50); padding: 10px 14px; border-radius: 6px;
    font-size: 13px; color: var(--grey-600); border-left: 3px solid var(--grey-300);
}
.modal-footer {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 16px 20px; border-top: 1px solid var(--grey-200);
}

/* -- Finding Detail Panel -- */
.detail-panel {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--white); border-top: 1px solid var(--grey-200);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
    z-index: 200; max-height: 40vh; overflow-y: auto;
}
.detail-panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 32px; border-bottom: 1px solid var(--grey-100);
    position: sticky; top: 0; background: var(--white);
}
.detail-panel-header h4 { font-size: 14px; font-weight: 700; }
.detail-panel-body { padding: 16px 32px 24px; }
.detail-recommendation {
    background: var(--blue-bg); border: 1px solid #bfdbfe; border-radius: 6px;
    padding: 10px 14px; font-size: 13px; color: #1e40af; margin-bottom: 12px;
}
.detail-json {
    background: var(--grey-50); border: 1px solid var(--grey-200); border-radius: 6px;
    padding: 12px 16px; font-size: 12px; font-family: 'SF Mono', 'Fira Code', monospace;
    color: var(--grey-700); overflow-x: auto; white-space: pre-wrap; word-break: break-word;
}

/* -- Toast -- */
.toast {
    position: fixed; top: 20px; right: 20px;
    padding: 12px 20px; border-radius: 8px;
    font-size: 13px; font-weight: 500; color: var(--white);
    z-index: 2000; box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease; max-width: 400px;
}
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.toast.info { background: var(--blue); }
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* -- Loading -- */
.loading-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.85);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    z-index: 500;
}
.loading-spinner {
    width: 40px; height: 40px;
    border: 4px solid var(--grey-200); border-top-color: var(--blue);
    border-radius: 50%; animation: spin 0.8s linear infinite; margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 14px; color: var(--grey-500); }

/* -- Responsive -- */
@media (max-width: 768px) {
    .header { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
    .section { padding: 16px; }
    .client-cards { grid-template-columns: 1fr; }
    .score-card { flex-direction: column; align-items: flex-start; }
    .category-bars { grid-template-columns: 1fr; min-width: auto; }
    .findings-table { font-size: 12px; }
    .col-category, .col-age { display: none; }
}
