:root {
  --blue: #0067b1;
  --blue-dark: #00518c;
  --blue-light: #e6f0f8;
  --red: #bf311a;
  --red-dark: #9c2713;
  --red-light: #fbeae7;
  --dark: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f3f6fa;
  --white: #fff;
  --green: #15803d;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 4px 14px rgba(16, 24, 40, 0.06);
  font-family:
    'Segoe UI',
    system-ui,
    -apple-system,
    Roboto,
    Arial,
    sans-serif;
  color: var(--dark);
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  background: var(--bg);
}
body {
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.45;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
a {
  color: var(--blue);
}
.hidden {
  display: none !important;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 13px;
}
.nowrap {
  white-space: nowrap;
}
.num {
  font-variant-numeric: tabular-nums;
}

/* ---------- header ---------- */
.topbar {
  background: var(--blue);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #fff;
}
.brand .logo-pill {
  background: #fff;
  border-radius: 8px;
  padding: 4px 8px;
  display: flex;
}
.brand img {
  height: 34px;
  display: block;
}
.brand-title {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.2px;
}
.nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-left: auto;
  align-items: center;
}
.nav a,
.nav button.linkish {
  color: #fff;
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  background: none;
  border: 0;
  cursor: pointer;
}
.nav a:hover,
.nav button.linkish:hover {
  background: rgba(255, 255, 255, 0.14);
}
.nav a.active {
  background: rgba(255, 255, 255, 0.22);
}
.ticket-badge {
  background: #fff;
  color: var(--blue);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.ticket-badge .n {
  font-size: 18px;
}
.ticket-badge.zero {
  color: var(--red);
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 22px 18px 90px;
}
h1 {
  font-size: 26px;
  margin: 4px 0 6px;
}
h2 {
  font-size: 20px;
  margin: 0 0 12px;
}
h3 {
  font-size: 17px;
  margin: 0 0 8px;
}

/* ---------- banners & cards ---------- */
.banner {
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-weight: 600;
  display: flex;
  gap: 10px;
  align-items: center;
}
.banner.closed {
  background: var(--red);
  color: #fff;
}
.banner.info {
  background: var(--blue-light);
  color: var(--blue-dark);
  font-weight: 500;
}
.banner.warn {
  background: var(--red-light);
  color: var(--red-dark);
}
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.spacer {
  flex: 1;
}

/* ---------- buttons & inputs ---------- */
.btn {
  border: 0;
  border-radius: 8px;
  padding: 9px 16px;
  font-weight: 700;
  cursor: pointer;
  background: var(--blue);
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  text-decoration: none;
}
.btn:hover:not(:disabled) {
  background: var(--blue-dark);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn.red {
  background: var(--red);
}
.btn.red:hover:not(:disabled) {
  background: var(--red-dark);
}
.btn.ghost {
  background: #fff;
  color: var(--blue);
  border: 1.5px solid var(--blue);
}
.btn.ghost:hover:not(:disabled) {
  background: var(--blue-light);
}
.btn.plain {
  background: transparent;
  color: var(--dark);
  border: 1px solid var(--line);
  font-weight: 600;
}
.btn.plain:hover:not(:disabled) {
  background: #f9fafb;
}
.btn.sm {
  padding: 5px 10px;
  font-size: 13px;
}
.btn.lg {
  padding: 14px 26px;
  font-size: 18px;
}
.btn.xl {
  padding: 18px 40px;
  font-size: 24px;
  border-radius: 12px;
}
label.field {
  display: block;
  margin-bottom: 12px;
}
label.field > span {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
}
input[type='text'],
input[type='email'],
input[type='number'],
input[type='search'],
textarea,
select {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
}
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 103, 177, 0.15);
}
textarea {
  min-height: 80px;
  resize: vertical;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}
