:root {
  --rust: #a35236;
  --orange: #f49636;
  --ink: #221916;
  --muted: #766a63;
  --line: #eadbd3;
  --paper: #fffdf9;
  --cream: #f8f1ea;
  --green: #2f6f52;
  --shadow: 0 18px 45px rgba(51, 29, 19, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(244, 150, 54, 0.08), transparent 280px),
    var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(18px, 4vw, 48px);
  background: rgba(255, 253, 249, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand img,
.login-logo img,
.print-logo {
  display: block;
  object-fit: contain;
}

.brand img {
  width: 58px;
  height: 58px;
}

.brand-title {
  display: grid;
  gap: 2px;
}

.brand-title strong {
  color: var(--rust);
  font-size: 1rem;
}

.brand-title span {
  color: var(--muted);
  font-size: 0.82rem;
}

.main {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 440px);
  background: var(--paper);
}

.login-visual {
  position: relative;
  display: flex;
  align-items: end;
  min-height: 100vh;
  padding: clamp(26px, 6vw, 76px);
  overflow: hidden;
  color: white;
  background:
    linear-gradient(135deg, rgba(34, 25, 22, 0.76), rgba(163, 82, 54, 0.58)),
    url("logo_muladeiros.png") center / min(56vw, 720px) no-repeat,
    var(--rust);
}

.login-visual::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 34%;
  background: repeating-linear-gradient(
    -4deg,
    rgba(255, 255, 255, 0.08) 0 8px,
    transparent 8px 22px
  );
}

.login-copy {
  position: relative;
  max-width: 680px;
}

.login-copy h1,
.page-title h1 {
  margin: 0;
  line-height: 1.03;
  letter-spacing: 0;
}

.login-copy h1 {
  max-width: 640px;
  font-size: clamp(2.5rem, 7vw, 5.5rem);
}

.login-copy p {
  max-width: 520px;
  margin: 18px 0 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 1.04rem;
}

.login-panel {
  display: flex;
  align-items: center;
  padding: 24px;
  border-left: 1px solid var(--line);
  background: rgba(255, 253, 249, 0.96);
}

.login-card {
  width: 100%;
}

.login-logo {
  display: grid;
  justify-items: start;
  gap: 10px;
  margin-bottom: 28px;
}

.login-logo img {
  width: 136px;
  max-width: 52vw;
}

.login-logo strong {
  color: var(--rust);
  font-size: 1.15rem;
}

.form-grid {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 750;
}

.field-hint {
  color: var(--muted);
  font-size: 0.8rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 12px;
  border: 1px solid #ddc9bd;
  border-radius: 8px;
  background: white;
  color: var(--ink);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 4px rgba(244, 150, 54, 0.18);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.actions form {
  margin: 0;
}

.btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 15px;
  border-radius: 8px;
  font-weight: 800;
  color: var(--ink);
  background: #efe2d9;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

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

.btn-primary {
  color: white;
  background: linear-gradient(135deg, var(--rust), var(--orange));
  box-shadow: 0 12px 22px rgba(163, 82, 54, 0.22);
}

.btn-mono {
  color: white;
  background: var(--orange);
  box-shadow: 0 12px 22px rgba(244, 150, 54, 0.18);
}

.btn-outline {
  border: 1px solid #d6bfb1;
  background: white;
}

.btn-danger {
  color: white;
  background: #9d392f;
}

.helper,
.error {
  margin: 10px 0 0;
  font-size: 0.9rem;
}

.helper {
  color: var(--muted);
}

.error {
  display: none;
  color: #9d392f;
  font-weight: 700;
}

.error.is-visible {
  display: block;
}

.page-title {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  margin-bottom: 22px;
}

.page-title h1 {
  color: var(--rust);
  font-size: clamp(2rem, 5vw, 3.6rem);
}

.page-title p {
  max-width: 660px;
  margin: 8px 0 0;
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 22px;
}

.stat {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 8px 24px rgba(34, 25, 22, 0.05);
}

.stat strong {
  display: block;
  color: var(--rust);
  font-size: 1.65rem;
}

.stat span {
  color: var(--muted);
  font-size: 0.86rem;
}

.section {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.2rem;
}

.event-form,
.competitor-form {
  display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf4;
}

.event-form.is-open,
.competitor-form.is-open {
  display: grid;
}

.event-form .wide,
.competitor-form .wide {
  grid-column: span 2;
}

.event-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.event-card {
  display: grid;
  gap: 0;
  min-height: 214px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
  text-align: left;
}

.event-card-link {
  display: grid;
  gap: 14px;
  padding: 18px 18px 8px;
}

.event-card:hover {
  border-color: rgba(244, 150, 54, 0.85);
}

.event-card h3 {
  margin: 0;
  color: var(--rust);
  font-size: 1.28rem;
}

.event-meta {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.event-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  color: var(--green);
  font-weight: 800;
}

.event-delete-form {
  display: flex;
  justify-content: flex-end;
  padding: 0 18px 18px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--rust);
  background: #fff0df;
  font-size: 0.78rem;
  font-weight: 850;
}

