:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #17202a;
  --muted: #667085;
  --subtle: #94a3b8;
  --line: #dbe3ec;
  --line-soft: #e8edf3;
  --primary: #235c9f;
  --primary-dark: #184675;
  --primary-soft: #e8f1fb;
  --danger: #b42318;
  --danger-soft: #fee7e4;
  --ok: #16704b;
  --ok-soft: #e5f4ed;
  --fusion: #50be7b;
  --fusion-dark: #1f6849;
  --fusion-ink: #16262f;
  --warning: #8a5a12;
  --shadow: 0 18px 48px rgba(31, 41, 55, .08);
  --shadow-soft: 0 1px 2px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 0%, rgba(35, 92, 159, .07), transparent 26rem),
    linear-gradient(180deg, #f8fafc 0%, var(--bg) 18rem);
  letter-spacing: 0;
}

a { color: inherit; }

.app-shell {
  display: grid;
  grid-template-columns: 284px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px 18px;
  background: rgba(255, 255, 255, .86);
  border-right: 1px solid var(--line-soft);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 17px;
  line-height: 1.2;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
}

.brand-mark {
  display: inline-flex;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: #203247;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 28px rgba(32, 50, 71, .18);
}

.sidebar nav {
  display: grid;
  gap: 4px;
}

.sidebar nav a {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  color: #3b4756;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.sidebar nav a::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-right: 11px;
  border-radius: 50%;
  background: #c5cfdb;
}

.sidebar nav a:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.sidebar nav a.active {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.sidebar nav a.active::before {
  background: var(--primary);
}

.user-box {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--surface-soft);
}

.user-avatar {
  display: inline-flex;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: #dfe8f2;
  color: #26384c;
  font-weight: 500;
}

.user-box strong,
.user-box span {
  display: block;
}

.user-box strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.user-box span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.content {
  min-width: 0;
  padding: 24px 34px 48px;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 1480px;
  margin: 0 auto 24px;
  padding: 16px 18px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(255, 255, 255, .82);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
}

.topbar strong {
  display: block;
  margin-top: 3px;
  font-size: 19px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
}

.page-head,
.panel,
.event-card,
.stats-grid,
.toolbar {
  max-width: 1480px;
  margin-left: auto;
  margin-right: auto;
}

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

h1,
h2 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
  font-weight: 650;
}

h2 {
  margin-bottom: 14px;
  font-size: 18px;
  font-weight: 600;
}

small {
  color: var(--muted);
  font-weight: 500;
}

.panel,
.event-card {
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow-soft);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  position: relative;
  min-height: 112px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  box-shadow: var(--shadow-soft);
}

.stat::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 18px;
  width: 34px;
  height: 6px;
  border-radius: 99px;
  background: #d7e2ee;
}

.stat span {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 34px;
  font-weight: 500;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  padding: 12px 11px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--surface-soft);
  color: #516071;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
}

th:first-child { border-top-left-radius: 8px; }
th:last-child { border-top-right-radius: 8px; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfdff; }

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #7ea7d3;
  box-shadow: 0 0 0 4px rgba(35, 92, 159, .10);
}

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

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 500;
}

fieldset {
  margin: 0;
}

legend {
  padding: 0 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 500;
}

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

.wide { grid-column: 1 / -1; }

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-soft);
  font-weight: 500;
}

.check input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--primary);
}

.check.compact {
  min-height: 34px;
  padding: 7px 9px;
  white-space: nowrap;
  font-size: 12px;
}

.compact-field {
  min-width: 160px;
  min-height: 34px;
  padding: 7px 9px;
  font-size: 13px;
}

.quick-result {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto auto;
  gap: 6px;
  align-items: center;
  min-width: 360px;
}

