:root {
  --bg: #f5f7fb;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-2: rgba(246, 248, 252, 0.94);
  --line: rgba(14, 42, 74, 0.1);
  --gold: #c59a43;
  --gold-2: #dfbd71;
  --text: #111b2e;
  --muted: #67758b;
  --blue: #0b2a4a;
  --green: #35c981;
  --red: #ef6767;
  --orange: #e8a94f;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -8%, rgba(197, 154, 67, 0.16), transparent 30%),
    radial-gradient(circle at 0% 16%, rgba(11, 42, 74, 0.08), transparent 34%),
    linear-gradient(180deg, #fbfcff 0%, #f4f7fb 58%, #edf2f8 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.28;
  background-image:
    linear-gradient(rgba(14,42,74,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(14,42,74,0.03) 1px, transparent 1px);
  background-size: 42px 42px;
}

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

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 16px 86px;
  position: relative;
}

.app-content { display: none; }
.app-content.active { display: block; }

.auth-page {
  min-height: calc(100vh - 36px);
  display: grid;
  align-items: center;
}

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

.auth-card {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 24px 60px rgba(17, 27, 46, 0.12);
  border-radius: 8px;
  padding: 22px;
  display: grid;
  gap: 16px;
}

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

.cloud-warning {
  display: none;
  color: #84621d;
  background: rgba(197, 154, 67, 0.1);
  border: 1px solid rgba(197, 154, 67, 0.22);
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
  line-height: 1.6;
}

.cloud-warning.active { display: block; }

.secondary-button {
  min-height: 46px;
  color: var(--blue);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(11, 42, 74, 0.04);
  font-weight: 700;
}

.wide { width: 100%; text-align: center; }

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sync-pill {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--blue);
  background: rgba(11, 42, 74, 0.06);
  border: 1px solid rgba(11, 42, 74, 0.1);
  font-size: 12px;
  white-space: nowrap;
}

.topbar, .section-head, .customer-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 25px; letter-spacing: 0; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }

.page { display: none; padding-top: 18px; }
.page.active { display: block; }

.hero-panel, .card, .metric-card, .dialog-card, .market-panel, .home-funnel {
  border: 1px solid var(--line);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.94), rgba(250, 252, 255, 0.78));
  box-shadow: 0 18px 44px rgba(17, 27, 46, 0.1);
  border-radius: 8px;
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.hero-panel {
  min-height: 164px;
  padding: 19px;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 12px;
}

.advisor-hero {
  position: relative;
  overflow: hidden;
}

.advisor-hero::after {
  content: "";
  position: absolute;
  right: -44px;
  top: -66px;
  width: 180px;
  height: 180px;
  border: 1px solid rgba(197, 154, 67, 0.2);
  border-radius: 999px;
  box-shadow: inset 0 0 42px rgba(197, 154, 67, 0.08);
}

.hero-copy {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: space-between;
  gap: 10px;
  max-width: 75%;
}

.hero-copy h2 {
  font-size: 28px;
  line-height: 1.12;
  letter-spacing: 0;
  color: var(--blue);
}

.hero-subtitle {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.hero-orbit {
  position: relative;
  z-index: 1;
  width: 82px;
  height: 82px;
  align-self: center;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--gold);
  background:
    radial-gradient(circle, rgba(197, 154, 67, 0.14), rgba(197, 154, 67, 0.02) 62%),
    rgba(11, 42, 74, 0.03);
  border: 1px solid rgba(197, 154, 67, 0.28);
}

.hero-orbit span {
  font-size: 30px;
  font-weight: 800;
}

.hero-orbit small {
  position: absolute;
  bottom: 15px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.12em;
}

.gold-pill, .stage-tag, .level-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}