.detail-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(163, 82, 54, 0.08), rgba(244, 150, 54, 0.08)),
    white;
}

.detail-hero h1 {
  margin: 4px 0 12px;
  color: var(--rust);
  font-size: clamp(1.8rem, 4vw, 3rem);
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

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

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid #f0e2d9;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--rust);
  background: #fff6ec;
  font-size: 0.82rem;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.empty {
  padding: 28px;
  color: var(--muted);
  border: 1px dashed #d8c2b5;
  border-radius: 8px;
  background: rgba(255, 250, 244, 0.7);
  text-align: center;
}

.print-report {
  display: none;
}

.print-only {
  display: none;
}

.print-competitor-report {
  display: none;
}

.competitor-cards {
  display: grid;
  gap: 14px;
}

.event-fee-panel {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #fffaf4, white);
  box-shadow: 0 10px 26px rgba(34, 25, 22, 0.06);
}

.event-fee-panel strong {
  display: block;
  color: var(--rust);
}

.event-fee-panel span {
  color: var(--muted);
  font-size: 0.88rem;
}

.event-fee-panel form {
  display: grid;
  grid-template-columns: 140px auto;
  gap: 8px;
}

.event-fee-panel input {
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid #ddc9bd;
  border-radius: 8px;
}

.competitor-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 12px 32px rgba(34, 25, 22, 0.07);
  animation: riseIn 0.28s ease both;
}

.competitor-card-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  background: linear-gradient(135deg, #fffaf4, #fff);
  border-bottom: 1px solid #f0e2d9;
}

.competitor-card-head h3 {
  margin: 0;
  color: var(--rust);
  font-size: 1.05rem;
}

.competitor-card-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.draw-chip {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  color: white;
  background: var(--rust);
  font-weight: 900;
}

.payment-badge {
  min-width: 88px;
  padding: 6px 9px;
  border-radius: 999px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 900;
}

.payment-badge.is-paid {
  color: #1f684c;
  background: #e4f4ec;
}

.payment-badge.is-pending {
  color: #8a4a18;
  background: #fff0df;
}

.competitor-card-body {
  display: grid;
  grid-template-columns: minmax(160px, 0.7fr) minmax(260px, 1fr) minmax(420px, 1.7fr);
  gap: 14px;
  padding: 14px;
}

.info-box {
  display: grid;
  align-content: center;
  gap: 4px;
  min-height: 86px;
  padding: 12px;
  border: 1px solid #f0e2d9;
  border-radius: 8px;
  background: #fffaf4;
}

.info-box span,
.payment-card-form label,
.score-card-form label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.info-box strong {
  color: var(--ink);
}

.info-box small {
  color: var(--muted);
}

.payment-card-form,
.score-card-form {
  display: grid;
  gap: 10px;
  align-items: end;
}

.payment-card-form {
  grid-template-columns: minmax(90px, 1fr) minmax(120px, 1fr) auto;
}

.score-card-form {
  grid-template-columns: repeat(4, minmax(72px, 1fr)) auto;
}

.score-card-form .wide {
  grid-column: span 2;
}

.payment-card-form label,
.score-card-form label {
  display: grid;
  gap: 5px;
}

.payment-card-form input,
.payment-card-form select,
.score-card-form input {
  width: 100%;
  min-height: 39px;
  padding: 8px 10px;
  border: 1px solid #ddc9bd;
  border-radius: 8px;
  background: white;
}

.management-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.management-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 8px 24px rgba(34, 25, 22, 0.05);
}

.mini-form {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.list-stack {
  display: grid;
  gap: 8px;
}

.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid #f0e2d9;
  border-radius: 8px;
  background: #fffaf4;
}

