:root {
  --green: #0f6a42;
  --green-dark: #07482d;
  --lime: #9fc757;
  --gold: #c49334;
  --ink: #17211d;
  --muted: #607069;
  --line: #dbe5df;
  --soft: #f4f8f5;
  --white: #ffffff;
  --danger: #b42318;
  --shadow: 0 16px 44px rgba(23, 33, 29, 0.12);
}

html {
  scroll-behavior: smooth;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: #f8fbf8;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

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

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  color: var(--green-dark);
}

.pin {
  width: 30px;
  height: 30px;
  border: 2px solid var(--green);
  border-radius: 50%;
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.pin:before {
  content: "";
  width: 2px;
  height: 17px;
  background: var(--green);
}

.pin:after {
  content: "";
  position: absolute;
  top: 7px;
  left: 15px;
  border-left: 10px solid var(--gold);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}

.nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.page {
  width: min(1160px, calc(100% - 36px));
  margin: 0 auto;
  padding: clamp(28px, 5vw, 56px) 0;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  align-items: center;
  gap: clamp(28px, 5vw, 58px);
  min-height: calc(100vh - 86px);
  padding-bottom: 34px;
}

.hero h1 {
  margin: 0 0 22px;
  font-size: clamp(46px, 7vw, 84px);
  line-height: 0.96;
  letter-spacing: 0;
}

.hero p, .lead {
  color: var(--muted);
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.55;
  margin: 0;
}

.hero-panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.mini-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-top: 14px;
  background: var(--soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid var(--green);
  border-radius: 8px;
  background: var(--green);
  color: white;
  font-weight: 750;
  cursor: pointer;
  text-decoration: none;
  font-size: 15px;
}

.btn:hover { background: var(--green-dark); text-decoration: none; }
.btn.secondary { background: white; color: var(--green); }
.btn.secondary:hover { background: var(--soft); }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.small { min-height: 34px; padding: 7px 11px; font-size: 13px; }

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

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.check-row input {
  width: auto;
}

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

.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 8px 22px rgba(23, 33, 29, 0.06);
}

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

.section-title h1, .section-title h2, .card h2, .card h3 {
  margin: 0;
  letter-spacing: 0;
}

.muted { color: var(--muted); }
.error { color: var(--danger); font-weight: 700; }
.success { color: var(--green-dark); font-weight: 700; }

.form {
  display: grid;
  gap: 14px;
}

