/* ══════════════════════════════════════════════════════
   Aptel — Sales Leaderboard Dashboard
   ══════════════════════════════════════════════════════ */

:root {
  /* ── Aptel Brand Palette ── */
  --sc-cyan:       #43B3AE;
  --sc-green:      #2E8B57;
  --sc-teal:       #43B3AE;
  --sc-navy:       #242124;
  --sc-steel:      #4A5568;

  /* Primary action (teal) */
  --blue-core:   #2C6E6A;
  --blue-deep:   #1E4F46;
  --blue-struct: #2C6E6A;

  /* Backgrounds — cream mode */
  --black:   #FEFAF3;
  --black-2: #F5F2EE;
  --black-3: #E8E4DF;
  --black-4: #D1CCC6;

  /* Text */
  --silver:     #4A5568;
  --silver-dim: #708090;
  --white:      #242124;

  /* Semantic colors */
  --red:        #E5564A;
  --red-bg:     rgba(229,86,74,0.10);
  --red-border: rgba(229,86,74,0.30);

  --yellow:        #f0b429;
  --yellow-bg:     rgba(240,180,41,0.14);
  --yellow-border: rgba(240,180,41,0.45);

  --green:        #2E8B57;
  --green-bg:     rgba(46,139,87,0.10);
  --green-border: rgba(46,139,87,0.30);

  --orange:        #f97316;
  --orange-bg:     rgba(249,115,22,0.12);
  --orange-border: rgba(249,115,22,0.30);

  /* Cards */
  --card-bg:     #FFFFFF;
  --card-border: rgba(0,0,0,0.08);

  /* ── Aptel Brand Typography ── */
  --font-heading:    'Neue Montreal', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-subheading: 'Helvetica Neue', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body:       'Cerebri Sans', 'DM Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-button:     'Neue Haas Grotesk', 'Helvetica Neue', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #FEFAF3;
  color: var(--white);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: none;
}

body::after { content: none; }

.container {
  position: relative;
  z-index: 1;
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 24px 60px;
}

/* ── HEADER ── */
header {
  position: sticky;
  top: 0;
  z-index: 900;
  background: #FFFFFF;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 12px 0 0;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  margin: 0 -24px 28px;
  padding-left: 24px;
  padding-right: 24px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-office-icon {
  height: 36px;
  width: 36px;
  object-fit: contain;
  flex-shrink: 0;
}

/* Full-logo mode: wide horizontal logo instead of small icon */
.header-office-icon.header-logo-full {
  width: auto;
  height: 44px;
  max-width: 200px;
}

.header-office-name {
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 700;
  color: var(--silver);
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.header-label-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  border-left: 1.5px solid rgba(0,0,0,0.12);
  padding-left: 14px;
  margin-left: 2px;
}

.week-label {
  font-family: var(--font-subheading);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--silver-dim);
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #2E8B57;
  border: none;
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
  text-transform: uppercase;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

/* ── SECTION ── */
.section {
  margin-bottom: 48px;
  animation: fadeUp 0.6s ease both;
}

.section:nth-child(2) { animation-delay: 0.1s; }
.section:nth-child(3) { animation-delay: 0.2s; }
.section:nth-child(4) { animation-delay: 0.3s; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.section-icon { font-size: 20px; }

.section-title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--silver);
}

.section-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(0,0,0,0.5), transparent);
}

.section-count {
  font-family: var(--font-subheading);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--silver-dim);
}

/* ── TABLE ── */
.table-wrap { }

table {
  width: 100%;
  border-collapse: collapse;
  background: #FFFFFF;
}

thead tr {
  background: rgba(0,0,0,0.06);
  border-bottom: 1px solid rgba(0,0,0,0.1);
}

th {
  font-family: var(--font-subheading);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--silver-dim);
  padding: 5px 16px;
  text-align: center;
}

th.name-col { text-align: left; padding-left: 20px; }

