:root {
  color-scheme: dark;
  --bg: #090909;
  --panel: #151515;
  --panel-2: #1d1d1d;
  --text: #f4f2ed;
  --muted: #a9a39a;
  --line: #33302b;
  --amber: #ffb000;
  --green: #18d26b;
  --red: #ff3030;
  --blue: #69a7ff;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid #4b453d;
  background: #f3f0e8;
  color: #111;
  min-height: 42px;
  border-radius: 6px;
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  background: white;
}

.live-shell,
.admin-shell,
.secretariat-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 42px;
}

.live-header,
.admin-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.secretariat-login {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(220px, 1.4fr) auto;
  gap: 12px;
  align-items: end;
}

.secretariat-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin: 22px 0 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.secretariat-title h2 {
  margin-bottom: 4px;
  font-size: clamp(24px, 4vw, 42px);
}

.secretariat-title p {
  color: var(--muted);
  margin-bottom: 0;
}

.secretariat-title strong {
  color: var(--green);
}

.secretariat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.print-only {
  display: none;
}

.pdf-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.72);
  padding: 28px;
  overflow: auto;
}

.pdf-modal-card {
  width: min(1040px, 100%);
  margin: 0 auto;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  overflow: hidden;
}

.pdf-modal-card > header,
.pdf-modal-card > footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 16px 20px;
  background: #101010;
  border-bottom: 1px solid var(--line);
}

.pdf-modal-card > footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
  position: sticky;
  bottom: 0;
}

.pdf-modal-card h2,
.pdf-modal-card h3 {
  margin: 0;
}

.pdf-options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 20px;
}

.pdf-options-grid section {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 16px;
}

.pdf-options-grid label {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  color: var(--text);
}

.pdf-options-grid input[type="checkbox"] {
  justify-self: start;
}

.pdf-options-grid input,
.pdf-options-grid select,
.pdf-options-grid textarea {
  width: 100%;
}

.pdf-column-choices {
  columns: 2;
  margin-top: 8px;
}

.pdf-column-choices label {
  break-inside: avoid;
  display: block;
  margin: 0 0 8px;
}

.secretariat-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.secretariat-current > p {
  color: var(--amber);
  font-weight: 700;
}

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

.secretariat-lanes > div {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 14px;
}

.secretariat-lanes strong {
  display: block;
  font-size: 30px;
  color: var(--amber);
}

.secretariat-lanes dl {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 6px 12px;
  margin: 10px 0 0;
}

.secretariat-lanes dt {
  color: var(--muted);
  font-weight: 700;
}

.secretariat-lanes dd {
  margin: 0;
  font-weight: 700;
}

.secretariat-add {
  display: grid;
  grid-template-columns: 90px 1.2fr 1.2fr 1fr 110px auto;
  gap: 8px;
  align-items: center;
}

.secretariat-add input,
#competitorsTable input {
  min-height: 34px;
  border-color: #555047;
  background: #050505;
  font-weight: 700;
}

#competitorsTable {
  min-width: 900px;
}

#competitorsTable th:first-child,
#competitorsTable td:first-child {
  width: 90px;
  text-align: center;
}

#competitorsTable button {
  min-height: 34px;
  padding: 0 12px;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: clamp(28px, 5vw, 56px);
  line-height: 1;
}

.status-pill,
.ghost-link {
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  border-radius: 999px;
  padding: 10px 14px;
  white-space: nowrap;
}

.tree-strip {
  display: grid;
  grid-template-columns: 64px minmax(160px, 250px) 64px;
  justify-content: center;
  gap: 18px;
  margin: 28px 0;
}

.live-dashboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 8px;
}

.live-dashboard div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-height: 78px;
}

.live-dashboard span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 8px;
}

.live-dashboard strong {
  font-size: clamp(18px, 2.8vw, 34px);
  line-height: 1;
}

.tree {
  width: 64px;
  min-height: 320px;
  display: grid;
  grid-template-rows: repeat(5, 64px);
  background: #050505;
  border: 1px solid #2c2925;
}

.tree span {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  align-self: center;
  justify-self: center;
  background: #1d1b18;
  border: 2px solid #3a342e;
}

.tree.amber1 span:nth-child(1),
.tree.amber2 span:nth-child(-n+2),
.tree.amber3 span:nth-child(-n+3) {
  background: var(--amber);
  box-shadow: 0 0 22px rgba(255, 176, 0, .72);
}

.tree.green span:nth-child(4) {
  background: var(--green);
  box-shadow: 0 0 22px rgba(24, 210, 107, .72);
}

