:root {
  --navy: #073763;
  --blue: #00a6e8;
  --green: #65b32e;
  --yellow: #f6c343;
  --orange: #f47b20;
  --purple: #7e57c2;
  --teal: #26a69a;
  --bg: #f3fbff;
  --card: #ffffff;
  --ink: #142d42;
  --muted: #5c7284;
  --line: #d9edf6;
  --shadow: 0 16px 40px rgba(7, 55, 99, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 6% 12%, rgba(246, 195, 67, 0.5) 0 7px, transparent 8px),
    radial-gradient(circle at 93% 18%, rgba(0, 166, 232, 0.45) 0 8px, transparent 9px),
    radial-gradient(circle at 78% 87%, rgba(101, 179, 46, 0.28) 0 9px, transparent 10px),
    linear-gradient(135deg, #f3fbff 0%, #fff 48%, #eefcff 100%);
  letter-spacing: 0;
}

button,
input,
a {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
}

.teams-live-page {
  overflow: hidden;
}

.teams-dashboard {
  position: relative;
  display: grid;
  grid-template-rows: 74px minmax(0, 1fr) 58px;
  gap: 10px;
  width: 100vw;
  height: 100vh;
  padding: 12px;
}

.teams-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-width: 0;
}

.brand-cluster,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bot-mark {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  width: 58px;
  height: 50px;
  padding: 15px 10px 10px;
  border: 4px solid var(--navy);
  border-radius: 16px;
  background: var(--blue);
  box-shadow: 5px 5px 0 var(--yellow);
}

.bot-mark::before {
  content: "";
  position: absolute;
  top: -14px;
  left: 50%;
  width: 20px;
  height: 20px;
  border: 4px solid var(--navy);
  border-radius: 50%;
  background: var(--yellow);
  transform: translateX(-50%);
}

.bot-mark::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 8px;
  width: 24px;
  height: 10px;
  border-bottom: 4px solid #fff;
  border-radius: 0 0 999px 999px;
  transform: translateX(-50%);
}

.bot-mark span {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #fff;
}

h1,
h2,
p {
  margin: 0;
}

.teams-topbar h1 {
  color: var(--navy);
  font-size: clamp(2rem, 4.2vw, 4rem);
  line-height: 0.95;
  font-weight: 950;
}

.scan-button,
.primary-button,
.secondary-button,
.danger-button,
.corner-button,
.quiet-link,
.print-header button {
  border: 0;
  border-radius: 14px;
  font-weight: 900;
  transition: transform 140ms ease, filter 140ms ease;
}

.scan-button {
  padding: 12px 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--orange), var(--purple));
  box-shadow: 0 8px 0 rgba(126, 87, 194, 0.28);
  font-size: 1.05rem;
}

.quiet-link,
.corner-button {
  padding: 9px 12px;
  color: var(--navy);
  background: rgba(255, 255, 255, 0.72);
  border: 2px solid rgba(7, 55, 99, 0.18);
}

.scan-button:hover,
.primary-button:hover,
.secondary-button:hover,
.danger-button:hover,
.corner-button:hover,
.quiet-link:hover,
.export-card:hover {
  transform: translateY(-2px);
  filter: saturate(1.08);
}

.teams-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-height: 0;
}

.team-card {
  --team-bg: none;
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 4px solid var(--team-color);
  border-radius: 18px;
  background:
    radial-gradient(circle at 12% 16%, rgba(255, 255, 255, 0.95) 0 64px, transparent 65px),
    linear-gradient(135deg, color-mix(in srgb, var(--team-color), white 64%), #fff 58%);
  box-shadow: var(--shadow);
}

.team-card::after {
  content: "";
  position: absolute;
  z-index: 1;
  border-radius: 50%;
  pointer-events: none;
}

.team-card::after {
  bottom: 20px;
  left: 28px;
  width: 14px;
  height: 14px;
  background: var(--blue);
  box-shadow: 34px 0 0 var(--green), 68px 0 0 var(--orange);
}

.team-art {
  position: absolute;
  inset: 0;
  background-image: var(--team-bg);
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center center;
}

.team-art.no-image {
  background-image:
    linear-gradient(90deg, rgba(7, 55, 99, 0.16) 2px, transparent 2px),
    linear-gradient(0deg, rgba(7, 55, 99, 0.12) 2px, transparent 2px);
  background-size: 44px 44px;
  opacity: 0.2;
}

.team-overlay {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.94) 0%, rgba(255, 255, 255, 0.82) 48%, rgba(255, 255, 255, 0.58) 100%),
    linear-gradient(135deg, color-mix(in srgb, var(--team-color), transparent 76%), transparent 58%);
}

