/* Atlas Dashboard — dark, scannable, fast */
:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-head: #1c2330;
  --border: #2d333b;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #f0b429;      /* Atlas lightning gold */
  --green: #3fb950;
  --red: #f85149;
  --orange: #d29922;
  --blue: #58a6ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--blue); text-decoration: none; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.muted { color: var(--muted); font-size: 12px; }
.err { color: var(--red); }
.loading { color: var(--muted); font-style: italic; }
.wikilink { color: var(--accent); }

/* ---------- topbar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50; }
.brand { font-weight: 700; font-size: 16px; }
.brand span { color: var(--accent); }
.topbar-right { display: flex; gap: 10px; align-items: center; }
.topbar button { background: var(--panel-head); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 10px; cursor: pointer; font-size: 13px; }
.topbar button:hover { border-color: var(--accent); }
.topbar .user { color: var(--accent); }
.topbar .logout { color: var(--muted); }

main { padding: 12px; max-width: 1500px; margin: 0 auto; }

/* ---------- auth pages ---------- */
.auth-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.auth-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 28px; width: 340px; }
.auth-card .brand { font-size: 20px; margin-bottom: 18px; text-align: center; }
.auth-card label { display: block; margin: 12px 0 4px; color: var(--muted); font-size: 12px; }
.auth-card input { width: 100%; padding: 9px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); }
.auth-card button { width: 100%; margin-top: 18px; padding: 10px; border: none; border-radius: 6px;
  background: var(--accent); color: #1a1a1a; font-weight: 700; cursor: pointer; }
.auth-card .error { background: #3d1d20; border: 1px solid var(--red); color: var(--red);
  padding: 8px; border-radius: 6px; margin-top: 10px; font-size: 13px; }
.auth-card .note { color: var(--muted); font-size: 13px; }

/* ---------- widgets ---------- */
.grid-stack-item-content { overflow: visible !important; }
.widget { background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.widget.hero { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.widget-head { display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; background: var(--panel-head); border-bottom: 1px solid var(--border);
  cursor: grab; user-select: none; }
.widget-title { font-weight: 600; font-size: 13px; }
.widget-ctl { display: flex; gap: 4px; }
.widget-ctl .ctl { background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 13px; padding: 2px 6px; border-radius: 4px; }
.widget-ctl .ctl:hover { background: var(--border); color: var(--text); }
.widget-body { padding: 10px 12px; overflow-y: auto; flex: 1; }
.widget.minimized .widget-body { display: none; }
.widget.maximized { position: fixed; inset: 60px 5vw 3vh 5vw; z-index: 200;
  box-shadow: 0 10px 60px rgba(0,0,0,.7); }
body.has-max::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 150; }
.widget.maximized { z-index: 201; }

.needle { font-size: 16px; }
.needle p { margin: 4px 0; }
.stale-tag { color: var(--orange); font-size: 11px; }

/* pills */
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px;
  font-weight: 700; white-space: nowrap; }
.pill-active { background: #0f2e1c; color: var(--green); border: 1px solid var(--green); }
.pill-stalled, .pill-failed { background: #3d1d20; color: var(--red); border: 1px solid var(--red); }
.pill-done { background: #1c2330; color: var(--muted); border: 1px solid var(--border); }
.pill-cancelled { background: #1c2330; color: var(--muted); border: 1px solid var(--border); }
.pill-awaiting-approval { background: #3a2c10; color: var(--orange); border: 1px solid var(--orange); }
.pill-open { background: #14273d; color: var(--blue); border: 1px solid var(--blue); }
.pill-stale { background: #3a2c10; color: var(--orange); border: 1px solid var(--orange); }

/* build jobs */
.job-row { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px;
  cursor: pointer; }
.job-row:hover { background: var(--panel-head); }
.job-id { font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--accent);
  flex: 0 0 auto; }
.job-task { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.dismiss-btn { background: none; border: none; color: var(--muted); cursor: pointer;
  border-radius: 4px; padding: 1px 5px; }
.dismiss-btn:hover { background: var(--border); color: var(--red); }

/* team */
.team-sec { margin-bottom: 10px; }
.team-sec > b { display: block; font-size: 12px; margin-bottom: 3px; color: var(--accent); }
.mini-row { padding: 2px 0; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.timers { max-height: 190px; overflow-y: auto; }

/* falling behind */
.loop-row { display: flex; gap: 8px; padding: 6px 4px; border-bottom: 1px solid var(--border);
  font-size: 13px; align-items: flex-start; }
.loop-row:last-child { border-bottom: none; }

/* usage */
.usage-line { display: flex; align-items: baseline; gap: 8px; }
.usage-pct { font-size: 26px; font-weight: 700; color: var(--green); }
.gauge { height: 10px; background: var(--panel-head); border-radius: 5px; margin: 6px 0;
  border: 1px solid var(--border); }
.gauge-fill { height: 100%; border-radius: 5px; background: var(--green); }
.gauge-fill.warm { background: var(--orange); }
.gauge-fill.hot { background: var(--red); }

/* MC */
.mc-tallies { display: flex; gap: 14px; margin-bottom: 6px; }
.tally { text-align: center; background: var(--panel-head); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 14px; font-size: 11px; color: var(--muted); }
.tally-n { font-size: 22px; font-weight: 700; color: var(--text); }
.tally.hot .tally-n { color: var(--red); }
.tally.warm .tally-n { color: var(--orange); }
.tally.attn .tally-n { color: var(--blue); }
.mc-link { font-size: 13px; }

/* modal */
#modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 300;
  display: flex; align-items: center; justify-content: center; }
#modal-backdrop.hidden { display: none; }
#modal { background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  width: min(720px, 92vw); max-height: 84vh; display: flex; flex-direction: column; }
#modal-head { display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 700; }
#modal-head button { background: none; border: none; color: var(--muted); font-size: 15px; cursor: pointer; }
#modal-body { padding: 14px; overflow-y: auto; }
.detail-status { margin-bottom: 8px; }
.detail-task { background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; margin-bottom: 10px; max-height: 180px; overflow-y: auto; font-size: 13px; }
.detail-why { background: #3a2c10; border: 1px solid var(--orange); border-radius: 8px;
  padding: 8px 10px; margin-bottom: 10px; font-size: 13px; }
.detail-rp { margin-bottom: 8px; font-size: 13px; }
.detail-tl b { display: block; margin-bottom: 4px; font-size: 12px; color: var(--accent); }
.detail-last { margin-top: 10px; }
.detail-last pre { white-space: pre-wrap; font-size: 11.5px; background: var(--bg);
  padding: 8px; border-radius: 6px; max-height: 260px; overflow-y: auto; }
.add-choice { display: block; width: 100%; margin: 5px 0; padding: 10px; text-align: left;
  background: var(--panel-head); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; font-size: 14px; }
.add-choice:hover { border-color: var(--accent); }

/* drag handle */
.drag-handle { color: var(--muted); margin-right: 7px; cursor: grab; font-size: 16px;
  letter-spacing: -2px; opacity: 0.55; flex: 0 0 auto; user-select: none; }
.drag-handle:hover { opacity: 1; color: var(--accent); }

/* builds widget filters */
.builds-filters { display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.filter-group { display: flex; gap: 3px; }
.filt-btn { background: var(--panel-head); color: var(--muted); border: 1px solid var(--border);
  border-radius: 5px; padding: 3px 9px; font-size: 11px; cursor: pointer; white-space: nowrap; }
.filt-btn:hover { border-color: var(--accent); color: var(--text); }
.filt-btn.sel { background: var(--accent); color: #1a1a1a; border-color: var(--accent);
  font-weight: 700; }

/* gridstack dark tweaks */
.grid-stack-placeholder > .placeholder-content { background: rgba(240,180,41,.08) !important;
  border: 1px dashed var(--accent) !important; border-radius: 10px; }

/* ---------- mobile responsive ---------- */
@media (max-width: 767px) {
  /* topbar: stack brand + controls */
  .topbar { flex-wrap: wrap; gap: 6px; padding: 8px 12px; }
  .topbar-right { flex-wrap: wrap; gap: 6px; flex: 1; }
  .topbar button { font-size: 12px; padding: 6px 10px; min-height: 36px; }
  .topbar .user, .topbar .logout { font-size: 12px; }

  /* prevent any horizontal scroll */
  html, body { overflow-x: hidden; }
  main { padding: 6px; }

  /* widget controls: bigger tap targets */
  .widget-ctl .ctl { font-size: 15px; padding: 6px 10px; min-width: 32px; min-height: 32px; }
  .widget-title { font-size: 14px; }
  .widget-body { font-size: 15px; line-height: 1.55; padding: 12px 14px; }

  /* usage: keep big % readable */
  .usage-pct { font-size: 32px; }
  .gauge { height: 14px; }

  /* job list: don't truncate task names on mobile */
  .job-task { white-space: normal; font-size: 14px; }
  .mini-row { white-space: normal; font-size: 13px; }

  /* needle hero bigger */
  .needle { font-size: 17px; }

  /* tally boxes: let them wrap */
  .mc-tallies { flex-wrap: wrap; }
  .tally { flex: 1 1 80px; padding: 8px 10px; }
  .tally-n { font-size: 26px; }

  /* dismiss btn: bigger touch target */
  .dismiss-btn { padding: 4px 10px; font-size: 15px; }
}
