:root {
  --bg: #f5f8fc;
  --panel: rgba(255, 255, 255, .88);
  --text: #111827;
  --muted: #667085;
  --line: #d8e2f0;
  --blue: #3478ff;
  --cyan: #12c8d2;
  --green: #13a36f;
  --red: #ec3d5a;
  --violet: #8b5cf6;
  --shadow: 0 20px 55px rgba(31, 64, 112, .12);
  font-family: "Segoe UI Variable", "Segoe UI", Inter, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-weight: 400;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
  background:
    radial-gradient(circle at 10% 8%, rgba(18, 200, 210, .16), transparent 28%),
    radial-gradient(circle at 88% 12%, rgba(139, 92, 246, .14), transparent 28%),
    var(--bg);
}

button, input, select {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.sidebar, .panel, .topbar {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.sidebar {
  position: sticky;
  top: 18px;
  height: calc(100vh - 36px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
}

.brand {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.logo {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  color: white;
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--violet), var(--blue), var(--cyan));
}

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

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

.brand p, .hint, .feed-item span {
  color: var(--muted);
  font-weight: 400;
}

nav {
  display: grid;
  gap: 10px;
}

nav a {
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: #20304d;
  font-weight: 600;
  text-decoration: none;
  background: rgba(255,255,255,.58);
}

nav a.active {
  color: #075985;
  border-color: rgba(18, 200, 210, .58);
  background: rgba(18, 200, 210, .12);
  box-shadow: inset 3px 0 0 var(--cyan);
}

.status-card {
  margin-top: auto;
  display: grid;
  gap: 7px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(18, 200, 210, .08);
}

.status-card span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #b7c4d8;
}

.status-card span.active {
  background: var(--green);
  box-shadow: 0 0 20px rgba(19, 163, 111, .5);
}

.workspace {
  display: grid;
  gap: 18px;
}

.page {
  display: none !important;
}

.page.active {
  display: block !important;
}

.page.grid.active {
  display: grid !important;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px;
}

.topbar h2 {
  margin-top: 4px;
  font-size: 34px;
  font-weight: 650;
}

.kicker {
  color: #0d78d5;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .02em;
  text-transform: uppercase;
}

h3 {
  font-weight: 650;
}

.top-actions, .panel-head, .row-actions, .link-card div, .inline-controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

.panel-head {
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel {
  padding: 20px;
}

.mini-panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.64);
}

.mini-panel.wide {
  grid-column: span 2;
}

.compact {
  margin-bottom: 12px;
}

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

.projector-layout {
  display: grid;
  gap: 18px;
}

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

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

.upload-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: end;
}

.upload-grid label { grid-column: span 2; }
.upload-grid .file-field { grid-column: span 3; }

.projector-upload {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto;
  gap: 14px;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
}

input, select {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  font-weight: 400;
  background: white;
}

button, .primary, .secondary, .danger {
  min-height: 42px;
  display: inline-grid;
  place-items: center;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 13px;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

button:hover, .primary:hover, .secondary:hover, .danger:hover {
  transform: translateY(-1px);
}

.primary {
  color: white;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
}

.secondary {
  color: #185d8d;
  border-color: #bed5ee;
  background: rgba(255,255,255,.8);
}

.danger {
  color: #b4233f;
  border-color: rgba(236, 61, 90, .25);
  background: rgba(236, 61, 90, .08);
}

.full {
  width: 100%;
  margin-top: 16px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 18px;
}

.channel-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
}

.channel-avatar {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 22px;
  color: white;
  font-size: 31px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--violet), var(--blue), var(--cyan));
}

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

.channel-card h3,
.channel-card p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-card p,
.mini-hint {
  color: var(--muted);
}

.stat-row div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.7);
}

.stat-row strong {
  display: block;
  font-size: 28px;
  font-weight: 650;
}

.stat-row span {
  color: var(--muted);
  font-weight: 450;
}

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

.toggle-card {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 12px;
  align-items: center;
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.7);
  cursor: pointer;
}

.toggle-card input {
  appearance: none;
  width: 44px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  border: 1px solid #bdd0e7;
  border-radius: 999px;
  background: #dbe7f4;
  transition: .16s ease;
}

.toggle-card input::after {
  content: "";
  display: block;
  width: 18px;
  height: 18px;
  margin: 2px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 8px rgba(31,64,112,.2);
  transition: .16s ease;
}

.toggle-card input:checked {
  border-color: rgba(19, 163, 111, .45);
  background: var(--green);
}