.team-content {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  padding: clamp(14px, 1.4vw, 24px);
}

.team-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.team-heading h2 {
  color: var(--navy);
  font-size: clamp(2.25rem, 4.5vw, 5.5rem);
  line-height: 0.88;
  font-weight: 950;
  text-transform: uppercase;
}

.team-heading p {
  margin-top: 5px;
  color: var(--team-color);
  font-size: clamp(1rem, 1.4vw, 1.35rem);
  font-weight: 900;
  text-transform: uppercase;
}

.team-total {
  display: grid;
  place-items: center;
  min-width: 118px;
  padding: 10px 12px;
  color: #fff;
  border: 4px solid var(--navy);
  border-radius: 18px;
  background: var(--team-color);
  box-shadow: 6px 6px 0 rgba(7, 55, 99, 0.2);
}

.team-total span {
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
}

.team-total strong {
  font-size: clamp(2.3rem, 4vw, 4.9rem);
  line-height: 0.95;
}

.activity-grid {
  align-self: end;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.activity-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  min-height: 52px;
  padding: 10px 12px;
  border: 3px solid rgba(7, 55, 99, 0.22);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 6px 16px rgba(7, 55, 99, 0.1);
}

.activity-chip span {
  overflow: hidden;
  font-size: clamp(0.82rem, 1.05vw, 1.05rem);
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-chip strong {
  color: var(--team-color);
  font-size: clamp(1.35rem, 2vw, 2.2rem);
  line-height: 1;
  font-weight: 950;
}

.activity-chip.negative strong {
  color: #d92525;
}

.recent-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 8px 12px;
  border: 3px solid rgba(7, 55, 99, 0.16);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.8);
}

.recent-strip > strong {
  flex: 0 0 auto;
  color: var(--navy);
  font-size: 0.95rem;
  text-transform: uppercase;
}

.recent-items {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}

.recent-items.empty {
  color: var(--muted);
  font-weight: 800;
}

.recent-pill {
  flex: 0 0 auto;
  max-width: 260px;
  overflow: hidden;
  padding: 7px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--team-color), white 78%);
  color: var(--navy);
  font-size: 0.9rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-pill b {
  color: var(--team-color);
  margin-right: 5px;
}

.corner-tools {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 6;
  display: flex;
  gap: 6px;
}

.corner-tools .corner-button {
  font-size: 0.76rem;
  opacity: 0.72;
}

.corner-tools .danger {
  color: #a61f1f;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(7, 55, 99, 0.5);
}

.modal.open {
  display: grid;
}

.modal-card {
  width: min(560px, 100%);
  padding: 24px;
  border: 4px solid var(--navy);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 28px 70px rgba(7, 55, 99, 0.34);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h2 {
  color: var(--navy);
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  line-height: 1.05;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: var(--navy);
  font-size: 1.5rem;
  font-weight: 900;
}

.scanner-help,
.hint {
  margin-top: 12px;
  color: var(--muted);
  font-weight: 750;
}

.scanner-status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 18px;
  padding: 10px 12px;
  border-radius: 999px;
  background: #e9f8fd;
  color: var(--navy);
  font-weight: 900;
}

.scanner-status.error {
  background: #ffe8e8;
  color: #9b1b1b;
}

.scanner-status.success {
  background: #e9f8e2;
  color: #2d6d19;
}

.scanner-status.busy .scanner-dot {
  animation: pulse 650ms infinite alternate;
}

.scanner-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: currentColor;
}

.scanner-label {
  display: block;
  margin-top: 18px;
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.scanner-input {
  width: 100%;
  margin-top: 7px;
  padding: 16px;
  border: 4px solid var(--blue);
  border-radius: 16px;
  color: var(--navy);
  font-size: 1.18rem;
  font-weight: 850;
  outline: 0;
}

.scanner-input:focus {
  box-shadow: 0 0 0 5px rgba(0, 166, 232, 0.2);
}

.scan-error {
  min-height: 28px;
  margin-top: 10px;
  color: #b11f1f;
  font-weight: 950;
}

.secondary-button,
.primary-button,
.danger-button,
.print-header button {
  padding: 12px 18px;
}

.secondary-button {
  color: var(--navy);
  background: #e7f7fd;
}

.primary-button {
  color: #fff;
  background: var(--navy);
}

.danger-button {
  color: #fff;
  background: #c62828;
}

.celebration {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  pointer-events: none;
}

.celebration.show {
  display: grid;
}

.celebration-card {
  display: grid;
  place-items: center;
  min-width: min(580px, 88vw);
  padding: 34px;
  border: 6px solid var(--navy);
  border-radius: 30px;
  background: #fff;
  box-shadow: 0 26px 0 color-mix(in srgb, var(--team-color), black 8%), 0 40px 80px rgba(7, 55, 99, 0.34);
  animation: pop 420ms cubic-bezier(.2, 1.5, .4, 1);
}

.celebration-symbol {
  display: grid;
  width: 90px;
  height: 90px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--team-color);
  font-size: 3.4rem;
  font-weight: 950;
}