.list-row span,
.muted-line {
  color: var(--muted);
  font-size: 0.84rem;
}

.list-row form,
.delete-card-form {
  margin: 0;
}

.list-row .btn,
.delete-card-form .btn {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.84rem;
}

.delete-card-form {
  display: flex;
  justify-content: flex-end;
  grid-column: 1 / -1;
  padding-top: 2px;
}

.muted-line {
  display: block;
  margin-top: 4px;
}

.score-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(72px, 1fr)) auto;
  gap: 6px;
  align-items: center;
}

.score-form input,
.payment-form input,
.payment-form select,
.payout-row input {
  width: 100%;
  min-height: 36px;
  padding: 7px 8px;
  border: 1px solid #ddc9bd;
  border-radius: 8px;
}

.payment-form {
  display: grid;
  grid-template-columns: 86px 112px auto;
  gap: 6px;
  align-items: center;
}

.finance-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr)) minmax(220px, 260px);
  gap: 16px;
  align-items: end;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 14px 34px rgba(34, 25, 22, 0.07);
}

.finance-summary {
  min-height: 64px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 12px;
  border-radius: 8px;
  background: #fff0df;
}

.finance-summary span {
  color: var(--muted);
  font-size: 0.86rem;
}

.finance-summary strong {
  color: var(--rust);
  font-size: 1.25rem;
}

.payout-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.payout-row {
  display: grid;
  grid-template-columns: minmax(70px, 1fr) 86px minmax(90px, auto);
  align-items: center;
  gap: 6px;
  padding: 12px;
  border: 1px solid #f0e2d9;
  border-radius: 8px;
  background: #fffaf4;
  animation: riseIn 0.22s ease both;
}

.payout-row.is-hidden {
  display: none;
}

.payout-row span {
  font-weight: 800;
}

.payout-row strong {
  color: var(--green);
  font-size: 0.9rem;
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 860px) {
  .login-page {
    grid-template-columns: 1fr;
  }

  .login-visual {
    min-height: 36vh;
    align-items: center;
  }

  .login-panel {
    border-left: 0;
  }

  .topbar,
  .page-title,
  .section-head,
  .detail-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .detail-hero {
    grid-template-columns: 1fr;
  }

  .stats,
  .event-grid,
  .management-grid,
  .finance-form,
  .payout-grid {
    grid-template-columns: 1fr;
  }

  .payment-form,
  .score-form,
  .event-fee-panel,
  .event-fee-panel form,
  .competitor-card-head,
  .competitor-card-body,
  .payment-card-form,
  .score-card-form,
  .payout-row {
    grid-template-columns: 1fr;
  }

  .score-card-form .wide {
    grid-column: auto;
  }

  .event-form,
  .competitor-form {
    grid-template-columns: 1fr;
  }

  .event-form .wide,
  .competitor-form .wide {
    grid-column: auto;
  }

  .actions {
    width: 100%;
  }

  .btn {
    flex: 1 1 auto;
  }
}

@media (max-width: 560px) {
  .brand-title span {
    display: none;
  }

  .main {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .login-copy h1 {
    font-size: 2.25rem;
  }
}

@media print {
  @page {
    margin: 12mm;
  }

  body {
    background: white;
    color: #000;
  }

  .no-print,
  .topbar,
  .detail-hero,
  .section-head,
  .competitor-form,
  .app-actions,
  .screen-only {
    display: none !important;
  }

  .main {
    width: 100%;
    padding: 0;
  }

  .print-report {
    display: block;
  }

  .print-only {
    display: none;
  }

  .print-competitor-report {
    display: block;
  }

  .print-header {
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: 18px;
    align-items: center;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 2px solid #000;
  }

  .print-logo {
    width: 88px;
    height: 88px;
  }

  .print-header h1 {
    margin: 0 0 5px;
    color: #000;
    font-size: 22pt;
  }

  .print-header p {
    margin: 2px 0;
    color: #000;
    font-size: 11pt;
  }

  .table-wrap {
    border: 0;
    overflow: visible;
  }

  table {
    min-width: 0;
    font-size: 10.5pt;
  }

  th,
  td {
    color: #000;
    border: 1px solid #000;
    background: white;
    padding: 8px;
  }

  .print-note {
    height: 38px;
  }
}
