:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --panel: #ffffff;
  --ink: #12211e;
  --muted: #62706c;
  --line: #d9e3df;
  --brand: #0f6b5f;
  --brand-dark: #0a5148;
  --separated: #ffe082;
  --separated-strong: #f1b600;
  --owned: #a7e7bd;
  --owned-strong: #21844a;
  --danger: #d64b4b;
  --shadow: 0 10px 30px rgba(18, 33, 30, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: auto;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.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;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(14px, env(safe-area-inset-top)) 16px 12px;
  background: rgba(244, 247, 245, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--brand);
  font-size: 0.76rem;
  font-weight: 750;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.35rem, 6vw, 2rem);
  line-height: 1.05;
}

main {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 14px 12px 40px;
}

.icon-button {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  color: var(--brand-dark);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.header-cloud {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
  min-width: 0;
}

.summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.summary-item {
  min-height: 76px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 5px solid #ffffff;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.summary-item.separated {
  border-left-color: var(--separated-strong);
}

.summary-item.owned {
  border-left-color: var(--owned-strong);
}

.summary-item span {
  display: block;
  font-size: 1.45rem;
  font-weight: 820;
}

.summary-item small {
  color: var(--muted);
  font-weight: 650;
}

.toolbar {
  position: sticky;
  top: 70px;
  z-index: 20;
  padding: 12px;
  margin-bottom: 12px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.search-field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
  text-transform: uppercase;
}

.search-field input {
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  color: var(--ink);
  background: #f9fbfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.search-field input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 107, 95, 0.13);
}

.control-row,
.action-row {
  display: grid;
  gap: 8px;
}

.action-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 10px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 0;
  margin: 0;
  border: 0;
}

.segmented.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.segmented legend {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
  text-transform: uppercase;
}

.segmented label {
  min-width: 0;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  place-items: center;
  min-height: 42px;
  padding: 0 8px;
  overflow-wrap: anywhere;
  color: var(--brand-dark);
  background: #edf5f2;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 750;
}

.segmented input:checked + span {
  color: #ffffff;
  background: var(--brand);
  border-color: var(--brand-dark);
}

.action-button {
  min-height: 44px;
  padding: 0 12px;
  color: #ffffff;
  background: var(--brand);
  border: 1px solid var(--brand-dark);
  border-radius: 8px;
  font-weight: 780;
}

.action-button.secondary {
  color: var(--brand-dark);
  background: #eef6f3;
  border-color: #c9ded8;
}

.sync-status {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.header-sync {
  display: flex;
  align-items: center;
  gap: 5px;
  max-width: none;
  min-height: 0;
  margin: 0;
  overflow: visible;
}

.status-dot {
  width: 9px;
  height: 9px;
  background: #d64b4b;
  border: 1px solid rgba(18, 33, 30, 0.24);
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.9);
}

.status-dot.is-ok {
  background: #21844a;
}

.status-dot.is-warn {
  background: #f1b600;
}

.status-wifi,
.status-refresh,
.status-icon-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: var(--danger);
  background: transparent;
  border: 0;
  border-radius: 6px;
  padding: 0;
}

.status-wifi svg,
.status-refresh svg,
.status-icon-button svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.7;
}

.status-wifi.is-ok,
.status-refresh.is-ok,
.status-icon-button.is-ok {
  color: var(--owned-strong);
}

.status-wifi:not(.is-ok)::after,
.status-refresh:not(.is-ok)::after,
.status-icon-button:not(.is-ok)::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 3px;
  background: var(--danger);
  border-radius: 999px;
  transform: rotate(-42deg);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.8);
}

.list-info {
  margin: 0 2px 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 650;
}

.sticker-list {
  display: grid;
  gap: 8px;
}

.team-heading {
  position: sticky;
  top: 300px;
  z-index: 10;
  margin: 12px 0 2px;
  padding: 7px 10px;
  color: #ffffff;
  background: var(--brand-dark);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 820;
}

