* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: #0d1117; color: #c9d1d9; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; min-height: 100vh; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #30363d; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #484f58; }

/* HEADER */
.header { background: #161b22; border-bottom: 1px solid #30363d; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10; }
.header-left { display: flex; align-items: center; gap: 10px; }
.header h1 { font-size: 16px; font-weight: 600; color: #f0f6fc; }
.header h1 span { color: #fc6d26; }
.header-right { display: flex; align-items: center; gap: 12px; }
.sidebar-toggle { display: none; background: none; border: 1px solid #30363d; border-radius: 6px; color: #8b949e; font-size: 16px; padding: 4px 8px; cursor: pointer; }
.sidebar-toggle:hover { color: #f0f6fc; border-color: #8b949e; }
.refresh-info { font-size: 12px; color: #8b949e; display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #3fb950; flex-shrink: 0; }
.dot.loading { background: #fc6d26; animation: blink 0.8s infinite; }
.dot.error   { background: #f85149; }
.dot.paused  { background: #d29922; }
.paused-banner { background: #2d1f00; border-bottom: 1px solid #d29922; padding: 8px 24px; font-size: 13px; color: #d29922; display: none; text-align: center; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* USER INFO */
.user-info { display: flex; align-items: center; gap: 8px; }
.user-info img { width: 24px; height: 24px; border-radius: 50%; }
.user-info span { font-size: 12px; color: #8b949e; }
.btn-logout { padding: 4px 10px; font-size: 11px; background: transparent; border: 1px solid #30363d; border-radius: 6px; color: #8b949e; cursor: pointer; }
.btn-logout:hover { color: #f85149; border-color: #f85149; }

/* LOADING OVERLAY */
#loading-overlay { position: fixed; inset: 0; z-index: 999; background: #0d1117; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; transition: opacity 0.3s ease; }
#loading-overlay.hidden { opacity: 0; pointer-events: none; }
.spinner { width: 40px; height: 40px; border: 3px solid #21262d; border-top-color: #fc6d26; border-radius: 50%; animation: spin 0.75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 13px; color: #8b949e; }
.countdown-bar { height: 2px; background: #21262d; width: 100%; position: sticky; top: 53px; z-index: 9; }
.countdown-fill { height: 100%; background: #fc6d26; transition: width 1s linear; }
.btn-sm { padding: 6px 14px; font-size: 12px; background: #21262d; border: 1px solid #30363d; border-radius: 6px; color: #8b949e; cursor: pointer; }
.btn-sm:hover { color: #f0f6fc; border-color: #8b949e; }

/* AUTH GATE */
#auth-gate { position: fixed; inset: 0; z-index: 9999; background: #0d1117; display: flex; align-items: center; justify-content: center; }
#auth-gate.hidden { display: none; }
.auth-box { background: #161b22; border: 1px solid #30363d; border-radius: 12px; padding: 40px; width: 400px; text-align: center; }
.auth-box h2 { font-size: 20px; color: #f0f6fc; margin-bottom: 6px; }
.auth-box p  { font-size: 13px; color: #6e7681; margin-bottom: 28px; }
.auth-error { font-size: 12px; color: #f85149; margin-top: 14px; display: none; }

/* ERROR */
.error-banner { background: #3d0d0d; border-bottom: 1px solid #f85149; padding: 10px 24px; font-size: 13px; color: #f85149; display: none; }

/* LAYOUT */
.layout { display: flex; }

/* SIDEBAR */
.sidebar { width: 300px; flex-shrink: 0; background: #161b22; border-right: 1px solid #30363d; position: sticky; top: 55px; height: calc(100vh - 55px); display: flex; flex-direction: column; z-index: 8; }
.sidebar-header { padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #21262d; }
.sidebar-title { font-size: 11px; font-weight: 600; color: #8b949e; text-transform: uppercase; letter-spacing: 0.5px; }
.sidebar-list { flex: 1; overflow-y: auto; padding: 6px 0; }
.sidebar-footer { padding: 10px 16px; border-top: 1px solid #21262d; font-size: 11px; color: #6e7681; }
.sidebar-backdrop { display: none; }

/* Runner cards (sidebar) */
.runner-group-label { padding: 8px 12px 4px; font-size: 10px; font-weight: 600; color: #6e7681; text-transform: uppercase; letter-spacing: 0.5px; }
.runner-group-label:first-child { padding-top: 4px; }
.runner-card { background: #0d1117; border: 1px solid #21262d; border-left: 3px solid #30363d; border-radius: 6px; margin: 4px 10px; padding: 10px 12px; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.runner-card:hover { background: #1c2128; }
.runner-card.online  { border-left-color: #3fb950; }
.runner-card.stale   { border-left-color: #d29922; }
.runner-card.offline { border-left-color: #f85149; }
.runner-card.active  { background: #1c2128; border-color: #58a6ff; border-left-color: #58a6ff; }
.rc-header { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 4px; }
.rc-name { font-size: 12px; font-weight: 600; color: #f0f6fc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.platform-icon { width: 14px; height: 14px; flex-shrink: 0; color: #8b949e; }
.platform-icon-fallback { font-size: 12px; color: #6e7681; }
.rc-id { font-size: 10px; color: #6e7681; flex-shrink: 0; }
.rc-meta { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.rc-meta:empty { display: none; }

/* Mini jobs (shared) */
.mini-jobs { display: flex; gap: 3px; flex-wrap: wrap; }
.mj { width: 12px; height: 12px; border-radius: 2px; }
.mj.success  { background: #3fb950; }
.mj.failed   { background: #f85149; }
.mj.running  { background: #58a6ff; animation: blink 1.2s infinite; }
.mj.pending, .mj.created  { background: #484f58; }
.mj.canceled { background: #30363d; }

/* Badge (shared) */
.badge { font-size: 10px; padding: 2px 6px; border-radius: 10px; font-weight: 500; }
.badge.arch    { background: #0d1b2a; color: #58a6ff; }
.badge.ver     { background: #1e1040; color: #bc8cff; }
.badge.tag     { background: #0d1f1a; color: #39d353; }

/* MAIN */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: calc(100vh - 55px); overflow: hidden; }

/* STATS */
.stats { display: flex; gap: 10px; padding: 16px 24px; flex-wrap: wrap; }
.stat { background: #161b22; border: 1px solid #30363d; border-radius: 8px; padding: 10px 16px; cursor: pointer; transition: border-color 0.15s, background 0.15s; flex: 1; min-width: 100px; }
.stat:hover { background: #1c2128; border-color: #58a6ff; }
.stat.stat-active { background: #1c2128; border-color: #58a6ff; box-shadow: 0 0 0 1px #58a6ff; }
.stat .num   { font-size: 22px; font-weight: 700; }
.stat .label { font-size: 11px; color: #8b949e; margin-top: 2px; }
.stat.online .num  { color: #3fb950; }
.stat.stale .num   { color: #d29922; }
.stat.offline .num { color: #f85149; }
.stat.total .num   { color: #58a6ff; }
.stat.jobs .num    { color: #bc8cff; }
.stat.failed .num  { color: #f85149; }

/* SECTION */
.section { padding: 16px 24px; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-title { font-size: 12px; font-weight: 600; color: #8b949e; text-transform: uppercase; letter-spacing: 0.5px; }
.section-count { font-size: 12px; color: #8b949e; background: #21262d; padding: 2px 8px; border-radius: 10px; }

/* JOBS */
.filter-row { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.search-input { flex: 1; min-width: 160px; padding: 8px 12px; background: #0d1117; border: 1px solid #30363d; border-radius: 6px; color: #c9d1d9; font-size: 13px; }
.search-input:focus { outline: none; border-color: #fc6d26; }
.filter-select { padding: 8px 12px; background: #0d1117; border: 1px solid #30363d; border-radius: 6px; color: #c9d1d9; font-size: 13px; min-width: 155px; cursor: pointer; }
.filter-select:focus { outline: none; border-color: #fc6d26; }
.btn-clear { padding: 8px 12px; background: transparent; border: 1px solid #30363d; border-radius: 6px; color: #8b949e; font-size: 12px; cursor: pointer; }
.btn-clear:hover { border-color: #f85149; color: #f85149; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tab { padding: 5px 12px; border-radius: 6px; font-size: 12px; cursor: pointer; border: 1px solid #30363d; background: transparent; color: #8b949e; transition: all 0.15s; }
.tab.active { background: #1f6feb; border-color: #1f6feb; color: #fff; }
.tab:hover:not(.active) { border-color: #58a6ff; color: #58a6ff; }

/* TABLE */
.table-wrap { flex: 1; min-height: 0; overflow: auto; border: 1px solid #21262d; border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 10px 12px; color: #8b949e; font-weight: 500; border-bottom: 1px solid #21262d; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; background: #161b22; position: sticky; top: 0; z-index: 1; white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid #161b22; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #161b22; }
.sbadge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 3px 8px; border-radius: 10px; font-weight: 600; white-space: nowrap; }
.sbadge.success  { background: #0f2d14; color: #3fb950; }
.sbadge.failed   { background: #2d0d0d; color: #f85149; }
.sbadge.running  { background: #0d1b2a; color: #58a6ff; }
.sbadge.pending, .sbadge.created { background: #1c2128; color: #8b949e; }
.sbadge.canceled { background: #21262d; color: #6e7681; }
.job-link { color: #58a6ff; text-decoration: none; font-weight: 600; }
.job-link:hover { text-decoration: underline; }
.user-cell { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.user-avatar { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.mono { font-family: monospace; font-size: 11px; background: #21262d; padding: 2px 6px; border-radius: 4px; color: #d29922; }
.muted { color: #8b949e; font-size: 12px; }
.trunc { max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.no-data { text-align: center; padding: 48px; color: #6e7681; }
.footer { text-align: center; padding: 20px; font-size: 11px; color: #484f58; border-top: 1px solid #21262d; margin-top: 8px; }

/* LOG PANEL */
.log-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 50; opacity: 0; pointer-events: none; transition: opacity 0.25s ease; }
.log-backdrop.open { opacity: 1; pointer-events: auto; }
.log-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 85vw); background: #0d1117; border-left: 1px solid #30363d; z-index: 51; transform: translateX(100%); transition: transform 0.25s ease; display: flex; flex-direction: column; }
.log-panel.open { transform: translateX(0); }
.log-panel-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid #21262d; background: #161b22; gap: 12px; }
.log-job-title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: #f0f6fc; flex-wrap: wrap; }
.log-gitlab-link { font-size: 12px; color: #58a6ff; text-decoration: none; margin-top: 6px; display: inline-block; }
.log-gitlab-link:hover { text-decoration: underline; }
.log-header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.log-copy-btn { background: #21262d; border: 1px solid #30363d; color: #c9d1d9; font-size: 12px; padding: 4px 12px; border-radius: 6px; cursor: pointer; white-space: nowrap; transition: background 0.15s, border-color 0.15s; }
.log-copy-btn:hover { background: #30363d; border-color: #8b949e; }
.log-copy-btn.copied { background: #238636; border-color: #2ea043; color: #fff; }
.log-close { background: none; border: none; color: #8b949e; font-size: 24px; cursor: pointer; padding: 0 4px; line-height: 1; flex-shrink: 0; }
.log-close:hover { color: #f0f6fc; }
#log-job-info { padding: 14px 20px; border-bottom: 1px solid #21262d; }
.log-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; font-size: 13px; }
.log-info-grid .log-info-full { grid-column: 1 / -1; }
.log-info-label { display: block; font-size: 11px; color: #6e7681; text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 2px; }
.log-content { flex: 1; overflow: auto; margin: 0; padding: 16px 20px; font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace; font-size: 12px; line-height: 1.6; color: #c9d1d9; background: #010409; white-space: pre-wrap; word-break: break-all; }

/* RESPONSIVE — hide columns progressively (sidebar=300px, so main≈viewport-300) */
/* col indices: 1=Job 2=Project 3=User 4=Ref 5=Status 6=Duration 7=Runner 8=Started */
@media (max-width: 1500px) {
  td:nth-child(8), th:nth-child(8) { display: none; } /* hide Started */
}
@media (max-width: 1300px) {
  td:nth-child(6), th:nth-child(6) { display: none; } /* hide Duration */
  td:nth-child(7), th:nth-child(7) { display: none; } /* hide Runner */
}
@media (max-width: 768px) {
  .sidebar-toggle { display: block; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; transform: translateX(-100%); transition: transform 0.25s ease; z-index: 40; height: 100vh; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 39; opacity: 0; pointer-events: none; transition: opacity 0.25s ease; }
  .sidebar-backdrop.open { display: block; opacity: 1; pointer-events: auto; }
  .stats { padding: 12px 16px; gap: 8px; }
  .stat { min-width: 80px; padding: 8px 12px; }
  .stat .num { font-size: 18px; }
  .section { padding: 12px 16px; }
  .header { padding: 14px 16px; }
  td:nth-child(3), th:nth-child(3) { display: none; } /* hide User */
  td:nth-child(4), th:nth-child(4) { display: none; } /* hide Ref */
}