/* Frozen rank + name columns */
thead th.sticky-rank,
thead th.sticky-name {
  position: sticky; z-index: 3; background: var(--card-bg);
}
thead th.sticky-rank { left: 0; }
thead th.sticky-name { left: 34px; z-index: 4; }
td.rank {
  position: sticky; left: 0; z-index: 2;
  background: var(--card-bg);
}
td.name-cell {
  position: sticky; left: 34px; z-index: 3;
  background: var(--card-bg);
  padding-left: 6px;
}
tbody tr:hover td.rank,
tbody tr:hover td.name-cell { background: #ededed; }
tr.own-row td.rank,
tr.own-row td.name-cell { background: #e2f0ef; }
tr.own-row:hover td.rank,
tr.own-row:hover td.name-cell { background: #d5e8e6; }
tr.leader-total-row td.rank,
tr.leader-total-row td.name-cell { background: #ebebeb; }
/* Shadow hint on frozen edge */
td.name-cell::after, thead th.sticky-name::after {
  content: ''; position: absolute; top: 0; right: -6px;
  width: 6px; height: 100%;
  background: linear-gradient(to right, rgba(0,0,0,0.06), transparent);
  pointer-events: none;
}

.day-group {
  background: rgba(0,0,0,0.05);
  font-size: 10px;
  letter-spacing: 0.5px;
  color: var(--silver-dim);
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

tbody tr {
  transition: background 0.2s;
  background: var(--card-bg);
}
tbody td {
  border-bottom: 1px solid rgba(0,0,0,0.10);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(0,0,0,0.07); }

/* Rank */
.rank {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  color: var(--silver-dim);
  padding: 0 6px 0 12px;
  text-align: center;
  width: 36px;
}

.rank-1 { color: #FFD700; }
.rank-2 { color: #C0C0C0; }
.rank-3 { color: #CD7F32; }
.rank-medal { font-size: 16px; }

/* Name */
.name-cell {
  padding: 4px 16px 4px 4px;
  text-align: left;
  line-height: 1.2;
}

.name-text {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--white);
}

/* Value cells */
td.val {
  text-align: center;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  padding: 4px 4px;
  min-width: 32px;
}

td.val-weekly {
  font-size: 16px;
  font-weight: 700;
  padding: 7px 10px;
  min-width: 56px;
}

td.val-4w {
  font-size: 16px;
  font-weight: 700;
  padding: 7px 10px;
  min-width: 64px;
  color: var(--silver);
}

/* Color states */
.c-red {
  color: #a80020;
  background: rgba(210,0,40,0.30);
  border-right: 3px solid #cc0028;
  font-weight: 700;
}
.c-yellow {
  color: #7a5200;
  background: rgba(220,160,0,0.35);
  border-right: 3px solid #b87c00;
  font-weight: 700;
}
.c-green {
  color: #005c2a;
  background: rgba(0,160,75,0.32);
  border-right: 3px solid #007a38;
  font-weight: 700;
}
.c-none  { color: var(--silver-dim); }
.c-zero  { color: rgba(0,0,0,0.2); }

/* Top performer glow */
tbody tr.top-row { background: rgba(0,0,0,0.04); }
tbody tr.top-row .name-text { color: var(--sc-cyan); }

/* Total row */
tr.total-row {
  background: rgba(255,255,255,0.4) !important;
  border-top: 1px solid rgba(0,0,0,0.3);
}
tr.total-row td {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1px;
  color: var(--silver);
  padding: 7px 6px;
}
tr.total-row .name-text {
  font-size: 13px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--silver-dim);
}

/* Day / Week separators */
.day-sep { border-left: 1px solid rgba(0,0,0,0.15); }
.week-sep { border-left: 2px solid rgba(0,0,0,0.3); }

/* ── TEAM SECTION ── */
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.team-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: border-color 0.2s, transform 0.2s;
}

.team-card:hover {
  border-color: rgba(0,0,0,0.5);
  transform: translateY(-2px);
}

.team-card.rank-1-card {
  border-color: rgba(255,215,0,0.4);
  background: rgba(255,215,0,0.04);
}

.team-rank {
  font-family: var(--font-subheading);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--silver-dim);
  text-transform: uppercase;
}

.team-name {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--white);
  text-align: center;
}

.team-score {
  font-family: var(--font-heading);
  font-size: 36px;
  font-weight: 700;
  color: var(--sc-cyan);
  line-height: 1;
}

.team-label {
  font-size: 11px;
  color: var(--silver-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.col-group-header { background: rgba(0,0,0,0.04); }

/* ── HERO BAR ── */
.hero-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  background: rgba(255,255,255,0.5);
  border: 1px solid rgba(0,0,0,0.3);
  border-radius: 14px;
  margin-bottom: 32px;
  overflow: hidden;
}

.hero-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 40px;
  gap: 6px;
}

.hero-divider {
  width: 1px;
  height: 60px;
  background: rgba(0,0,0,0.3);
}

.hero-stat-label {
  font-family: var(--font-subheading);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--silver-dim);
}

.hero-stat-value {
  font-family: var(--font-heading);
  font-size: 56px;
  font-weight: 700;
  line-height: 1;
  color: var(--white);
}

.hero-units {
  background: linear-gradient(90deg, var(--sc-cyan), #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── PODIUM ── */
.podium-wrap {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  justify-content: center;
}

.podium-card {
  flex: 1;
  max-width: 340px;
  border-radius: 12px;
  padding: 24px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.2);
  background: rgba(255,255,255,0.5);
}

.podium-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}

.podium-card.p1 {
  padding-top: 32px;
  border-color: rgba(255,215,0,0.4);
  background: linear-gradient(180deg, rgba(255,215,0,0.06) 0%, var(--black-2) 60%);
}
.podium-card.p1::before { background: linear-gradient(90deg, #FFD700, #fbbf24); }
.podium-card.p2::before { background: linear-gradient(90deg, #C0C0C0, #94a3b8); }
.podium-card.p3::before { background: linear-gradient(90deg, #CD7F32, #b45309); }

.podium-position { font-size: 28px; line-height: 1; }

.podium-name {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--white);
  text-align: center;
}

.podium-role {
  font-family: var(--font-subheading);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--silver-dim);
}
#team-podium .podium-role {
  font-size: 28px;
  letter-spacing: 0;
}

.podium-stats { display: flex; gap: 20px; margin-top: 8px; }
.podium-stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.podium-stat-val {
  font-family: var(--font-heading);
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
}
.podium-stat-val.units-val { color: var(--sc-cyan); }
.podium-stat-val.yeses-val { color: var(--silver); }
.podium-stat-lbl {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--silver-dim);
}

@media (max-width: 700px) {
  .podium-wrap { flex-direction: column; align-items: center; }
  .podium-card { max-width: 100%; width: 100%; }
}

/* ── Separator / group total rows ── */
tr.group-total-row td {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 10px 6px;
}
tr.leader-total-row td { background: rgba(0,0,0,0.08); color: var(--silver); }
tr.rep-total-row td    { background: rgba(249,115,22,0.15); color: #7a5200; }
tr.daily-total-row td  { background: rgba(0,0,0,0.04); color: var(--silver); font-weight: 700; }
tr.office-total-row td { background: rgba(0,0,0,0.08); color: var(--silver); font-weight: 700; font-size: 14px; }

/* Day border */
td.day-start, th.day-start { border-left: 2px solid rgba(0,0,0,0.12) !important; }
td.week-start, th.week-start { border-left: 3px solid rgba(0,0,0,0.2) !important; }

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.1);
}
.table-scroll table {
  min-width: max-content;
  width: 100%;
}

/* Collapsible day columns */
.day-toggle { cursor: pointer; user-select: none; white-space: nowrap; }
.day-toggle:hover { color: var(--sc-cyan); }
.day-toggle .toggle-icon {
  display: inline-block;
  font-size: 9px;
  margin-left: 4px;
  transition: transform 0.2s;
  opacity: 0.6;
}
.day-toggle.expanded .toggle-icon { transform: rotate(180deg); }
.detail-col { transition: opacity 0.2s; }
.hidden { display: none !important; visibility: collapse; }

/* ── VIEW TOGGLE GROUP ── */
.view-toggle-group {
  display: flex;
  background: rgba(255,255,255,0.5);
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 8px;
  overflow: hidden;
  margin-right: 12px;
}
.view-toggle {
  padding: 6px 16px;
  font-family: var(--font-subheading);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--silver-dim);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border-right: 1px solid rgba(0,0,0,0.1);
}
.view-toggle:last-child { border-right: none; }
.view-toggle:hover { color: var(--silver); background: rgba(0,0,0,0.08); }
.view-toggle.active { background: rgba(0,0,0,0.12); color: var(--silver); }

/* Own row highlight */
tr.own-row { background: rgba(44,110,106,0.10) !important; }
tr.own-row td { border-top: 2px solid var(--sc-cyan); border-bottom: 2px solid var(--sc-cyan); }
tr.own-row td:first-child { border-left: 3px solid var(--sc-cyan); }
tr.own-row td:last-child { border-right: 3px solid var(--sc-cyan); }
.team-locked { opacity: 0.45; cursor: default; }
.team-locked .team-name { cursor: default !important; }

/* Week summary columns */
th.week-col { color: var(--silver); }
.week-start { border-left: 3px solid rgba(0,0,0,0.15) !important; }
.day-start { border-left: 2px solid rgba(0,0,0,0.07); }

/* ── NAV TABS ── */
#main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 0 10px;
}
.nav-tab {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 18px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--silver-dim);
  font-family: var(--font-button);
  font-size: 13px; font-weight: 700; letter-spacing: 0.5px;
  text-transform: uppercase; cursor: pointer;
  transition: all 0.15s; white-space: nowrap;
}
.nav-tab:hover { color: var(--white); background: rgba(44,110,106,0.08); border-color: rgba(44,110,106,0.2); }
.nav-tab.active { color: var(--sc-cyan); background: rgba(44,110,106,0.12); border-color: rgba(44,110,106,0.35); }
.nav-tab-edit { padding: 8px 12px; font-size: 14px; }
#nav-team-edit { display: none; }

