:root {
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --paper: #fffaf1;
  --shell: #f6f3eb;
  --panel: #ffffff;
  --orange: #f97316;
  --orange-dark: #c2410c;
  --teal: #0f766e;
  --teal-soft: #d8f3ef;
  --gold: #f59e0b;
  --red: #dc2626;
  --blue: #2563eb;
  --shadow: 0 16px 50px rgba(34, 30, 24, 0.12);
  --small-shadow: 0 8px 24px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.08) 1px, transparent 1px) 0 0 / 42px 42px,
    linear-gradient(0deg, rgba(249, 115, 22, 0.06) 1px, transparent 1px) 0 0 / 42px 42px,
    var(--shell);
  font-family: "Microsoft YaHei UI", "Source Han Sans SC", "PingFang SC", sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 78px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 26px;
  border-bottom: 1px solid rgba(17, 24, 39, 0.08);
  background: rgba(255, 250, 241, 0.9);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 238px;
}

.brand p {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
}

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

.brand-mark {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 8px;
  background: #000;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.brand-mark svg {
  width: 100%;
  height: 100%;
  display: block;
}

.topnav {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 7px;
  align-items: center;
  overflow-x: auto;
}

.nav-btn,
.icon-btn,
.ghost-btn,
.primary-btn,
.secondary-btn,
.table-btn {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.nav-btn {
  padding: 0 13px;
  color: #4b5563;
  background: transparent;
}

.nav-btn.is-active {
  color: var(--ink);
  background: #fff;
  border-color: rgba(249, 115, 22, 0.22);
  box-shadow: 0 6px 18px rgba(249, 115, 22, 0.1);
}

.nav-btn:hover,
.icon-btn:hover,
.ghost-btn:hover,
.primary-btn:hover,
.secondary-btn:hover,
.table-btn:hover {
  transform: translateY(-1px);
}

.icon-btn {
  padding: 0 12px;
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.icon-btn svg,
.ghost-btn svg,
.primary-btn svg,
.secondary-btn svg,
.table-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.workspace {
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  gap: 24px;
  padding: 24px;
  align-items: start;
  flex: 1;
}

.site-footer {
  display: flex;
  justify-content: center;
  padding: 0 24px 20px;
  color: var(--muted);
  font-size: 13px;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--ink);
  text-decoration: underline;
}

.phone-stage {
  position: sticky;
  top: 102px;
  display: grid;
  gap: 14px;
}

.phone {
  width: 390px;
  height: 780px;
  border-radius: 30px;
  padding: 14px;
  background: #191713;
  box-shadow: var(--shadow);
}

.phone-status {
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #f9fafb;
  padding: 0 14px;
  font-size: 12px;
}

.status-dot {
  width: 72px;
  height: 18px;
  border-radius: 99px;
  background: #050505;
}

.mini-app {
  height: calc(100% - 34px);
  overflow: auto;
  border-radius: 22px;
  background: var(--paper);
  scrollbar-width: thin;
}

.mini-hero {
  padding: 18px 18px 14px;
  background: linear-gradient(180deg, #fff4dc, #fffaf1 88%);
  border-bottom: 1px solid rgba(245, 158, 11, 0.18);
}

.mini-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 12px;
}

.mini-poster {
  min-height: 170px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(249, 115, 22, 0.95), rgba(245, 158, 11, 0.86)),
    #f97316;
  color: #fff;
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.mini-poster::before,
.mini-poster::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.28);
  transform: rotate(-12deg);
}

.mini-poster::before {
  width: 150px;
  height: 150px;
  right: -52px;
  top: -36px;
}

.mini-poster::after {
  width: 96px;
  height: 96px;
  right: 28px;
  bottom: -42px;
}

.mini-poster small,
.mini-poster h1,
.mini-poster p {
  position: relative;
  z-index: 1;
}

.mini-poster small {
  display: inline-flex;
  border: 1px solid rgba(255, 255, 255, 0.45);
  padding: 4px 8px;
  border-radius: 6px;
  margin-bottom: 18px;
}

