:root {
  --page-bg: #f5f6f8;
  --panel: #ffffff;
  --text: #2d241e;
  --muted: #746a63;
  --line: #e6dfd9;
  --dbsa-yellow: #f2b61f;
  --dbsa-brown: #4a2d1c;
  --positive: #147a43;
  --positive-bg: #eaf8f0;
  --negative: #a22b2b;
  --negative-bg: #fff0f0;
  --danger: #b62424;
  --shadow: 0 10px 28px rgba(55, 39, 27, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--page-bg);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background: var(--page-bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.operator-header,
main {
  width: min(100% - 32px, 1540px);
  margin-inline: auto;
}

.operator-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  padding: 28px 0 20px;
}

.header-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--dbsa-yellow);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.operator-header h1 {
  margin: 0;
  color: var(--dbsa-brown);
  font-size: clamp(31px, 4vw, 54px);
  line-height: 1;
  letter-spacing: -0.045em;
}

.subheading {
  max-width: 720px;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: clamp(14px, 1.2vw, 18px);
  line-height: 1.45;
}

.header-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9a9a9a;
}

.status-pill.online span {
  background: #27ad63;
  box-shadow: 0 0 0 4px rgba(39, 173, 99, 0.12);
}

.status-pill.offline span {
  background: #d75858;
}

main {
  padding-bottom: 44px;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 7px 20px rgba(55, 39, 27, 0.07);
  backdrop-filter: blur(10px);
}

.button,
.score-button {
  min-height: 44px;
  border: 0;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 850;
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.button {
  padding: 10px 15px;
  color: #ffffff;
  background: var(--dbsa-brown);
}

.button.secondary {
  border: 1px solid var(--line);
  color: var(--dbsa-brown);
  background: #ffffff;
}

.button.danger {
  color: #ffffff;
  background: var(--danger);
}

.button:disabled,
.score-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.button:not(:disabled):active,
.score-button:not(:disabled):active {
  transform: translateY(1px) scale(0.99);
}

.last-action {
  flex: 1 1 280px;
  min-width: 0;
  padding: 8px 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.operator-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr));
  gap: 18px;
}

.station-card {
  --team-color: var(--dbsa-yellow);
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 7px solid var(--team-color);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.card-header {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 13px;
}

.station-badge {
  display: grid;
  place-items: center;
  width: 52px;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 14px;
  color: #ffffff;
  background: var(--team-color);
  font-size: 23px;
  font-weight: 900;
}

.station-badge img,
.station-badge svg {
  width: 62%;
  height: 62%;
  object-fit: contain;
}

.card-title {
  min-width: 0;
}

.station-label {
  margin: 0 0 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.card-title h2 {
  margin: 0;
  overflow: hidden;
  color: var(--dbsa-brown);
  font-size: clamp(20px, 2vw, 28px);
  line-height: 1.05;
  letter-spacing: -0.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.percentage-badge {
  min-width: 67px;
  padding: 8px 10px;
  border-radius: 999px;
  color: var(--dbsa-brown);
  background: #f6f1eb;
  font-size: 14px;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
}

.score-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 0 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--line);
}

.score-summary > div {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  padding: 13px 14px;
  background: #fbfaf9;
}

.score-summary span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.score-summary strong {
  color: var(--dbsa-brown);
  font-size: 28px;
  line-height: 1;
}

.mini-progress {
  height: 12px;
  margin: 14px 18px 17px;
  overflow: hidden;
  border-radius: 999px;
  background: #eae5e0;
}

.mini-progress > div {
  width: 0;
  height: 100%;
  max-width: 100%;
  border-radius: inherit;
  background: var(--team-color);
  transition: width 500ms ease;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 7px;
  padding: 0 18px 17px;
}

.score-button {
  min-width: 0;
  padding: 10px 5px;
  font-size: 14px;
}

.score-button.positive {
  border: 1px solid #bde6cc;
  color: var(--positive);
  background: var(--positive-bg);
}

.score-button.negative {
  border: 1px solid #f0c5c5;
  color: var(--negative);
  background: var(--negative-bg);
}

.custom-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: end;
  padding: 15px 18px;
  border-top: 1px solid var(--line);
  background: #fbfaf9;
}

