:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel2: #1e2530;
  --border: #262d38;
  --text: #e6edf3;
  --dim: #8b98a9;
  --orange: #f6821f;
  --blue: #4c8dff;
  --green: #2f9e6a;
  --red: #e5484d;
  --yellow: #d29922;
}

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }

body {
  width: 400px;
  max-height: 580px;
  overflow-y: auto;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; gap: 7px; align-items: center; font-weight: 600; flex: 1; min-width: 0; }
.brand img { border-radius: 4px; flex: none; }
#account-name { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { display: flex; gap: 4px; align-items: center; flex: none; }

/* square icon buttons — header + detail bar */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  color: var(--dim);
}
.icon-btn:hover { color: var(--text); background: var(--panel2); }
.icon-btn svg { width: 17px; height: 17px; display: block; }

button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 4px 9px;
  cursor: pointer;
  font-size: 13px;
}
button:hover { background: var(--panel2); }
button.primary { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--red); }

/* reload = restart the whole extension (dev action); bordered + orange so it reads apart from the gray data-refresh */
#btn-reload { color: var(--orange); border-color: rgba(246, 130, 31, 0.45); }
#btn-reload:hover { color: var(--orange); background: rgba(246, 130, 31, 0.14); }

#poll-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--dim); opacity: 0.5;
}
#poll-dot.busy { background: var(--orange); opacity: 1; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

@keyframes spin { to { transform: rotate(360deg); } }
.ref-ico { transform-origin: center; }
.ref-ico.spin { animation: spin 0.8s linear infinite; color: var(--orange); }

.mini-refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--dim);
  border-radius: 7px;
  cursor: pointer;
  flex: none;
  transform-origin: center;
}
.mini-refresh svg { width: 15px; height: 15px; display: block; }
.mini-refresh:hover { color: var(--text); background: var(--panel2); }
.mini-refresh.spin { color: var(--orange); animation: spin 0.8s linear infinite; }

/* ---------- list view ---------- */

.toolbar { display: flex; gap: 8px; padding: 10px 12px 6px; align-items: center; }
#search {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  padding: 5px 9px;
  outline: none;
}
#search:focus { border-color: var(--orange); }

.seg { display: flex; background: var(--panel); border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 4px 8px; font-size: 12px; color: var(--dim); background: transparent; }
.seg button.on { background: var(--panel2); color: var(--text); font-weight: 600; }

.list { padding: 4px 8px 10px; }

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 9px;
  border-radius: 9px;
  cursor: pointer;
}
.row:hover { background: var(--panel); }
.row-main { flex: 1; min-width: 0; }
.row-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--dim); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.star-mini { color: var(--yellow); font-size: 11px; }
.main-mini { color: var(--orange); font-size: 10px; font-weight: 700; letter-spacing: 0.3px; }

.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot-building { background: var(--orange); animation: pulse 1.1s infinite; }
.dot-success { background: var(--green); }
.dot-failed { background: var(--red); }
.dot-canceled, .dot-skipped, .dot-unknown, .dot-none { background: var(--dim); }
.dot-neutral { background: var(--blue); }

.chip {
  flex: none;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  color: var(--dim);
}
.chip-pages { color: var(--orange); border-color: rgba(246, 130, 31, 0.4); }
.chip-worker { color: var(--blue); border-color: rgba(76, 141, 255, 0.4); }

.empty { color: var(--dim); text-align: center; padding: 22px 0; }

/* ---------- detail view ---------- */

.detail-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 4px;
}
.detail-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
#detail-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#btn-watch.on { color: var(--yellow); border-color: rgba(210, 153, 34, 0.5); }
#btn-watch.on .star-ico { fill: var(--yellow); }
#btn-main { font-size: 12px; font-weight: 600; padding: 2px 9px; }
#btn-main.on { color: var(--orange); border-color: rgba(246, 130, 31, 0.5); background: rgba(246, 130, 31, 0.12); }
.dash-link { text-decoration: none; }

.detail-links { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 12px 2px; }
.link-chip {
  color: var(--blue);
  text-decoration: none;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link-chip:hover { border-color: var(--blue); }

/* deployment cards */

.dep {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  margin: 7px 4px;
}
.dep-top { display: flex; align-items: center; gap: 8px; }
.dep-time { margin-left: auto; color: var(--dim); font-size: 11px; white-space: nowrap; }

.state { font-size: 12px; font-weight: 700; }
.state-building { color: var(--orange); }
.state-success { color: var(--green); }
.state-failed { color: var(--red); }
.state-canceled, .state-skipped, .state-unknown, .state-neutral { color: var(--dim); }

.env-production { color: var(--blue); border-color: rgba(76, 141, 255, 0.4); }
.env-preview { color: var(--dim); }

.dep-msg {
  margin-top: 5px;
  font-size: 12.5px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.dep-meta {
  margin-top: 5px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  color: var(--dim);
  font-size: 11.5px;
  align-items: center;
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.row-sub .hash { color: var(--text); text-transform: uppercase; letter-spacing: 0.3px; }
.dep-link { color: var(--blue); text-decoration: none; }
.dep-link:hover { text-decoration: underline; }

.stages { display: flex; gap: 4px; margin-top: 8px; }
.stage { flex: 1; height: 4px; border-radius: 2px; background: var(--panel2); }
.st-done { background: var(--green); }
.st-active { background: var(--orange); animation: pulse 1.1s infinite; }
.st-fail { background: var(--red); }

/* ---------- settings ---------- */

#view-settings { padding: 12px 14px 16px; }
#view-settings h2 { font-size: 14px; margin-bottom: 10px; }
.field { display: block; margin-bottom: 10px; }
.field span { display: block; color: var(--dim); font-size: 12px; margin-bottom: 4px; }
.field em { font-style: normal; opacity: 0.75; }
.field input, .field select {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  padding: 6px 9px;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--orange); }
.check { display: flex; gap: 8px; align-items: center; margin: 8px 0; color: var(--text); }
.btn-row { display: flex; gap: 8px; margin-top: 12px; }
.status { margin-top: 10px; color: var(--yellow); min-height: 18px; }
.hint { margin-top: 10px; color: var(--dim); font-size: 11.5px; line-height: 1.5; }

/* toast */
#toast {
  position: fixed;
  left: 12px; right: 12px; bottom: 12px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 20;
}
#toast.show { opacity: 1; }