.mini-poster h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.18;
}

.mini-poster p {
  margin: 14px 0 0;
  max-width: 240px;
  line-height: 1.6;
}

.mini-content {
  padding: 16px 18px 18px;
}

.mini-card,
.admin-card,
.stat-card,
.filter-card {
  background: var(--panel);
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 8px;
  box-shadow: var(--small-shadow);
}

.mini-card {
  padding: 15px;
  margin-bottom: 12px;
}

.mini-card h2,
.admin-card h2 {
  margin: 0 0 12px;
  font-size: 17px;
}

.mini-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mini-list li {
  display: flex;
  gap: 8px;
  line-height: 1.55;
  color: #374151;
}

.mini-list li::before {
  content: "";
  flex: 0 0 7px;
  height: 7px;
  margin-top: 8px;
  border-radius: 2px;
  background: var(--teal);
}

.mini-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mini-meta div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fcfcfb;
}

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

.mini-meta strong {
  font-size: 14px;
}

.campus-entry {
  width: 100%;
  margin: 0 0 12px;
  padding: 12px;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  text-align: left;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff, #f2fbf8);
  box-shadow: var(--small-shadow);
  color: var(--ink);
}

.campus-entry small,
.campus-entry em,
.campus-facts span,
.campus-feature-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.campus-entry strong {
  display: block;
  margin: 3px 0;
  font-size: 16px;
}

.campus-entry b {
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 12px;
}

.campus-entry-visual {
  height: 58px;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, #f97316, #f59e0b);
}

.campus-entry-visual::before {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 9px;
  height: 24px;
  border-radius: 5px 5px 2px 2px;
  background: #fffaf1;
}

.campus-entry-visual i {
  position: absolute;
  width: 9px;
  height: 13px;
  bottom: 16px;
  border-radius: 2px;
  background: #0f766e;
}

.campus-entry-visual i:nth-child(1) { left: 18px; }
.campus-entry-visual i:nth-child(2) { left: 32px; }
.campus-entry-visual i:nth-child(3) { left: 46px; }

.campus-page {
  background: var(--paper);
  min-height: 100%;
}

.campus-hero {
  padding: 18px;
  color: #fff;
  background:
    linear-gradient(145deg, rgba(15, 118, 110, 0.94), rgba(17, 24, 39, 0.86)),
    #0f766e;
  position: relative;
  overflow: hidden;
}

.campus-hero h2 {
  margin: 8px 0;
  font-size: 27px;
  line-height: 1.12;
}

.campus-hero p {
  margin: 0;
  max-width: 310px;
  color: rgba(255, 255, 255, 0.86);
  line-height: 1.7;
  font-size: 13px;
}

.campus-hero .eyebrow {
  color: rgba(255, 255, 255, 0.74);
}

.campus-back {
  position: absolute;
  right: 14px;
  top: 14px;
  min-height: 32px;
  padding: 0 10px;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.24);
}

.campus-scene {
  height: 148px;
  margin-top: 16px;
  border-radius: 8px;
  background: linear-gradient(180deg, #fff8ea 0 58%, #e8d4b4 58% 100%);
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.32);
}

.scene-window {
  position: absolute;
  left: 22px;
  top: 20px;
  width: 92px;
  height: 58px;
  border: 5px solid #0f766e;
  background: linear-gradient(135deg, #dff7ff, #fff);
}

.scene-board {
  position: absolute;
  right: 24px;
  top: 24px;
  width: 116px;
  height: 48px;
  border-radius: 5px;
  background: #113f3a;
  box-shadow: 0 8px 0 rgba(17, 24, 39, 0.08);
}

.scene-desk {
  position: absolute;
  width: 96px;
  height: 26px;
  border-radius: 6px;
  background: #f97316;
  box-shadow: 0 14px 0 #7c4a20;
}

.desk-a { left: 44px; bottom: 30px; }
.desk-b { right: 48px; bottom: 28px; }

.campus-content {
  display: grid;
  gap: 12px;
}

.campus-facts,
.campus-feature-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.campus-facts div,
.campus-feature-grid div {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.campus-facts strong,
.campus-feature-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
}

.campus-gallery {
  display: grid;
  gap: 10px;
}

.campus-photo-card {
  padding: 12px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--small-shadow);
}