.sticker-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 5px solid #ffffff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(18, 33, 30, 0.05);
}

.sticker-row[data-status="separada"] {
  background: #fff8df;
  border-left-color: var(--separated-strong);
}

.sticker-row[data-status="tenho"] {
  background: #ecfbf0;
  border-left-color: var(--owned-strong);
}

.sticker-number {
  display: grid;
  place-items: center;
  min-height: 74px;
  padding: 7px;
  background: #f5f8f7;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--brand-dark);
  font-size: 1rem;
  font-weight: 850;
  text-align: center;
}

.sticker-main {
  min-width: 0;
}

.sticker-name {
  display: block;
  width: 100%;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  text-align: left;
  font-weight: 780;
  line-height: 1.25;
}

.sticker-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.86rem;
}

.status-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin-top: 9px;
}

.status-chip {
  min-height: 34px;
  padding: 0 6px;
  color: var(--muted);
  background: #f7faf9;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 760;
}

.status-chip.active[data-status-choice="faltante"] {
  color: var(--ink);
  background: #ffffff;
  border-color: #acbbb6;
}

.status-chip.active[data-status-choice="separada"] {
  color: #4d3d00;
  background: var(--separated);
  border-color: var(--separated-strong);
}

.status-chip.active[data-status-choice="tenho"] {
  color: #0b4c2d;
  background: var(--owned);
  border-color: var(--owned-strong);
}