.celebration-card strong {
  margin-top: 16px;
  color: var(--navy);
  font-size: clamp(2.6rem, 7vw, 6rem);
  line-height: 0.9;
  text-align: center;
  text-transform: uppercase;
}

.celebration-card p {
  margin-top: 8px;
  color: var(--team-color);
  font-size: clamp(1.5rem, 3vw, 2.7rem);
  font-weight: 950;
}

.celebration-card small {
  margin-top: 8px;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 850;
}

.settings-page,
.print-page {
  min-height: 100vh;
  overflow: auto;
}

.settings-shell,
.print-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 46px;
}

.service-header,
.print-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.service-header h1,
.print-header h1 {
  color: var(--navy);
  font-size: clamp(2.2rem, 4vw, 4.1rem);
  line-height: 0.95;
}

.service-header p,
.print-header p {
  margin-top: 8px;
  color: var(--muted);
  font-weight: 750;
}

.service-header nav,
.print-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.service-header a,
.print-header a,
.print-header button {
  padding: 10px 13px;
  border: 2px solid rgba(7, 55, 99, 0.14);
  border-radius: 12px;
  background: #fff;
  font-weight: 900;
}

.service-panel,
.export-card,
.qr-team-section {
  margin-top: 14px;
  padding: 18px;
  border: 3px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(7, 55, 99, 0.08);
}

.service-panel h2,
.qr-team-section h2 {
  color: var(--navy);
  font-size: 1.45rem;
}

.settings-form label {
  display: grid;
  gap: 5px;
  color: var(--navy);
  font-weight: 850;
}

.settings-form input:not([type="checkbox"]):not([type="color"]) {
  min-width: 0;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 11px;
}

.toggle-line {
  display: flex !important;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
}

.settings-table {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.settings-row {
  display: grid;
  align-items: end;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: #f7fcff;
}

.team-settings-row {
  grid-template-columns: 1.1fr 0.8fr 1fr 86px 90px;
}

.activity-settings-row {
  grid-template-columns: 1fr 140px 100px;
}

.settings-actions {
  margin-top: 16px;
}

.export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.export-card {
  display: grid;
  gap: 7px;
}

.export-card span {
  color: var(--orange);
  font-size: 0.8rem;
  font-weight: 950;
}

.export-card strong {
  color: var(--navy);
  font-size: 1.4rem;
}

.export-card small,
.qr-card small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.qr-team-section {
  border-color: var(--team-color);
  break-inside: avoid;
}

.qr-team-section h2 span {
  color: var(--team-color);
  font-size: 0.7em;
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.qr-card {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 12px;
  border: 2px solid #dbe7ee;
  border-radius: 14px;
}

.qr-card strong {
  color: var(--navy);
  font-size: 1.1rem;
  text-transform: uppercase;
}

.qr-card.malus strong {
  color: #b51d1d;
}

.qr-card img {
  width: 100%;
  height: 92px;
  object-fit: contain;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.72) rotate(-2deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

@keyframes pulse {
  from {
    transform: scale(0.85);
    opacity: 0.5;
  }
  to {
    transform: scale(1.2);
    opacity: 1;
  }
}

@media (max-width: 900px) {
  .teams-live-page {
    overflow: auto;
  }

  .teams-dashboard {
    height: auto;
    min-height: 100vh;
    grid-template-rows: auto auto auto;
  }

  .teams-topbar,
  .service-header,
  .print-header {
    align-items: stretch;
    flex-direction: column;
  }

  .teams-grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }

  .team-card {
    min-height: 360px;
  }

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

  .team-settings-row,
  .activity-settings-row {
    grid-template-columns: 1fr;
  }

  .corner-tools {
    position: static;
    margin-top: 8px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .no-print {
    display: none !important;
  }

  .print-shell {
    width: 100%;
    padding: 0;
  }

  .qr-team-section {
    box-shadow: none;
    page-break-inside: avoid;
  }

  .qr-card {
    min-height: 150px;
  }
}
