:root {
  --bg: #ece6d5;
  --bg-soft: rgba(255, 248, 231, 0.8);
  --panel: rgba(252, 248, 238, 0.9);
  --line: rgba(67, 56, 36, 0.12);
  --text: #30271d;
  --muted: #6f6657;
  --accent: #8a7d2f;
  --accent-strong: #605514;
  --shadow: 0 20px 50px rgba(78, 63, 39, 0.15);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --font-display: "Rockwell", "Georgia", serif;
  --font-body: "Aptos", "Trebuchet MS", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(170, 154, 66, 0.28), transparent 24%),
    radial-gradient(circle at top right, rgba(96, 85, 20, 0.18), transparent 20%),
    linear-gradient(180deg, #f6f1e3 0%, #ece3cb 56%, #e5dcc4 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.8), transparent);
}

button,
input,
table {
  font: inherit;
}

button {
  cursor: pointer;
}

code {
  padding: 0.08rem 0.36rem;
  border-radius: 999px;
  background: rgba(48, 39, 29, 0.08);
  font-size: 0.92em;
}

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

.page-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

.hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 1.5rem;
  padding: 2rem;
  border: 1px solid rgba(96, 85, 20, 0.12);
  border-radius: calc(var(--radius-lg) + 8px);
  background:
    linear-gradient(140deg, rgba(255, 251, 241, 0.98), rgba(242, 234, 211, 0.96)),
    linear-gradient(90deg, rgba(138, 125, 47, 0.08), rgba(96, 85, 20, 0.04));
  box-shadow: var(--shadow);
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -4rem -4rem auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(138, 125, 47, 0.26), transparent 66%);
}

.hero__brand {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

.hero__logo {
  width: clamp(140px, 20vw, 220px);
  height: auto;
  display: block;
}

.hero__content {
  width: 100%;
}

.eyebrow,
.section-heading__eyebrow {
  margin: 0 0 0.4rem;
  color: var(--accent-strong);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 700;
}

.hero h1,
.section-heading h2,
.modal__header h3 {
  margin: 0;
  font-family: var(--font-display);
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.hero h1 {
  max-width: none;
  font-size: clamp(2.2rem, 5vw, 3.8rem);
}

.layout {
  display: grid;
  gap: 1.2rem;
}

.panel {
  padding: 1.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(252, 248, 238, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

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

.section-heading__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
}

.section-heading h2 {
  font-size: clamp(1.5rem, 2vw, 2rem);
}

.upload-panel {
  display: grid;
  gap: 1rem;
}

.dropzone {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  align-items: center;
  min-height: 148px;
  padding: 1.1rem 1.2rem;
  border: 1.5px dashed rgba(96, 85, 20, 0.3);
  border-radius: var(--radius-md);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.85), rgba(249, 244, 230, 0.85));
  transition: transform 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

.dropzone.is-hovered,
.dropzone:focus-visible,
.dropzone:hover {
  transform: translateY(-2px);
  border-color: rgba(96, 85, 20, 0.55);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(244, 237, 214, 0.96));
  outline: none;
}

.dropzone__icon {
  display: grid;
  place-items: center;
  width: 70px;
  aspect-ratio: 1;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(138, 125, 47, 0.15), rgba(96, 85, 20, 0.06));
  color: var(--accent-strong);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
}

.dropzone__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.dropzone__subtitle {
  margin: 0.45rem 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.message {
  padding: 0.95rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  line-height: 1.5;
}

.message--hidden {
  display: none;
}

.message[data-tone="success"] {
  color: #19452f;
  border-color: rgba(46, 111, 82, 0.22);
  background: rgba(46, 111, 82, 0.09);
}

.message[data-tone="warning"] {
  color: #674f20;
  border-color: rgba(138, 125, 47, 0.22);
  background: rgba(138, 125, 47, 0.1);
}

.message[data-tone="danger"] {
  color: #6e241a;
  border-color: rgba(142, 59, 46, 0.24);
  background: rgba(142, 59, 46, 0.08);
}

.message[data-tone="info"] {
  color: #4f4637;
  border-color: rgba(48, 39, 29, 0.12);
  background: rgba(48, 39, 29, 0.05);
}

.file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.file-chip {
  display: grid;
  gap: 0.22rem;
  min-width: 220px;
  padding: 0.85rem 0.95rem;
  border: 1px solid rgba(96, 85, 20, 0.1);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
}

.file-chip__name {
  font-weight: 700;
}

.file-chip__meta {
  color: var(--muted);
  font-size: 0.92rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1rem;
}

.stat-card {
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.9), rgba(247, 241, 227, 0.76));
  box-shadow: 0 14px 30px rgba(78, 63, 39, 0.08);
}

