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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0f1117;
    color: #e1e4e8;
    min-height: 100vh;
}

/* Navbar */
.navbar {
    background: #161b22;
    border-bottom: 1px solid #30363d;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.nav-brand { font-size: 18px; font-weight: 600; color: #58a6ff; }
.nav-links a {
    color: #8b949e;
    text-decoration: none;
    margin-left: 20px;
    font-size: 14px;
}
.nav-links a:hover { color: #e1e4e8; }

/* Container */
.container { max-width: 1400px; margin: 0 auto; padding: 24px; }

/* Summary Bar */
.summary-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.summary-item {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 12px 20px;
    flex: 1;
    min-width: 100px;
    text-align: center;
}
.summary-label { display: block; font-size: 12px; color: #8b949e; margin-bottom: 4px; }
.summary-value { display: block; font-size: 24px; font-weight: 700; }
.summary-item.healthy .summary-value { color: #3fb950; }
.summary-item.warning .summary-value { color: #d29922; }
.summary-item.error .summary-value { color: #f85149; }
.summary-item.stale .summary-value { color: #a371f7; }
.summary-item.no-data .summary-value { color: #8b949e; }
.summary-item.skipped .summary-value { color: #6e7681; }

/* Controls */
.controls {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    align-items: center;
}
.search-box {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 8px 12px;
    color: #e1e4e8;
    font-size: 14px;
    flex: 1;
    max-width: 400px;
}
.search-box:focus { outline: none; border-color: #58a6ff; }
.filter-select {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 8px 12px;
    color: #e1e4e8;
    font-size: 14px;
}
.showing-count { color: #8b949e; font-size: 13px; }

/* Dealer Table */
.dealer-table {
    width: 100%;
    border-collapse: collapse;
    background: #161b22;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #30363d;
}
.dealer-table th {
    background: #1c2129;
    padding: 10px 14px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #30363d;
    cursor: pointer;
    user-select: none;
}
.dealer-table th:hover { color: #e1e4e8; }
.dealer-table th.sorted-asc::after { content: ' \u25B2'; font-size: 10px; }
.dealer-table th.sorted-desc::after { content: ' \u25BC'; font-size: 10px; }
.dealer-table td {
    padding: 10px 14px;
    font-size: 14px;
    border-bottom: 1px solid #21262d;
}
.dealer-table tr:hover { background: #1c2129; }
.dealer-table a { color: #58a6ff; text-decoration: none; }
.dealer-table a:hover { text-decoration: underline; }

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}
.status-badge.healthy { background: #0d3117; color: #3fb950; }
.status-badge.warning { background: #3d2e00; color: #d29922; }
.status-badge.error { background: #3d0a0a; color: #f85149; }
.status-badge.stale { background: #271a45; color: #a371f7; }
.status-badge.no_data { background: #1c1c1c; color: #8b949e; }
.status-badge.counter_failed { background: #3d2800; color: #db6d28; }
.status-badge.skipped { background: #1c1c1c; color: #6e7681; }

.loading { text-align: center; color: #8b949e; padding: 40px; }

/* Login */
.login-container {
    max-width: 360px;
    margin: 120px auto;
    padding: 32px;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    text-align: center;
}
.login-container h1 { font-size: 20px; margin-bottom: 24px; color: #58a6ff; }
.login-container input {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 12px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #e1e4e8;
    font-size: 14px;
}
.login-container input:focus { outline: none; border-color: #58a6ff; }
.login-container button {
    width: 100%;
    padding: 10px;
    background: #238636;
    border: none;
    border-radius: 6px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.login-container button:hover { background: #2ea043; }
.flash-error {
    background: #3d0a0a;
    color: #f85149;
    padding: 8px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 13px;
}

/* Detail page */
.detail-header { margin-bottom: 24px; }
.back-link { color: #58a6ff; text-decoration: none; font-size: 14px; }
.back-link:hover { text-decoration: underline; }
.detail-header h2 { margin-top: 8px; }
.chart-container {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
    max-height: 400px;
}

.muted { color: #8b949e; font-size: 13px; margin-top: 4px; }

/* Note indicator on the dashboard table: small ⓘ icon next to the dealer name
   with the note text revealed on hover. Read-only here; editing is on /dealer/<name>. */
.note-icon {
    display: inline-block;
    margin-left: 6px;
    color: #58a6ff;
    font-size: 13px;
    cursor: help;
    position: relative;
    user-select: none;
}
.note-icon:hover { color: #79b8ff; }
.note-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 0;
    bottom: calc(100% + 6px);
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 6px 10px;
    color: #c9d1d9;
    font-size: 12px;
    font-style: normal;
    line-height: 1.4;
    width: max-content;
    max-width: 280px;
    white-space: normal;
    text-align: left;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease;
    z-index: 100;
}
.note-icon:hover::after,
.note-icon:focus::after { opacity: 1; visibility: visible; }

/* Legacy .note-cell wrapper (kept harmless in case any cached HTML references it). */
.note-cell { margin-top: 2px; }
.dealer-note {
    color: #8b949e;
    font-size: 12px;
    font-style: italic;
    line-height: 1.3;
    max-width: 320px;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
}
.dealer-note .note-text { white-space: normal; }
.dealer-note .note-meta {
    font-style: normal;
    color: #6e7681;
    font-size: 11px;
}
.dealer-note .note-edit,
.note-add {
    color: #58a6ff;
    font-size: 11px;
    text-decoration: none;
    font-style: normal;
}
.dealer-note .note-edit:hover,
.note-add:hover { text-decoration: underline; }
.note-add { color: #6e7681; }

.note-editor { display: flex; flex-direction: column; gap: 6px; max-width: 360px; margin-top: 2px; }
.note-input {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 6px 8px;
    color: #e1e4e8;
    font-size: 12px;
    font-family: inherit;
    resize: vertical;
}
.note-input:focus { outline: none; border-color: #58a6ff; }
.note-actions { display: flex; gap: 4px; }
.note-error { color: #f85149; font-size: 11px; }
.btn-danger {
    background: #3d0a0a;
    border-color: #f85149;
    color: #ffb4b4;
}
.btn-danger:hover:not(:disabled) { background: #5a1010; }

/* Dealer detail note panel */
.note-panel {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 24px;
}
.note-panel-label {
    font-size: 11px;
    font-weight: 600;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.note-panel-body { font-size: 14px; }
.note-panel .dealer-note {
    font-size: 14px;
    max-width: none;
}
.note-panel .note-meta { font-size: 12px; }
.note-panel .note-editor { max-width: 600px; }
.note-panel .note-input { font-size: 13px; }

/* Jobs page controls */
.btn-small {
    background: #21262d;
    color: #e1e4e8;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    margin-right: 4px;
}
.btn-small:hover:not(:disabled) { background: #30363d; }
.btn-small:disabled { opacity: 0.6; cursor: not-allowed; }

.cron-input {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 4px 8px;
    color: #e1e4e8;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 13px;
    width: 130px;
}
.cron-input:focus { outline: none; border-color: #58a6ff; }
.cron-error { color: #f85149; font-size: 12px; margin-left: 8px; }

/* Status badges for job runs */
.status-badge.running { background: #0d2b3d; color: #58a6ff; }
.status-badge.success { background: #0d3117; color: #3fb950; }
.status-badge.failed  { background: #3d0a0a; color: #f85149; }

/* Failed-job banner on main dashboard */
.alert-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #3d0a0a;
    border: 1px solid #f85149;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    color: #f0d4d4;
    font-size: 14px;
}
.alert-banner .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #f85149;
    box-shadow: 0 0 6px #f85149;
    flex-shrink: 0;
}
.alert-banner a { color: #ffb4b4; text-decoration: underline; }

/* Job run log <pre> */
.dealer-table details summary { cursor: pointer; color: #58a6ff; }
.dealer-table pre {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 10px;
    margin-top: 6px;
    max-height: 320px;
    overflow: auto;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 12px;
    color: #c9d1d9;
    white-space: pre-wrap;
    word-break: break-word;
}