.campus-photo-card strong {
  display: block;
  margin-top: 10px;
}

.campus-photo-card p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.65;
  font-size: 13px;
}

.campus-photo-art {
  height: 74px;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #fff7ed, #d8f3ef);
}

.campus-photo-art i {
  position: absolute;
  border-radius: 4px;
  background: currentColor;
  opacity: 0.9;
}

.campus-photo-art i:nth-child(1) {
  left: 18px;
  top: 18px;
  width: 58px;
  height: 38px;
  color: #0f766e;
}

.campus-photo-art i:nth-child(2) {
  left: 88px;
  bottom: 17px;
  width: 78px;
  height: 18px;
  color: #f97316;
}

.campus-photo-art i:nth-child(3) {
  right: 18px;
  top: 16px;
  width: 34px;
  height: 42px;
  color: #f59e0b;
}

.tone-1 .campus-photo-art {
  background: linear-gradient(135deg, #f2fbf8, #fff7ed);
}

.tone-2 .campus-photo-art {
  background: linear-gradient(135deg, #fffaf1, #eef6ff);
}

.campus-feature-card {
  margin-bottom: 0;
}

.campus-tips {
  margin: 12px 0 0;
  padding-left: 18px;
  color: #4b5563;
  line-height: 1.7;
}

.mini-bottom.inline {
  padding: 0;
  background: transparent;
  border: 0;
}

.mini-bottom {
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  background: rgba(255, 250, 241, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(17, 24, 39, 0.08);
}

.primary-btn {
  background: var(--orange);
  color: #fff;
  border-color: var(--orange);
  padding: 0 16px;
  box-shadow: 0 10px 22px rgba(249, 115, 22, 0.24);
}

.secondary-btn {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
  padding: 0 14px;
}

.ghost-btn {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
  padding: 0 13px;
}

.mini-bottom .primary-btn,
.mini-bottom .ghost-btn {
  flex: 1;
}

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

.field {
  display: grid;
  gap: 7px;
}

.field label {
  font-size: 13px;
  color: #374151;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #d7dbe2;
  background: #fff;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  outline: none;
}

.field textarea {
  padding-top: 10px;
  min-height: 72px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.16);
}

.error-text {
  min-height: 18px;
  color: var(--red);
  font-size: 12px;
}

.success-panel {
  padding: 24px 18px;
  text-align: center;
}

.success-panel textarea {
  width: 100%;
  min-height: 108px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  resize: vertical;
}

.success-badge {
  width: 60px;
  height: 60px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--teal-soft);
  color: var(--teal);
}

.success-badge svg {
  width: 32px;
  height: 32px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.referral-box {
  margin-top: 18px;
  display: grid;
  gap: 8px;
  text-align: left;
}

.referral-box p {
  margin: 0;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.55;
}

.referral-poster {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding: 12px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 8px;
  background: #f8fffd;
  text-align: left;
}

.poster-head {
  display: grid;
  gap: 2px;
}

.poster-head strong {
  font-size: 15px;
}

.referral-poster img {
  width: 100%;
  aspect-ratio: 3 / 4;
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff8ef;
  object-fit: contain;
}

.poster-save-btn {
  width: 100%;
  text-align: center;
  text-decoration: none;
}

.referral-poster p {
  margin: 0;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.55;
}

.copy-field {
  display: grid;
  gap: 6px;
}

.share-actions {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  text-align: left;
}

.share-actions button,
.share-actions .primary-btn,
.share-actions .secondary-btn,
.share-actions .ghost-btn {
  width: 100%;
}

.share-actions p {
  margin: 0;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.55;
}

.mini-mine {
  padding-bottom: 16px;
}

.mine-hero .mini-card p {
  font-size: 13px;
}

.mine-lead-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--small-shadow);
}