/* ── NAV SEPARATORS ── */
.nav-separator {
  display: inline-block;
  width: 1px;
  height: 20px;
  background: rgba(0, 200, 255, 0.25);
  margin: 0 6px;
  flex-shrink: 0;
  align-self: center;
}

/* ── ROLE SWITCHER (superadmin View-As) ── */
#role-switcher {
  display: none;  /* hidden by default, shown for superadmin */
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 9999;
  align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 24px;
  background: #1a1a2e;
  border-bottom: 2px solid var(--sc-cyan);
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
body.has-role-switcher .container { padding-top: 44px; }
body.has-role-switcher #profile-page { padding-top: 44px; }
body.has-role-switcher header { top: 44px; }
.role-switcher-label {
  font-family: var(--font-subheading); font-size: 11px;
  font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase;
  color: rgba(255,255,255,0.5); white-space: nowrap;
}
.role-switcher-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.role-pill {
  padding: 5px 14px; border-radius: 20px; border: 1px solid rgba(255,255,255,0.2);
  background: transparent; color: rgba(255,255,255,0.6); cursor: pointer;
  font-family: var(--font-subheading); font-size: 12px;
  font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  transition: all 0.15s;
}
.role-pill:hover { border-color: var(--sc-cyan); color: #fff; }
.role-pill.active { background: rgba(0,200,255,0.2); border-color: var(--sc-cyan); color: var(--sc-cyan); }
#role-persona-wrap { margin-left: auto; }
#role-persona {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px; color: #fff; padding: 5px 10px;
  font-family: var(--font-body); font-size: 13px;
  cursor: pointer; min-width: 160px;
}
#role-persona option { background: #1a1a2e; color: #fff; }

/* ── LOCKED / RESTRICTED STATES ── */
.row-locked td { opacity: 0.4; }
.row-locked td.name-cell span.name-text { cursor: default !important; text-decoration: none !important; color: var(--silver-dim) !important; }
.locked-badge {
  display: inline-block; font-size: 9px; letter-spacing: 1px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px; padding: 1px 5px; color: var(--silver-dim);
  vertical-align: middle; margin-left: 6px; text-transform: uppercase;
}
/* Name cell flex layout */
.name-cell-inner {
  display: flex; align-items: center; gap: 8px;
}
.name-cell-left { flex: 1; min-width: 0; }

.tier-badge {
  display: inline-block; font-size: 9px; font-weight: 800; letter-spacing: 0.5px;
  border-radius: 4px; padding: 2px 8px; flex-shrink: 0;
  text-transform: uppercase; white-space: nowrap; cursor: pointer;
  transition: filter 0.15s;
}
.tier-badge:hover { filter: brightness(1.3); }
.tier-badge.tier-1 { background: rgba(34,197,94,0.15); border: 1px solid rgba(34,197,94,0.4); color: #22c55e; }
.tier-badge.tier-2 { background: rgba(0,200,255,0.12); border: 1px solid rgba(0,200,255,0.4); color: #00c8ff; }
.tier-badge.tier-3 { background: rgba(240,180,41,0.15); border: 1px solid rgba(240,180,41,0.4); color: #f0b429; }
.tier-badge.tier-dnq { background: rgba(229,53,53,0.12); border: 1px solid rgba(229,53,53,0.35); color: #e53535; }

/* Tier popup */
.tier-popup {
  position: fixed; z-index: 9999;
  background: var(--card-bg); border: 1px solid rgba(0,200,255,0.25);
  border-radius: 8px; padding: 10px 14px; min-width: 160px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  font-size: 12px; color: var(--white);
}
.tier-popup-title { font-weight: 800; font-size: 13px; margin-bottom: 4px; }
.tier-popup-row { color: var(--silver-dim); line-height: 1.5; }
.tier-popup-label { font-weight: 700; color: var(--white); }
.tier-popup-payout { font-weight: 800; color: #22c55e; font-size: 14px; }
.tier-popup-projected { margin-top: 4px; padding-top: 4px; border-top: 1px solid rgba(255,255,255,0.1); }

/* NAME LINKS */
.name-link { cursor: pointer; transition: color 0.15s; }
.name-link:hover { color: var(--sc-cyan) !important; text-decoration: underline; }

/* ── PROFILE PAGE ── */
#profile-page {
  display: none;
  position: fixed; inset: 0; z-index: 1000;
  background: #FEFAF3;
  overflow-y: auto;
}
#profile-page.open { display: block; }

.profile-page-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

.profile-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid rgba(44,110,106,0.18);
  margin: 0 -24px 28px;
  position: sticky; top: 0; z-index: 10;
  background: #FFFFFF;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.profile-back {
  display: flex; align-items: center; gap: 8px;
  background: rgba(44,110,106,0.12); border: 1px solid rgba(44,110,106,0.30);
  border-radius: 8px; padding: 8px 16px; cursor: pointer;
  color: var(--sc-cyan); font-family: var(--font-button);
  font-size: 14px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  transition: background 0.15s;
}
.profile-back:hover { background: rgba(44,110,106,0.22); }
.profile-back-arrow { font-size: 18px; line-height: 1; }

.profile-heading { text-align: right; }
.profile-page-name { font-family: var(--font-heading); font-size: 36px; font-weight: 700; color: var(--white); letter-spacing: 0.5px; line-height: 1; }
.profile-page-sub { font-size: 13px; color: var(--silver-dim); margin-top: 4px; }
.profile-page-sub span { color: var(--sc-cyan); }

/* ── ORDER CARDS (kept for future use) ── */
.order-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 2px;
}
.urgent-card {
  background: rgba(229,53,53,0.07);
  border-color: rgba(229,53,53,0.30);
  box-shadow: 0 2px 20px rgba(229,53,53,0.10);
}
.pending-card {
  background: rgba(240,180,41,0.06);
  border-color: rgba(240,180,41,0.25);
}
.issue-badge {
  display: inline-block;
  font-family: var(--font-subheading);
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.5px; text-transform: uppercase;
  padding: 3px 10px; border-radius: 6px;
}
.order-field-label {
  font-family: var(--font-subheading);
  font-size: 9px; letter-spacing: 0.5px;
  text-transform: uppercase; color: var(--silver-dim);
  margin-bottom: 2px;
}
.order-field-val {
  font-family: var(--font-body);
  font-size: 14px; font-weight: 700; color: var(--white);
}
.order-num { color: var(--sc-cyan); letter-spacing: 1px; }

.profile-section-title {
  font-family: var(--font-subheading); font-size: 11px; font-weight: 700;
  letter-spacing: 3px; text-transform: uppercase; color: var(--silver-dim);
  margin: 28px 0 12px; border-bottom: 1px solid rgba(0,0,0,0.15); padding-bottom: 8px;
}

.profile-stats-bar { display: flex; background: rgba(255,255,255,0.5); border-radius: 12px; border: 1px solid rgba(0,0,0,0.2); overflow: hidden; margin-bottom: 4px; }
.profile-stat { flex: 1; padding: 20px 12px; text-align: center; border-right: 1px solid rgba(0,0,0,0.15); }
.profile-stat:last-child { border-right: none; }
.profile-stat-val { font-family: var(--font-heading); font-size: 34px; font-weight: 700; color: var(--white); line-height: 1; }
.profile-stat-val.units-val { color: var(--sc-cyan); }
.profile-stat-lbl { font-size: 10px; color: var(--silver-dim); letter-spacing: 0.5px; text-transform: uppercase; margin-top: 4px; }

/* ── BREAKDOWN GRID ── */
.breakdown-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr;
  gap: 8px; margin-bottom: 4px;
}
.breakdown-remark { border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; justify-content: center; }
.breakdown-stat { background: rgba(255,255,255,0.4); border: 1px solid rgba(0,0,0,0.15); border-radius: 8px; padding: 10px 8px; text-align: center; }
.breakdown-val { font-family: var(--font-heading); font-size: 20px; font-weight: 700; color: var(--white); }
.breakdown-lbl { font-size: 9px; letter-spacing: 0.5px; text-transform: uppercase; color: var(--silver-dim); margin-top: 2px; }

/* ── CHURN BUCKETS ── */
.churn-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 4px; }
.churn-bucket { background: rgba(255,255,255,0.4); border: 1px solid rgba(0,0,0,0.15); border-radius: 8px; padding: 12px 8px; text-align: center; transition: background 0.2s; }
.churn-label { font-family: var(--font-subheading); font-size: 11px; font-weight: 700; letter-spacing: 1px; color: var(--silver-dim); text-transform: uppercase; margin-bottom: 6px; }
.churn-pct { font-family: var(--font-heading); font-size: 18px; font-weight: 700; }
.churn-fraction { font-size: 11px; font-weight: 600; color: var(--silver-dim); margin-top: 2px; }

