:root {
  --ink: #0b1b3a;
  --navy: #1a3673;
  --deep: #102654;
  --gold: #c5ae7d;
  --paper: #f5f7fb;
  --muted: #68748b;
  --line: #dfe5ef;
  --green: #1f8a61;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font:
    15px/1.5 "Segoe UI Variable",
    "Noto Sans",
    Arial,
    sans-serif;
  background:
    radial-gradient(
      circle at 90% -10%,
      rgba(197, 174, 125, 0.18),
      transparent 30rem
    ),
    var(--paper);
}
button,
input,
select,
textarea {
  font: inherit;
}
button {
  cursor: pointer;
}
.admin-topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(18px, 4vw, 54px);
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(26, 54, 115, 0.1);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}
.brand img {
  object-fit: contain;
}
.brand span {
  display: grid;
  line-height: 1.05;
}
.brand small {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 5px;
}
.live-state {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.live-state i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c2cad8;
}
.live-state.connected i {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(31, 138, 97, 0.12);
}
main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 54px 0 100px;
}
.login-card {
  width: min(520px, 100%);
  margin: 8vh auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: clamp(26px, 5vw, 48px);
  box-shadow: 0 26px 70px rgba(16, 38, 84, 0.12);
}
.eyebrow {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: #947b45;
  font-weight: 800;
}
.login-card h1,
.page-heading h1 {
  font-size: clamp(36px, 5vw, 58px);
  line-height: 1;
  letter-spacing: -0.055em;
  margin: 12px 0;
}
.login-card p,
.page-heading p,
.hint {
  color: var(--muted);
}
label {
  display: grid;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
}
input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fbfcfe;
  color: var(--ink);
  padding: 12px;
  outline: 0;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(197, 174, 125, 0.16);
}
textarea {
  min-height: 100px;
  resize: vertical;
}
.login-card form {
  display: grid;
  gap: 14px;
  margin-top: 28px;
}
.login-card button,
.panel button {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--navy);
  border-radius: 12px;
  background: var(--navy);
  color: #fff;
  font-weight: 700;
}
.secondary,
.panel button.secondary {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--navy);
  font-weight: 700;
}
.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 30px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
}
.stat small {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.stat strong {
  display: block;
  font-size: 30px;
  letter-spacing: -0.04em;
  margin-top: 5px;
}
.panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(26, 54, 115, 0.1);
  border-radius: 24px;
  padding: clamp(20px, 3vw, 30px);
  box-shadow: 0 12px 32px rgba(26, 54, 115, 0.055);
  margin: 16px 0;
}
.panel > header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.panel-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.panel h2 {
  font-size: 25px;
  letter-spacing: -0.035em;
  margin: 5px 0 0;
}
.control-grid,
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.wide {
  grid-column: 1/-1;
}
.switch-row {
  min-height: 68px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 12px 14px;
}
.switch-row span {
  display: grid;
}
.switch-row small {
  font-weight: 400;
  color: var(--muted);
  margin-top: 3px;
}
.switch-row input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.switch-row i {
  width: 48px;
  height: 28px;
  border-radius: 99px;
  background: #d8deea;
  position: relative;
  transition: 0.2s;
}
.switch-row i:after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: 0.2s;
}
.switch-row input:checked + i {
  background: var(--navy);
}
.switch-row input:checked + i:after {
  transform: translateX(20px);
}
.schedule-editor {
  display: grid;
  gap: 8px;
}
.schedule-edit-row {
  display: grid;
  grid-template-columns: 78px 110px minmax(180px, 1.1fr) minmax(210px, 1.35fr) minmax(210px, 1.35fr);
  gap: 8px;
  align-items: stretch;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfcfe;
}
.schedule-edit-row input,
.schedule-edit-row textarea {
  padding: 10px;
  font-size: 13px;
  line-height: 1.45;
}
.schedule-edit-row textarea {
  min-height: 72px;
  resize: vertical;
}
.recipient-picker {
  margin: 20px 0 4px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
}
.recipient-picker legend {
  padding: 0 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.audience-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.audience-options > label,
.recipient-item {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  cursor: pointer;
}
.audience-options input,
.recipient-item input {
  width: 18px;
  height: 18px;
  accent-color: var(--navy);
}
.audience-options span,
.recipient-item span {
  display: grid;
  gap: 2px;
}
.audience-options small,
.recipient-item small,
#recipient-selection-count {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}
.recipient-controls {
  margin-top: 12px;
}
.recipient-controls > div:first-child {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  margin-bottom: 9px;
}
.recipient-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 310px;
  overflow: auto;
  padding: 2px;
}
#recipient-selection-count {
  display: block;
  margin-top: 9px;
  font-weight: 750;
}
.feedback-item .danger {
  align-self: center;
  color: #a32d3d;
  border-color: #e8c9ce;
}
.question-list,
.feedback-list {
  display: grid;
  gap: 9px;
}
.question-item,
.feedback-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
}
.question-item p,
.feedback-item p {
  margin: 0;
}
.question-item small,
.feedback-item small {
  color: var(--muted);
}
.question-item button {
  min-height: 34px;
  background: #fff;
  color: var(--navy);
  border-color: var(--line);
}
.question-item.hidden-item {
  opacity: 0.55;
}
.csv {
  min-height: 150px;
  font-family: ui-monospace, Consolas, monospace;
}
.empty {
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 26px;
  text-align: center;
  color: var(--muted);
}
output {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 10px;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  background: var(--deep);
  color: #fff;
  padding: 12px 17px;
  border-radius: 13px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
@media (max-width: 800px) {
  main {
    padding-top: 30px;
  }
  .stats {
    grid-template-columns: 1fr 1fr;
  }
  .page-heading {
    align-items: start;
  }
  .control-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }
  .wide {
    grid-column: auto;
  }
  .schedule-edit-row {
    grid-template-columns: 72px 1fr;
  }
  .schedule-edit-row textarea {
    grid-column: 1/-1;
  }
  .recipient-list {
    grid-template-columns: 1fr;
  }
  .panel > header {
    align-items: start;
  }
  .panel > header button {
    flex: 0 0 auto;
  }
}
@media (max-width: 520px) {
  .stats {
    grid-template-columns: 1fr 1fr;
  }
  .page-heading h1 {
    font-size: 38px;
  }
  .page-heading p {
    margin-right: 10px;
  }
  .question-item,
  .feedback-item {
    grid-template-columns: 1fr;
  }
  .admin-topbar {
    padding: 0 14px;
  }
  .brand strong {
    font-size: 14px;
  }
  .panel > header {
    display: grid;
  }
  .panel-actions {
    justify-content: flex-start;
  }
  .audience-options,
  .recipient-controls > div:first-child {
    grid-template-columns: 1fr;
  }
}

