:root {
    --bg-color: #f8f9fa; --card-bg: #ffffff; --text-color: #212529;
    --border-color: #dee2e6; --shadow-color: rgba(0, 0, 0, 0.05);
    --primary-color: #007bff; --primary-light: #e6f2ff; --secondary-color: #6c757d;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --status-failed-bg: #dc3545;
    --status-broken-bg: #ffc107;
}
body.dark-mode {
    --bg-color: #121212; --card-bg: #1e1e1e; --text-color: #e0e0e0;
    --border-color: #333; --shadow-color: rgba(0, 0, 0, 0.2); --primary-light: #2a3a5e;
    --status-failed-bg: #a12832;
    --status-broken-bg: #b98c00;
}
body { 
    font-family: var(--font-family); 
    background-color: var(--bg-color); 
    color: var(--text-color); 
    margin: 0; 
    padding: 20px;
    transition: background-color 0.2s, color 0.2s; 
    padding-right: calc(33.33vw + 20px);
}
.container { max-width: 1200px; margin: 0 auto; }
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 20px; }
h1 { margin: 0; font-size: 24px; }
.header-meta { font-size: 14px; color: var(--secondary-color); }
.controls { display: flex; gap: 10px; align-items: center; }
#search-box, #report-selector { padding: 8px; border-radius: 5px; border: 1px solid var(--border-color); background-color: var(--card-bg); color: var(--text-color); }
#search-box { width: 250px; }
#dark-mode-toggle { cursor: pointer; border: none; background: none; font-size: 24px; padding: 5px; }
.group-card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 8px; margin-bottom: 15px; box-shadow: 0 4px 6px var(--shadow-color); transition: box-shadow 0.2s; overflow: hidden; }
.card-header { padding: 15px 20px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; background-color: rgba(0,0,0,0.02); }
body.dark-mode .card-header { background-color: rgba(255,255,255,0.05); }
.card-title { font-weight: bold; font-size: 18px; }
.card-title .arrow { display: inline-block; transition: transform 0.2s; }
.card-title .arrow.expanded { transform: rotate(90deg); }
.card-summary { color: var(--secondary-color); font-size: 14px; display: flex; align-items: center; gap: 15px;}
.card-content { display: none; padding: 20px; border-top: 1px solid var(--border-color); }
h4 { margin-top: 0; margin-bottom: 8px; font-size: 14px; color: var(--secondary-color); text-transform: uppercase; }
code, pre { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; background-color: var(--primary-light); border-radius: 4px; padding: 2px 5px; font-size: 14px; }
pre { padding: 15px; white-space: pre-wrap; word-wrap: break-word; max-height: 400px; overflow-y: auto; border: 1px solid var(--border-color); }
.label-tag { display: inline-block; background-color: var(--primary-light); color: var(--primary-color); padding: 3px 8px; border-radius: 12px; font-size: 12px; margin-right: 5px; margin-bottom: 5px; }
.progress-bar { display: flex; height: 10px; background-color: var(--primary-light); border-radius: 5px; overflow: hidden; width: 200px; }
.progress-segment { height: 100%; transition: width 0.3s; }
.progress-failed { background-color: var(--status-failed-bg); }
.progress-broken { background-color: var(--status-broken-bg); }
.status-tags { display: flex; gap: 8px; align-items: center; font-size: 12px; width: 80px; }
.status-tag { padding: 3px 10px; border-radius: 12px; color: white; font-weight: 500;}
.status-failed { background-color: var(--status-failed-bg); }
.status-broken { background-color: var(--status-broken-bg); color: #121212; }
body.dark-mode .status-broken { color: #e0e0e0; }
#loader { font-size: 18px; text-align: center; padding: 40px; }

#dashboard-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 25px;
}
.chart-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 6px var(--shadow-color);
    position: relative; /* Helps Chart.js manage responsiveness */
    height: 350px;      /* Prevents the infinite height bug */
}
.chart-card h3 {
    margin-top: 0;
    margin-bottom: 15px;
    text-align: center;
    font-size: 16px;
    color: var(--secondary-color);
}

#ai-chat-container {
    position: fixed; top: 0; right: 0; width: 33.33vw; height: 100vh;
    background: var(--card-bg); border-left: 1px solid var(--border-color);
    box-shadow: -5px 0 15px rgba(0,0,0,0.1); display: flex; flex-direction: column;
    z-index: 1000; transition: transform 0.3s ease-in-out;
}
#chat-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 15px; border-bottom: 1px solid var(--border-color);
    background-color: var(--primary-light); flex-shrink: 0;
}
#chat-header h3 { margin: 0; font-size: 16px; color: var(--primary-color); }
#chat-messages { flex-grow: 1; padding: 15px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.chat-message { max-width: 90%; line-height: 1.5; word-wrap: break-word; }
.user-message { background-color: var(--primary-color); color: white; border-radius: 15px; padding: 8px 12px; border-bottom-right-radius: 3px; align-self: flex-end; }
.ai-message { background-color: var(--primary-light); color: var(--text-color); border-radius: 15px; padding: 8px 12px; border-bottom-left-radius: 3px; align-self: flex-start; }
.ai-message p { margin: 0 0 10px 0; }
.ai-message ul, .ai-message ol { padding-left: 20px; margin: 0 0 10px 0;}
.ai-message li { margin-bottom: 5px; }
.ai-message strong { font-weight: bold; }
.ai-message code { background-color: var(--border-color); padding: 2px 6px; border-radius: 4px; }
.ai-message pre { background-color: var(--border-color); padding: 10px; border-radius: 4px; white-space: pre-wrap; }
.ai-message pre code { background: none; padding: 0; }
.ai-message.loading { display: flex; gap: 5px; align-items: center; }
.ai-message.loading span { width: 8px; height: 8px; background-color: var(--secondary-color); border-radius: 50%; animation: bounce 1.4s infinite ease-in-out both; }
.ai-message.loading span:nth-child(1) { animation-delay: -0.32s; }
.ai-message.loading span:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1.0); } }
#chat-input-form { display: flex; padding: 10px; border-top: 1px solid var(--border-color); flex-shrink: 0; }
#chat-input {
    flex-grow: 1; padding: 8px; border: 1px solid var(--border-color);
    border-radius: 5px; resize: none; background-color: var(--card-bg);
    color: var(--text-color); font-family: inherit;
}
#chat-input:focus { outline: 1px solid var(--primary-color); }
#chat-send-btn { margin-left: 10px; padding: 8px 15px; border: none; background-color: var(--primary-color); color: white; border-radius: 5px; cursor: pointer; }