.error-text {
  color: var(--red);
  font-weight: 600;
  font-size: 14px;
  min-height: 20px;
}

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(160deg, var(--blue) 0%, var(--blue-dark) 55%, #003a66 100%);
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 32px 30px;
  width: 100%;
  max-width: 410px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.login-card .logo {
  display: block;
  height: 58px;
  margin: 0 auto 10px;
}
.login-card h1 {
  text-align: center;
  font-size: 22px;
  margin: 0 0 4px;
}
.login-card .sub {
  text-align: center;
  color: var(--muted);
  margin: 0 0 22px;
}
.code-input {
  font-size: 30px !important;
  letter-spacing: 10px;
  text-align: center;
  font-weight: 800;
}
.dev-code {
  background: #fef3c7;
  color: #92400e;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 14px;
}
.dev-code b {
  font-size: 18px;
  letter-spacing: 2px;
}

/* ---------- prize grid ---------- */
.intro {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.prize-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}
.prize {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.prize.won {
  outline: 3px solid var(--red);
}
.photo {
  aspect-ratio: 16 / 10;
  background: var(--blue-light);
  position: relative;
  overflow: hidden;
}
.photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo .ph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--blue) 0%, #2b8ad0 100%);
}
.photo .ph svg {
  width: 34%;
  height: auto;
  opacity: 0.9;
}
.winner-ribbon {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--red);
  color: #fff;
  font-weight: 800;
  padding: 7px 12px;
  text-align: center;
}
.prize-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.prize-name {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
}
.prize-desc {
  color: var(--muted);
  font-size: 14px;
}
.prize-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
}
.chip {
  background: var(--bg);
  border-radius: 999px;
  padding: 3px 10px;
  font-weight: 600;
  white-space: nowrap;
}
.chip.mine {
  background: var(--blue-light);
  color: var(--blue-dark);
}
.chip.win {
  background: var(--red-light);
  color: var(--red-dark);
}
.enter-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: auto;
  padding-top: 6px;
}
.stepper {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.stepper button {
  width: 34px;
  height: 38px;
  border: 0;
  background: #f9fafb;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  color: var(--blue);
}
.stepper button:disabled {
  color: #c0c4cc;
  cursor: default;
}
.stepper input {
  width: 46px;
  border: 0 !important;
  text-align: center;
  font-weight: 800;
  font-size: 16px;
  padding: 0 !important;
  box-shadow: none !important;
  -moz-appearance: textfield;
}
.stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}
.enter-row .btn {
  flex: 1;
  height: 41px;
  white-space: nowrap;
}

/* ---------- tables ---------- */
.table-wrap {
  overflow-x: auto;
}
table.t {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}
table.t th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
}
table.t td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.t tr:last-child td {
  border-bottom: 0;
}
table.t td.actions {
  white-space: nowrap;
  text-align: right;
}
/* Narrower tables (Admin → Employees): tighter cells, email under the name */
table.t.compact th,
table.t.compact td {
  padding: 8px 9px;
}
table.t td.who .email {
  overflow-wrap: anywhere;
}
.badge {
  display: inline-block;
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 12px;
  font-weight: 700;
  background: var(--blue-light);
  color: var(--blue-dark);
}
.badge.red {
  background: var(--red-light);
  color: var(--red-dark);
}
.badge.green {
  background: #dcfce7;
  color: var(--green);
}
.thumb {
  width: 54px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--blue-light);
  display: block;
}

/* ---------- stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.stat .label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}
.stat .value {
  font-size: 30px;
  font-weight: 800;
  color: var(--blue);
  line-height: 1.15;
}
.stat .value.red {
  color: var(--red);
}

/* ---------- admin tabs ---------- */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--line);
}
.tabs a {
  padding: 9px 14px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 700;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}
.tabs a.active {
  color: var(--blue);
  border-color: var(--blue);
}
.switch {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.switch .track {
  width: 56px;
  height: 30px;
  border-radius: 999px;
  background: var(--red);
  position: relative;
  transition: background 0.15s;
}
.switch .track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.15s;
}
.switch.on .track {
  background: var(--green);
}
.switch.on .track::after {
  left: 29px;
}
.switch .lbl {
  font-weight: 800;
  font-size: 18px;
}

/* ---------- draw stage ---------- */
.draw-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 18px;
  align-items: start;
}
.draw-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.draw-item {
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  border: 2px solid transparent;
  text-align: left;
  width: 100%;
}
.draw-item.sel {
  border-color: var(--blue);
}
.draw-item .n {
  font-weight: 700;
}
.stage {
  background: linear-gradient(160deg, var(--blue) 0%, var(--blue-dark) 70%);
  color: #fff;
  border-radius: 16px;
  padding: 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
  min-height: 330px;
}
.stage .prize-title {
  font-size: 30px;
  font-weight: 800;
  margin-bottom: 4px;
}
.stage .pool {
  opacity: 0.85;
  margin-bottom: 18px;
}
.stage .reel {
  font-size: 46px;
  font-weight: 800;
  min-height: 70px;
  margin: 16px 0;
  letter-spacing: 0.5px;
}
.stage .reel.spinning {
  opacity: 0.85;
  filter: blur(0.4px);
}
.stage .reel.final {
  color: #ffe08a;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  animation: pop 0.5s ease-out;
}
.stage .winner-label {
  text-transform: uppercase;
  letter-spacing: 3px;
  font-weight: 700;
  opacity: 0.9;
}
@keyframes pop {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }
  70% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
.confetti {
  position: absolute;
  top: -12px;
  width: 10px;
  height: 16px;
  opacity: 0.95;
  animation: fall linear forwards;
  pointer-events: none;
}
@keyframes fall {
  to {
    transform: translateY(420px) rotate(540deg);
    opacity: 0.9;
  }
}