.field { display: grid; gap: 7px; }
.field label { font-weight: 750; font-size: 14px; color: #24342d; }
.field small { color: var(--muted); }

input, select, textarea {
  width: 100%;
  border: 1px solid #cbd8d0;
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: white;
  font: inherit;
}

textarea { min-height: 110px; resize: vertical; }

.crop-panel {
  display: none;
  gap: 16px;
  align-items: center;
  margin-top: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.crop-panel.is-active {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
}

.crop-preview-wrap {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid white;
  box-shadow: 0 8px 22px rgba(23, 33, 29, 0.12);
  background: white;
}

.crop-preview {
  width: 100%;
  height: 100%;
}

.crop-controls {
  display: grid;
  gap: 10px;
}

.crop-controls label {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.crop-controls input[type="range"] {
  padding: 0;
  accent-color: var(--green);
}

.claim-side {
  align-self: start;
}

.claim-preview {
  margin-top: 22px;
  padding: 18px;
  border-radius: 8px;
  border: 1px solid rgba(15, 106, 66, 0.2);
  background:
    linear-gradient(145deg, rgba(15, 106, 66, 0.08), rgba(196, 147, 52, 0.12)),
    #ffffff;
  box-shadow: 0 12px 30px rgba(23, 33, 29, 0.1);
}

.claim-preview-top {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.claim-preview-avatar {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--green);
  color: white;
  border: 4px solid white;
  box-shadow: 0 10px 24px rgba(23, 33, 29, 0.16);
  font-size: 28px;
  font-weight: 850;
}

.claim-preview-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.claim-preview strong {
  display: block;
  font-size: 24px;
  line-height: 1.1;
}

.claim-preview span {
  color: var(--muted);
}

.claim-preview-events {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.claim-preview-events div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(219, 229, 223, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.claim-preview-events strong {
  font-size: 14px;
  text-align: right;
}

.claim-preview-url {
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--green-dark);
  color: white;
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.dashboard-photo {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.dashboard-photo-avatar {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--green);
  color: white;
  border: 4px solid white;
  box-shadow: 0 8px 22px rgba(23, 33, 29, 0.12);
  font-size: 26px;
  font-weight: 850;
}

.dashboard-photo-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dashboard-photo strong {
  display: block;
  font-size: 15px;
}

.dashboard-photo span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  margin-top: 3px;
}

.template-import {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  scroll-margin-top: 96px;
}

.template-series-field[hidden] {
  display: none;
}

#manual-tournament {
  scroll-margin-top: 96px;
}

.template-top-link {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  color: var(--green);
  font-size: 22px;
  font-weight: 850;
  line-height: 1;
  text-decoration: none;
}

.template-top-link:hover {
  background: var(--soft);
  text-decoration: none;
}

.template-event-list {
  display: grid;
  gap: 10px;
}

.template-event {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  cursor: pointer;
}

.template-event:hover {
  border-color: rgba(15, 106, 66, 0.42);
  background: #ffffff;
}

.template-event input {
  width: auto;
  margin-top: 4px;
  accent-color: var(--green);
}

.template-event strong {
  display: block;
  line-height: 1.25;
}

.template-event small {
  display: block;
  color: var(--muted);
  line-height: 1.45;
  margin-top: 3px;
}

.template-event[hidden] {
  display: none;
}

.profile-head {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  gap: clamp(20px, 4vw, 34px);
  align-items: center;
  margin-bottom: 28px;
}

.avatar {
  width: 148px;
  height: 148px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--green);
  color: white;
  display: grid;
  place-items: center;
  font-size: 54px;
  font-weight: 850;
  border: 5px solid white;
  box-shadow: var(--shadow);
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }

.profile-head h1 {
  margin: 0;
  font-size: clamp(40px, 6vw, 70px);
  line-height: 0.98;
  letter-spacing: 0;
}

.badges { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 14px; }

.badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: white;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.event-list { display: grid; gap: 14px; }

.event {
  display: grid;
  grid-template-columns: 92px 96px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.event-thumb {
  width: 96px;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--soft);
}

.event-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.event-thumb.tour-logo-thumb {
  display: grid;
  place-items: center;
  padding: 12px;
  background: white;
}

.event-thumb.tour-logo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.event-thumb.is-empty {
  display: grid;
  place-items: center;
}

.event-thumb.is-empty .pin {
  transform: scale(.72);
  opacity: .7;
}

.date-box {
  border-left: 4px solid var(--green);
  padding-left: 12px;
}

.date-box strong {
  display: block;
  font-size: 18px;
}

.event h3 { margin: 0 0 6px; font-size: 22px; }
.event p { margin: 4px 0; color: var(--muted); }

.tour-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-weight: 750;
}

.tour-meta-logo {
  width: 22px;
  height: 22px;
  object-fit: contain;
  border-radius: 4px;
  background: white;
  border: 1px solid var(--line);
}

.tour-admin-name {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tour-logo-preview {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  overflow: hidden;
  padding: 6px;
}

.tour-logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tour-logo-preview.is-empty {
  background: var(--soft);
}

.tour-logo-preview.is-empty .pin {
  transform: scale(.55);
  opacity: .65;
}

.current-tour-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.current-tour-logo img {
  width: 82px;
  height: 48px;
  object-fit: contain;
  padding: 6px;
  border-radius: 8px;
  background: white;
  border: 1px solid var(--line);
}

.photo-grid,
.photo-manage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.event-photo,
.photo-manage-item {
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--soft);
}

.event-photo img,
.photo-manage-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-manage-item {
  position: relative;
}

.photo-manage-item .btn {
  position: absolute;
  right: 8px;
  bottom: 8px;
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 12px 10px; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.empty {
  border: 1px dashed #bdccc3;
  border-radius: 8px;
  padding: 28px;
  color: var(--muted);
  background: var(--soft);
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding: 24px clamp(18px, 4vw, 54px);
  font-size: 14px;
}

.footer a {
  color: var(--muted);
  font-weight: 750;
}

@media (max-width: 820px) {
  .topbar { align-items: flex-start; position: static; }
  .hero { grid-template-columns: 1fr; min-height: auto; }
  .grid { grid-template-columns: 1fr; }
  .span-4, .span-5, .span-6, .span-7, .span-8, .span-12 { grid-column: auto; }
  .profile-head {
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    margin-bottom: 18px;
  }
  .avatar {
    width: 92px;
    height: 92px;
    font-size: 34px;
    border-width: 4px;
  }
  .profile-head h1 {
    font-size: clamp(30px, 9vw, 44px);
    line-height: 1;
  }
  .profile-head .lead {
    font-size: 16px;
    line-height: 1.35;
  }
  .badges { gap: 6px; margin-top: 9px; }
  .badge { padding: 5px 8px; font-size: 12px; }
  .profile-head .actions { margin-top: 12px; }
  .event-list { gap: 10px; }
  .event {
    grid-template-columns: 68px minmax(0, 1fr);
    gap: 10px 12px;
    padding: 12px;
  }
  .event .date-box {
    grid-column: 1;
    border-left-width: 3px;
    padding-left: 9px;
  }
  .date-box strong { font-size: 16px; }
  .event .event-thumb {
    grid-column: 1;
    grid-row: 2;
    width: 68px;
  }
  .event-thumb.tour-logo-thumb { padding: 8px; }
  .event > div:not(.date-box):not(.event-thumb):not(.actions) { grid-column: 2; grid-row: 1 / span 2; }
  .event h3 { font-size: 18px; line-height: 1.2; margin-bottom: 4px; }
  .event p { font-size: 13px; line-height: 1.35; margin: 3px 0; }
  .event .actions { grid-column: 1 / -1; }
  .event .actions { margin-top: 2px; }
}

@media (max-width: 560px) {
  .topbar { padding: 15px 18px; }
  .brand span:last-child { max-width: 155px; }
  .nav { width: 100%; justify-content: flex-start; }
  .page { width: min(100% - 22px, 1160px); padding: 18px 0; }
  .hero h1 { font-size: 44px; }
  .hero-panel, .card { padding: 13px; }
  .section-title { align-items: flex-start; margin-bottom: 10px; }
  .dashboard-photo {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 10px;
    padding: 9px;
  }
  .dashboard-photo-avatar {
    width: 58px;
    height: 58px;
    border-width: 3px;
    font-size: 20px;
  }
  .dashboard-photo span { font-size: 12px; }
  .actions { gap: 8px; margin-top: 14px; }
  .actions .btn { flex: 1 1 145px; }
  .profile-head {
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 11px;
  }
  .avatar {
    width: 78px;
    height: 78px;
    font-size: 28px;
    border-width: 3px;
  }
  .profile-head h1 { font-size: clamp(27px, 8vw, 36px); }
  .profile-head .lead { font-size: 15px; }
  .event {
    grid-template-columns: 58px minmax(0, 1fr);
    padding: 10px;
    gap: 8px 10px;
  }
  .event .event-thumb { width: 58px; }
  .date-box strong { font-size: 15px; }
  .event h3 { font-size: 17px; }
  .tour-meta-logo {
    width: 18px;
    height: 18px;
  }
  .btn.small {
    min-height: 32px;
    padding: 6px 9px;
  }
  .crop-panel.is-active { grid-template-columns: 1fr; }
  .crop-preview-wrap { margin: 0 auto; }
  .crop-controls label { grid-template-columns: 1fr; }
}
