/* Salesforce Lightning look: grey page, white cards, #0176d3 accents, 4px radius. Dark mode follows the system. */
:root {
  --page: #f3f3f3;
  --card: #ffffff;
  --line: #dddbda;
  --text: #181818;
  --muted: #706e6b;
  --brand: #0176d3;
  --brand-hover: #014486;
  --link: #0176d3;
  --bad: #c23934;
  --warn: #ffb75d;
  --ok-band: #e5f3ff;
  --track: #ecebea;
  --pill: #ecebea;
  --toast-bg: #181818;
  --toast-text: #ffffff;
  --radius: 4px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #0f1216;
    --card: #1c2026;
    --line: #3e3e3c;
    --text: #f3f3f3;
    --muted: #b5b3b0;
    --brand: #1b96ff;
    --brand-hover: #5eb4ff;
    --link: #5eb4ff;
    --bad: #ea4f48;
    --warn: #ffb75d;
    --ok-band: #15324f;
    --track: #2e333b;
    --pill: #2e333b;
    --toast-bg: #f3f3f3;
    --toast-text: #181818;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; background: var(--page); color: var(--text); }

body {
  font-family: "Salesforce Sans", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3 { margin: 0; font-weight: 700; }

/* Top bar */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px max(12px, env(safe-area-inset-left));
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding-top: max(10px, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { border-radius: var(--radius); }
.brand h1 { font-size: 16px; }
.status { font-size: 12px; color: var(--muted); }

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 12px max(12px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}
#cockpit { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; min-width: 0; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.card-head h2 { font-size: 15px; }
.card-body { padding: 12px 14px; }

.pill {
  background: var(--pill);
  border-radius: 10px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 600;
}

.muted { color: var(--muted); margin: 0; }
.error { color: var(--bad); margin: 0; }
.sub { font-size: 12px; color: var(--muted); margin-top: 4px; padding: 0 2px; }

/* Buttons */
.btn, .btn-small, .btn-ghost {
  font: inherit;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
}
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #ffffff;
  font-size: 15px;
}
.btn:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-wide { width: 100%; }
.btn-small {
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #ffffff;
}
.btn-small:disabled { opacity: 0.6; }
.btn-ghost {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid #c9c7c5;
  background: var(--card);
  color: var(--link);
}
@media (prefers-color-scheme: dark) { .btn-ghost { border-color: #5a5f66; } }

.plain { padding: 10px 2px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; overflow-wrap: anywhere; }
.blockers-toggle { margin-top: 8px; }

/* Stacked lists */
.stack { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.stack li { margin: 0; }

/* Banners */
.banner-card {
  border-radius: var(--radius);
  padding: 12px 14px;
  border: 1px solid var(--line);
}
.banner-card.red { background: var(--bad); border-color: var(--bad); color: #ffffff; }
.banner-card.ok { background: var(--ok-band); }
.banner-card.offline { background: var(--bad); border-color: var(--bad); color: #ffffff; font-weight: 700; }
.banner-line { font-size: 16px; font-weight: 700; }
.banner-edit {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
}
.num-input {
  width: 96px;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid #8e8c8a;
  border-radius: var(--radius);
  background: #ffffff;
  color: #181818;
  font: inherit;
}

/* Chats */
.group + .group, .group-done { margin-top: 14px; }
.group-head {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 6px;
  font-weight: 700;
}
.group-done > summary { cursor: pointer; list-style-position: inside; }
.chat { border-top: 1px solid var(--line); padding: 10px 0; }
.chat:first-of-type { border-top: 0; }
.chat-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chat-title { font-weight: 600; }
.chat-lane { font-size: 12px; color: var(--muted); margin-top: 2px; }
.chat-doing { margin-top: 4px; }
.chat-seen { font-size: 12px; color: var(--muted); margin-top: 4px; }

.badge {
  font-size: 12px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius);
  color: var(--text);
  background: var(--warn);
}
.badge.bad { background: var(--bad); color: #ffffff; }
.badge.warn { background: var(--warn); color: #181818; }
.badge.info { background: var(--brand); color: #ffffff; }

/* Projects */
.repo { border-top: 1px solid var(--line); padding: 10px 0; }
.repo:first-child { border-top: 0; padding-top: 0; }
.repo-name { font-size: 15px; margin-bottom: 8px; }
.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
  margin: 0;
}
.stat dt { font-size: 12px; color: var(--muted); }
.stat dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
@media (min-width: 600px) { .stats { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

/* Key/value rows */
.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv strong { text-align: right; overflow-wrap: anywhere; }

.move { padding: 8px 0; border-bottom: 1px solid var(--line); }
.move:last-child { border-bottom: 0; }
.move-name { font-weight: 600; }
.move-text { color: var(--muted); margin-top: 2px; }

/* Widgets on the board */
.widget { padding: 12px; overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.w-title { font-size: 13px; margin-bottom: 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.w-body { min-width: 0; }

.metric-value { font-size: 28px; font-weight: 700; }
.metric-label { color: var(--muted); }
.metric-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.table-wrap { overflow-x: auto; }
.dtable { width: 100%; border-collapse: collapse; }
.dtable th, .dtable td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.dtable th { font-size: 12px; color: var(--muted); font-weight: 700; }

.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(70px, 30%) 1fr auto; gap: 8px; align-items: center; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; background: var(--track); border-radius: 2px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--brand); }
.bar-val { font-weight: 600; }

.donut { display: grid; gap: 8px; }
.donut-chart { width: 100%; height: 220px; }
.donut-chart-off { display: none; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend strong { margin-left: auto; }
.swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed-item { padding: 8px 0; border-bottom: 1px solid var(--line); }
.feed-item:last-child { border-bottom: 0; }
.feed-main { font-weight: 600; overflow-wrap: anywhere; }
.feed-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Gridstack: on wide screens the library places the cards. Phones show the cards stacked in order. */
#board .grid-stack { min-height: 40px; }
#board .grid-stack-item-content.widget { position: absolute; }
@media (max-width: 719px) {
  #board .grid-stack { height: auto !important; }
  #board .grid-stack-item {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    width: auto !important;
    height: auto !important;
    margin-bottom: 12px;
    transform: none !important;
  }
  #board .grid-stack-item-content.widget {
    position: relative !important;
    inset: auto !important;
    height: auto;
    overflow: visible;
  }
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  background: var(--toast-bg);
  color: var(--toast-text);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

body.is-demo .top::after {
  content: "Demo data";
  font-size: 12px;
  font-weight: 700;
  color: var(--link);
  margin-left: auto;
  margin-right: 12px;
}