.stat-card__label {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
}

.stat-card__value {
  display: block;
  margin-top: 0.25rem;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: -0.04em;
}

.stat-card__hint {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.control-panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 46px;
  padding: 0.78rem 1.1rem;
  border: 1px solid transparent;
  border-radius: 999px;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.button--primary {
  color: #fffaf1;
  background: linear-gradient(135deg, #7f7328, #5f5517);
  box-shadow: 0 12px 26px rgba(96, 85, 20, 0.25);
}

.button--ghost {
  color: var(--accent-strong);
  border-color: rgba(96, 85, 20, 0.16);
  background: rgba(255, 255, 255, 0.78);
}

.button--subtle {
  color: var(--text);
  border-color: rgba(48, 39, 29, 0.1);
  background: rgba(48, 39, 29, 0.05);
}

.button--danger {
  color: #fff6f2;
  background: linear-gradient(135deg, #915446, #7b2d23);
  box-shadow: 0 12px 26px rgba(123, 45, 35, 0.18);
}

.empty-state {
  padding: 1.1rem 1.2rem;
  border: 1px dashed rgba(96, 85, 20, 0.16);
  border-radius: var(--radius-md);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.58);
  line-height: 1.6;
}

.winner-card {
  position: relative;
  overflow: hidden;
  padding: 1.35rem;
  border-radius: calc(var(--radius-lg) - 4px);
  background:
    linear-gradient(135deg, rgba(96, 85, 20, 0.92), rgba(54, 46, 15, 0.92)),
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), transparent);
  color: #fffdf7;
}

.winner-card::after {
  content: "";
  position: absolute;
  inset: auto -30px -30px auto;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.18), transparent 68%);
}

.winner-card.is-hidden {
  display: none;
}

.winner-card--reveal {
  animation: winnerReveal 560ms cubic-bezier(0.2, 0.9, 0.2, 1);
}

@keyframes winnerReveal {
  0% {
    transform: scale(0.96);
    opacity: 0;
  }

  60% {
    transform: scale(1.02);
    opacity: 1;
  }

  100% {
    transform: scale(1);
  }
}

.winner-card__badge {
  display: inline-flex;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  font-size: 0.84rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.winner-card__id {
  margin: 1.1rem 0 0.2rem;
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 7vw, 5rem);
  line-height: 1;
}

.winner-card__name {
  margin: 0;
  max-width: 18ch;
  font-size: clamp(1.4rem, 2.5vw, 2rem);
}

.winner-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
  color: rgba(255, 255, 255, 0.84);
}

.winner-card__meta span {
  padding: 0.4rem 0.6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.winner-card__actions {
  margin-top: 1rem;
}

.history-list {
  display: grid;
  gap: 0.8rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 0.95rem 1rem;
  border: 1px solid rgba(96, 85, 20, 0.1);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
}

.history-item__order {
  font-family: var(--font-display);
  font-size: 1.35rem;
}

.history-item__name {
  font-weight: 700;
}

.history-item__meta {
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.45;
}

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

.modal.is-hidden {
  display: none;
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.loading-screen.is-hidden {
  display: none;
}

.loading-screen__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(25, 20, 12, 0.72);
  backdrop-filter: blur(10px);
}

.loading-screen__card {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 0.85rem;
  width: min(460px, 100%);
  padding: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 28px;
  background: rgba(248, 241, 222, 0.96);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  text-align: center;
}

.loading-screen__image {
  width: 100%;
  max-height: min(44vh, 320px);
  object-fit: cover;
  border-radius: 20px;
  box-shadow: 0 14px 30px rgba(48, 39, 29, 0.22);
}

.loading-screen__card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  color: var(--text);
}

.loading-screen__dots {
  display: flex;
  gap: 0.55rem;
}

