:root {
  color-scheme: light dark;
  --bg: #e8eef1;
  --surface: #fbfcfc;
  --surface-raised: #ffffff;
  --surface-muted: #e0e8ec;
  --line: #cbd6dc;
  --text: #17262f;
  --muted: #647782;
  --accent: #315f79;
  --accent-soft: #d6e5ed;
  --claim: #b17b12;
  --claim-soft: #fff4d5;
  --issue: #bd4f50;
  --issue-soft: #fde2e0;
  --buy: #187c78;
  --buy-soft: #d9f3ee;
  --open: #667789;
  --open-soft: #e8edf1;
  --shadow: 0 8px 24px rgba(23, 38, 47, 0.075);
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

:root[data-color-scheme="dark"] {
  --bg: #142128;
  --surface: #1b2a32;
  --surface-raised: #202b33;
  --surface-muted: #25323c;
  --line: #3b4954;
  --text: #edf4f5;
  --muted: #a7b5bb;
  --accent: #7cb7d2;
  --accent-soft: #213e4d;
  --claim: #e0ad3d;
  --claim-soft: #3c321d;
  --issue: #ef8582;
  --issue-soft: #452a2b;
  --buy: #62c7bd;
  --buy-soft: #173b39;
  --open: #a8b7c3;
  --open-soft: #2d3a44;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  position: relative;
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 85% -10%, color-mix(in srgb, var(--accent-soft) 80%, transparent), transparent 34%),
    linear-gradient(180deg, color-mix(in srgb, var(--surface-muted) 60%, var(--bg)) 0, var(--bg) 300px);
  color: var(--text);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(color-mix(in srgb, var(--accent) 10%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--accent) 10%, transparent) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.28;
  mask-image: linear-gradient(to bottom, black, transparent 58%);
}

button,
select {
  font: inherit;
}

button,
select,
input {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 18px 16px calc(28px + var(--safe-bottom));
}

.topbar,
.project-strip,
.controls,
.secondary-controls,
.action-bar,
.app-footer,
.brand-lockup,
.filter-row,
.record-heading,
.record-meta,
.record-footer,
.action-bar > div {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  min-height: 52px;
  padding-bottom: 14px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
}

.brand-lockup {
  gap: 10px;
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: var(--surface);
  font: 700 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.08em;
}

.brand-mark::after {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 8px;
  height: 8px;
  border-right: 1px solid var(--accent);
  border-bottom: 1px solid var(--accent);
  content: "";
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

h1,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1;
  letter-spacing: -0.03em;
}

.icon-button,
.text-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
}

.icon-button:hover,
.icon-button:active {
  background: var(--surface-muted);
  color: var(--text);
}