/* ── CHARTS ── */
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 4px; }
.chart-box { background: rgba(255,255,255,0.4); border: 1px solid rgba(0,0,0,0.15); border-radius: 10px; padding: 14px 12px; }
.chart-title { font-family: var(--font-subheading); font-size: 12px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; color: var(--sc-cyan); margin-bottom: 10px; }
.chart-wrap { position: relative; width: 100%; }
.chart-wrap canvas { position: absolute; top: 0; left: 0; width: 100% !important; height: 100% !important; }

@media (max-width: 600px) {
  .breakdown-grid { grid-template-columns: 1fr 1fr; }
  .churn-grid { grid-template-columns: repeat(3, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
}

/* ── LOGIN SCREEN (Aptel Brand) ── */
#login-screen {
  position: fixed; inset: 0; z-index: 9999;
  background: #FEFAF3;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.login-card {
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 20px;
  padding: 48px 40px;
  width: min(400px, 90vw);
  text-align: center;
  box-shadow: 0 4px 32px rgba(0,0,0,0.06);
}

/* Logo centering */
.login-logo-wrap {
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-logo-wrap img {
  height: 80px;
  width: auto;
  display: block;
}

.login-step-title {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 700;
  color: #242124;
  margin-bottom: 6px;
}

.login-step-subtitle {
  font-family: var(--font-body);
  font-size: 13px;
  color: #708090;
  margin-bottom: 28px;
}

.login-input {
  width: 100%;
  box-sizing: border-box;
  background: #F5F2EE;
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 10px;
  padding: 14px 18px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.2px;
  text-align: left;
  color: #242124;
  outline: none;
  margin-bottom: 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.login-input::placeholder { color: #9AA5B1; }

.login-input:focus {
  border-color: #43B3AE;
  box-shadow: 0 0 0 3px rgba(67,179,174,0.12);
}

.login-pin-input {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 12px;
  padding-left: 24px;
}

.login-pin-input::placeholder {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

#login-pin-create-wrap .login-input { margin-bottom: 12px; }
#login-pin-create-wrap .login-input:last-child { margin-bottom: 16px; }

#login-back-link {
  margin-top: 14px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: #43B3AE;
  cursor: pointer;
}
#login-back-link:hover { color: #242124; text-decoration: underline; }

.login-btn {
  width: 100%;
  background: #2C6E6A;
  border: none;
  border-radius: 10px;
  padding: 14px;
  color: #fff;
  font-family: var(--font-button);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: background 0.15s;
}

.login-btn:hover { background: #1E4F46; }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.login-error {
  color: #E5564A;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  margin-top: 12px;
  min-height: 20px;
}

/* ── LOADING SCREEN ── */
#loading-screen {
  position: fixed; inset: 0; z-index: 9998;
  background: #FEFAF3;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 24px;
}

.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(44,110,106,0.15);
  border-top-color: #2C6E6A;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-family: var(--font-subheading);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--silver-dim);
}

/* ── LAST UPDATED INDICATOR ── */
.last-updated {
  font-family: var(--font-subheading);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--silver-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.refresh-btn {
  background: rgba(44,110,106,0.1);
  border: 1px solid rgba(44,110,106,0.3);
  border-radius: 6px;
  color: var(--sc-cyan);
  padding: 3px 10px;
  font-family: var(--font-button);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  text-transform: uppercase;
}
.refresh-btn:hover { background: rgba(44,110,106,0.2); }

/* ── TOAST NOTIFICATIONS ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(0,0,0,0.3);
  border-radius: 10px;
  padding: 12px 20px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  color: var(--white);
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s;
  animation-fill-mode: forwards;
}

@keyframes slideIn {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
  to { opacity: 0; transform: translateY(10px); }
}

/* ═══════════════════════════════════════
   TEAM HIERARCHY — Sub-team cards
   ═══════════════════════════════════════ */

.team-card.sub-team-card {
  border-left: 3px solid var(--sc-cyan);
  opacity: 0.92;
}

.team-parent-badge {
  font-family: var(--font-subheading);
  font-size: 9px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--sc-cyan);
  background: rgba(44,110,106,0.08);
  border: 1px solid rgba(44,110,106,0.2);
  border-radius: 4px;
  padding: 2px 8px;
  align-self: flex-start;
}

/* ═══════════════════════════════════════
   TEAMS PAGE — Tree rows
   ═══════════════════════════════════════ */

.teams-tree-row td {
  padding: 12px 16px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--white);
  border-bottom: 1px solid rgba(0,0,0,0.12);
}

.teams-tree-row:hover {
  background: rgba(0,0,0,0.06);
}

/* ── ORDERS PAGE ── */
#all-orders-body tr:hover,
#my-orders-body tr:hover {
  background: rgba(0,0,0,0.06);
}