.toggle-card input:checked::after {
  transform: translateX(20px);
}

.toggle-card span {
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
}

.toggle-card small {
  grid-column: 2;
  color: var(--muted);
  line-height: 1.35;
}

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

.earning-card {
  min-height: 126px;
  display: grid;
  align-content: start;
  gap: 7px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,.92), rgba(248,252,255,.78));
}

.earning-card span {
  color: var(--muted);
  font-size: 12px;
}

.earning-card strong {
  font-size: 21px;
  font-weight: 650;
}

.earning-card em {
  color: var(--green);
  font-style: normal;
  font-weight: 650;
}

.earning-card small {
  color: var(--muted);
  line-height: 1.35;
}

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

.video-groups {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.trend-bars {
  min-height: 190px;
  display: grid;
  grid-template-columns: repeat(14, minmax(22px, 1fr));
  gap: 8px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(245, 248, 252, .74);
}

.trend-day {
  height: 160px;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 8px;
  align-items: end;
  text-align: center;
}

.trend-day span {
  display: block;
  width: 100%;
  min-height: 7px;
  border-radius: 10px 10px 4px 4px;
  background: linear-gradient(180deg, var(--cyan), var(--blue));
}

.trend-day small {
  color: var(--muted);
  font-size: 11px;
}

.stat-list, .gift-log {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
  padding-right: 3px;
}

.stat-row-item, .gift-log-row {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.78);
}

.gift-log-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.gift-type-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.stat-row-item b {
  width: 22px;
  color: #0d78d5;
  font-weight: 650;
}

.stat-row-item span,
.gift-log-row span,
.gift-feed-item span {
  min-width: 0;
}

.stat-row-item strong,
.gift-log-row strong,
.gift-feed-item strong {
  display: block;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-row-item small,
.gift-log-row small,
.gift-feed-item small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-row-item em,
.gift-log-row em {
  color: #183153;
  font-style: normal;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.avatar, .gift-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 12px;
  background: rgba(18, 200, 210, .12);
}

.avatar {
  border-radius: 50%;
}

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

.avatar.fallback, .gift-icon.fallback {
  color: #0d78d5;
  font-weight: 650;
}

.table {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.video-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.72);
}

.video-row strong, .video-row span {
  display: block;
}

.video-row strong {
  font-weight: 600;
}

.video-row span {
  margin-top: 4px;
  color: var(--muted);
}

.video-row video {
  width: 140px;
  height: 78px;
  border-radius: 12px;
  object-fit: cover;
  background: #111827;
}

.video-row.background-row {
  grid-template-columns: minmax(0, 1fr) 190px auto;
}

.video-row.background-row video {
  width: 190px;
  height: 106px;
}

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

.link-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.68);
}

.link-card span {
  color: #0d78d5;
  font-weight: 650;
}

.link-card code {
  overflow: hidden;
  padding: 10px;
  border-radius: 12px;
  color: #164e63;
  background: rgba(18, 200, 210, .1);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.feed-item, .empty {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.68);
}

.gift-feed-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.feed-item strong, .feed-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  padding: 14px 16px;
  border-radius: 16px;
  color: white;
  background: #111827;
  box-shadow: var(--shadow);
  transition: .18s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.good { background: var(--green); }
.toast.bad { background: var(--red); }

@media (max-width: 1100px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
  }
  .grid, .link-grid, .form-grid, .upload-grid {
    grid-template-columns: 1fr;
  }
  .projector-upload {
    grid-template-columns: 1fr;
  }
  .earning-cards,
  .gift-dashboard,
  .trend-bars,
  .toggle-grid {
    grid-template-columns: 1fr;
  }
  .mini-panel.wide {
    grid-column: auto;
  }
  .span-7, .span-6, .span-5, .upload-grid label, .upload-grid .file-field {
    grid-column: auto;
  }
  .video-row {
    grid-template-columns: 1fr;
  }
}

.hidden { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.auth-card {
  width: min(460px, 100%);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  border-radius: 14px;
  background: #eef3fb;
}

.auth-tab {
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}

.auth-tab.active {
  background: white;
  color: var(--text);
  box-shadow: 0 4px 14px rgba(31, 64, 112, .08);
}

.auth-lead {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: .95rem;
}

.pw-hint {
  margin: -4px 0 0;
  font-size: .82rem;
  color: var(--muted);
}

.auth-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 600;
  color: #fff;
  background: rgba(220, 38, 38, .92);
  border: 1px solid rgba(248, 113, 113, .6);
}