.gold-pill {
  color: #fff;
  background: linear-gradient(135deg, var(--blue), #164b7a);
}

.stage-tag {
  color: #84621d;
  border: 1px solid rgba(197, 154, 67, 0.26);
  background: rgba(197, 154, 67, 0.1);
}

.level-tag {
  color: var(--blue);
  background: rgba(11, 42, 74, 0.07);
}

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

.metric-card {
  position: relative;
  min-height: 104px;
  padding: 15px;
  overflow: hidden;
  cursor: pointer;
}

.metric-card:active {
  transform: scale(0.985);
}

.metric-card::after {
  content: "";
  position: absolute;
  right: 13px;
  bottom: 12px;
  width: 42px;
  height: 18px;
  border-bottom: 1px solid rgba(197, 154, 67, 0.4);
  border-right: 1px solid rgba(197, 154, 67, 0.2);
  transform: skewX(-18deg);
  opacity: 0.7;
}

.metric-card strong {
  display: block;
  color: var(--blue);
  font-size: 32px;
  line-height: 1.1;
  margin-top: 8px;
}

.metric-card em {
  position: absolute;
  top: 14px;
  right: 14px;
  color: rgba(103, 117, 139, 0.72);
  font-size: 10px;
  font-style: normal;
  letter-spacing: 0.11em;
}

.market-panel {
  min-height: 88px;
  margin: 2px 0 16px;
  padding: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.market-panel h3 {
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
  font-weight: 650;
}

.signal-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 7px rgba(53, 201, 129, 0.12), 0 0 20px rgba(53, 201, 129, 0.45);
  flex: 0 0 auto;
}

.compact-head { margin-top: 2px; }

.home-funnel {
  padding: 14px;
  display: grid;
  gap: 12px;
  margin: 10px 0 18px;
}

.home-funnel-item {
  display: grid;
  grid-template-columns: 48px 1fr 32px;
  align-items: center;
  gap: 10px;
}

.home-funnel-item span {
  color: var(--muted);
  font-size: 13px;
}

.home-funnel-item strong {
  color: var(--blue);
  text-align: right;
}

.home-funnel-track {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(11, 42, 74, 0.08);
}

.home-funnel-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #a9813f, #f2d68f);
}

.muted { color: var(--muted); font-size: 13px; }
.stack { display: grid; gap: 10px; margin-top: 12px; }

.card {
  padding: 14px;
  display: grid;
  gap: 11px;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.card:active {
  transform: scale(0.985);
  border-color: rgba(11, 42, 74, 0.24);
}

.reminder-card {
  border-left: 3px solid rgba(217, 173, 97, 0.5);
}

.reminder-card.alert-overdue {
  border-color: rgba(239, 103, 103, 0.42);
  border-left-color: var(--red);
}

.reminder-card.alert-today {
  border-left-color: var(--gold-2);
}

.reminder-card.alert-hot {
  border-left-color: var(--green);
}

.reminder-group {
  display: grid;
  gap: 6px;
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.compact-customer-card {
  display: grid;
  gap: 10px;
}

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

.compact-line strong {
  color: var(--blue);
}

.next-action-line {
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

.compact-tags {
  max-height: 32px;
  overflow: hidden;
}

.card-title {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.card-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 17px;
}

.progress {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(11, 42, 74, 0.08);
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--green));
}

.tag-row, .filter-row, .reminder-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag {
  color: #526174;
  background: rgba(11, 42, 74, 0.05);
  border: 1px solid rgba(11, 42, 74, 0.08);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
}

.status-chip {
  color: #fff;
  background: linear-gradient(135deg, var(--blue), #164b7a);
  border-color: transparent;
}

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

.check-option {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(11, 42, 74, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
}

.check-option input {
  width: auto;
}

.age-preview {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid rgba(197, 154, 67, 0.28);
  border-radius: 8px;
  color: var(--blue);
  background: rgba(197, 154, 67, 0.08);
  font-weight: 700;
}

.form-details {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(11, 42, 74, 0.1);
  border-radius: 8px;
  background: rgba(11, 42, 74, 0.035);
}

.form-details summary {
  color: var(--blue);
  font-weight: 800;
  cursor: pointer;
}

.form-details[open] {
  padding-bottom: 12px;
}

.form-details[open] summary {
  margin-bottom: 8px;
}

.search-wrap input, label input, label select, label textarea {
  width: 100%;
  color: var(--text);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(11, 42, 74, 0.12);
  border-radius: 8px;
  padding: 12px;
  outline: none;
}

.search-wrap input:focus, label input:focus, label select:focus, label textarea:focus {
  border-color: rgba(11, 42, 74, 0.42);
}

.filter-row, .reminder-tabs { margin: 12px 0 4px; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
.filter-row button, .reminder-tabs button, .text-button {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(11, 42, 74, 0.08);
  border-radius: 999px;
  padding: 8px 11px;
  white-space: nowrap;
}

.filter-row button.active, .reminder-tabs button.active {
  color: #fff;
  background: var(--blue);
}

.text-button { padding: 6px 10px; color: var(--blue); }
.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--blue);
  background: rgba(255, 255, 255, 0.86);
}

.primary-button {
  min-height: 46px;
  color: #fff;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--blue), #164b7a);
  font-weight: 700;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 520px);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 9px 12px 13px;
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.bottom-nav button {
  min-height: 44px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-size: 13px;
}

.bottom-nav button.active {
  color: #fff;
  background: var(--blue);
  font-weight: 700;
}

.staff-mode [data-nav="statsPage"],
.staff-mode [data-nav="adminPage"],
.staff-mode #statsPage,
.staff-mode #adminPage,
.staff-mode #seedBtn {
  display: none !important;
}

.staff-mode .bottom-nav {
  grid-template-columns: repeat(3, 1fr);
}

.fab {
  position: fixed;
  right: max(18px, calc((100vw - 520px) / 2 + 18px));
  bottom: 78px;
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), #164b7a);
  box-shadow: 0 12px 26px rgba(17, 27, 46, 0.18);
  font-size: 28px;
}

