:root {
  --ink: #1B2350; --ink-2: #3A4570; --line: #D5DAE3; --paper: #F3F5F8; --card: #FFFFFF;
  --heat: #D9480F; --heat-soft: #FCE6DA; --ok: #0F7B6C; --ok-soft: #DDF1EE; --warn: #B7791F; --warn-soft: #FBF0D9;
  --bad: #B42318; --bad-soft: #FDE7E5; --text: #1A1F33; --muted: #5E6779; --focus: #2F6FEB; --on-ink: #FFFFFF;
  --sans: "IBM Plex Sans", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --cond: "IBM Plex Sans Condensed", "Arial Narrow", "Segoe UI", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #C9D2F5; --ink-2: #9FAAD6; --line: #2C3348; --paper: #11141E; --card: #191D2A;
    --heat: #FF7A3D; --heat-soft: #3A2116; --ok: #3CC4AE; --ok-soft: #123029; --warn: #E8B04B; --warn-soft: #33280F;
    --bad: #F97066; --bad-soft: #3B1714; --text: #E6E9F2; --muted: #9AA3B5; --on-ink: #11141E;
    color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--text); font: 15px/1.5 var(--sans); min-height: 100vh; }
h1, h2, h3 { font-family: var(--cond); color: var(--ink); margin: 0; font-weight: 600; }
h1 { font-size: 26px; line-height: 1.15; }
h2 { font-size: 19px; }
a { color: var(--ink-2); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.pad { padding: 24px; }

/* ---------- top bar */
.topbar { display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--cond); font-size: 17px; color: var(--ink); white-space: nowrap; }
.brand-mark { width: 10px; height: 22px; background: var(--heat); border-radius: 2px; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { text-decoration: none; padding: 8px 12px; border-radius: 6px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--paper); color: var(--ink); }
.nav a.active { color: var(--ink); background: var(--paper); box-shadow: inset 0 -2px 0 var(--heat); }
.who { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; white-space: nowrap; }
.link-btn { background: none; border: 0; padding: 4px; color: var(--ink-2); text-decoration: underline; cursor: pointer; }

/* ---------- layout */
.view { max-width: 1120px; margin: 0 auto; padding: 28px 24px 120px; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; color: var(--muted); max-width: 640px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.banner { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; background: var(--warn-soft); color: var(--text); border: 1px solid var(--line); }
.banner.error { background: var(--bad-soft); }
.banner a { font-weight: 600; }

/* ---------- buttons */
.btn { border: 1px solid transparent; border-radius: 8px; padding: 9px 16px; font-weight: 600; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px; line-height: 1.2; }
.btn.primary { background: var(--heat); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: var(--paper); }
.btn.small { padding: 6px 12px; font-size: 14px; }

/* ---------- tabs and chips */
.tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; padding: 3px; background: var(--card); margin-bottom: 18px; }
.tabs button { border: 0; background: none; padding: 7px 14px; border-radius: 6px; cursor: pointer; color: var(--muted); font-weight: 500; }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--on-ink); }
.filters { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.chips { display: flex; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 12px; cursor: pointer; font-size: 14px; color: var(--muted); }
.chip[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); background: var(--paper); font-weight: 600; }
.search { flex: 1; min-width: 200px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.count { color: var(--muted); font-size: 14px; }

/* ---------- competitor list */
.list { max-height: calc(100vh - 330px); min-height: 240px; overflow: auto; }
.row { display: grid; grid-template-columns: 28px minmax(0, 1fr) 110px 150px; gap: 12px; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:hover { background: var(--paper); }
.row input { width: 18px; height: 18px; accent-color: var(--heat); cursor: pointer; }
.row .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { color: var(--muted); font-size: 13px; }
.row .when { color: var(--muted); font-size: 13px; text-align: right; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 4px; background: var(--paper);
  color: var(--ink-2); border: 1px solid var(--line); margin-right: 4px; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }

.actionbar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line);
  padding: 12px 24px; z-index: 4; }
.actionbar-inner { max-width: 1072px; margin: 0 auto; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.actionbar .summary { flex: 1; min-width: 200px; }
.actionbar .summary strong { color: var(--ink); }

/* ---------- sites */
.sites { display: grid; gap: 10px; padding: 16px; }
.site { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.site:has(input:checked) { border-color: var(--heat); background: var(--heat-soft); }
.site input { accent-color: var(--heat); }

/* ---------- history */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--paper); }
.table .what { max-width: 420px; }
.nowrap { white-space: nowrap; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.running, .badge.launching { background: var(--heat-soft); color: var(--heat); }
.badge.running::before, .badge.launching::before { animation: pulse 1.4s ease-in-out infinite; }
.badge.success { background: var(--ok-soft); color: var(--ok); }
.badge.error, .badge.launch_failed { background: var(--bad-soft); color: var(--bad); }
.badge.unknown { background: var(--warn-soft); color: var(--warn); }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .badge::before { animation: none !important; } }

/* ---------- run page */
.back { display: inline-block; margin-bottom: 14px; text-decoration: none; color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; gap: 8px 28px; padding: 16px 20px; }
.meta div { min-width: 120px; }
.meta dt { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.meta dd { margin: 2px 0 0; font-weight: 500; }
.section { margin-top: 18px; padding: 20px; }
.progress { height: 10px; background: var(--paper); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); margin: 12px 0 8px; }
.progress span { display: block; height: 100%; width: 0; background: var(--heat); transition: width .6s ease; }
.files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.viewer { margin-top: 18px; overflow: hidden; }
.viewer-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); gap: 12px; flex-wrap: wrap; }
.viewer iframe { width: 100%; height: 78vh; border: 0; display: block; background: #fff; }
.companies-line { color: var(--muted); font-size: 14px; margin-top: 6px; }

/* ---------- login */
.login { max-width: 380px; margin: 10vh auto 0; padding: 28px; }
.login h1 { margin-bottom: 4px; }
.login p { margin: 0 0 20px; color: var(--muted); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 14px; font-weight: 500; }
.field input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.form-error { color: var(--bad); min-height: 22px; font-size: 14px; margin: 0 0 8px; }

/* ---------- dialog and toast */
.dialog { border: 1px solid var(--line); border-radius: 12px; padding: 24px; max-width: 460px; width: calc(100% - 32px); background: var(--card); color: var(--text); }
.dialog::backdrop { background: rgba(10, 14, 30, .45); }
.dialog h2 { margin-bottom: 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.toast { position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--on-ink);
  padding: 10px 18px; border-radius: 8px; z-index: 10; max-width: calc(100% - 32px); }

/* ---------- small screens */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 8px 16px; }
  .brand-text { font-size: 15px; }
  .nav { order: 3; flex-basis: 100%; }
  .who #who-name { display: none; }
  .view { padding: 20px 16px 140px; }
  .row { grid-template-columns: 28px minmax(0, 1fr); }
  .row .mats, .row .when { grid-column: 2; text-align: left; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  .table td { border: 0; padding: 4px 14px; }
  .actionbar { padding: 12px 16px; }
  .viewer iframe { height: 70vh; }
}