#all-orders-body td,
#my-orders-body td {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--silver);
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

/* ═══════════════════════════════════════
   POST SALE — Wizard Form
   ═══════════════════════════════════════ */
#post-sale-page {
  padding: 24px;
}
.post-sale-header {
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(0,0,0,0.12);
  margin-bottom: 28px;
}

/* Step indicator */
.wizard-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 32px;
}
.wizard-step-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-subheading);
  font-size: 13px; font-weight: 700;
  color: var(--silver-dim);
  background: rgba(255,255,255,0.3);
  border: 2px solid rgba(0,0,0,0.15);
  transition: all 0.3s;
  flex-shrink: 0;
}
.wizard-step-dot.active {
  background: var(--sc-cyan);
  border-color: var(--sc-cyan);
  color: #fff;
  box-shadow: 0 0 12px rgba(0,200,255,0.3);
}
.wizard-step-dot.completed {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.wizard-step-line {
  width: 40px; height: 2px;
  background: rgba(0,0,0,0.1);
  transition: background 0.3s;
  flex-shrink: 0;
}
.wizard-step-line.completed { background: var(--green); }

/* Step body */
.wizard-body { min-height: 280px; }
.wizard-step-content { animation: wizardFadeIn 0.25s ease-out; }
@keyframes wizardFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Nav buttons */
.wizard-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid rgba(0,0,0,0.08);
}
.wizard-btn {
  padding: 12px 28px;
  border-radius: 10px;
  font-family: var(--font-subheading);
  font-size: 14px; font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  text-transform: uppercase;
}
.wizard-btn-primary { background: var(--blue-core); color: #fff; }
.wizard-btn-primary:hover { background: var(--blue-deep); }
.wizard-btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.wizard-btn-back {
  background: transparent;
  color: var(--silver-dim);
  border: 1px solid rgba(0,0,0,0.15);
}
.wizard-btn-back:hover { color: var(--white); border-color: rgba(0,0,0,0.3); }

/* Campaign selector */
.campaign-cards { display: flex; gap: 12px; margin-bottom: 24px; }
.campaign-card {
  flex: 1;
  padding: 18px 16px;
  border: 2px solid rgba(0,0,0,0.1);
  border-radius: 14px;
  background: rgba(255,255,255,0.4);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}
.campaign-card:hover { border-color: rgba(0,200,255,0.3); }
.campaign-card.selected {
  border-color: var(--sc-cyan);
  background: rgba(0,200,255,0.06);
}
.campaign-card .campaign-logo {
  max-height: 40px;
  max-width: 100%;
  object-fit: contain;
}

/* Form fields */
.wizard-field { margin-bottom: 20px; }
.wizard-label {
  font-family: var(--font-subheading);
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--silver-dim);
  margin-bottom: 6px;
  display: block;
}
.wizard-input {
  width: 100%; box-sizing: border-box;
  background: rgba(255,255,255,0.5);
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 10px;
  padding: 12px 16px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--white);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.wizard-input:focus {
  border-color: var(--sc-cyan);
  box-shadow: 0 0 0 3px rgba(0,200,255,0.1);
}
.wizard-input::placeholder { color: var(--silver-dim); }
.wizard-hint {
  font-size: 11px; color: var(--silver-dim);
  margin-top: 4px;
}
.wizard-error {
  font-size: 11px; color: var(--red);
  margin-top: 4px; display: none;
}
.wizard-field.has-error .wizard-input { border-color: var(--red); }
.wizard-field.has-error .wizard-error { display: block; }

/* Toggle buttons */
.toggle-group { display: flex; gap: 8px; }
.toggle-btn {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 10px;
  background: rgba(255,255,255,0.3);
  font-family: var(--font-subheading);
  font-size: 13px; font-weight: 700;
  color: var(--silver-dim);
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  letter-spacing: 0.3px;
}
.toggle-btn:hover { border-color: rgba(0,200,255,0.3); }
.toggle-btn.active {
  background: rgba(0,200,255,0.08);
  border-color: var(--sc-cyan);
  color: var(--sc-cyan);
}

/* Product cards */
.product-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.product-card {
  background: rgba(255,255,255,0.4);
  border: 2px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  padding: 20px 16px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  position: relative;
}
.product-card:hover { border-color: rgba(0,200,255,0.3); }
.product-card.selected {
  border-color: var(--sc-cyan);
  background: rgba(0,200,255,0.06);
}
.product-card .product-icon { font-size: 28px; margin-bottom: 8px; }
.product-card .product-label {
  font-family: var(--font-subheading);
  font-size: 13px; font-weight: 700;
  color: var(--white);
  letter-spacing: 0.5px;
}
.product-card .product-check {
  position: absolute; top: 8px; right: 10px;
  font-size: 16px; color: var(--sc-cyan);
  display: none;
}
.product-card.selected .product-check { display: block; }

/* Product sub-fields */
.product-subfields {
  grid-column: 1 / -1;
  max-height: 0; overflow: hidden;
  transition: max-height 0.3s ease-out, padding 0.3s;
  background: rgba(255,255,255,0.25);
  border-radius: 10px;
  padding: 0 16px;
}
.product-subfields.open {
  max-height: 250px;
  padding: 16px;
  border: 1px solid rgba(0,0,0,0.06);
}
.product-subfields .wizard-field { margin-bottom: 12px; }
.product-subfields .wizard-field:last-child { margin-bottom: 0; }

/* Review card */
.review-card {
  background: rgba(255,255,255,0.35);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 16px;
}
.review-card-title {
  font-family: var(--font-subheading);
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--silver-dim);
  margin-bottom: 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.review-edit {
  font-size: 11px; color: var(--sc-cyan);
  cursor: pointer; text-decoration: none;
  font-weight: 600;
}
.review-edit:hover { text-decoration: underline; }
.review-row {
  display: flex; justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  font-size: 13px;
}
.review-row:last-child { border-bottom: none; }
.review-row-label { color: var(--silver-dim); }
.review-row-value { color: var(--white); font-weight: 600; }

/* Success */
.success-check {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--green);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 24px;
  animation: successPop 0.4s ease-out;
  font-size: 36px; color: #fff;
}
@keyframes successPop {
  0%   { transform: scale(0); }
  70%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}