.empty-state {
  margin: 30px 0;
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

dialog {
  width: min(430px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(18, 33, 30, 0.24);
}

dialog::backdrop {
  background: rgba(18, 33, 30, 0.42);
}

.dialog-panel {
  padding: 18px;
}

.dialog-panel h2 {
  margin: 0 0 8px;
  font-size: 1.3rem;
}

.dialog-panel p {
  color: var(--muted);
  line-height: 1.45;
}

.dialog-actions {
  display: grid;
  gap: 8px;
}

.compact-dialog {
  padding: 18px;
}

.inline-actions {
  grid-template-columns: 1fr 1fr;
}

@media (min-width: 760px) {
  .app-header {
    padding-inline: 24px;
  }

  main {
    padding-inline: 24px;
  }

  .summary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .toolbar {
    top: 76px;
  }

  .control-row {
    grid-template-columns: 1.6fr 1fr;
    align-items: end;
  }

  .action-row {
    grid-template-columns: repeat(4, max-content);
  }

  .segmented {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .team-heading {
    top: 236px;
  }

  .sticker-row {
    grid-template-columns: 94px minmax(0, 1fr);
  }

  .status-buttons {
    max-width: 420px;
  }
}

/* Compact mobile-first board */
.app-header {
  padding: max(8px, env(safe-area-inset-top)) 10px 8px;
}

.eyebrow {
  margin-bottom: 0;
  font-size: 0.65rem;
}

h1 {
  font-size: 1.25rem;
}

main {
  padding: 8px 8px 28px;
}

.icon-button {
  flex-basis: 34px;
  width: 34px;
  height: 34px;
  box-shadow: none;
}

.icon-button svg,
.icon-action svg {
  width: 18px;
  height: 18px;
}

.summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 6px;
}

.summary-item {
  min-height: 42px;
  padding: 6px;
  border-left-width: 3px;
  box-shadow: none;
}

.summary-item span {
  font-size: 1rem;
  line-height: 1.05;
}

.summary-item small {
  display: block;
  overflow: hidden;
  font-size: 0.64rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar {
  top: 51px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px;
  align-items: end;
  padding: 6px;
  margin-bottom: 8px;
  border-radius: 8px;
  box-shadow: none;
}

.search-field {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
}

.search-field input {
  min-height: 34px;
  padding: 0 8px;
  font-size: 0.86rem;
}

.control-row {
  grid-column: 1 / -1;
  grid-row: 2;
  display: flex;
  gap: 5px;
}

.segmented {
  display: flex;
  gap: 3px;
}

.segmented legend {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.segmented span {
  min-width: 31px;
  min-height: 34px;
  padding: 0 6px;
  border-radius: 7px;
  font-size: 0.78rem;
}

.segmented.compact span {
  min-width: 39px;
}

.action-row {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  gap: 3px;
  margin-top: 0;
}

.action-button.icon-action {
  display: grid;
  place-items: center;
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 7px;
}

.sync-status {
  grid-column: 1 / -1;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-sync {
  grid-column: auto;
}

.list-info {
  margin: 0 0 5px;
  font-size: 0.78rem;
}

.sticker-list {
  gap: 6px;
}

.team-section {
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.team-title {
  margin: 0 0 5px;
  color: var(--brand-dark);
  font-size: 0.92rem;
  line-height: 1.1;
}

.tile-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.sticker-tile {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  padding: 2px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid #aebbb7;
  border-radius: 7px;
  font-size: 0.69rem;
  font-weight: 850;
  line-height: 1;
  text-align: center;
}

.sticker-tile[data-status="separada"] {
  color: #4d3d00;
  background: var(--separated);
  border-color: var(--separated-strong);
}

.sticker-tile[data-status="tenho"] {
  color: #0b4c2d;
  background: var(--owned);
  border-color: var(--owned-strong);
}

.sticker-tile:active {
  transform: scale(0.96);
}

@media (min-width: 760px) {
  .toolbar {
    top: 58px;
  }

  .sticker-tile {
    width: 56px;
    height: 56px;
    font-size: 0.72rem;
  }
}

/* Extra dense list requested for mobile use */
.toolbar {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px;
  padding: 5px;
}

.search-field input {
  min-height: 32px;
}

.action-row {
  align-self: stretch;
}

.control-row {
  grid-column: 1 / -1;
  overflow-x: auto;
  padding-bottom: 1px;
  scrollbar-width: thin;
}

.segmented span {
  min-width: 0;
  min-height: 30px;
  padding: 0 8px;
  font-size: 0.72rem;
  white-space: nowrap;
}

.segmented.compact span {
  min-width: 34px;
}

.action-button.icon-action {
  width: 34px;
  min-width: 34px;
  min-height: 32px;
}

.sync-status {
  font-size: 0.68rem;
}

.list-info {
  margin-bottom: 4px;
  font-size: 0.74rem;
}

.sticker-list {
  gap: 4px;
}

.team-section {
  display: block;
  gap: 5px;
  min-height: 44px;
  padding: 4px;
}

.team-title {
  display: flex;
  align-items: center;
  gap: 3px;
  margin: 0 0 4px;
  font-size: 0.78rem;
  line-height: 1.05;
  white-space: normal;
}

.team-flag {
  flex: 0 0 auto;
  width: 18px;
  height: 12px;
  border: 1px solid rgba(18, 33, 30, 0.18);
  border-radius: 2px;
  object-fit: cover;
  box-shadow: 0 1px 2px rgba(18, 33, 30, 0.12);
}

.team-flag.emoji {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 14px;
  border: 0;
  border-radius: 0;
  font-size: 0.85rem;
  line-height: 1;
  box-shadow: none;
}

.team-short-name {
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: normal;
}

.tile-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 1px 0 2px;
}

.sticker-tile {
  display: grid;
  grid-template-rows: 1fr 1fr;
  place-items: center;
  flex: 0 0 31px;
  width: 31px;
  height: 36px;
  gap: 0;
  border-radius: 5px;
  font-size: 0.52rem;
  line-height: 0.95;
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.sticker-tile.just-updated {
  transform: scale(0.92);
}

.tile-prefix,
.tile-number {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
}

@media (min-width: 760px) {
  .team-title {
    font-size: 0.86rem;
  }

  .sticker-tile {
    flex-basis: 34px;
    width: 34px;
    height: 38px;
    font-size: 0.54rem;
  }
}