.mine-lead-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.mine-lead-head h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.mine-lead-head strong {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-align: right;
}

.mine-lead-card p {
  margin: 0;
  color: #4b5563;
  font-size: 13px;
  line-height: 1.55;
}

.mine-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.mine-metrics span {
  min-height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f0fdfa;
  color: #0f766e;
  font-size: 12px;
  font-weight: 700;
}

.mine-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mine-actions .primary-btn,
.mine-actions .ghost-btn {
  width: 100%;
  min-height: 40px;
  text-align: center;
  text-decoration: none;
}

.share-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  background: #fff;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--small-shadow);
}

.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.share-panel select {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 10px;
}

.admin-stage {
  min-width: 0;
}

.app-shell[data-entry="parent"][data-route="mini"] .topnav,
.app-shell[data-entry="parent"][data-route="mini"] .admin-stage,
.app-shell[data-entry="parent"][data-route="mini"] .share-panel {
  display: none;
}

.app-shell[data-entry="parent"][data-route="mini"] .workspace {
  grid-template-columns: minmax(0, 430px);
  justify-content: center;
}

.app-shell[data-entry="parent"][data-route="mini"] .phone-stage {
  position: static;
}

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

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

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

.section-head h1 {
  margin: 0;
  font-size: 27px;
  line-height: 1.2;
}

.section-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.button-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.pdf-export-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #374151;
  font-size: 13px;
  font-weight: 700;
}

.pdf-export-control select {
  min-width: 116px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  outline: none;
}

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

.stat-card {
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--orange);
}

.stat-card.teal::before {
  background: var(--teal);
}

.stat-card.gold::before {
  background: var(--gold);
}

.stat-card.blue::before {
  background: var(--blue);
}

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

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
}

.admin-card {
  padding: 18px;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
  gap: 14px;
}