dialog {
  width: min(94vw, 480px);
  border: 0;
  padding: 0;
  background: transparent;
}

dialog::backdrop { background: rgba(0, 0, 0, 0.58); }
dialog.fallback-open {
  display: block;
  position: fixed;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  z-index: 30;
}

body.dialog-fallback::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 29;
  background: rgba(0, 0, 0, 0.58);
}

.dialog-card { padding: 16px; gap: 12px; display: grid; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
textarea { min-height: 84px; resize: vertical; }

.dialog-card {
  max-height: min(88vh, 820px);
  overflow: auto;
}

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

.danger-button {
  min-height: 38px;
  color: #b4232a;
  border: 1px solid rgba(239, 103, 103, 0.35);
  border-radius: 8px;
  background: rgba(239, 103, 103, 0.1);
}

.small-button {
  min-height: 38px;
  color: var(--blue);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

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

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

.deal-summary-card {
  display: grid;
  gap: 12px;
}

.next-action-hero {
  padding: 13px;
  border-radius: 8px;
  border: 1px solid rgba(197, 154, 67, 0.22);
  background: rgba(197, 154, 67, 0.08);
}

.next-action-hero p {
  margin-top: 5px;
  color: var(--blue);
  font-weight: 800;
  line-height: 1.6;
}

.info-box {
  padding: 12px;
  border-radius: 8px;
  background: rgba(11, 42, 74, 0.045);
}

.highlight-box {
  border: 1px solid rgba(11, 42, 74, 0.08);
  background: rgba(255, 255, 255, 0.72);
}

.detail-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 14px 32px rgba(17, 27, 46, 0.08);
  overflow: hidden;
}

.detail-section summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  color: var(--blue);
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

.detail-section summary::-webkit-details-marker {
  display: none;
}

.detail-section summary::after {
  content: "+";
  margin-left: auto;
  color: var(--gold);
  font-size: 20px;
}

.detail-section[open] summary::after {
  content: "-";
}

.detail-section-body {
  display: grid;
  gap: 10px;
  padding: 0 14px 14px;
}

.guidance-panel {
  border-color: rgba(197, 154, 67, 0.22);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(246, 249, 252, 0.88)),
    radial-gradient(circle at top right, rgba(197, 154, 67, 0.16), transparent 36%);
}

.script-box {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid rgba(11, 42, 74, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.script-box p {
  margin: 6px 0 0;
  line-height: 1.7;
}

.timeline {
  border-left: 1px solid var(--line);
  padding-left: 13px;
  display: grid;
  gap: 12px;
}

.timeline-item {
  position: relative;
  display: grid;
  gap: 4px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -18px;
  top: 5px;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--gold);
}

.funnel {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.funnel-row {
  display: grid;
  grid-template-columns: 72px 1fr 44px;
  align-items: center;
  gap: 9px;
}

.bar {
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), rgba(197, 154, 67, 0.35));
}

@media (min-width: 760px) {
  .app-shell { padding-top: 28px; }
}