.console-tabs {
  position: sticky;
  top: 84px;
  z-index: 12;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: none;
  padding: 9px;
  margin: 0 0 18px;
  background: rgba(245, 247, 251, 0.9);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(26, 54, 115, 0.08);
  border-radius: 18px;
  box-shadow: 0 8px 28px rgba(16, 38, 84, 0.06);
}
.console-tabs::-webkit-scrollbar {
  display: none;
}
.console-tabs button {
  min-height: 43px;
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  padding: 0 17px;
  font-weight: 750;
  white-space: nowrap;
}
.console-tabs button:hover {
  background: #fff;
  color: var(--navy);
}
.console-tabs button.active {
  background: var(--deep);
  color: #fff;
  box-shadow: 0 7px 18px rgba(16, 38, 84, 0.2);
}
.console-tabs button span {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-left: 5px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(104, 116, 139, 0.12);
  font-size: 10px;
}
.console-tabs button.active span {
  background: rgba(255, 255, 255, 0.16);
}
.page-heading > .secondary {
  flex: 0 0 auto;
  white-space: nowrap;
}
.admin-tab-panel {
  animation: tab-enter 0.22s ease;
}
.admin-tab-panel > .panel:first-child {
  margin-top: 0;
}
@keyframes tab-enter {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.feedback-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.feedback-summary article {
  min-height: 105px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 15px;
  background: #fbfcfe;
}
.feedback-summary small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.feedback-summary strong {
  display: block;
  font-size: 25px;
  margin: 5px 0 2px;
}
.feedback-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}
.feedback-filter {
  width: min(320px, 100%);
  margin: 0 0 16px;
}
.feedback-scope {
  display: inline-flex;
  margin-right: 7px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #edf1fa;
  color: var(--navy);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.leaderboard-admin {
  display: grid;
  gap: 8px;
}
.leaderboard-row {
  display: grid;
  grid-template-columns: 48px minmax(160px, 1fr) repeat(4, minmax(72px, auto)) 72px;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.leaderboard-row.header {
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.leaderboard-row > strong:first-child {
  color: #947b45;
  font-size: 18px;
}
.leaderboard-row > span {
  color: var(--muted);
  font-size: 12px;
}
.leaderboard-row .leader-score {
  color: var(--navy);
  font-size: 19px;
  text-align: right;
}
.analytics-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 20px 0;
}
.analytics-stats article,
.analytics-grid > article {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fbfcfe;
  padding: 17px;
}
.analytics-stats small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.analytics-stats strong {
  display: block;
  margin-top: 6px;
  color: var(--navy);
  font-size: 30px;
  letter-spacing: -.04em;
}
.analytics-stats p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
}
.analytics-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 12px;
}
.analytics-grid > article > header {
  margin-bottom: 16px;
}
.analytics-grid h3 {
  margin: 4px 0 0;
  font-size: 19px;
}
.analytics-days {
  min-height: 190px;
  display: flex;
  align-items: stretch;
  gap: 7px;
}
.analytics-day {
  min-width: 0;
  flex: 1;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 7px;
  text-align: center;
  color: var(--muted);
  font-size: 9px;
}
.analytics-day i {
  min-height: 130px;
  display: flex;
  align-items: end;
  justify-content: center;
  border-radius: 9px;
  background: #edf1f8;
  overflow: hidden;
}
.analytics-day i b {
  width: 100%;
  min-height: 4px;
  border-radius: 7px 7px 0 0;
  background: linear-gradient(180deg, var(--gold), var(--navy));
}
.analytics-day strong {
  color: var(--ink);
  font-size: 11px;
}
.analytics-ranking {
  display: grid;
  gap: 13px;
}
.analytics-rank > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
  font-size: 12px;
}
.analytics-rank > div span {
  color: var(--muted);
}
.analytics-rank i {
  display: block;
  height: 6px;
  border-radius: 99px;
  overflow: hidden;
  background: #e8edf5;
}
.analytics-rank i b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--navy);
}
.analytics-rank b.level-1 { width: 10%; }
.analytics-rank b.level-2 { width: 20%; }
.analytics-rank b.level-3 { width: 30%; }
.analytics-rank b.level-4 { width: 40%; }
.analytics-rank b.level-5 { width: 50%; }
.analytics-rank b.level-6 { width: 60%; }
.analytics-rank b.level-7 { width: 70%; }
.analytics-rank b.level-8 { width: 80%; }
.analytics-rank b.level-9 { width: 90%; }
.analytics-rank b.level-10 { width: 100%; }
.analytics-day b.level-1 { height: 10%; }
.analytics-day b.level-2 { height: 20%; }
.analytics-day b.level-3 { height: 30%; }
.analytics-day b.level-4 { height: 40%; }
.analytics-day b.level-5 { height: 50%; }
.analytics-day b.level-6 { height: 60%; }
.analytics-day b.level-7 { height: 70%; }
.analytics-day b.level-8 { height: 80%; }
.analytics-day b.level-9 { height: 90%; }
.analytics-day b.level-10 { height: 100%; }

@media (max-width: 800px) {
  .console-tabs {
    top: 78px;
    margin-inline: -4px;
  }
  .feedback-summary {
    grid-template-columns: 1fr 1fr;
  }
  .leaderboard-row {
    grid-template-columns: 40px minmax(140px, 1fr) 64px;
  }
  .leaderboard-row > span:not(.leader-score) {
    display: none;
  }
  .leaderboard-row.header {
    display: none;
  }
  .analytics-stats,
  .analytics-grid {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 520px) {
  .console-tabs {
    border-radius: 14px;
  }
  .console-tabs button {
    padding: 0 14px;
  }
  .feedback-summary {
    grid-template-columns: 1fr;
  }
  .admin-tab-panel > .panel {
    margin-top: 0;
  }
  .analytics-stats,
  .analytics-grid {
    grid-template-columns: 1fr;
  }
  .analytics-days {
    overflow-x: auto;
  }
  .analytics-day {
    flex: 0 0 42px;
  }
}