.notification-panel {
  margin-bottom: 14px;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card-title-row h2 {
  margin: 0;
}

.pill-count {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  color: var(--teal);
  background: var(--teal-soft);
  font-size: 12px;
  font-weight: 800;
}

.notification-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.audio-alert-status {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.notification-list {
  display: grid;
  gap: 10px;
}

.notification-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.notification-row.is-unread {
  border-color: rgba(249, 115, 22, 0.35);
  box-shadow: 0 8px 22px rgba(249, 115, 22, 0.08);
}

.notification-main {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.notification-main strong,
.notification-main p {
  margin: 0;
}

.notification-main p {
  color: var(--muted);
  font-size: 13px;
}

.notification-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.funnel-row {
  display: grid;
  grid-template-columns: 100px 1fr 46px;
  align-items: center;
  gap: 10px;
  color: #374151;
}

.funnel-track {
  height: 12px;
  border-radius: 8px;
  background: #f3f4f6;
  overflow: hidden;
}

.funnel-bar {
  height: 100%;
  width: var(--value);
  background: linear-gradient(90deg, var(--teal), var(--orange));
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  min-width: 760px;
}

th,
td {
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid #edf0f4;
  vertical-align: middle;
  font-size: 14px;
}

th {
  color: #4b5563;
  background: #fafafa;
  font-size: 12px;
  font-weight: 800;
}

tr:last-child td {
  border-bottom: 0;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
  line-height: 1.5;
}

.referral-alert {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-size: 13px;
  line-height: 1.5;
}

.referral-alert.compact {
  margin-top: 6px;
  padding: 6px 8px;
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 6px;
  background: #f3f4f6;
  color: #374151;
  font-size: 12px;
  font-weight: 700;
}

.badge.new {
  background: #fff7ed;
  color: #c2410c;
}

.badge.contacted,
.badge.trial_booked {
  background: #eff6ff;
  color: #1d4ed8;
}

.badge.trial_done {
  background: #fef3c7;
  color: #92400e;
}

.badge.visited {
  background: #fef3c7;
  color: #92400e;
}

.badge.enrolled {
  background: #ccfbf1;
  color: #0f766e;
}

.badge.invalid {
  background: #fee2e2;
  color: #991b1b;
}

.filter-card {
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(160px, 1.4fr) repeat(5, minmax(120px, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

.filter-card .field {
  gap: 5px;
}

.filter-card input,
.filter-card select {
  min-height: 38px;
}

.lead-actions {
  display: grid;
  grid-template-columns: minmax(118px, 0.9fr) minmax(150px, 1.2fr) repeat(3, auto);
  gap: 8px;
  align-items: center;
  min-width: 520px;
}

.lead-actions select,
.lead-actions input {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
}

.table-btn {
  min-height: 34px;
  padding: 0 10px;
  background: #fff7ed;
  color: var(--orange-dark);
  border-color: rgba(249, 115, 22, 0.25);
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 22px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.52);
  backdrop-filter: blur(5px);
}

.lead-modal {
  position: relative;
  width: min(980px, 100%);
  max-height: min(860px, calc(100vh - 44px));
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.lead-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: #fffaf1;
}

.lead-modal-head h2 {
  margin: 4px 0 6px;
  font-size: 22px;
}

.lead-modal-head p {
  margin: 0;
  color: var(--muted);
}

.lead-modal .icon-btn {
  width: 40px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.lead-modal-body {
  overflow: auto;
  padding: 18px;
  display: grid;
  gap: 14px;
}

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

.detail-section h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.detail-section h4 {
  margin: 14px 0 8px;
  font-size: 14px;
}

.referral-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 4px;
}

.referral-metrics div {
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  background: #f9fafb;
  border: 1px solid #edf0f4;
}

.referral-metrics span,
.referral-metrics strong {
  display: block;
}

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

.referral-metrics strong {
  margin-top: 4px;
  font-size: 18px;
}

.detail-followup-form {
  display: grid;
  grid-template-columns: minmax(140px, 0.8fr) minmax(240px, 1.7fr) auto;
  gap: 10px;
  align-items: end;
}

.detail-followup-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.detail-followup-form select,
.detail-followup-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
}

.detail-followup-form textarea {
  min-height: 40px;
  resize: vertical;
}

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

.detail-row {
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  background: #f9fafb;
  border: 1px solid #edf0f4;
}

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

.detail-row strong {
  display: block;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.timeline-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.timeline-list li {
  border-left: 3px solid var(--teal);
  padding: 8px 10px;
  background: #f9fafb;
  border-radius: 0 8px 8px 0;
}

.timeline-list strong,
.timeline-list span {
  display: block;
}

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

.timeline-list p {
  margin: 6px 0 0;
  color: #374151;
  line-height: 1.6;
}

.branch-chart {
  overflow-x: auto;
  padding: 8px 0 8px 4px;
}

.branch-subtree {
  display: flex;
  align-items: center;
  min-width: max-content;
}

.branch-node {
  max-width: 160px;
  min-width: 54px;
  padding: 6px 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--branch-color, #0f766e);
}

.branch-node strong {
  display: block;
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.branch-children {
  display: grid;
  gap: 12px;
  margin-left: 34px;
  position: relative;
}

.branch-subtree > .branch-children::before {
  content: "";
  position: absolute;
  left: -18px;
  top: 18px;
  bottom: 18px;
  width: 1px;
  background: #c9d2dc;
  border-radius: 999px;
}

.branch-row {
  display: flex;
  align-items: center;
  min-width: max-content;
  position: relative;
}

.branch-row::before {
  content: "";
  position: absolute;
  left: -18px;
  top: 50%;
  width: 18px;
  height: 1px;
  background: #c9d2dc;
  border-radius: 999px;
}

.branch-subtree > .branch-node::after {
  content: "";
  display: inline-block;
  width: 18px;
  height: 1px;
  margin: 0 -26px 4px 8px;
  background: #c9d2dc;
  border-radius: 999px;
}

.branch-subtree:not(.has-children) > .branch-node::after {
  display: none;
}

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

.channel-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  display: grid;
  gap: 12px;
}

.qr-stub {
  width: 86px;
  height: 86px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, #111827 10px, transparent 10px 18px, #111827 18px 28px, transparent 28px) 0 0 / 30px 30px,
    linear-gradient(#111827 10px, transparent 10px 18px, #111827 18px 28px, transparent 28px) 0 0 / 30px 30px,
    #fff;
  border: 8px solid #fff;
  box-shadow: inset 0 0 0 1px var(--line), 0 4px 12px rgba(17, 24, 39, 0.12);
}

.channel-card-top {
  display: flex;
  gap: 12px;
  align-items: center;
}

.mono {
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  color: #4b5563;
  overflow-wrap: anywhere;
}

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

.auth-card {
  max-width: 460px;
}

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

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

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  min-width: 220px;
  max-width: 360px;
  min-height: 46px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: #111827;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.empty {
  padding: 28px;
  border: 1px dashed #d1d5db;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  background: #fff;
}

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

  .phone-stage {
    position: static;
    grid-template-columns: 390px minmax(260px, 1fr);
    align-items: start;
  }
}

@media (max-width: 900px) {
  .topbar {
    height: auto;
    padding: 14px;
    flex-wrap: wrap;
  }

  .brand {
    min-width: 0;
    flex: 1 1 100%;
  }

  .workspace {
    padding: 14px;
  }

  .phone-stage {
    grid-template-columns: 1fr;
  }

  .app-shell[data-route="mini"] .admin-stage {
    display: none;
  }

  .app-shell:not([data-route="mini"]) .phone-stage {
    display: none;
  }

  .phone {
    width: 100%;
    max-width: 430px;
    height: auto;
    min-height: 0;
    margin: 0 auto;
    padding: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .phone-status {
    display: none;
  }

  .mini-app {
    height: auto;
    min-height: 680px;
    overflow: visible;
    border: 1px solid rgba(17, 24, 39, 0.08);
    border-radius: 12px;
  }

  .mini-content {
    padding-bottom: 16px;
  }

  .form-hero {
    display: none;
  }

  .form-grid {
    gap: 6px;
  }

  .field {
    gap: 4px;
  }

  .field label {
    font-size: 12px;
  }

  .field input,
  .field select,
  .field textarea {
    min-height: 34px;
    padding: 0 10px;
    border-radius: 7px;
  }

  .field textarea {
    min-height: 42px;
    padding-top: 8px;
  }

  .error-text {
    min-height: 0;
    line-height: 1.25;
  }

  .form-grid .primary-btn,
  .form-grid .ghost-btn {
    min-height: 36px;
  }

  .stats-grid,
  .split-grid,
  .settings-grid,
  .referral-metrics,
  .filter-card {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .button-row {
    width: 100%;
    justify-content: stretch;
  }

  .button-row > button {
    flex: 1;
  }

  .pdf-export-control {
    width: 100%;
    justify-content: space-between;
  }

  #leadsView .table-wrap {
    overflow: visible;
    border: 0;
  }

  #leadsView table,
  #leadsView tbody,
  #leadsView tr,
  #leadsView td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  #leadsView thead {
    display: none;
  }

  #leadsView tr {
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  #leadsView td {
    padding: 6px 0;
    border-bottom: 0;
  }

  #leadsView .lead-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    min-width: 0;
  }

  #leadsView .lead-actions select,
  #leadsView .lead-actions input,
  #leadsView .lead-actions .table-btn {
    width: 100%;
  }

  .modal-root {
    padding: 10px;
  }

  .lead-modal {
    max-height: calc(100vh - 20px);
  }

  .lead-modal-head {
    flex-direction: column;
  }

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

  .detail-followup-form {
    grid-template-columns: 1fr;
  }
}