.success-summary {
  text-align: center;
  margin-bottom: 32px;
}
.success-title {
  font-family: 'Neue Montreal','Inter',sans-serif;
  font-size: 24px; font-weight: 700;
  color: var(--white); margin-bottom: 8px;
}
.success-subtitle {
  font-size: 14px; color: var(--silver-dim);
}
.success-actions {
  display: flex; gap: 12px; justify-content: center;
}

/* Responsive — Post Sale small screen */
@media (max-width: 500px) {
  .product-cards { grid-template-columns: 1fr; }
  .campaign-cards { flex-direction: column; }
  .wizard-nav { flex-direction: column-reverse; gap: 10px; }
  .wizard-nav .wizard-btn { width: 100%; text-align: center; }
  .success-actions { flex-direction: column; }
}


/* ═══════════════════════════════════════════════════════
   MOBILE RESPONSIVE — Tablet & Phone (≤768px)
   ═══════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── Nav tabs — horizontal scroll strip ── */
  #main-nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;       /* Firefox */
    padding-bottom: 8px;
    gap: 3px;
  }
  #main-nav::-webkit-scrollbar { display: none; }  /* Chrome/Safari */

  .nav-tab {
    flex-shrink: 0;
    padding: 8px 14px;
    font-size: 12px;
    min-height: 44px;
  }
  .nav-tab-edit { padding: 8px 10px; }
  .nav-separator { width: 1px; height: 16px; margin: 0 3px; }

  /* ── Header — compact ── */
  header {
    padding: 8px 0 0;
    margin: 0 -16px 20px;
    padding-left: 16px;
    padding-right: 16px;
  }
  .header-top {
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 6px;
  }
  .header-office-icon { height: 28px; width: 28px; }
  .header-office-icon.header-logo-full { height: 32px; max-width: 140px; }
  .header-office-name { font-size: 14px; }
  .logo-area { gap: 10px; }

  .header-label-group {
    display: none;  /* Hide week label + live badge on mobile */
  }

  .header-right { gap: 6px; }
  #last-updated { font-size: 9px; letter-spacing: 0.5px; }
  #header-user-info { font-size: 11px !important; }
  .refresh-btn { padding: 3px 8px; font-size: 9px; }

  /* ── Container — reduce padding ── */
  .container {
    padding: 0 16px 40px;
  }

  /* ── Hero bar — stack on small screens ── */
  .hero-bar {
    flex-wrap: wrap;
    border-radius: 12px;
    margin-bottom: 20px;
  }
  .hero-stat {
    padding: 16px 20px;
    min-width: 45%;
    flex: 1 1 45%;
  }
  .hero-stat-value { font-size: 40px; }
  .hero-stat-label { font-size: 10px; letter-spacing: 2px; }
  .hero-divider {
    height: 1px;
    width: 40px;
    background: rgba(0,0,0,0.2);
  }

  /* ── Podium — already handled at 700px ── */

  /* ── Leaderboard table — touch-friendly ── */
  .table-scroll { border-radius: 10px; }
  th { padding: 6px 10px; font-size: 10px; }
  th.name-col { padding-left: 12px; }
  .name-cell { padding: 6px 10px 6px 4px; }
  .name-text { font-size: 13px; }
  td.val { padding: 5px 4px; font-size: 13px; min-width: 28px; }
  td.val-weekly { padding: 6px 6px; font-size: 14px; min-width: 44px; }
  td.val-4w { padding: 6px 6px; font-size: 14px; min-width: 50px; }
  .rank { padding: 0 4px 0 8px; font-size: 12px; width: 28px; }

  /* ── Section headers ── */
  .section { margin-bottom: 32px; }
  .section-title { font-size: 16px; letter-spacing: 2px; }
  .section-icon { font-size: 18px; }

  /* ── Login — compact card ── */
  .login-card {
    padding: 32px 24px;
    border-radius: 16px;
  }
  .login-logo-wrap img { height: 60px; }
  .login-step-title { font-size: 20px; }
  .login-input { font-size: 16px; padding: 14px 16px; }  /* 16px prevents iOS zoom */
  .login-btn { min-height: 44px; font-size: 15px; padding: 14px; }

  /* ── Post Sale wizard — touch targets ── */
  #post-sale-page { padding: 16px; }
  .wizard-btn { min-height: 44px; padding: 12px 20px; }
  .wizard-input { font-size: 16px; min-height: 44px; }  /* Prevent iOS zoom */
  .toggle-btn { min-height: 44px; font-size: 12px; padding: 10px 12px; }

  /* ── Profile page — compact ── */
  .profile-page-inner { padding: 0 16px 60px; }
  .profile-topbar { padding: 12px 16px; margin: 0 -16px 20px; }
  .profile-page-name { font-size: 24px; }
  .profile-page-sub { font-size: 12px; }
  .profile-stat { padding: 14px 8px; }
  .profile-stat-val { font-size: 26px; }
  .profile-stat-lbl { font-size: 9px; }

  /* ── Breakdown grid ── */
  .breakdown-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .breakdown-val { font-size: 18px; }

  /* ── Charts ── */
  .charts-row { grid-template-columns: 1fr; gap: 10px; }

  /* ── Churn buckets ── */
  .churn-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .churn-label { font-size: 10px; }
  .churn-pct { font-size: 16px; }

  /* ── Team grid ── */
  .team-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .team-card { padding: 14px 12px; }
  .team-name { font-size: 15px; }
  .team-score { font-size: 28px; }

  /* ── Orders tables ── */
  #all-orders-body td,
  #my-orders-body td { font-size: 12px; padding: 8px 8px; }

  /* ── Modals — full-width on mobile ── */
  .modal-overlay .modal {
    width: min(95vw, 500px);
    max-height: 90vh;
    overflow-y: auto;
  }

  /* ── Toast — bottom center ── */
  .toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
    text-align: center;
  }

  /* ── Global touch targets ── */
  button, .nav-tab, select, .toggle-btn, .wizard-btn, .campaign-card {
    min-height: 44px;
  }
  select, textarea {
    font-size: 16px;  /* Prevent iOS zoom */
  }

  /* ── Role switcher — compact ── */
  #role-switcher { padding: 6px 16px; flex-wrap: wrap; gap: 8px; }
  .role-switcher-label { font-size: 10px; }
  .role-pill { padding: 4px 10px; font-size: 10px; }
  body.has-role-switcher .container { padding-top: 36px; }
  body.has-role-switcher header { top: 36px; }

  /* ── View toggle group ── */
  .view-toggle-group { margin-right: 6px; }
  .view-toggle { padding: 6px 10px; font-size: 10px; }

  /* ── Full-page overlays ── */
  #roster-page,
  #team-roster-page,
  #teams-page,
  #all-orders-page,
  #my-orders-page,
  #office-page,
  #payroll-page { padding: 16px; }
}


/* ═══════════════════════════════════════════════════════
   MOBILE RESPONSIVE — Small Phones (≤480px)
   ═══════════════════════════════════════════════════════ */
