:root {
  --ink: #17202a;
  --muted: #637083;
  --line: #d8e0e8;
  --paper: #f5f7fa;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --danger: #b4232c;
  --gold: #d7a63d;
  --shadow: 0 18px 45px rgba(20, 32, 45, .12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

[hidden],
.is-hidden {
  display: none !important;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
a.button,
.portal-links a {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
a.button:hover,
.portal-links a:hover {
  background: var(--accent-dark);
}

button.secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
}

label {
  display: grid;
  gap: 6px;
  color: #344252;
  font-size: 13px;
}

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

.portal {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(15,118,110,.12), transparent 36%),
    linear-gradient(315deg, rgba(215,166,61,.18), transparent 42%),
    var(--paper);
}

.portal-main {
  width: min(720px, calc(100vw - 32px));
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.portal-main h1 {
  margin: 0 0 8px;
  font-size: 28px;
}

.portal-main p {
  color: var(--muted);
  margin: 0 0 24px;
}

.portal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 16px 22px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header h1 {
  margin: 0;
  font-size: 20px;
}

.app-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.auth-view {
  min-height: calc(100vh - 73px);
  display: grid;
  place-items: center;
  padding: 18px;
}

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

.admin-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: calc(100vh - 73px);
}

.admin-sidebar {
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 14px;
  display: grid;
  align-content: start;
  gap: 12px;
}

.sidebar-head,
.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.activity-list {
  display: grid;
  gap: 8px;
}

.side-nav {
  display: grid;
  gap: 6px;
}

.side-nav-button {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  text-align: left;
}

.side-nav-button.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.activity-card {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-align: left;
  padding: 11px;
}

.activity-card.is-active {
  border-color: var(--accent);
  background: #eef8f6;
}

.activity-card strong,
.activity-card span {
  display: block;
}

.activity-card span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.admin-content {
  min-width: 0;
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 14px;
}

.detail-view {
  display: grid;
  gap: 14px;
}

.detail-head {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.detail-head.flat {
  padding: 0;
  border: 0;
}

.detail-head h2,
.detail-head p {
  margin: 0;
}

.detail-head p {
  color: var(--muted);
  margin-top: 4px;
  font-size: 13px;
}

.detail-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2f4;
}

.tab-button {
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
}

.tab-button.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(22, 32, 42, .12);
}

.form-grid {
  display: grid;
  gap: 12px;
}

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

.form-grid.three {
  grid-template-columns: repeat(3, minmax(150px, 1fr));
}

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

.check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.check-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

.check-chip input {
  width: auto;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-line input {
  width: auto;
}

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

.panel h2 {
  margin: 0 0 14px;
  font-size: 16px;
}

.stack {
  display: grid;
  gap: 12px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.row > * {
  flex: 1;
}

.message {
  padding: 10px 12px;
  border-radius: 6px;
  background: #fff8e6;
  color: #735300;
  border: 1px solid #f0d48b;
}

.table-wrap {
  overflow: auto;
}

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

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

th {
  color: #415063;
  background: #f8fafc;
}

.phone-page {
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: 18px;
  background:
    linear-gradient(135deg, #e6422e, #ffad4d 46%, #f4f7fb 100%);
}

.phone {
  width: min(430px, 100%);
  min-height: calc(100vh - 36px);
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(255,255,255,.55);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.result-list {
  display: grid;
  gap: 8px;
  max-height: 310px;
  overflow: auto;
}

.result-list button {
  text-align: left;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.selected-box {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 16px;
}

.desktop-body {
  height: 100vh;
  overflow: hidden;
  background: #130606;
}

.desktop-control {
  position: fixed;
  z-index: 20;
  left: 16px;
  top: 16px;
  width: 340px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(255,255,255,.6);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.desktop-control.is-collapsed {
  width: auto;
  padding: 8px;
}

.desktop-control.is-collapsed .control-content {
  display: none;
}

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 44%, rgba(255,214,99,.28), transparent 18%),
    linear-gradient(140deg, #a70505, #e33a11 46%, #ff9a2a 100%);
}

#wallCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.stage-title {
  position: absolute;
  left: 50%;
  top: 7vh;
  transform: translateX(-50%);
  color: #fff4c6;
  text-shadow: 0 4px 14px rgba(90,0,0,.5);
  text-align: center;
  pointer-events: none;
}

.stage-title strong {
  display: block;
  font-size: clamp(28px, 5vw, 72px);
}

.stage-title span {
  display: block;
  margin-top: 8px;
  color: rgba(255,255,255,.82);
  font-size: clamp(14px, 1.8vw, 26px);
}

.big-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .15);
  opacity: 0;
  pointer-events: none;
  transition: opacity .45s ease;
}

.big-overlay.is-showing {
  opacity: 1;
}

.big-overlay img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  animation: imageIn .55s ease both;
}

.missing-card {
  display: grid;
  gap: 12px;
  place-items: center;
  min-width: 420px;
  padding: 32px;
  background: rgba(255,255,255,.96);
  border-radius: 8px;
  color: var(--ink);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border-radius: 999px;
  background: #edf7f5;
  color: var(--accent-dark);
  font-size: 13px;
}

@keyframes imageIn {
  from {
    transform: scale(.985);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

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

  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .form-grid.two,
  .form-grid.three,
  .form-grid.four {
    grid-template-columns: 1fr;
  }

  .app-header {
    align-items: stretch;
    flex-direction: column;
  }
}


/* ===== H5 Page Enhancements ===== */
.bg-orbs {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.3;
}
.orb-1 {
  width: 300px;
  height: 300px;
  background: #e6422e;
  top: -80px;
  right: -60px;
  animation: orbFloat 8s ease-in-out infinite;
}
.orb-2 {
  width: 200px;
  height: 200px;
  background: #ffad4d;
  bottom: 10%;
  left: -40px;
  animation: orbFloat 10s ease-in-out infinite reverse;
}
.orb-3 {
  width: 180px;
  height: 180px;
  background: #f59e0b;
  bottom: -40px;
  right: 20%;
  animation: orbFloat 12s ease-in-out infinite 2s;
}
@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(20px, -20px) scale(1.1); }
  66% { transform: translate(-10px, 15px) scale(0.9); }
}

.h5-card {
  position: relative;
  z-index: 1;
  width: min(430px, 100%);
  min-height: calc(100vh - 36px);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.6);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.12);
  padding: 24px 20px;
}
.h5-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, #e6422e, #ff8a4d);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  margin-bottom: 8px;
}
.h5-card h1 {
  margin: 0 0 4px;
  font-size: 24px;
}
.h5-card header p {
  color: var(--muted);
  margin: 0 0 16px;
  font-size: 13px;
}