.project-strip {
  justify-content: space-between;
  gap: 18px;
  margin: 20px 0 13px;
  padding: 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.project-label {
  display: block;
}

.project-label select,
.select-wrap select {
  max-width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 750;
}

.project-label select {
  margin-left: -5px;
  padding: 2px 23px 2px 4px;
  font-size: 18px;
}

.project-day {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.count-number {
  display: block;
  font: 750 25px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: -0.07em;
}

.count-label {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.count-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.count-card {
  min-width: 0;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease;
  padding: 13px 11px 12px;
  /* RESTING: no colour at all. Colour is reserved for the selected tab, so "which one am
     I in" never depends on telling two tints apart - a distinction that disappears in
     light mode, where the soft fills sit a couple of percent off the surface. */
  border: 1px solid var(--line);
  border-top: 3px solid var(--line);
  border-radius: 10px;
  background: transparent;
}

.count-card .count-number { color: var(--muted); }
.count-card .count-label { color: var(--muted); }


/* SELECTED. The signal is COLOUR ITSELF, not a tint: at rest every card is neutral -
   grey rule, grey number, no fill. Only the selected one carries colour, on three
   surfaces at once (a 4px top bar, a 2px ring, and the number). That reads on any
   ground, in either theme, and it does not rely on telling two near-identical
   background washes apart - which is exactly what failed in light mode. */
.count-card.is-active {
  border-width: 2px;
  border-top-width: 4px;
  background: var(--accent-soft);
}
.count-card.is-active .count-label {
  color: var(--text);
  font-weight: 800;
}

.count-claim.is-active { border-color: var(--claim); }
.count-open.is-active  { border-color: var(--open); }
.count-buy.is-active   { border-color: var(--buy); }

.count-claim.is-active .count-number { color: var(--claim); }
.count-open.is-active  .count-number { color: var(--open); }
.count-buy.is-active   .count-number { color: var(--buy); }

/* the 2px ring must not shift the row: pull the extra border back out of the padding */
.count-card.is-active { padding: 12px 10px 11px; }

.controls {
  align-items: flex-start;
  flex-direction: column;
  gap: 10px;
  margin: 19px 0 13px;
}

.filter-row {
  width: 100%;
  gap: 7px;
  overflow-x: auto;
  padding: 2px 1px 5px;
  scrollbar-width: none;
}

.filter-row::-webkit-scrollbar { display: none; }

.filter-chip {
  flex: 0 0 auto;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}

.filter-chip:hover,
.filter-chip.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--surface);
}

.secondary-controls {
  width: 100%;
  gap: 8px;
}

.select-wrap {
  min-width: 0;
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.select-wrap select {
  width: 100%;
  padding-right: 8px;
  color: var(--muted);
  font-size: 12px;
}

.record-list {
  display: grid;
  gap: 10px;
}

.record-card {
  position: relative;
  display: grid;
  grid-template-columns: 27px minmax(0, 1fr);
  gap: 11px;
  padding: 15px 14px 14px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--open);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 3px 12px rgba(23, 38, 47, 0.04);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.record-card.state-claim { border-left-color: var(--claim); }
.record-card.state-issue { border-left-color: var(--issue); }
.record-card.state-buy { border-left-color: var(--buy); }

.record-card.is-selected {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
  border-left-color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 30%, var(--surface));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 16%, transparent);
}

.record-card:focus-within {
  transform: translateY(-1px);
}

.record-group {
  display: grid;
  gap: 0;
}

.nested-records {
  position: relative;
  display: grid;
  gap: 8px;
  margin: -2px 0 0 17px;
  padding: 10px 0 0 13px;
  border-left: 2px solid color-mix(in srgb, var(--accent) 34%, var(--line));
}

.nested-records::before {
  position: absolute;
  top: 22px;
  left: -2px;
  width: 12px;
  border-top: 2px solid color-mix(in srgb, var(--accent) 34%, var(--line));
  content: "";
}

.record-card.is-child {
  border-left-color: var(--open);
  background: color-mix(in srgb, var(--accent-soft) 22%, var(--surface));
  box-shadow: none;
}

.record-card.is-child .record-title {
  font-size: 14px;
}

.record-checkbox {
  width: 23px;
  height: 23px;
  margin: 1px 0 0;
  border: 2px solid var(--line);
  border-radius: 7px;
  accent-color: var(--accent);
  cursor: pointer;
}

.record-checkbox:checked {
  border-color: var(--accent);
}