@media (max-width: 480px) {

  /* ── Nav — extra compact ── */
  .nav-tab { padding: 6px 10px; font-size: 11px; }
  .nav-tab-edit { padding: 6px 8px; font-size: 12px; }
  .nav-separator { margin: 0 2px; }

  /* ── Container ── */
  .container { padding: 0 12px 32px; }

  /* ── Header ── */
  header {
    margin: 0 -12px 16px;
    padding-left: 12px;
    padding-right: 12px;
  }
  .header-office-icon { height: 24px; width: 24px; }
  .header-office-icon.header-logo-full { height: 28px; max-width: 120px; }
  .header-office-name { font-size: 13px; }
  .logo-area { gap: 8px; }

  /* ── Hero stats — single column ── */
  .hero-bar {
    flex-direction: column;
    border-radius: 10px;
    margin-bottom: 16px;
  }
  .hero-stat {
    min-width: 100%;
    flex: 1 1 100%;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
  }
  .hero-stat:last-child { border-bottom: none; }
  .hero-stat-value { font-size: 36px; }
  .hero-divider { display: none; }

  /* ── Login ── */
  .login-card { padding: 24px 16px; }
  .login-logo-wrap img { height: 48px; }
  .login-step-title { font-size: 18px; }
  .login-step-subtitle { font-size: 12px; margin-bottom: 20px; }

  /* ── Profile ── */
  .profile-page-inner { padding: 0 12px 50px; }
  .profile-topbar { padding: 10px 12px; margin: 0 -12px 16px; }
  .profile-page-name { font-size: 20px; }
  .profile-stats-bar { flex-wrap: wrap; }
  .profile-stat {
    flex: 1 1 45%;
    min-width: 45%;
    border-right: none;
    border-bottom: 1px solid rgba(0,0,0,0.1);
  }
  .profile-stat:nth-child(odd) { border-right: 1px solid rgba(0,0,0,0.1); }
  .profile-stat-val { font-size: 22px; }
  .breakdown-grid { grid-template-columns: 1fr 1fr; }
  .churn-grid { grid-template-columns: repeat(2, 1fr); }

  /* ── Podium — stack and compact ── */
  .podium-name { font-size: 18px; }
  .podium-stat-val { font-size: 26px; }
  .podium-card { padding: 18px 14px 16px; }

  /* ── Post Sale — full-width buttons ── */
  .wizard-steps { gap: 0; }
  .wizard-step-dot { width: 28px; height: 28px; font-size: 12px; }
  .wizard-step-line { width: 24px; }
  .wizard-btn { font-size: 13px; }

  /* ── Team cards ── */
  .team-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .team-card { padding: 12px 8px; border-radius: 8px; }
  .team-name { font-size: 13px; letter-spacing: 0; }
  .team-score { font-size: 24px; }
  .team-label { font-size: 9px; }

  /* ── Section ── */
  .section { margin-bottom: 24px; }
  .section-title { font-size: 14px; letter-spacing: 1.5px; }
  .section-header { gap: 8px; margin-bottom: 10px; }

  /* ── Role switcher ── */
  #role-switcher { padding: 4px 12px; gap: 6px; }
  .role-pill { padding: 3px 8px; font-size: 9px; }
  body.has-role-switcher .container { padding-top: 32px; }
  body.has-role-switcher header { top: 32px; }

  /* ── Orders ── */
  #all-orders-body td,
  #my-orders-body td { font-size: 11px; padding: 6px 6px; }

  /* ── Full-page overlays ── */
  #roster-page,
  #team-roster-page,
  #teams-page,
  #all-orders-page,
  #my-orders-page,
  #office-page,
  #payroll-page,
  #challenge-page { padding: 12px; }
}


/* ═══════════════════════════════════════════════════════
   CHALLENGE
   ═══════════════════════════════════════════════════════ */

.challenge-empty {
  text-align: center;
  padding: 64px 24px;
  background: #FFFFFF;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 16px;
}

