/* SharkScope Build Service — CSS */
:root {
  --ss-primary: #005a8d;
  --ss-primary-dark: #00446b;
  --ss-accent: #e31e24;
  --ss-bg: #f4f8fc;
  --ss-card-bg: #ffffff;
  --ss-border: #d8e0e8;
  --ss-text: #1b2430;
  --ss-text-muted: #586574;
  --ss-success: #16a34a;
  --ss-warning: #d97706;
  --ss-danger: #dc2626;
  --ss-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --ss-mono: "SF Mono", "Fira Code", "Consolas", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--ss-font); background: var(--ss-bg); color: var(--ss-text); }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 24px;
  background: var(--ss-primary); color: #fff;
  padding: 0 24px; height: 52px;
}
.topbar__brand { display: flex; align-items: center; gap: 10px; }
.topbar__brand img { filter: brightness(0) invert(1); }
.topbar__title { font-weight: 700; font-size: 16px; }
.topbar__links { display: flex; gap: 16px; margin-left: 24px; }
.topbar__link { color: rgba(255,255,255,0.85); text-decoration: none; font-size: 14px; font-weight: 500; }
.topbar__link:hover { color: #fff; }
.topbar__user { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.topbar__link--logout { color: rgba(255,255,255,0.6); }

/* Display time-zone selector */
.tz-wrap { display: inline-flex; align-items: center; gap: 6px; color: rgba(255,255,255,0.85); font-size: 13px; }
.tz-wrap select {
  background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.35); color: #fff;
  border-radius: 4px; padding: 3px 6px; font-size: 13px; cursor: pointer; max-width: 11rem;
}
.tz-wrap select:focus { outline: none; border-color: rgba(255,255,255,0.7); }
.tz-wrap select option { color: var(--ss-text); }
.tz-wrap .tz-label { font-variant-numeric: tabular-nums; opacity: 0.9; min-width: 2.5rem; }
time.tz { white-space: nowrap; }

/* Content */
.content { max-width: 1200px; margin: 24px auto; padding: 0 24px; }
h1 { font-size: 24px; margin-bottom: 8px; color: var(--ss-primary-dark); }
h2 { font-size: 16px; margin-bottom: 12px; color: var(--ss-primary); }
.subtitle { color: var(--ss-text-muted); margin-bottom: 4px; }
.meta { color: var(--ss-text-muted); font-size: 13px; margin-bottom: 16px; }
.empty { color: var(--ss-text-muted); font-style: italic; padding: 16px 0; }

/* Cards */
.card {
  background: var(--ss-card-bg); border: 1px solid var(--ss-border);
  border-radius: 12px; padding: 20px; margin-bottom: 16px;
}
/* Jobs left on retired legacy serverful dispatch: read-only, no trigger. */
.card--retired { border-left: 4px solid var(--ss-warning); }
.card--retired h2 { color: var(--ss-warning); }
.card--retired p { color: var(--ss-text-muted); font-size: 14px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn--primary { background: var(--ss-primary); color: #fff; border-color: var(--ss-primary); }
.btn--primary:hover { background: var(--ss-primary-dark); }
.btn--secondary { background: #edf2f7; color: var(--ss-text); border-color: var(--ss-border); }
.btn--danger { background: var(--ss-danger); color: #fff; }
.btn--ghost { background: transparent; color: var(--ss-primary); border: none; padding: 4px 8px; }
.btn--sm { padding: 4px 10px; font-size: 13px; }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; color: var(--ss-text-muted); border-bottom: 2px solid var(--ss-border); padding: 8px 12px; }
.table td { padding: 8px 12px; border-bottom: 1px solid #edf2f7; }
.table a { color: var(--ss-primary); text-decoration: none; }
.table a:hover { text-decoration: underline; }
.table--compact td, .table--compact th { padding: 6px 8px; }
code { font-family: var(--ss-mono); font-size: 13px; background: #f0f4f8; padding: 2px 6px; border-radius: 4px; }

/* Status badges */
.status { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; font-weight: 700; text-transform: uppercase; }
.status--queued { background: #dbeafe; color: #1d4ed8; }
.status--running { background: #fef3c7; color: #92400e; }
.status--success { background: #dcfce7; color: #166534; }
.status--failed { background: #fee2e2; color: #991b1b; }
.status--cancelled { background: #f3f4f6; color: #6b7280; }
.status--timeout { background: #fce7f3; color: #9d174d; }
.status--warning { background: #fef3c7; color: #92400e; }
.status--neutral { background: #f3f4f6; color: #6b7280; }
/* Admin-driven promote/rollback from the Deployments UI — the audit-worthy
   action, set apart from automatic job-driven promotes. */
.status--manual { background: #ede9fe; color: #5b21b6; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 8px; font-size: 11px; font-weight: 700; }
.badge--finally { background: #fef3c7; color: #92400e; }

/* Job cards */
.job-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.job-card { display: flex; flex-direction: column; border: 1px solid var(--ss-border); border-radius: 10px; transition: box-shadow 0.15s; overflow: hidden; }
.job-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.06); }
.job-card__link { display: block; text-decoration: none; color: inherit; padding: 16px; flex: 1; }
.job-card__name { font-weight: 700; font-size: 16px; color: var(--ss-primary-dark); }
.job-card__desc { color: var(--ss-text-muted); font-size: 14px; margin-top: 4px; }
.job-card__meta { display: flex; gap: 16px; margin-top: 10px; font-size: 13px; color: var(--ss-text-muted); }
.job-card__status--disabled { color: var(--ss-danger); }
.job-card--disabled .job-card__link { opacity: 0.55; }
.job-card__actions { padding: 8px 16px 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px solid var(--ss-border); background: #f8fafc; }

/* Repo categorisation — jobs and runs are grouped and tinted by the repo they
   build (website, pokercopilot, ...). A repo declares its colour by setting
   --repo-accent here; everything downstream reads the variable, and an
   unmapped repo simply keeps the neutral fallback in each var() below. So a
   job pointed at a new repo categorises itself with no CSS change. */
.repo--website      { --repo-accent: #005a8d; }
.repo--pokercopilot { --repo-accent: #7c3aed; }

.repo-group { margin-bottom: 28px; }
.repo-group__header {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-bottom: 8px; margin-bottom: 12px;
  border-bottom: 2px solid var(--repo-accent, var(--ss-border));
}
.repo-group__dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: var(--repo-accent, var(--ss-text-muted)); }
.repo-group__title { margin: 0; font-size: 17px; color: var(--repo-accent, var(--ss-primary)); }
.repo-group__slug { font-size: 12px; color: var(--ss-text-muted); }
.repo-group__count { margin-left: auto; font-size: 13px; color: var(--ss-text-muted); }
/* Cards inherit --repo-accent from their group section. */
.job-card { border-left: 3px solid var(--repo-accent, var(--ss-border)); }

.repo-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  color: var(--repo-accent, var(--ss-text-muted));
  background: color-mix(in srgb, var(--repo-accent, #94a3b8) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--repo-accent, #94a3b8) 35%, transparent);
}
.repo-tag__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* Repo column in a table: colour gutter down the left edge, one tone per repo.
   Set on the repo cell itself, not the row, so a rowspan'd cell keeps the
   stripe at the table edge instead of drawing one mid-table. */
.repo-cell { border-left: 3px solid var(--repo-accent, var(--ss-border)); }

/* Toggle switch (used for job enable/disable) */
.toggle-switch { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-switch__slider { position: absolute; cursor: pointer; inset: 0; background: #cbd5e0; border-radius: 22px; transition: background 0.15s; }
.toggle-switch__slider::before { content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform 0.15s; }
.toggle-switch input:checked + .toggle-switch__slider { background: var(--ss-primary); }
.toggle-switch input:checked + .toggle-switch__slider::before { transform: translateX(16px); }
.toggle-switch input:disabled + .toggle-switch__slider { opacity: 0.6; cursor: wait; }

.job-detail__enable { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.job-detail__enable-label { font-weight: 600; font-size: 14px; }

/* Trigger form */
.trigger-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.trigger-field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 600; }
.trigger-field input { border: 1px solid var(--ss-border); border-radius: 8px; padding: 8px 12px; font: inherit; width: 260px; }
.trigger-status { font-size: 13px; color: var(--ss-text-muted); }

/* Env vars */
/* Schedule editor — same visual language as the env-var row above it. */
.schedule-edit { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.schedule-edit label { font-size: 13px; color: var(--ss-muted, #6b7280); }
.schedule-edit input[type="text"] { border: 1px solid var(--ss-border); border-radius: 6px; padding: 6px 10px; font: inherit; font-size: 13px; }
.schedule-edit #schedule-cron { font-family: ui-monospace, Menlo, Consolas, monospace; min-width: 140px; }
.schedule-enabled-label { display: inline-flex; align-items: center; gap: 4px; }
.schedule-help code { font-size: 12px; }
.schedule-status--error { color: var(--ss-danger, #b3261e); font-weight: 600; }

.env-add { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.env-add input { border: 1px solid var(--ss-border); border-radius: 6px; padding: 6px 10px; font: inherit; font-size: 13px; }
.env-val { border: 1px solid var(--ss-border); border-radius: 6px; padding: 4px 8px; font: inherit; font-size: 13px; width: 100%; }
#env-save-btn { margin-top: 8px; }

/* Runnables */
.runnable-item { border: 1px solid var(--ss-border); border-radius: 8px; padding: 12px; margin-bottom: 8px; }
.runnable-item__header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.runnable-item__order { background: var(--ss-primary); color: #fff; border-radius: 50%; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.runnable-item__name { font-weight: 700; font-size: 14px; }
.runnable-item__timeout { font-size: 12px; color: var(--ss-text-muted); }
.runnable-item__actions { margin-left: auto; display: flex; gap: 4px; }
.runnable-item__path { margin-top: 6px; font-size: 12px; }
.runnable-item__preview { margin-top: 8px; background: #1e293b; color: #e2e8f0; padding: 12px; border-radius: 8px; font-size: 13px; overflow-x: auto; max-height: 300px; }
.runnable-add { display: flex; gap: 8px; margin-top: 12px; align-items: center; flex-wrap: wrap; }
.runnable-add input[type="text"], .runnable-add input[type="number"] { border: 1px solid var(--ss-border); border-radius: 6px; padding: 6px 10px; font: inherit; font-size: 13px; }
.runnable-add input[type="text"] { width: 200px; }
.runnable-add input[type="number"] { width: 100px; }
.runnable-add label { font-size: 13px; display: flex; align-items: center; gap: 4px; }

/* Detail grid */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 24px; margin-bottom: 16px; }
.detail-item { display: flex; flex-direction: column; gap: 2px; }
.detail-item--full { grid-column: 1 / -1; }
.detail-label { font-size: 12px; font-weight: 600; color: var(--ss-text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.error-msg { background: #fee2e2; color: #991b1b; padding: 8px; border-radius: 6px; font-size: 13px; white-space: pre-wrap; }

/* Changes section */
.changes-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.changes-run { color: var(--ss-primary); text-decoration: none; font-weight: 600; }
.changes-run:hover { text-decoration: underline; }
.changes-arrow { color: var(--ss-text-muted); font-size: 16px; }
.changes-commits { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.changes-commits li { display: flex; align-items: baseline; gap: 8px; }
.changes-sha { color: var(--ss-text-muted); flex-shrink: 0; }

/* Build log */
.log-controls {
  display: flex; align-items: center; gap: 14px; margin-bottom: 8px;
  font-size: 13px; flex-wrap: wrap;
}
.log-live-indicator { color: var(--ss-accent); font-weight: 700; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.log-toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.log-hint { color: var(--ss-text-muted); font-size: 12px; display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.log-hint__text { white-space: nowrap; }
@media (max-width: 720px) { .log-hint__text { display: none; } }

/* Search bar */
.log-search {
  display: inline-flex; align-items: center; gap: 4px;
  background: #fff; border: 1px solid var(--ss-border); border-radius: 8px;
  padding: 2px 8px; min-width: 280px;
}
.log-search:focus-within { border-color: var(--ss-primary); box-shadow: 0 0 0 3px rgba(0,90,141,0.12); }
.log-search__icon { color: var(--ss-text-muted); font-size: 12px; }
.log-search__input {
  flex: 1; border: 0; outline: none; background: transparent;
  padding: 6px 4px; font: inherit; color: var(--ss-text); min-width: 0;
}
.log-search__count { color: var(--ss-text-muted); font-size: 12px; min-width: 4ch; text-align: right; }
.log-search__btn {
  background: transparent; border: 0; color: var(--ss-text-muted);
  cursor: pointer; padding: 4px 6px; border-radius: 4px; font-size: 12px;
}
.log-search__btn:hover:not(:disabled) { background: var(--ss-bg); color: var(--ss-primary); }
.log-search__btn:disabled { opacity: 0.4; cursor: default; }

/* Log viewport */
.log-output {
  background: #0f172a; color: #e2e8f0; padding: 12px 16px; border-radius: 8px;
  font-family: var(--ss-mono); font-size: 13px; line-height: 1.55;
  max-height: 600px; overflow: auto;
  scrollbar-color: #475569 #1e293b;
}
.log-output:focus { outline: 2px solid var(--ss-primary); outline-offset: 2px; }

.log-line {
  white-space: pre-wrap; word-break: break-word;
  padding: 0 4px; margin: 0 -4px; border-left: 3px solid transparent;
}
.log-line--header {
  color: #93c5fd; font-weight: 700; margin-top: 6px; padding-top: 2px;
  border-left-color: #60a5fa; background: rgba(96,165,250,0.06);
}
.log-line--success { color: #86efac; border-left-color: #22c55e; background: rgba(34,197,94,0.07); }
.log-line--failed  { color: #fca5a5; border-left-color: #ef4444; background: rgba(239,68,68,0.10); font-weight: 600; }
.log-line--error   { color: #fca5a5; border-left-color: #ef4444; }
.log-line--warn    { color: #fde047; border-left-color: #eab308; }
.log-line--meta    { color: #94a3b8; font-style: italic; }

/* ANSI SGR styles */
.ansi-bold { font-weight: 700; }
.ansi-dim  { opacity: 0.65; }
.ansi-fg-k { color: #475569; }  /* black (dim slate) */
.ansi-fg-r { color: #f87171; }
.ansi-fg-g { color: #4ade80; }
.ansi-fg-y { color: #facc15; }
.ansi-fg-b { color: #60a5fa; }
.ansi-fg-m { color: #c084fc; }
.ansi-fg-c { color: #22d3ee; }
.ansi-fg-w { color: #e2e8f0; }
.ansi-fg-K { color: #94a3b8; }  /* bright black (gray) */
.ansi-fg-R { color: #fca5a5; }
.ansi-fg-G { color: #86efac; }
.ansi-fg-Y { color: #fde047; }
.ansi-fg-B { color: #93c5fd; }
.ansi-fg-M { color: #d8b4fe; }
.ansi-fg-C { color: #67e8f9; }
.ansi-fg-W { color: #f8fafc; }

/* Search match highlighting */
.log-mark {
  background: #facc15; color: #0f172a; border-radius: 2px;
  padding: 0 1px; font-weight: 600;
}
.log-mark--current {
  background: #fb923c; box-shadow: 0 0 0 2px rgba(251,146,60,0.45);
}

/* Login page */
.login-body { background: linear-gradient(180deg, #f4f8fc 0%, #edf2f7 100%); display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-shell { width: 100%; max-width: 520px; padding: 16px; }
.login-card { background: #fff; border: 1px solid var(--ss-border); border-radius: 18px; box-shadow: 0 8px 24px rgba(15,59,99,0.06); padding: 28px; }
.login-card__brand { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.login-eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: #6c7a89; }
.login-title { font-size: 30px; font-weight: 700; color: var(--ss-primary-dark); margin-top: 2px; }
.login-subtitle { color: var(--ss-text-muted); margin-top: 10px; line-height: 1.5; }
.login-error { background: #fff2f4; border: 1px solid #f1c7ce; border-radius: 14px; color: #8f1d2c; padding: 12px 14px; font-size: 14px; margin-bottom: 16px; }
.login-form { display: grid; gap: 16px; margin-top: 18px; }
.login-field { display: grid; gap: 8px; font-size: 14px; font-weight: 600; color: #25313d; }
.login-field input { width: 100%; border: 1px solid #cfd8e3; border-radius: 10px; padding: 12px 14px; font: inherit; }
.login-field input:focus { outline: none; border-color: var(--ss-primary-dark); box-shadow: 0 0 0 3px rgba(15,59,99,0.12); }

/* Version-diff toolbar (Deployments page) */
.versions-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.versions-toolbar__hint { margin: 0; margin-right: auto; }
.version-select { width: 16px; height: 16px; cursor: pointer; }
.u-hidden { display: none !important; }

/* Live-version badges: mark the version currently pointed at by a tier. */
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; line-height: 1.5; margin-left: 6px; vertical-align: middle; }
.pill--prod { background: var(--ss-primary); color: #fff; }
.pill--alpha { background: #e9d8a6; color: #5c4a12; }
.pill--tasks { background: #5390d9; color: #fff; }
.hist-change { white-space: nowrap; }
.hist-arrow { color: var(--ss-text-muted); margin: 0 3px; }
/* Tier folded into the Change cell (the standalone Tier column was dropped to
   stop the History table overflowing). */
.hist-tier { display: inline-block; margin-right: 6px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--ss-text-muted); }
/* Notes can be long (esp. automatic "auto: deploy-to-all …"); cap the width and
   ellipsize — full text is on the cell's title tooltip. */
.hist-notes { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.version-select:disabled { cursor: not-allowed; opacity: 0.4; }

/* Change-list modal (deploy confirm + version diff) */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(16, 28, 40, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal {
  background: var(--ss-card-bg); border: 1px solid var(--ss-border);
  border-radius: 12px; width: 100%; max-width: 640px;
  max-height: 85vh; display: flex; flex-direction: column;
  box-shadow: 0 18px 48px rgba(16, 28, 40, 0.28);
}
.modal__header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--ss-border);
}
.modal__header h2 { margin: 0; flex: 1; }
.modal__x {
  background: transparent; border: none; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--ss-text-muted);
}
.modal__x:hover { color: var(--ss-text); }
.modal__body { padding: 18px 20px; overflow-y: auto; }
.modal__commits { max-height: 48vh; overflow-y: auto; }
.modal__footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--ss-border);
}