.tree.red span:nth-child(5) {
  background: var(--red);
  box-shadow: 0 0 22px rgba(255, 48, 48, .72);
  animation: blink .5s linear infinite;
}

@keyframes blink {
  50% { opacity: .25; }
}

.run-board {
  min-height: 250px;
  display: grid;
  place-items: center;
  align-content: center;
  background: #111;
  border: 1px solid var(--line);
}

.run-board p,
.run-board span {
  color: var(--muted);
  margin: 0;
  text-transform: uppercase;
  font-weight: 700;
}

.run-board strong {
  font-size: 84px;
  line-height: 1;
}

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

.lane-panel,
.panel,
.history {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.lane-top,
.section-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.lane-top strong {
  color: var(--green);
}

.lane-panel h2 {
  font-size: clamp(24px, 4vw, 42px);
  margin: 20px 0 4px;
  line-height: 1;
}

.lane-panel p {
  color: var(--muted);
  min-height: 22px;
}

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

.metrics div {
  background: var(--panel-2);
  padding: 12px;
  min-height: 78px;
  border: 1px solid #27231f;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.metrics strong {
  font-size: clamp(18px, 2.4vw, 30px);
  line-height: 1;
}

.history {
  margin-top: 16px;
}

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

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

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

.panel h2 {
  font-size: 20px;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border-radius: 6px;
  border: 1px solid #3b362f;
  background: #0d0d0d;
  color: var(--text);
  padding: 0 10px;
}

.two,
.four {
  display: grid;
  gap: 10px;
}

.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.toggles label {
  display: flex;
  align-items: center;
  grid-template-columns: none;
}

.toggles input {
  width: auto;
  min-height: auto;
}

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

.lane-edit {
  background: #101010;
  border: 1px solid #27231f;
  padding: 12px;
  margin-bottom: 12px;
}

.button-row,
.light-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hint {
  color: var(--muted);
  margin: 14px 0 0;
}

.accounts-shell {
  width: min(1440px, calc(100vw - 32px));
}

.accounts-login-panel {
  max-width: 520px;
  margin-top: 24px;
}

.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.plans-grid article {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  padding: 18px;
}

.plans-grid h3 {
  margin-top: 0;
}

.license-page {
  background:
    linear-gradient(140deg, rgba(255, 176, 0, 0.14), transparent 28%),
    radial-gradient(circle at 82% 18%, rgba(105, 167, 255, 0.12), transparent 30%),
    #090909;
}

.license-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 26px 0 54px;
}

.license-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 28px;
  align-items: center;
  min-height: 320px;
  border-bottom: 1px solid var(--line);
  padding: 20px 0 28px;
}

.license-hero h1 {
  font-size: clamp(34px, 5vw, 64px);
  line-height: 0.95;
  margin: 8px 0 18px;
}

.license-hero-copy > p:not(.eyebrow) {
  max-width: 690px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

.license-hero-media {
  min-height: 210px;
  display: grid;
  place-items: center;
}

.license-hero-media img {
  width: min(420px, 100%);
  max-height: 220px;
  object-fit: contain;
  filter: drop-shadow(0 18px 34px rgba(0, 0, 0, 0.4));
}

.license-top-actions {
  position: absolute;
  top: 18px;
  right: 0;
  display: flex;
  gap: 10px;
  align-items: center;
}

.license-top-actions select {
  width: 92px;
  min-height: 38px;
}

.license-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}

.license-badges span {
  border: 1px solid rgba(255, 176, 0, 0.32);
  background: rgba(255, 176, 0, 0.09);
  color: #ffe0a0;
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 13px;
}

.license-grid {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 22px;
  margin-top: 24px;
  align-items: start;
}

.license-login {
  position: sticky;
  top: 16px;
}

.password-reveal {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 8px;
  align-items: center;
}

.password-reveal input {
  width: 100%;
}

.password-reveal button {
  min-height: 42px;
  padding: 0 10px;
  font-size: 13px;
}

.license-section-title {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.license-section-title h2,
.license-section-heading h2 {
  margin: 0;
}

.license-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 176, 0, 0.34);
  background: linear-gradient(145deg, rgba(255, 222, 138, 0.18), rgba(255, 176, 0, 0.06));
}

.license-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: #ffd476;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.plan-card {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.035));
  padding: 22px;
  min-height: 360px;
  display: grid;
  align-content: start;
  gap: 12px;
}

.plan-card.featured {
  border-color: rgba(255, 176, 0, 0.45);
  box-shadow: 0 0 0 1px rgba(255, 176, 0, 0.12), 0 22px 48px rgba(0, 0, 0, 0.28);
}