.loading-screen__dots span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-strong);
  animation: loadingPulse 1s infinite ease-in-out;
}

.loading-screen__dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.loading-screen__dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes loadingPulse {
  0%,
  80%,
  100% {
    transform: scale(0.75);
    opacity: 0.45;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(33, 28, 22, 0.56);
  backdrop-filter: blur(8px);
}

.modal__dialog {
  position: relative;
  z-index: 1;
  width: min(980px, 100%);
  max-height: min(92vh, 920px);
  overflow: auto;
  padding: 1.3rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 28px;
  background: rgba(252, 248, 238, 0.98);
  box-shadow: 0 25px 60px rgba(17, 13, 8, 0.24);
}

.modal__dialog--wide {
  width: min(1120px, 100%);
}

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

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

.modal__close {
  width: 42px;
  aspect-ratio: 1;
  border: 1px solid rgba(48, 39, 29, 0.1);
  border-radius: 50%;
  background: rgba(48, 39, 29, 0.05);
}

.search-field {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1rem;
  color: var(--muted);
}

.search-field input {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(48, 39, 29, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
}

.table-wrap {
  overflow: auto;
  border: 1px solid rgba(48, 39, 29, 0.08);
  border-radius: 18px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
  background: rgba(255, 255, 255, 0.76);
}

.data-table th,
.data-table td {
  padding: 0.9rem 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(48, 39, 29, 0.08);
  vertical-align: top;
}

.data-table thead th {
  position: sticky;
  top: 0;
  background: #f7f1df;
  color: var(--accent-strong);
  font-size: 0.84rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
}

.status-pill--active {
  color: #19452f;
  background: rgba(46, 111, 82, 0.12);
}

.status-pill--drawn {
  color: #694f15;
  background: rgba(138, 125, 47, 0.12);
}

.details-content {
  display: grid;
  gap: 1rem;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
}

.detail-card {
  padding: 1rem;
  border: 1px solid rgba(96, 85, 20, 0.12);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.76);
}

.detail-card span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
}

.detail-card strong {
  display: block;
  margin-top: 0.3rem;
  font-size: 1rem;
  line-height: 1.45;
}

.detail-section {
  padding: 1rem;
  border: 1px solid rgba(96, 85, 20, 0.12);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.72);
}

.detail-section h4 {
  margin: 0 0 0.9rem;
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.meta-item {
  padding: 0.85rem;
  border-radius: 16px;
  background: rgba(48, 39, 29, 0.04);
}

.meta-item span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.meta-item strong {
  display: block;
  margin-top: 0.25rem;
}

.raw-row {
  border-radius: 16px;
  border: 1px solid rgba(48, 39, 29, 0.08);
  background: rgba(48, 39, 29, 0.03);
}

.raw-row + .raw-row {
  margin-top: 0.65rem;
}

.raw-row summary {
  cursor: pointer;
  padding: 0.85rem 1rem;
  font-weight: 700;
}

.raw-row__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
  padding: 0 1rem 1rem;
}

.raw-row__field {
  padding: 0.7rem 0.8rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.74);
}

.raw-row__field span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.raw-row__field strong {
  display: block;
  margin-top: 0.28rem;
  line-height: 1.4;
}

.mono {
  font-family: "Consolas", "Courier New", monospace;
}

@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .details-grid,
  .meta-grid,
  .raw-row__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 1rem, 100%);
    padding-top: 1rem;
  }

  .hero {
    padding: 1.2rem;
  }

  .hero__brand {
    justify-items: center;
  }

  .hero h1 {
    max-width: none;
  }

  .panel {
    padding: 1rem;
    border-radius: 24px;
  }

  .section-heading,
  .modal__header {
    flex-direction: column;
    align-items: stretch;
  }

  .section-heading__actions {
    width: 100%;
    flex-direction: column;
  }

  .dropzone,
  .history-item {
    grid-template-columns: 1fr;
  }

  .stats-grid,
  .details-grid,
  .meta-grid,
  .raw-row__grid {
    grid-template-columns: 1fr;
  }

  .control-panel__actions {
    flex-direction: column;
  }

  .button {
    width: 100%;
  }

  .winner-card__meta {
    flex-direction: column;
    align-items: flex-start;
  }

  .loading-screen__card {
    padding: 1rem;
  }
}
