:root {
  --bg: #f6f7f9; --card: #ffffff; --text: #1f2328; --muted: #6b7280; --line: #e5e7eb;
  --link: #1f5fbf; --primary: #2563eb; --danger: #b91c1c; --purple: #6d28d9;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 24px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 13px; }

.topbar { background: #1f2328; color: #fff; }
.topbar-inner { max-width: 1100px; margin: 0 auto; padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.topbar a { color: #fff; }
.brand { font-weight: 700; letter-spacing: .3px; }
.crumbs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; overflow-wrap: anywhere; }
.crumbs .sep { color: #9ca3af; }
.account { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.username { color: #d1d5db; }

.container { max-width: 1100px; margin: 0 auto; padding: 20px 16px 48px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.repo-card h2 { margin: 0 0 8px; font-size: 16px; }
.login-card { max-width: 380px; margin: 60px auto; }
.error-card { max-width: 640px; margin: 40px auto; }

.form-stack { display: flex; flex-direction: column; gap: 12px; }
.form-stack label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
input[type=text], input[type=password] { padding: 7px 9px; border: 1px solid #cbd5e1; border-radius: 6px; font: inherit; }
input[type=text].mono { font-family: var(--mono); }
.inline { display: inline; }
.inline-form { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.inline-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.inline-form input { font-family: var(--mono); min-width: 240px; }

.btn { display: inline-block; padding: 6px 12px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; color: var(--text); font: inherit; cursor: pointer; line-height: 1.3; }
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn-sm { padding: 2px 8px; font-size: 12px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { color: var(--danger); border-color: #fca5a5; }
.btn-danger:hover { background: #fef2f2; }
.btn-purple { color: var(--purple); border-color: #c4b5fd; }
.btn-purple:hover { background: #f5f3ff; }
.btn-ghost { background: transparent; border-color: #4b5563; color: #fff; }
.btn-ghost:hover { background: #374151; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 12px 0 0; }
.row-actions { white-space: nowrap; }
.row-actions form { margin-left: 4px; }
.link-ext { white-space: nowrap; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tab { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--text); border-bottom-color: var(--primary); font-weight: 600; }
.tab:hover { text-decoration: none; color: var(--text); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.filters { display: flex; gap: 6px; }
.chip { padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 13px; }
.chip.active { background: var(--text); color: #fff; border-color: var(--text); }
.chip:hover { text-decoration: none; }
.pager { display: flex; align-items: center; gap: 8px; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 8px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafafa; }
.table tr:last-child td { border-bottom: 0; }
.branches { white-space: nowrap; }
.arrow { color: var(--muted); }

.meta { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 8px 0 0; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.mr-header h1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.tag { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; vertical-align: middle; }
.tag-draft { background: #fef3c7; color: #92400e; }
.tag-state { background: #e5e7eb; color: #374151; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.4; white-space: nowrap; color: #fff; background: #9ca3af; }
a.badge:hover { text-decoration: none; filter: brightness(.92); }
.badge-success { background: #16a34a; }
.badge-failed { background: #dc2626; }
.badge-running { background: #2563eb; animation: pulse 1.6s ease-in-out infinite; }
.badge-pending, .badge-created, .badge-preparing, .badge-waiting-for-resource, .badge-scheduled { background: #9ca3af; }
.badge-manual { background: #7c3aed; }
.badge-canceled, .badge-canceling { background: #4b5563; }
.badge-skipped { background: #d1d5db; color: #374151; }
.badge-none, .badge-unknown, .badge-loading { background: #e5e7eb; color: #6b7280; font-weight: 500; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

.pipeline-block { padding: 12px 16px; }
.pipeline-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.jobs-status { margin-bottom: 8px; }
.polling { color: var(--primary); }
.notice { color: #92400e; }
.stage { display: grid; grid-template-columns: 140px 1fr; gap: 12px; padding: 6px 0; border-top: 1px dashed var(--line); }
.stage:first-of-type { border-top: 0; }
.stage-name { font-weight: 600; color: var(--muted); font-size: 13px; padding-top: 2px; overflow-wrap: anywhere; }
.stage-jobs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.job-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.job-name { font-family: var(--mono); font-size: 13px; }

.flash { padding: 10px 12px; border-radius: 6px; margin-bottom: 14px; border: 1px solid; }
.flash-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.flash-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.flash-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

.log-panel { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.log-status { margin-bottom: 8px; }
.log { background: #111827; color: #e5e7eb; font-family: var(--mono); font-size: 12px; line-height: 1.45; padding: 12px; margin: 0; border-radius: 6px; max-height: 70vh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.ansi-bold { font-weight: 700; }
.ansi-fg-black { color: #6b7280; } .ansi-fg-red { color: #f87171; } .ansi-fg-green { color: #4ade80; }
.ansi-fg-yellow { color: #facc15; } .ansi-fg-blue { color: #60a5fa; } .ansi-fg-magenta { color: #e879f9; }
.ansi-fg-cyan { color: #22d3ee; } .ansi-fg-white { color: #f9fafb; }
.ansi-fg-bright-black { color: #9ca3af; } .ansi-fg-bright-red { color: #fca5a5; } .ansi-fg-bright-green { color: #86efac; }
.ansi-fg-bright-yellow { color: #fde68a; } .ansi-fg-bright-blue { color: #93c5fd; } .ansi-fg-bright-magenta { color: #f0abfc; }
.ansi-fg-bright-cyan { color: #67e8f9; } .ansi-fg-bright-white { color: #ffffff; }
.ansi-bg-black { background: #000; } .ansi-bg-red { background: #7f1d1d; } .ansi-bg-green { background: #14532d; }
.ansi-bg-yellow { background: #713f12; } .ansi-bg-blue { background: #1e3a8a; } .ansi-bg-magenta { background: #701a75; }
.ansi-bg-cyan { background: #164e63; } .ansi-bg-white { background: #e5e7eb; color: #111827; }
.ansi-bg-bright-black { background: #374151; } .ansi-bg-bright-red { background: #991b1b; } .ansi-bg-bright-green { background: #166534; }
.ansi-bg-bright-yellow { background: #854d0e; } .ansi-bg-bright-blue { background: #1e40af; } .ansi-bg-bright-magenta { background: #86198f; }
.ansi-bg-bright-cyan { background: #155e75; } .ansi-bg-bright-white { background: #f3f4f6; color: #111827; }

@media (max-width: 640px) {
  .stage { grid-template-columns: 1fr; gap: 4px; }
  .meta { grid-template-columns: 1fr; gap: 2px; }
  .meta dt { margin-top: 6px; }
}