.auth-error.hidden {
  display: none;
}

.pw-hint.bad {
  color: var(--red);
}

.pw-hint.good {
  color: var(--green);
}

.link-button {
  border: 0;
  background: none;
  color: var(--blue);
  cursor: pointer;
  text-decoration: underline;
  font-size: .9rem;
  padding: 0;
}

.plan-card {
  width: min(920px, 100%);
}

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

.plan-option {
  display: grid;
  gap: 10px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .7);
}

.plan-option h3 {
  margin: 0;
}

.plan-option .price {
  font-size: 1.35rem;
  font-weight: 700;
}

.plan-option ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: .92rem;
}

.plan-billing-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.plan-billing-toggle button {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: white;
  cursor: pointer;
}

.plan-billing-toggle button.active {
  border-color: var(--blue);
  color: var(--blue);
  font-weight: 600;
}

.pending-plan {
  padding: 14px 16px;
  border-radius: 14px;
  background: #fff8e8;
  border: 1px solid #f5d78e;
  color: #7a5b00;
}

.plan-hint {
  margin: 0;
}

@media (max-width: 760px) {
  .plan-grid {
    grid-template-columns: 1fr;
  }
}

.brand.compact {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.account-card {
  display: grid;
  gap: 8px;
}

.account-card button {
  width: 100%;
}

.plan-locked-wrap {
  position: relative;
}

.plan-locked-wrap.is-locked > :not(.plan-lock-banner) {
  filter: blur(7px);
  pointer-events: none;
  user-select: none;
}

.plan-lock-banner {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  background: rgba(255, 255, 255, .35);
}

.plan-lock-banner strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.plan-lock-banner::before {
  content: "🔒";
  display: block;
  font-size: 2rem;
  margin-bottom: 8px;
}

.storage-meter {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.storage-meter span {
  height: 8px;
  border-radius: 999px;
  background: #e5edf8;
  overflow: hidden;
}

.storage-meter span em {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid #e5edf8;
  background: #f4f8ff;
  color: #5a6b85;
}

.live-badge.is-live {
  background: #eafaf0;
  border-color: #b9ecca;
  color: #1f8f4d;
}

.live-badge-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #c2cede;
}

.live-badge-dot.active {
  background: #21c45d;
  box-shadow: 0 0 0 4px rgba(33, 196, 93, 0.18);
  animation: livePulse 1.6s infinite;
}

@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(33, 196, 93, 0.32); }
  70% { box-shadow: 0 0 0 6px rgba(33, 196, 93, 0); }
  100% { box-shadow: 0 0 0 0 rgba(33, 196, 93, 0); }
}

.plan-info {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 16px 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: #f4f8ff;
  border: 1px solid #e5edf8;
}

.plan-info-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.plan-info-row strong {
  font-size: 14px;
  color: #1f2d45;
}

@media (max-width: 640px) {
  .plan-info {
    grid-template-columns: 1fr;
  }
}

.earning-card.highlight {
  grid-column: 1 / -1;
  background: linear-gradient(120deg, #eef4ff, #f7fbff);
  border: 1px solid #d8e6fb;
}

.inline-controls select {
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid #e5edf8;
  background: #fff;
  font: inherit;
  color: #1f2d45;
  min-width: 150px;
}

.projector-link-panel {
  margin-bottom: 18px;
}

.projector-link-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.projector-link-row code {
  flex: 1 1 320px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f4f8ff;
  border: 1px solid #e5edf8;
  color: #1f2d45;
}

.projector-link-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.projector-link-actions .primary {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.trigger-panel {
  margin-top: 18px;
}

.trigger-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

.trigger-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.trigger-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: #5a6b85;
}

.trigger-form input,
.trigger-form select {
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid #e5edf8;
  background: #fff;
  font: inherit;
  color: #1f2d45;
}

.trigger-form-actions {
  display: flex;
  gap: 10px;
}

.trigger-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.trigger-card {
  border: 1px solid #e5edf8;
  border-radius: 14px;
  padding: 14px;
  background: #fbfdff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.trigger-card.is-disabled {
  opacity: 0.55;
}

.trigger-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.trigger-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eaf1ff;
  color: #2a6df0;
}

.trigger-thumb {
  width: 100%;
  height: 110px;
  object-fit: cover;
  border-radius: 10px;
}

.trigger-meta {
  color: #8493a8;
}

.trigger-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: auto;
}

.trigger-card-actions button {
  padding: 6px 10px;
  font-size: 12px;
}
