:root {
  --ink: #161411;
  --muted: #6b645b;
  --line: #e4ddd3;
  --paper: #f7f3ec;
  --white: #fffcf7;
  --header: #10211b;
  --accent: #1b6b4a;
  --accent-2: #c4a35a;
  --red: #b42318;
  --amber: #b54708;
  --green: #176c45;
  --blue: #175cd3;
  --shadow: 0 1px 0 rgba(16, 33, 27, 0.06);
  --sans: "IBM Plex Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
}

body {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 28px;
  background: var(--header);
  color: #f4efe6;
  flex: 0 0 auto;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand-kicker {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.sync {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.sync-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 12px;
  color: #cfc6b8;
}

.sync-meta strong {
  color: #fff;
  font-weight: 500;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.status-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #66756e;
}

.status-dot.live::before {
  background: #3dd68c;
}

.status-dot.loading::before {
  background: var(--accent-2);
}

.status-dot.error::before {
  background: #f97066;
}

button {
  font: inherit;
  cursor: pointer;
}

.btn {
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  border-radius: 4px;
  font-size: 13px;
}

.btn:hover {
  background: #155a3e;
}

.btn.ghost {
  background: transparent;
  border-color: #3a4e46;
  color: #f4efe6;
}

.btn.ghost:hover {
  border-color: #c4a35a;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 10px;
  padding: 16px 28px 8px;
  flex: 0 0 auto;
}

.kpi {
  background: var(--white);
  border: 1px solid var(--line);
  padding: 12px 14px;
  min-height: 84px;
}

.kpi span {
  display: block;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.kpi b {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.kpi b.long {
  font-size: 14px;
  letter-spacing: 0;
  font-weight: 600;
}

.kpi em {
  display: block;
  margin-top: 6px;
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
}

.rag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.rag.green,
.rag.done,
.rag.go,
.rag.yes,
.rag.pass {
  background: #e8f5ee;
  color: var(--green);
}

.rag.amber,
.rag.at-risk,
.rag.modify,
.rag.open {
  background: #fef4e6;
  color: var(--amber);
}

.rag.red,
.rag.overdue,
.rag.hold,
.rag.fail,
.rag.no {
  background: #fde8e6;
  color: var(--red);
}

.rag.on-track,
.rag.pending {
  background: #e8eefc;
  color: var(--blue);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 28px 12px;
  flex: 0 0 auto;
}

.toolbar input {
  flex: 1;
  max-width: 420px;
  border: 1px solid var(--line);
  background: var(--white);
  padding: 9px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
}

.toolbar input:focus {
  outline: 2px solid #1b6b4a33;
  border-color: var(--accent);
}

.sheet-note {
  font-size: 12px;
  color: var(--muted);
}

.sheet-tabs {
  display: flex;
  gap: 0;
  overflow-x: auto;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: #efeae1;
  flex: 0 0 auto;
}

.sheet-tabs button {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  padding: 11px 14px;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.sheet-tabs button:hover {
  color: var(--ink);
}

.sheet-tabs button.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.grid-wrap {
  flex: 1;
  overflow: auto;
  padding: 0 0 48px;
  background: var(--white);
}

table.sheet {
  border-collapse: collapse;
  min-width: 100%;
  font-size: 13px;
}

table.sheet th,
table.sheet td {
  border: 1px solid #ece6dc;
  padding: 7px 10px;
  vertical-align: top;
  white-space: nowrap;
}

table.sheet td.wrap {
  white-space: normal;
  min-width: 280px;
  max-width: 460px;
  overflow-wrap: anywhere;
}

table.sheet thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f1ebe2;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

table.sheet .row-num,
table.sheet .col-letter {
  background: #f6f1ea;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  text-align: center;
  width: 36px;
  min-width: 36px;
  max-width: 36px;
  position: sticky;
  left: 0;
  z-index: 1;
}

table.sheet thead .col-letter {
  z-index: 3;
}

table.sheet tbody tr:nth-child(even) td {
  background: #fcfaf6;
}

table.sheet tbody tr:hover td {
  background: #f3eee4;
}

table.sheet .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 12px;
}

.intro {
  padding: 16px 28px 0;
  flex: 0 0 auto;
}

.intro h2 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 600;
}

.intro p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  max-width: 920px;
}

.empty,
.error-box,
.loading-box {
  margin: 48px auto;
  max-width: 560px;
  text-align: center;
  color: var(--muted);
}

.error-box {
  color: var(--red);
}

.hidden {
  display: none !important;
}

@media (max-width: 960px) {
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .sync,
  .sync-meta {
    align-items: flex-start;
  }
}