.record-heading {
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.record-id {
  flex: 0 0 auto;
  margin: 0;
  color: var(--accent);
  font: 800 13px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: -0.03em;
}

.state-badge {
  flex: 0 0 auto;
  padding: 4px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.state-claim .state-badge { background: var(--claim-soft); color: var(--claim); }
.state-issue .state-badge { background: var(--issue-soft); color: var(--issue); }
.state-buy .state-badge { background: var(--buy-soft); color: var(--buy); }
.state-open .state-badge { background: var(--open-soft); color: var(--open); }

.record-title {
  margin: 8px 0 11px;
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
  line-height: 1.38;
  overflow-wrap: anywhere;
}

.record-meta {
  flex-wrap: wrap;
  gap: 6px 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.owner {
  min-width: 0;
  overflow-wrap: anywhere;
}

.owner::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin: 0 6px 2px 0;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}

.record-footer {
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
}

.nested-label {
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.related-label {
  padding: 4px 7px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
}

.notice-copy {
  min-width: 0;
}

.undo-button {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid currentColor;
  border-radius: 7px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}

.notice[data-tone="warning"] {
  border-color: color-mix(in srgb, var(--claim) 48%, var(--line));
  background: var(--claim-soft);
}

.notice[data-tone="error"] {
  border-color: color-mix(in srgb, var(--issue) 48%, var(--line));
  background: var(--issue-soft);
}

.message-state {
  padding: 34px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.message-state h2 {
  margin: 0 0 7px;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.message-state p {
  max-width: 330px;
  margin: 0 auto 15px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.retry-button,
.bulk-action {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

.retry-button {
  padding: 9px 14px;
  font-size: 12px;
}

.loading-state {
  display: grid;
  gap: 10px;
}

.skeleton-card {
  height: 137px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(100deg, var(--surface) 35%, var(--surface-muted) 50%, var(--surface) 65%);
  background-size: 300% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

.action-bar {
  position: sticky;
  z-index: 5;
  bottom: calc(10px + var(--safe-bottom));
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 10px 10px 10px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 38%, var(--line));
  border-radius: 14px;
  background: var(--accent);
  color: var(--surface);
  box-shadow: var(--shadow);
}

.record-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 12px;
  padding-top: 9px;
  border-top: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
}

.card-action,
.secondary-action,
.primary-action,
.danger-action {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}

.card-action,
.secondary-action {
  background: var(--surface-muted);
  color: var(--text);
}

.card-action-danger,
.danger-action {
  border-color: color-mix(in srgb, var(--issue) 38%, var(--line));
  background: var(--issue-soft);
  color: var(--issue);
}

.primary-action {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--surface);
}

.card-action:disabled,
.secondary-action:disabled,
.primary-action:disabled,
.danger-action:disabled {
  cursor: wait;
  opacity: 0.55;
}

.card-action:hover,
.secondary-action:hover {
  border-color: var(--accent);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--text) 32%, transparent);
  backdrop-filter: blur(3px);
}

.modal-card {
  position: relative;
  width: min(100%, 560px);
  max-height: min(92vh, 680px);
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 18px 18px 10px 10px;
  background: var(--surface-raised);
  box-shadow: 0 20px 55px rgba(23, 38, 47, 0.24);
}

.confirm-card {
  border-top-color: var(--issue);
}

.modal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.modal-heading h2 {
  margin: 0;
  font-size: 19px;
  letter-spacing: -0.03em;
}

.modal-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-muted);
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

.form-field {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.form-field-wide {
  grid-column: 1 / -1;
}

.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  letter-spacing: normal;
  text-transform: none;
}

.form-field input,
.form-field select {
  min-height: 38px;
  padding: 8px 10px;
}

.form-field textarea {
  min-height: 94px;
  padding: 10px;
  resize: vertical;
}

.form-field small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 550;
  letter-spacing: normal;
  text-transform: none;
}

.modal-message {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 7px;
}

.action-bar > div {
  min-width: 0;
  gap: 8px;
}

.action-bar strong {
  font-size: 12px;
  white-space: nowrap;
}

.text-button {
  padding: 4px;
  font-size: 11px;
  font-weight: 750;
  color: color-mix(in srgb, var(--surface) 72%, transparent);
}

.bulk-action {
  min-height: 37px;
  padding: 9px 12px;
  background: var(--surface);
  color: var(--accent);
  font-size: 12px;
  white-space: nowrap;
}

.bulk-action:disabled,
.retry-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.app-footer {
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 20px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.02em;
  text-align: center;
}

.footer-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

@media (min-width: 600px) {
  .app-shell {
    padding-right: 24px;
    padding-left: 24px;
  }

  .controls {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .secondary-controls {
    width: auto;
    flex: 0 0 auto;
  }

  .select-wrap {
    width: 150px;
    flex: 0 0 auto;
  }

  .modal {
    align-items: center;
  }

  .modal-card {
    border-radius: 18px;
  }
}

@media (max-width: 480px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-field-wide {
    grid-column: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* A record nobody owns is the quietest way work dies, and a third of the pilot board is
   in this state. It reads as a flag, not as somebody's name. */
.owner-none {
  color: var(--issue);
  font-weight: 750;
}

/* A claim is a request, not a status: somebody has said the work is done and is waiting
   on the manager to accept it. Yellow because that is the colour the board already uses
   for "needs confirmation", and a left rule so it reads as a callout rather than a label. */
.claim-banner {
  margin: 9px 0 0;
  padding: 8px 10px;
  border-left: 3px solid var(--claim);
  border-radius: 8px;
  background: var(--claim-soft);
  color: var(--claim);
  font-size: 12.5px;
  font-weight: 750;
  line-height: 1.35;
}