.custom-entry label {
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input {
  width: 100%;
  min-height: 44px;
  margin-top: 7px;
  padding: 10px 12px;
  border: 1px solid #d8d0ca;
  border-radius: 10px;
  outline: none;
  background: #ffffff;
  color: var(--text);
  font-size: 16px;
}

input:focus {
  border-color: var(--dbsa-yellow);
  box-shadow: 0 0 0 3px rgba(242, 182, 31, 0.18);
}

.custom-subtract {
  color: var(--negative);
  background: var(--negative-bg);
}

.custom-add {
  color: #ffffff;
  background: var(--positive);
}

.set-total-panel {
  border-top: 1px solid var(--line);
  background: #ffffff;
}

.set-total-panel summary {
  padding: 14px 18px;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  user-select: none;
}

.set-total-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 0 18px 18px;
}

.set-total-controls input {
  margin-top: 0;
}

dialog {
  width: min(92vw, 460px);
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: transparent;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

dialog::backdrop {
  background: rgba(30, 22, 17, 0.55);
  backdrop-filter: blur(3px);
}

.dialog-card {
  padding: 27px;
  border-radius: 20px;
  background: #ffffff;
  text-align: center;
}

.dialog-icon {
  display: grid;
  place-items: center;
  width: 52px;
  aspect-ratio: 1;
  margin: 0 auto 14px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--danger);
  font-size: 27px;
  font-weight: 900;
}

.dialog-card h2 {
  margin: 0;
  color: var(--dbsa-brown);
  font-size: 25px;
}

.dialog-card p {
  margin: 11px 0 22px;
  color: var(--muted);
  line-height: 1.5;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

@media (hover: hover) {
  .button:not(:disabled):hover,
  .score-button:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(55, 39, 27, 0.10);
  }
}

@media (max-width: 900px) {
  .operator-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 18px;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .last-action {
    flex-basis: 100%;
    padding-left: 2px;
    text-align: left;
  }
}

@media (max-width: 620px) {
  .operator-header,
  main {
    width: min(100% - 22px, 1540px);
  }

  .operator-header {
    padding-top: 19px;
  }

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

  .status-pill,
  .header-actions .button {
    width: 100%;
    justify-content: center;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    top: 6px;
    padding: 9px;
  }

  .toolbar .button {
    width: 100%;
    padding-inline: 9px;
    font-size: 13px;
  }

  #resetButton {
    grid-column: 1 / -1;
  }

  .last-action {
    grid-column: 1 / -1;
    white-space: normal;
    line-height: 1.35;
  }

  .operator-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .card-header {
    grid-template-columns: 45px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 15px 14px 12px;
  }

  .station-badge {
    width: 45px;
    border-radius: 12px;
  }

  .percentage-badge {
    min-width: 58px;
    padding: 7px 8px;
    font-size: 13px;
  }

  .score-summary {
    margin-inline: 14px;
  }

  .mini-progress {
    margin-inline: 14px;
  }

  .quick-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding-inline: 14px;
  }

  .score-button {
    min-height: 48px;
    font-size: 15px;
  }

  .custom-entry {
    grid-template-columns: 1fr 1fr;
    padding: 14px;
  }

  .custom-entry label {
    grid-column: 1 / -1;
  }

  .custom-entry .button {
    width: 100%;
  }

  .set-total-panel summary {
    padding-inline: 14px;
  }

  .set-total-controls {
    grid-template-columns: 1fr;
    padding-inline: 14px;
  }

  .set-total-controls .button {
    width: 100%;
  }
}

@media (max-width: 390px) {
  .card-header {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .station-badge {
    width: 42px;
  }

  .percentage-badge {
    grid-column: 1 / -1;
    justify-self: stretch;
  }

  .score-summary strong {
    font-size: 24px;
  }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* =========================================================
   TEAM COLOURS — each operator card now keeps the colour of
   its matching team instead of using yellow for all stations.
   ========================================================= */

.station-card {
  border-top-color: var(--team-color);
}

.station-card .station-badge {
  background: linear-gradient(145deg, var(--team-light), var(--team-color));
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.10);
}

.station-card .percentage-badge {
  border: 1px solid var(--team-border);
  color: var(--team-dark);
  background: var(--team-tint);
}

.station-card .mini-progress > div {
  background: linear-gradient(90deg, var(--team-dark), var(--team-light));
}

.station-card input:focus {
  border-color: var(--team-color);
  box-shadow: 0 0 0 3px var(--team-focus);
}