.challenge-btn-primary {
  background: var(--sc-teal, #43B3AE);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 28px;
  font-family: 'Neue Haas Grotesk','Helvetica Neue','Inter',sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.challenge-btn-primary:hover { opacity: 0.85; }

.challenge-btn-secondary {
  background: rgba(0,0,0,0.06);
  color: var(--white);
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 8px;
  padding: 8px 20px;
  font-family: 'Neue Haas Grotesk','Helvetica Neue','Inter',sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.challenge-btn-secondary:hover { background: rgba(0,0,0,0.1); }

.challenge-btn-danger {
  background: rgba(229,86,74,0.12);
  color: #E5564A;
  border: 1px solid rgba(229,86,74,0.25);
  border-radius: 8px;
  padding: 8px 20px;
  font-family: 'Neue Haas Grotesk','Helvetica Neue','Inter',sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.challenge-btn-danger:hover { background: rgba(229,86,74,0.2); }

.challenge-btn-icon {
  background: none;
  border: none;
  color: var(--silver-dim);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
}
.challenge-btn-icon:hover { background: rgba(0,0,0,0.08); color: #E5564A; }

/* Challenge header bar */
.challenge-header-bar {
  background: #FFFFFF;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 12px;
}
.challenge-header-detail {
  font-family: 'Cerebri Sans','DM Sans','Inter',sans-serif;
  font-size: 13px;
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 6px;
}
.challenge-header-label {
  font-family: 'Helvetica Neue','Inter',sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--silver-dim);
}
.challenge-status-badge {
  display: inline-block;
  font-family: 'Cerebri Sans','DM Sans','Inter',sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 3px 10px;
  border-radius: 6px;
}
.challenge-status-active {
  background: rgba(46,139,87,0.12);
  color: #2E8B57;
  border: 1px solid rgba(46,139,87,0.25);
}
.challenge-status-upcoming {
  background: rgba(249,115,22,0.12);
  color: #f97316;
  border: 1px solid rgba(249,115,22,0.25);
}
.challenge-status-ended {
  background: rgba(0,0,0,0.06);
  color: var(--silver-dim);
  border: 1px solid rgba(0,0,0,0.1);
}

/* Management bar */
.challenge-mgmt {
  background: #FFFFFF;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 16px;
}

.challenge-rule-badge {
  display: inline-block;
  background: rgba(67,179,174,0.12);
  color: var(--sc-teal, #43B3AE);
  border: 1px solid rgba(67,179,174,0.25);
  border-radius: 6px;
  padding: 3px 10px;
  font-family: 'Cerebri Sans','DM Sans','Inter',sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

/* Leaderboard table */
.challenge-table {
  width: 100%;
  border-collapse: collapse;
  background: #FFFFFF;
}
.challenge-table th {
  padding: 10px 16px;
  font-family: 'Helvetica Neue','Inter',sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--silver-dim);
  border-bottom: 1px solid rgba(0,0,0,0.15);
  text-align: center;
}
.challenge-table td {
  padding: 10px 16px;
  font-family: 'Cerebri Sans','DM Sans','Inter',sans-serif;
  font-size: 14px;
  color: var(--white);
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.challenge-rank {
  text-align: center;
  font-weight: 700;
  width: 48px;
}
.challenge-name {
  text-align: left;
  font-weight: 600;
}
.challenge-pts {
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.challenge-total {
  font-weight: 800;
  color: var(--sc-teal, #43B3AE);
}
.challenge-penalty {
  color: #E5564A;
  font-size: 12px;
  font-weight: 700;
}
.challenge-penalty-sup {
  color: #E5564A;
  font-size: 9px;
  font-weight: 700;
  vertical-align: super;
  margin-left: 1px;
  letter-spacing: -0.3px;
}
.challenge-row-me {
  background: rgba(67,179,174,0.08);
}
.challenge-row-me td {
  font-weight: 700;
}

/* Rule cards (wizard step 2) */
.challenge-rule-card {
  background: #FFFFFF;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 10px;
  transition: opacity 0.15s;
}
.challenge-rule-card.challenge-rule-disabled {
  opacity: 0.5;
}

/* Toggle switch */
.challenge-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.challenge-toggle input { opacity: 0; width: 0; height: 0; }
.challenge-toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(0,0,0,0.15);
  border-radius: 24px;
  transition: background 0.2s;
}
.challenge-toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.challenge-toggle input:checked + .challenge-toggle-slider {
  background: var(--sc-teal, #43B3AE);
}
.challenge-toggle input:checked + .challenge-toggle-slider::before {
  transform: translateX(20px);
}

/* Role checkboxes */
.challenge-role-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Cerebri Sans','DM Sans','Inter',sans-serif;
  font-size: 13px;
  color: var(--white);
  cursor: pointer;
  user-select: none;
  background: rgba(0,0,0,0.04);
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 6px;
  padding: 6px 12px;
}
.challenge-role-check input {
  accent-color: var(--sc-teal, #43B3AE);
  cursor: pointer;
}

/* Review */
.challenge-review {
  background: #FFFFFF;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 12px;
  padding: 24px;
}
.challenge-review-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  font-family: 'Cerebri Sans','DM Sans','Inter',sans-serif;
  font-size: 14px;
  color: var(--white);
}
.challenge-review-label {
  font-family: 'Helvetica Neue','Inter',sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--silver-dim);
}

/* Tooltip on hover */
.challenge-tip-wrap {
  position: relative;
  cursor: default;
}
.challenge-tip {
  display: none;
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: #FFFFFF;
  color: var(--white);
  font-size: 11px;
  font-family: 'Cerebri Sans','DM Sans','Inter',sans-serif;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: 8px;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  border: 1px solid rgba(0,0,0,0.1);
  min-width: 160px;
}
.challenge-tip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #FFFFFF;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.08));
}
.challenge-tip-wrap:hover .challenge-tip {
  display: block;
}
/* Prevent right-side overflow */
td:nth-last-child(-n+2) .challenge-tip {
  left: auto;
  right: 0;
  transform: none;
}
td:nth-last-child(-n+2) .challenge-tip::after {
  left: auto;
  right: 12px;
  transform: none;
}
/* Flip tooltip below for top rows */
tr:nth-child(-n+3) .challenge-tip {
  bottom: auto;
  top: calc(100% + 10px);
}
tr:nth-child(-n+3) .challenge-tip::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: #FFFFFF;
}
/* Also flip inside thead */
thead .challenge-tip {
  bottom: auto;
  top: calc(100% + 10px);
}
thead .challenge-tip::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: #FFFFFF;
}
/* Receipt rows */
.rcpt-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--silver-dim);
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px dashed rgba(0,0,0,0.12);
}
.rcpt-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 2px 0;
  font-size: 11px;
  color: var(--white);
}
.rcpt-row.rcpt-bold {
  font-weight: 800;
}
.rcpt-row.rcpt-red, .rcpt-row.rcpt-red span {
  color: #E5564A;
}
.rcpt-row.rcpt-teal, .rcpt-row.rcpt-teal span {
  color: var(--sc-teal, #43B3AE);
}
.rcpt-divider {
  border-top: 1px dashed rgba(0,0,0,0.12);
  margin: 4px 0;
}
.rcpt-empty {
  font-size: 11px;
  color: var(--silver-dim);
  font-style: italic;
  padding: 2px 0;
}

/* View toggle (Teams / Individual) */
.challenge-view-toggle {
  display: inline-flex;
  background: rgba(0,0,0,0.06);
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 16px;
}
.challenge-view-btn {
  padding: 6px 18px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-family: 'Neue Haas Grotesk','Helvetica Neue','Inter',sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--silver-dim);
  cursor: pointer;
  transition: all 0.15s;
}
.challenge-view-btn.active {
  background: #FFFFFF;
  color: var(--white);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Banner */
.challenge-banner {
  background: rgba(249,115,22,0.1);
  border: 1px solid rgba(249,115,22,0.25);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-family: 'Cerebri Sans','DM Sans','Inter',sans-serif;
  font-size: 13px;
  color: #f97316;
  text-align: center;
}

/* Team leaderboard cards */
.challenge-team-card {
  background: #FFFFFF;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 10px;
  transition: box-shadow 0.15s;
}
.challenge-team-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.challenge-team-member td {
  font-size: 13px;
  padding: 6px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}

/* Team assignment layout */
.challenge-assign-layout {
  display: flex;
  gap: 20px;
  min-height: 300px;
}
.challenge-assign-pool {
  width: 220px;
  flex-shrink: 0;
  background: #FFFFFF;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 12px;
  padding: 12px;
  max-height: 500px;
  overflow-y: auto;
}
.challenge-assign-pool-header {
  font-family: 'Helvetica Neue','Inter',sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--silver-dim);
  margin-bottom: 8px;
}
.challenge-assign-teams {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-content: flex-start;
}
.challenge-assign-team {
  flex: 1;
  min-width: 200px;
  background: #FFFFFF;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 12px;
  padding: 12px;
}
.challenge-assign-members {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.challenge-assign-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0,0,0,0.04);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: 'Cerebri Sans','DM Sans','Inter',sans-serif;
  font-size: 13px;
  color: var(--white);
}
.challenge-emoji-opt {
  display: inline-block;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0.5;
  transition: opacity 0.1s;
}
.challenge-emoji-opt.active,
.challenge-emoji-opt:hover {
  opacity: 1;
  background: rgba(0,0,0,0.06);
}

@media (max-width: 700px) {
  .challenge-assign-layout { flex-direction: column; }
  .challenge-assign-pool { width: 100%; max-height: 200px; }
}