.quick-result-button {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: #354256;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.quick-result-button.pass.active,
.quick-result-button.pass:hover {
  border-color: #b7dfcc;
  background: var(--ok-soft);
  color: var(--ok);
}

.quick-result-button.fail.active,
.quick-result-button.fail:hover {
  border-color: #f2b9b4;
  background: var(--danger-soft);
  color: var(--danger);
}

.participant-search-form {
  display: block;
}

.participant-search {
  display: grid;
  gap: 8px;
}

.participant-search-input {
  max-width: 620px;
}

.participant-search-results {
  width: min(100%, 620px);
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.participant-search-result {
  display: grid;
  width: 100%;
  gap: 3px;
  padding: 11px 12px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.participant-search-result:last-child {
  border-bottom: 0;
}

.participant-search-result:hover,
.participant-search-result:focus {
  background: var(--primary-soft);
  outline: none;
}

.participant-search-result strong {
  font-size: 14px;
  font-weight: 600;
}

.participant-search-result small,
.participant-search-empty {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.participant-search-empty {
  padding: 12px;
}

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

.toolbar {
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(255, 255, 255, .88);
  box-shadow: var(--shadow-soft);
}

.toolbar input {
  max-width: 560px;
}

.actions form {
  display: inline;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  background: #fff;
  color: #263446;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease, box-shadow .16s ease;
}

.button:hover {
  border-color: #b9c6d5;
  background: #f9fbfd;
  transform: translateY(-1px);
}

.button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 10px 22px rgba(35, 92, 159, .18);
}

.button.primary:hover {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

.button.ghost {
  background: var(--surface-soft);
}

.button.danger {
  border-color: #f2b9b4;
  background: #fff;
  color: var(--danger);
}

.button.danger:hover {
  background: var(--danger-soft);
}

.button.small {
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 9px;
  border-radius: 99px;
  background: #eef3f8;
  color: #415166;
  font-size: 12px;
  font-weight: 500;
}

.badge.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.muted {
  background: #f1f5f9;
  color: var(--muted);
}

.badge-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.alert {
  max-width: 1480px;
  margin: 0 auto 16px;
  padding: 13px 15px;
  border-radius: 9px;
  font-weight: 500;
}

.alert.success {
  border: 1px solid #b7dfcc;
  background: var(--ok-soft);
  color: #0d5a3b;
}

.alert.error {
  border: 1px solid #f2b9b4;
  background: var(--danger-soft);
  color: #8f1d14;
}

.event-card {
  padding: 0;
  overflow: hidden;
}

.event-card summary {
  cursor: pointer;
  display: grid;
  grid-template-columns: 28px minmax(220px, 1.7fr) minmax(110px, .75fr) minmax(110px, .75fr) minmax(170px, 1.1fr) auto auto auto auto;
  gap: 12px;
  align-items: center;
  padding: 17px 18px;
  list-style: none;
}

.event-card summary::-webkit-details-marker {
  display: none;
}

.event-card summary::before {
  content: "+";
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--primary);
  font-weight: 500;
}

.event-card[open] summary::before {
  content: "-";
}

.event-card summary > span:first-child {
  display: grid;
  gap: 4px;
}

.event-card summary strong {
  font-size: 16px;
}

.event-card summary small {
  display: block;
}

.event-body {
  padding: 18px;
  border-top: 1px solid var(--line-soft);
  background: #fbfdff;
}

.split {
  display: grid;
  grid-template-columns: minmax(220px, .9fr) minmax(360px, 2fr);
  gap: 18px;
  margin-bottom: 18px;
}

.split section {
  padding: 15px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: #fff;
}

.split ol {
  margin: 0;
  padding-left: 22px;
  color: #344054;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.commission-fieldset {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.commission-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  gap: 10px;
  margin-bottom: 10px;
}

.field-hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
}

.login-page,
.fusion-auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.fusion-auth-page {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 12%, rgba(80, 190, 123, .20), transparent 25rem),
    radial-gradient(circle at 82% 78%, rgba(31, 104, 73, .13), transparent 28rem),
    linear-gradient(135deg, #f8fbf8 0%, #edf4f1 54%, #f7faf8 100%);
}

.fusion-auth-page::before {
  content: "";
  position: fixed;
  inset: 8%;
  pointer-events: none;
  background:
    linear-gradient(120deg, transparent 0 47%, rgba(80, 190, 123, .10) 47% 48%, transparent 48% 100%),
    linear-gradient(30deg, transparent 0 58%, rgba(22, 38, 47, .06) 58% 59%, transparent 59% 100%);
  opacity: .9;
}

.splash-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 760px);
  padding: 28px;
}

.splash-panel {
  display: grid;
  justify-items: center;
  gap: 18px;
  padding: clamp(30px, 7vw, 58px);
  border: 1px solid rgba(80, 190, 123, .22);
  border-radius: 16px;
  background: rgba(255, 255, 255, .86);
  box-shadow: 0 28px 80px rgba(22, 38, 47, .12);
  text-align: center;
  backdrop-filter: blur(18px);
}

.fusion-logo-card {
  display: grid;
  place-items: center;
  width: 142px;
  height: 122px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 18px 44px rgba(31, 104, 73, .16);
}

.fusion-logo-card img {
  width: 112px;
  height: auto;
}

.splash-kicker {
  margin: 4px 0 0;
  color: var(--fusion-dark);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.splash-panel h1 {
  max-width: 620px;
  color: var(--fusion-ink);
  font-size: clamp(34px, 6vw, 56px);
}

.splash-copy {
  max-width: 590px;
  margin: 0;
  color: #526171;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.6;
}

.splash-actions {
  margin-top: 8px;
}

.login-box {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  padding: 28px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.fusion-login-box {
  border-color: rgba(80, 190, 123, .25);
  box-shadow: 0 28px 80px rgba(22, 38, 47, .12);
}

.login-brand {
  display: flex;
  gap: 13px;
  align-items: center;
  margin-bottom: 22px;
}

.login-brand h1 {
  font-size: 24px;
}

.login-brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.login-box form {
  display: grid;
  gap: 15px;
}

.login-logo {
  width: 78px;
  height: auto;
  flex: 0 0 auto;
}

.button.fusion-primary,
.fusion-auth-page .button.primary {
  border-color: var(--fusion);
  background: var(--fusion);
  color: #102018;
  box-shadow: 0 14px 28px rgba(80, 190, 123, .24);
}

.button.fusion-primary:hover,
.fusion-auth-page .button.primary:hover {
  border-color: #44aa6c;
  background: #44aa6c;
  color: #0d1d14;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 236px minmax(0, 1fr);
  }

  .event-card summary {
    grid-template-columns: 28px minmax(220px, 1fr) repeat(2, minmax(110px, auto));
  }

  .event-card summary > span:nth-child(n+5) {
    grid-column: auto;
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: relative;
    height: auto;
    padding: 16px;
  }

  .sidebar nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 3px;
  }

  .sidebar nav a {
    flex: 0 0 auto;
  }

  .user-box {
    display: none;
  }

  .content {
    padding: 18px;
  }

  .panel,
  .event-card,
  .toolbar,
  .topbar,
  .page-head,
  .stats-grid {
    max-width: 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

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

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

  .toolbar input {
    max-width: none;
  }

  .event-card summary {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .commission-row {
    grid-template-columns: 1fr;
  }

  .event-card summary > span {
    grid-column: 2;
  }

  .event-card summary::before {
    grid-column: 1;
    grid-row: 1;
  }

  .panel table,
  .event-body table {
    min-width: 760px;
  }

  .panel,
  .event-body {
    overflow-x: auto;
  }
}