.plan-card h3 {
  font-size: 24px;
  margin: 0;
}

.plan-card p,
.plan-card li {
  color: var(--muted);
  line-height: 1.48;
}

.plan-card ul {
  margin: 0 0 8px;
  padding-left: 18px;
}

.plan-card button {
  margin-top: auto;
  background: linear-gradient(180deg, #ffe59a, #e2aa22);
  border-color: #ffd476;
  color: #16120a;
  font-weight: 700;
}

.license-note {
  margin-top: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.045);
  padding: 14px 16px;
}

.license-note p {
  color: var(--muted);
  margin-bottom: 0;
}

#accountsTable {
  min-width: 1280px;
}

#accountsTable td {
  vertical-align: top;
}

#accountsTable small,
#accountsTable span {
  color: var(--muted);
}

#accountsTable textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  border-radius: 6px;
  border: 1px solid #3b362f;
  background: #0d0d0d;
  color: var(--text);
  padding: 8px 10px;
}

#accountsTable .manual-expiry {
  min-width: 170px;
}

#accountsTable .secretariat-cell {
  min-width: 250px;
}

#accountsTable .secretariat-cell label {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
}

#accountsTable .secretariat-cell input {
  width: 100%;
}

#accountsTable .secretariat-cell button {
  width: 100%;
  margin-top: 10px;
}

#accountsTable .account-actions {
  min-width: 190px;
}

#accountsTable .account-actions button {
  width: 100%;
  margin-bottom: 8px;
}

.ok {
  color: var(--green);
  font-weight: 700;
}

.bad {
  color: var(--red);
  font-weight: 700;
}

@media (max-width: 760px) {
  .live-header,
  .admin-header,
  .lanes,
  .admin-grid,
  .secretariat-login,
  .secretariat-add,
  .secretariat-lanes,
  .license-hero,
  .license-grid,
  .two,
  .four,
  .channel-grid {
    grid-template-columns: 1fr;
  }

  .live-header,
  .admin-header {
    display: grid;
    align-items: start;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .live-dashboard {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 10mm 10mm 12mm;
  }

  body {
    background: white;
    color: black;
    min-height: auto;
  }

  body > *:not(#secretariatPrintRoot),
  .no-print,
  .ghost-link,
  .secretariat-actions {
    display: none !important;
  }

  #secretariatPrintRoot,
  .print-only {
    display: block !important;
  }

  .pdf-report {
    position: relative;
    background: white;
    color: black;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 9.5pt;
    padding-bottom: 12mm;
  }

  .pdf-image {
    width: 100%;
    margin: 0 0 4mm;
  }

  .pdf-image.align-left {
    text-align: left;
  }

  .pdf-image.align-center {
    text-align: center;
  }

  .pdf-image.align-right {
    text-align: right;
  }

  .pdf-image img {
    width: auto;
    max-width: 100%;
    object-fit: contain;
    vertical-align: top;
  }

  .pdf-report-header {
    text-align: center;
    margin-bottom: 5mm;
  }

  .pdf-report-header h1 {
    color: black;
    font-size: 19pt;
    line-height: 1.1;
    margin: 0 0 2mm;
  }

  .pdf-report-header h2 {
    color: black;
    font-size: 13pt;
    margin: 0 0 1.5mm;
  }

  .pdf-report-header p {
    color: #444;
    margin: 0;
    font-size: 9pt;
  }

  .pdf-results-table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
    table-layout: auto;
    page-break-inside: auto;
  }

  .pdf-results-table thead {
    display: table-header-group;
  }

  .pdf-results-table tr {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .pdf-results-table th,
  .pdf-results-table td {
    color: black;
    border: 1px solid #9a9a9a;
    padding: 2.2mm 1.7mm;
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .pdf-results-table th {
    background: #dedede !important;
    font-weight: 700;
  }

  .pdf-results-table tbody tr:nth-child(even) td {
    background: #f1f1f1 !important;
  }

  .pdf-results-table .best-cell {
    background: #fff1a8 !important;
    font-weight: 700;
  }

  .pdf-report-footer {
    margin-top: 6mm;
    page-break-inside: avoid;
  }

  .pdf-custom-text {
    color: #333;
    margin: 2mm 0 0;
    font-size: 9pt;
  }

  .pdf-custom-text.align-left {
    text-align: left;
  }

  .pdf-custom-text.align-center {
    text-align: center;
  }

  .pdf-custom-text.align-right {
    text-align: right;
  }

  .pdf-signature {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    text-align: center;
    color: #555;
    font-size: 8.5pt;
  }
}