/* ---------- board (TV) ---------- */
body.board-mode {
  background: linear-gradient(160deg, #004f89 0%, var(--blue) 45%, #003a66 100%);
  min-height: 100vh;
}
.board {
  padding: 26px 34px;
  color: #fff;
}
.board-head {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-bottom: 18px;
}
.board-head .logo-pill {
  background: #fff;
  border-radius: 12px;
  padding: 8px 14px;
}
.board-head img {
  height: 60px;
  display: block;
}
.board-head h1 {
  font-size: 40px;
  margin: 0;
}
.board-head .status {
  font-size: 20px;
  opacity: 0.92;
}
.board-head .total {
  margin-left: auto;
  text-align: right;
}
.board-head .total .big {
  font-size: 52px;
  font-weight: 800;
  line-height: 1;
}
.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}
.board-card {
  background: #fff;
  color: var(--dark);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.board-card .photo {
  aspect-ratio: 16 / 10;
}
.board-card .bc-body {
  padding: 12px 16px 14px;
}
.board-card .bc-name {
  font-size: 21px;
  font-weight: 800;
  line-height: 1.2;
}
.board-card .bc-count {
  font-size: 40px;
  font-weight: 800;
  color: var(--blue);
  line-height: 1.1;
}
.board-card .bc-count small {
  font-size: 16px;
  color: var(--muted);
  font-weight: 700;
}
.board-card.won .bc-winner {
  background: var(--red);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  padding: 10px 16px;
}
.board-foot {
  margin-top: 18px;
  opacity: 0.75;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
}
.board-foot a {
  color: #fff;
}

/* ---------- dialog & toast ---------- */
dialog {
  border: 0;
  border-radius: 14px;
  padding: 0;
  width: min(520px, 94vw);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
dialog::backdrop {
  background: rgba(15, 23, 42, 0.55);
}
.dlg-head {
  padding: 18px 20px 6px;
  font-size: 19px;
  font-weight: 800;
}
.dlg-body {
  padding: 6px 20px 8px;
  max-height: 70vh;
  overflow: auto;
}
.dlg-foot {
  padding: 12px 20px 18px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
#toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--dark);
  color: #fff;
  padding: 11px 18px;
  border-radius: 10px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  animation: toastIn 0.2s ease-out;
  max-width: 92vw;
}
.toast.ok {
  background: var(--green);
}
.toast.err {
  background: var(--red);
}
@keyframes toastIn {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
}
.empty {
  text-align: center;
  color: var(--muted);
  padding: 30px;
}
.loading {
  text-align: center;
  padding: 60px;
  color: var(--muted);
}

@media (max-width: 600px) {
  .topbar {
    position: static;
  }
  .topbar-inner {
    padding: 8px 12px;
    gap: 8px;
  }
  .brand img {
    height: 28px;
  }
  .nav {
    gap: 0;
    margin-left: 0;
    width: 100%;
  }
  .nav a,
  .nav button.linkish {
    padding: 6px 8px;
    font-size: 13px;
  }
  .ticket-badge {
    margin-left: auto;
    padding: 4px 10px;
  }
  main {
    padding: 16px 12px 90px;
  }
  h1 {
    font-size: 22px;
  }
}
@media (max-width: 820px) {
  .draw-layout {
    grid-template-columns: 1fr;
  }
  .brand-title {
    display: none;
  }
  .grid2 {
    grid-template-columns: 1fr;
  }
  .board-head {
    flex-wrap: wrap;
  }
  .board-head h1 {
    font-size: 28px;
  }
}

/* ---------- prize photo upload ---------- */
.thumb-btn {
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  border-radius: 8px;
  display: block;
}
.thumb-btn .thumb {
  width: 84px;
  height: 56px;
}
.thumb-btn:hover .thumb {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.thumb.add {
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--blue);
  border: 1.5px dashed var(--blue);
  background: var(--blue-light);
  line-height: 1.2;
}
.photo-picker {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}
.pp-preview {
  width: 180px;
  aspect-ratio: 16 / 10;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  background: var(--blue-light);
  flex: none;
}
.pp-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.pp-preview .ph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--blue) 0%, #2b8ad0 100%);
}
.pp-preview .ph svg {
  width: 34%;
}
.pp-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  flex: 1;
  min-width: 180px;
}

.ms-btn {
  background: #2f2f2f;
}
.ms-btn:hover:not(:disabled) {
  background: #111;
}

/* disabled employees */
tr.is-disabled td:not(.actions) {
  opacity: 0.5;
}
tr.is-disabled td .badge.red {
  opacity: 1;
}

.badge.super {
  background: var(--blue);
  color: #fff;
}
.lock {
  display: inline-block;
  padding: 0 6px;
  cursor: help;
  opacity: 0.7;
}

/* row "more actions" menu */
.more {
  position: relative;
  display: inline-block;
}
.more .menu {
  display: none;
  position: fixed;
  z-index: 60;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.18);
  border: 1px solid var(--line);
  padding: 6px;
  min-width: 190px;
  text-align: left;
}
.more.open .menu {
  display: block;
}
.more .menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 8px 10px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}
.more .menu button:hover {
  background: var(--bg);
}
.more .menu button.danger {
  color: var(--red);
}

/* Admin > Employees: the coins-on-hand number opens that employee's coin history */
.coin-link {
  background: none;
  border: 0;
  padding: 2px 6px;
  margin: -2px -6px;
  border-radius: 6px;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.coin-link:hover,
.coin-link:focus-visible {
  background: var(--blue-light);
}