.phone-page {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: 18px;
  background: linear-gradient(135deg, #e6422e, #ffad4d 46%, #f4f7fb 100%);
}

.loading-bar {
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
  border-radius: 2px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.empty-state {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  padding: 20px !important;
  color: var(--muted);
}
.empty-icon {
  font-size: 20px;
}

.result-list {
  display: grid;
  gap: 8px;
  max-height: 340px;
  overflow: auto;
}
.result-list button {
  text-align: left;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  transition: all .15s ease;
}
.result-list button:hover {
  border-color: var(--accent);
  background: #f0fdfa;
  transform: translateX(4px);
}

.btn-glow {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), #0d9488);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(15,118,110,.3);
  transition: all .15s ease;
}
.btn-glow:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(15,118,110,.4);
}
.btn-glow:active {
  transform: translateY(0);
}

.submit-success {
  text-align: center;
  padding: 20px;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: 12px;
}
.success-icon {
  display: inline-flex;
  width: 48px;
  height: 48px;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 8px;
}
.submit-success p {
  margin: 4px 0;
  color: var(--ink);
}
.submit-success strong {
  color: var(--accent);
  font-size: 20px;
}

.selected-box {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 16px;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Desktop Control Enhancements ===== */
.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #6b7280;
  transition: all .3s ease;
  flex-shrink: 0;
}
.desktop-control {
  position: fixed;
  z-index: 20;
  left: 16px;
  top: 16px;
  width: 340px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.6);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
  padding: 16px;
}
.desktop-control h2 {
  margin: 0 0 12px;
  font-size: 16px;
}
.drop-info {
  font-size: 12px;
  color: var(--muted);
  padding: 8px 0 4px;
}
.wall-stats {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 20;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  color: rgba(255,255,255,.7);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  pointer-events: none;
}

/* ===== Admin UI Enhancements ===== */
.row.gap {
  gap: 8px;
}
.row > button.danger {
  flex: 0 0 auto;
}
.activity-card {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-align: left;
  padding: 11px;
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s ease;
}
.activity-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(15,118,110,.1);
}
.activity-card.is-active {
  border-color: var(--accent);
  background: #eef8f6;
  box-shadow: 0 2px 8px rgba(15,118,110,.12);
}

.member-count {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  margin-left: 6px;
}

/* ===== Responsive fixes ===== */
@media (max-width: 640px) {
  .h5-card {
    border-radius: 12px;
    padding: 16px;
  }
  .desktop-control {
    left: 8px;
    top: 8px;
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
  }
}

/* ===== Directory selector ===== */
.dir-row { display: flex; align-items: center; gap: 8px; }
.dir-label { flex: 1; font-size: 13px; color: #637083; }
.dir-btn { flex-shrink: 0; }
