:root {
  --bg: #edf3ff;
  --bg-soft: #dde9ff;
  --card: #ffffff;
  --ink: #172033;
  --muted: #64748b;
  --primary: #173b7a;
  --primary-strong: #102a58;
  --accent: #2b6fcc;
  --danger: #d93f3f;
  --ring: rgba(43, 111, 204, 0.25);
  --shadow: 0 20px 45px rgba(31, 41, 51, 0.08);
  --radius-lg: 22px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  font-family: "DM Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 18%, #d7e4ff 0%, transparent 40%),
    radial-gradient(circle at 92% 22%, #d8edff 0%, transparent 35%),
    linear-gradient(140deg, var(--bg), #f9fbff 65%, var(--bg-soft));
  position: relative;
  overflow-x: hidden;
}

.bg-shape {
  position: fixed;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(18px);
  z-index: 0;
  opacity: 0.65;
}

.bg-shape-a {
  width: 360px;
  height: 360px;
  background: #c9dcff;
  top: -100px;
  right: -80px;
}

.bg-shape-b {
  width: 300px;
  height: 300px;
  background: #cde7ff;
  bottom: -80px;
  left: -110px;
}

.app-shell {
  width: min(1200px, calc(100% - 2rem));
  margin: 1.4rem auto 2rem;
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.tab-nav-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
  position: relative;
}

.tab-nav {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(23, 59, 122, 0.2);
  border-radius: 999px;
  padding: 0.32rem;
}

.tab-btn {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #475569;
  font: inherit;
  font-weight: 700;
  padding: 0.5rem 0.88rem;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.tab-btn:hover {
  background: #ebf2ff;
  color: #1f2937;
}

.tab-btn.is-active {
  background: linear-gradient(140deg, var(--primary), #2a5fb4);
  color: #fff;
}

.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(23, 59, 122, 0.2);
  background: #edf4ff;
  color: #102a58;
  border-radius: 999px;
  padding: 0.5rem 0.85rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.tab-panel {
  animation: card-in 0.35s ease both;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 700;
}

h1,
h2,
h3 {
  font-family: "Sora", sans-serif;
  margin: 0;
}

h1 {
  font-size: clamp(1.7rem, 2.5vw, 2.3rem);
}

h2 {
  font-size: 1.25rem;
  margin-bottom: 0.35rem;
}

h3 {
  font-size: 1rem;
}

.shop-name-display {
  margin: 0;
  font-weight: 700;
  color: var(--primary-strong);
  font-size: 1rem;
}

.layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.card {
  background: color-mix(in srgb, var(--card) 90%, #ebf2ff 10%);
  border: 1px solid rgba(23, 59, 122, 0.14);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1rem;
  backdrop-filter: blur(8px);
  animation: card-in 0.55s ease both;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.muted {
  margin: 0 0 0.8rem;
  color: var(--muted);
}

.form-grid,
.settings-grid,
.records-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-weight: 700;
  font-size: 0.9rem;
}

input[type="text"],
input[type="tel"],
input[type="number"],
input[type="url"],
input[type="datetime-local"],
select {
  width: 100%;
  border: 1px solid #c5d7f2;
  border-radius: 10px;
  padding: 0.58rem 0.68rem;
  font: inherit;
  color: var(--ink);
  background: #fffdfa;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--ring);
}

.wheel-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 470px;
  margin: 0.9rem auto 0.55rem;
  position: relative;
}

#wheelCanvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
  border: 12px solid #fff2df;
  box-shadow: inset 0 0 0 8px #ffe3c2, 0 12px 28px rgba(31, 41, 51, 0.15);
  background: #fffaf5;
}

.wheel-pointer {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -6px;
  width: 0;
  height: 0;
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-top: 26px solid #111827;
  filter: drop-shadow(0 5px 5px rgba(17, 24, 39, 0.35));
  z-index: 2;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.52rem;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.62rem 0.9rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.2s ease, opacity 0.2s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(140deg, var(--primary), #2a5fb4);
  color: #fff;
}

.btn-secondary {
  background: linear-gradient(140deg, var(--accent), #5e8ed8);
  color: #fff;
}

.btn-ghost {
  background: #f6f7f9;
  color: #1f2937;
}

.btn-danger {
  background: #ffe9e9;
  color: #8b1d1d;
}

.btn-small {
  padding: 0.4rem 0.7rem;
  font-size: 0.83rem;
}

.status {
  margin: 0.8rem 0 0;
  font-weight: 700;
  color: var(--accent);
}

.result-card {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.result-details {
  border: 1px dashed #bfd3f3;
  background: #f7faff;
  border-radius: 12px;
  padding: 0.72rem;
}

.result-details p {
  margin: 0.34rem 0;
}

.hidden {
  display: none !important;
}

.coupon-preview-wrap {
  border: 1px solid #c5d7f2;
  border-radius: 14px;
  padding: 0.5rem;
  background: #fff;
}

#couponCanvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 9px;
}

.settings-card {
  margin-bottom: 1rem;
}

.settings-header {
  margin-bottom: 0.6rem;
}

.manual-time-box {
  background: #eef4ff;
  border: 1px solid #c9d8f3;
  border-radius: 12px;
  padding: 0.58rem;
  display: grid;
  gap: 0.5rem;
}

.checkbox-label {
  flex-direction: row;
  align-items: center;
  font-weight: 700;
  gap: 0.5rem;
}

.prize-manager {
  margin-top: 0.8rem;
}

.records-card .prize-manager {
  margin-top: 0;
  margin-bottom: 0.8rem;
}

.prize-manager-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 550px;
}

th,
td {
  border-bottom: 1px solid #d6e1f4;
  padding: 0.45rem;
  text-align: left;
  vertical-align: middle;
}

th {
  font-family: "Sora", sans-serif;
  font-size: 0.85rem;
}

.centered {
  text-align: center;
}

.settings-actions {
  margin-top: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.records-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.records-controls {
  margin-bottom: 0.65rem;
}

.records-summary {
  margin: 0 0 0.6rem;
  color: #334155;
  font-weight: 700;
}

.records-table-wrap {
  max-height: 700px;
  overflow: auto;
  border: 1px solid #d0def4;
  border-radius: 12px;
  background: #fffdfa;
}

#recordsTable {
  min-width: 980px;
}

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.record-actions .btn {
  padding: 0.32rem 0.55rem;
  font-size: 0.77rem;
}

.record-row-selected td {
  background: #f2f7ff;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.2rem 0.58rem;
  font-size: 0.76rem;
}

.status-pending {
  background: #fff5cd;
  color: #8a6700;
}

.status-completed {
  background: #dff8ea;
  color: #0b6b3f;
}

.status-rejected {
  background: #ffe4e4;
  color: #8c1f1f;
}

.status-expired {
  background: #e8ebf0;
  color: #4b5563;
}

.bulk-actions-bar {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  left: auto;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: flex-end;
  width: min(100%, 420px);
  padding: 0.95rem 1rem;
  background: #ffffff;
  border: 1px solid #d0def4;
  border-radius: 18px;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.12);
  transition: opacity 0.2s ease, transform 0.2s ease;
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
}

.bulk-actions-bar.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.bulk-actions-bar.hidden {
  display: none !important;
}

.bulk-actions-bar label {
  min-width: 220px;
}

.select-col {
  width: 52px;
}

.record-select-checkbox,
#selectAllRecords {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  backdrop-filter: blur(2px);
}

.modal-panel {
  position: relative;
  width: min(520px, calc(100% - 1.2rem));
  background: #fff;
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.28);
}

.modal-form {
  margin-top: 0.55rem;
  display: grid;
  gap: 0.6rem;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.toast-container {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: grid;
  gap: 0.45rem;
  z-index: 50;
}

.toast {
  min-width: 240px;
  max-width: 340px;
  border-radius: 12px;
  padding: 0.6rem 0.75rem;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.2);
  animation: toast-in 0.25s ease both;
}

.toast-info {
  background: #334155;
}

.toast-success {
  background: #0f9d8a;
}

.toast-error {
  background: #d93f3f;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .layout,
  .form-grid,
  .settings-grid,
  .records-controls {
    grid-template-columns: 1fr;
  }

  .bulk-actions-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .bulk-actions-bar label {
    min-width: 0;
  }
}

@media (max-width: 760px) {
  .hamburger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .tab-nav {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 0.45rem);
    z-index: 20;
    flex-direction: column;
    border-radius: 16px;
    padding: 0.45rem;
    background: rgba(255, 252, 247, 0.98);
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.13);
  }

  .tab-nav.open {
    display: flex;
  }

  .tab-btn {
    width: 100%;
    text-align: left;
  }

  .bulk-actions-bar {
    right: 0.85rem;
    left: 0.85rem;
    width: auto;
    padding: 0.95rem 0.9rem;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: calc(100% - 1rem);
    margin-top: 0.7rem;
  }

  .card {
    padding: 0.78rem;
    border-radius: 16px;
  }

  .action-row .btn {
    flex: 1 1 calc(50% - 0.6rem);
  }

  .shop-name-display {
    font-size: 0.9rem;
  }

  .records-header {
    flex-direction: column;
  }

  .toast-container {
    right: 0.5rem;
    left: 0.5rem;
    bottom: 0.5rem;
  }

  .toast {
    min-width: 0;
    max-width: unset;
  }
}
