:root {
      --bg: #1a1a2e;
      --card: #16213e;
      --card-2: #111b31;
      --accent: #0f3460;
      --accent-2: #214f83;
      --text: #e0e0e0;
      --green: #00b894;
      --yellow: #fdcb6e;
      --orange: #ff9f43;
      --red: #e74c3c;
      --black: #000000;
      --muted: #8fa3bf;
      --border: rgba(255,255,255,0.1);
      --shadow-soft: 0 12px 28px rgba(0, 0, 0, 0.22);
      --shadow-panel: 0 18px 40px rgba(0, 0, 0, 0.28);
      --header-height: 110px;
    }
    * { box-sizing: border-box; }
    body {
      margin: 0;
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
      background: radial-gradient(circle at top right, #243b6b 0%, var(--bg) 50%);
      color: var(--text);
      padding: calc(var(--header-height) + 24px) 20px 24px;
      font-size: 16px;
      line-height: 1.45;
    }
    .container { max-width: 1280px; margin: 0 auto; }
    .header-shell {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      z-index: 40;
      padding: 14px 20px 0;
      backdrop-filter: blur(14px);
      background: linear-gradient(180deg, rgba(255, 255, 255, 0.97) 0%, rgba(255, 255, 255, 0.92) 72%, rgba(255, 255, 255, 0) 100%);
    }
    .header-shell[data-header-ready="false"] {
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
    }
    .header-shell[data-header-ready="true"] {
      opacity: 1;
      visibility: visible;
      transition: opacity 120ms ease-out;
    }
    .top-nav {
      display: flex;
      align-items: center;
      gap: 16px;
      padding: 12px 16px;
      border: 1px solid var(--border);
      background: rgba(17, 27, 49, 0.72);
      border-radius: 14px;
      box-shadow: var(--shadow-soft);
      min-height: 60px;
    }
    .back-btn {
      border: 1px solid rgba(255,255,255,0.15);
      background: rgba(255,255,255,0.05);
      color: var(--text);
      border-radius: 10px;
      width: auto;
      height: 40px;
      padding: 0 14px;
      font-size: 14px;
      font-weight: 600;
      line-height: 1;
      cursor: pointer;
      visibility: hidden;
    }
    .back-btn:hover {
      background: rgba(255,255,255,0.1);
      border-color: rgba(255,255,255,0.22);
    }
    .view-title { font-weight: 700; font-size: 1.05rem; letter-spacing: 0.01em; }
    .header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 18px;
      max-width: 1280px;
      margin: 0 auto;
      padding: 12px 22px;
      border: 1px solid #dbeafe;
      background: #ffffff;
      border-radius: 12px;
    }
    .header-brand {
      display: flex;
      align-items: center;
      gap: 16px;
      min-width: 0;
    }
    .header-logo {
      width: 200px;
      max-width: 34vw;
      height: auto;
      flex: 0 0 auto;
      filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.28));
    }
    .header-logo.logo-light-bg {
      background: transparent;
      border-radius: 0;
      padding: 0;
      filter: none;
      box-shadow: none;
      width: auto;
      max-width: 180px;
    }
    .brand-lockup-logo.header-logo.logo-light-bg {
      max-width: min(360px, 42vw);
    }
    .text-logo {
      font-family: 'Inter', sans-serif;
      font-weight: 800;
      font-size: 20px;
      color: #0f172a;
      text-decoration: none;
      letter-spacing: -0.02em;
      flex: 0 0 auto;
    }
    .text-logo span {
      color: #2563eb;
    }
    .text-logo:hover {
      opacity: 0.85;
    }
    .brand-only-header .header {
      display: grid;
      grid-template-columns: 1fr auto 1fr;
      align-items: center;
      padding: 8px 22px;
    }
    .brand-only-header .header-brand {
      justify-self: start;
    }
    .brand-only-header .header-brand > :not(.header-logo) {
      display: none;
    }
    .brand-only-header .brand-center-title {
      display: flex;
      flex-direction: column;
      align-items: center;
      text-align: center;
    }
    .brand-only-header .brand-center-title .title {
      font-size: 1.25rem;
      font-weight: 700;
      white-space: nowrap;
    }
    .brand-only-header .brand-center-title .subtitle {
      font-size: 0.75rem;
      color: var(--muted);
    }
    .brand-only-header .header-meta {
      justify-self: end;
    }
    /* Brand-only: two-row sticky header */
    body.brand-mode .header-shell {
      padding-bottom: 0;
    }
    body.brand-mode .brand-center-title .center-logo-brand {
      display: none;
    }
    .brand-header-logo {
      display: none;
    }
    /* Brand nav row: compact, centered, with doTERRA logo */
    /* Company bar = solid white */
    body.brand-mode .header {
      background: #ffffff;
    }
    body.brand-mode .header-shell {
      background: #ffffff;
      border-bottom: none;
    }
    /* Seller nav: same clean white shell as brand mode */
    body.seller-nav-visible .header-shell {
      background: #ffffff;
      border-bottom: none;
      padding-bottom: 0;
    }
    .brand-nav-row {
      display: flex;
      align-items: center;
      justify-content: center;
      max-width: 1280px;
      padding: 8px 16px;
      border: 1px solid #dbeafe;
      background: #eff6ff;
      position: relative;
      border-radius: 12px;
      margin: 8px auto;
    }
    .brand-nav-row .brand-nav-logo {
      height: 26px;
      width: auto;
      opacity: 1;
      flex-shrink: 0;
    }
    .brand-nav-row .brand-nav-back-wrap {
      position: absolute;
      left: 16px;
      top: 50%;
      transform: translateY(-50%);
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .seller-nav-row .seller-nav-section-title {
      font-weight: 600;
      font-size: 0.85rem;
      color: #0f172a;
      white-space: nowrap;
    }
    .brand-nav-row .brand-nav-back,
    .seller-nav-row .seller-nav-back {
      border: 1px solid #2563eb;
      background: #2563eb;
      color: #ffffff;
      border-radius: 8px;
      width: 32px;
      height: 28px;
      font-size: 16px;
      line-height: 1;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      visibility: hidden;
    }
    .brand-nav-row .brand-nav-back:hover,
    .seller-nav-row .seller-nav-back:hover {
      background: #1d4ed8;
      border-color: #1d4ed8;
    }
    .brand-nav-row .brand-nav-title {
      font-weight: 600;
      font-size: 0.9rem;
      color: #2563eb;
    }
    .seller-nav-row {
      display: flex;
      align-items: center;
      justify-content: center;
      max-width: 1280px;
      padding: 10px 16px;
      border: 1px solid #dbeafe;
      background: #eff6ff;
      position: relative;
      border-radius: 12px;
      margin: 8px auto;
      min-height: 50px;
    }
    .seller-nav-row .seller-nav-logo {
      height: 26px;
      width: auto;
      flex-shrink: 0;
    }
    .seller-nav-row .seller-nav-back-wrap {
      position: absolute;
      left: 16px;
      top: 50%;
      transform: translateY(-50%);
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .seller-nav-row .seller-nav-title {
      font-weight: 600;
      font-size: 0.9rem;
      color: #2563eb;
    }
    .seller-nav-row .seller-nav-toggle-wrap {
      position: absolute;
      right: 16px;
      top: 50%;
      transform: translateY(-50%);
    }
    .seller-nav-row .seller-nav-toggle-wrap .view-switcher {
      display: flex;
      gap: 4px;
      padding: 0;
      margin: 0;
      background: transparent;
      border: none;
      box-shadow: none;
      width: auto;
    }
    .seller-nav-row .seller-nav-toggle-wrap .view-tab {
      padding: 4px 12px;
      font-size: 0.75rem;
      border-radius: 6px;
      border: 1px solid #dbeafe;
      background: #ffffff;
      color: #64748b;
      line-height: 1.25;
      text-align: center;
      white-space: normal;
    }
    .seller-nav-row .seller-nav-toggle-wrap .view-tab:hover {
      color: #1d4ed8;
      background: #ffffff;
    }
    .seller-nav-row .seller-nav-toggle-wrap .view-tab.active {
      background: #2563eb;
      border-color: #2563eb;
      color: #ffffff;
      box-shadow: none;
    }
    .seller-nav-row .seller-nav-side-label {
      position: absolute;
      right: 16px;
      top: 50%;
      transform: translateY(-50%);
      font-family: Inter, sans-serif;
      font-size: 0.75rem;
      font-weight: 600;
      color: #2563eb;
      letter-spacing: 0.01em;
      white-space: nowrap;
    }
    .brand-nav-row .brand-nav-select-wrap {
      position: absolute;
      right: 16px;
      top: 50%;
      transform: translateY(-50%);
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .brand-nav-row .brand-nav-select-label {
      font-family: Inter, sans-serif;
      font-size: 0.75rem;
      font-weight: 600;
      color: #2563eb;
      letter-spacing: 0.01em;
      white-space: nowrap;
    }
    .brand-nav-row .brand-nav-select {
      font-family: Inter, sans-serif;
      font-size: 0.8rem;
      font-weight: 600;
      color: #1d4ed8;
      background: #ffffff;
      border: 1px solid #dbeafe;
      border-radius: 8px;
      padding: 6px 30px 6px 10px;
      min-width: 124px;
      line-height: 1.2;
      box-shadow: 0 1px 2px rgba(37, 99, 235, 0.08);
      appearance: none;
      -webkit-appearance: none;
      -moz-appearance: none;
      background-image:
        linear-gradient(45deg, transparent 50%, #2563eb 50%),
        linear-gradient(135deg, #2563eb 50%, transparent 50%);
      background-position:
        calc(100% - 16px) calc(50% - 1px),
        calc(100% - 11px) calc(50% - 1px);
      background-size: 5px 5px, 5px 5px;
      background-repeat: no-repeat;
      cursor: pointer;
    }
    .brand-nav-row .brand-nav-select:hover {
      border-color: #93c5fd;
    }
    .brand-nav-row .brand-nav-select:focus {
      outline: none;
      border-color: #60a5fa;
      box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
    }
    @media (max-width: 720px) {
      .brand-nav-row {
        justify-content: flex-start;
        padding: 8px 14px;
        min-height: 58px;
      }
      .brand-nav-row .brand-nav-logo {
        margin-left: 112px;
      }
      .brand-nav-row .brand-nav-select-wrap {
        right: 14px;
      }
      .brand-nav-row .brand-nav-select-label {
        display: none;
      }
      .brand-nav-row .brand-nav-select {
        min-width: 106px;
      }
      .seller-nav-row {
        min-height: 48px;
        padding: 8px 14px;
      }
      .seller-nav-row .seller-nav-side-label {
        right: 14px;
      }
    }
    /* Hide the original dashboard-nav top-nav in brand mode */
    body.brand-mode .dashboard-nav .top-nav {
      display: none;
    }
    /* Hide the entire legacy dashboard-nav when the seller nav row is active */
    body.seller-nav-visible .dashboard-nav {
      display: none;
    }
    .center-logo {
      height: 28px;
      width: auto;
      margin-bottom: 4px;
    }
    .center-logo-brand {
      height: 36px;
      margin-top: 0;
      margin-bottom: 2px;
      opacity: 1;
    }
    .center-logo-seller {
      height: 24px;
      border-radius: 4px;
      background: rgba(255,255,255,0.9);
      padding: 2px 6px;
    }
    .header-meta {
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      gap: 6px;
      text-align: right;
    }
    .title { font-size: 1.75rem; font-weight: 700; letter-spacing: 0.01em; color: #0f172a; }
    .sub { color: #64748b; font-size: 0.92rem; }
    .powered-by {
      color: #94a3b8;
      font-size: 0.78rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.08em;
    }
    .dashboard-nav {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 14px;
      align-items: center;
      margin-bottom: 18px;
    }
    .control-panel {
      padding: 0;
      border: none;
      border-radius: 0;
      background: transparent;
      box-shadow: none;
      margin-bottom: 20px;
    }
    .section-grid {
      display: block;
    }
    .card {
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: 16px;
      padding: 18px;
    }
    .card h2 { margin: 0 0 10px; font-size: 18px; }
    table { width: 100%; border-collapse: collapse; font-size: 13px; }
    th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid rgba(255,255,255,0.07); }
    th { color: #bcd2f7; font-weight: 600; }
    tr:nth-child(even) { background: rgba(255,255,255,0.02); }
    .pill { display: inline-block; padding: 2px 7px; border-radius: 999px; font-size: 12px; font-weight: 600; }
    .level-healthy { color: var(--green); }
    .level-warning { color: var(--yellow); }
    .level-caution { color: var(--orange); }
    .level-critical { color: var(--red); }
    .level-zero { color: var(--red); }
    .metrics { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
    .metric {
      background: var(--accent);
      border-radius: 8px;
      padding: 10px;
      min-width: 130px;
    }
    .metric .label { font-size: 12px; color: #a8c3eb; }
    .metric .value { font-size: 20px; font-weight: 700; }
    .alerts {
      margin-bottom: 16px;
      display: grid;
      gap: 8px;
    }
    .alert {
      border-radius: 8px;
      padding: 10px 12px;
      font-size: 13px;
      border: 1px solid transparent;
    }
    .alert.warn { background: rgba(253, 203, 110, 0.12); border-color: rgba(253, 203, 110, 0.45); }
    .alert.error { background: rgba(231, 76, 60, 0.12); border-color: rgba(231, 76, 60, 0.45); }
    #accordion-panel {
      margin-top: 0;
      padding-top: 0;
    }
    @keyframes pulse {
      0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 149, 0, 0.8);
      }
      70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 8px rgba(255, 149, 0, 0);
      }
      100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 149, 0, 0);
      }
    }
    .section-view {
      max-height: 0;
      overflow: hidden;
      opacity: 0;
      border-color: rgba(255,255,255,0);
      padding-top: 0;
      padding-bottom: 0;
      margin-bottom: 0;
      transition: max-height 350ms cubic-bezier(0.4, 0, 0.2, 1), opacity 300ms ease, padding 350ms cubic-bezier(0.4, 0, 0.2, 1), border-color 200ms ease;
    }
    .section-view.active {
      opacity: 1;
      padding-top: 18px;
      padding-bottom: 20px;
      border-color: var(--border);
      transition: max-height 350ms cubic-bezier(0.4, 0, 0.2, 1), opacity 300ms ease 50ms, padding 350ms cubic-bezier(0.4, 0, 0.2, 1), border-color 200ms ease;
    }
    .section-view.collapsing {
      max-height: 0 !important;
      opacity: 0;
      padding-top: 0;
      padding-bottom: 0;
      transition: max-height 250ms cubic-bezier(0.4, 0, 0.2, 1), opacity 200ms ease, padding 250ms cubic-bezier(0.4, 0, 0.2, 1);
    }
    .orders-toggle-btn { background: #16213e; color: #e0e0e0; border: 1px solid rgba(255,255,255,0.15); border-radius: 4px; padding: 4px 12px; cursor: pointer; font-size: 12px; transition: background 0.15s; }
    .orders-toggle-btn:hover { background: #0f3460; }
    .orders-toggle-btn.active-toggle { background: #00b894; color: #1a1a2e; border-color: #00b894; font-weight: 600; }
    .chart-wrap {
      position: relative;
      height: 320px;
    }
    .sales-metrics .value {
      font-size: 28px;
      letter-spacing: 0.2px;
    }
    .sales-placeholder {
      display: none;
      margin-top: 12px;
      padding: 12px;
      border-radius: 8px;
      border: 1px dashed rgba(255,255,255,0.25);
      color: #bcd2f7;
      font-size: 14px;
    }
    .sales-placeholder.active {
      display: block;
    }
    .ipi-console {
      margin: 12px 0 10px;
      border: 1px solid rgba(255,255,255,0.12);
      border-radius: 10px;
      padding: 12px;
      background: rgba(15, 52, 96, 0.25);
    }
    .ipi-console-form {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      align-items: flex-end;
      margin-bottom: 8px;
    }
    .ipi-field {
      display: flex;
      flex-direction: column;
      gap: 5px;
      font-family: "Courier New", Courier, monospace;
    }
    .ipi-field label {
      font-size: 12px;
      color: #bcd2f7;
    }
    .ipi-field input {
      min-width: 150px;
      padding: 8px 10px;
      border-radius: 8px;
      border: 1px solid rgba(255,255,255,0.2);
      background: rgba(0,0,0,0.35);
      color: var(--text);
      font-family: "Courier New", Courier, monospace;
    }
    .ipi-submit {
      height: 36px;
      padding: 0 12px;
      border: 1px solid rgba(125,190,255,0.55);
      border-radius: 8px;
      background: #1f75fe;
      color: #fff;
      font-weight: 600;
      font-family: "Courier New", Courier, monospace;
      cursor: pointer;
    }
    .ipi-submit:disabled {
      opacity: 0.6;
      cursor: not-allowed;
    }
    .ipi-feedback {
      min-height: 18px;
      font-size: 12px;
      font-family: "Courier New", Courier, monospace;
      color: #9ec8ff;
    }
    .ipi-log-title {
      margin: 0 0 6px;
      font-size: 13px;
      color: #bcd2f7;
      font-family: "Courier New", Courier, monospace;
    }
    #ipiLogTable th, #ipiLogTable td {
      font-family: "Courier New", Courier, monospace;
      font-size: 12px;
    }
    /* View switcher tabs */
    .view-switcher {
      display: flex;
      gap: 6px;
      padding: 6px;
      background: rgba(17, 27, 49, 0.78);
      border: 1px solid var(--border);
      border-radius: 14px;
      width: min(100%, 420px);
      justify-content: center;
      box-shadow: var(--shadow-soft);
    }
    .view-tab {
      padding: 10px 18px;
      flex: 1;
      border-radius: 10px;
      border: 1px solid rgba(255,255,255,0.06);
      background: transparent;
      color: var(--muted);
      font-size: 0.95rem;
      font-weight: 700;
      cursor: pointer;
      transition: all 0.15s ease;
      font-family: inherit;
      letter-spacing: 0.01em;
    }
    .view-tab:hover {
      color: var(--text);
      background: rgba(255,255,255,0.06);
    }
    .view-tab.active {
      background: linear-gradient(180deg, rgba(33, 79, 131, 0.95) 0%, rgba(15, 52, 96, 0.98) 100%);
      border-color: rgba(125,190,255,0.32);
      color: #f4f8ff;
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 10px 22px rgba(15, 52, 96, 0.35);
    }
    /* Brand tile special colors */
    .tile-alert {
      background: linear-gradient(160deg, rgba(96, 15, 15, 0.88) 0%, rgba(62, 22, 22, 0.95) 100%) !important;
      border-color: rgba(231, 76, 60, 0.4) !important;
    }
    .tile-brand {
      background: linear-gradient(160deg, rgba(15, 60, 96, 0.88) 0%, rgba(22, 33, 62, 0.95) 100%);
    }
    .placeholder-note {
      background: var(--accent);
      border-radius: 8px;
      padding: 14px 16px;
      color: var(--muted);
      font-size: 13px;
      margin: 12px 0;
    }
    .placeholder-layout {
      display: flex;
      gap: 14px;
      flex-wrap: wrap;
      margin: 14px 0;
      opacity: 0.5;
    }
    .placeholder-metric {
      background: rgba(255,255,255,0.05);
      border: 1px dashed rgba(255,255,255,0.15);
      border-radius: 8px;
      padding: 10px 16px;
      min-width: 130px;
    }
    .placeholder-metric .label { font-size: 12px; color: var(--muted); }
    .placeholder-metric .value { font-size: 20px; font-weight: 700; color: rgba(255,255,255,0.3); }
    .detail-panel {
      background: transparent;
      border: none;
      border-radius: 0;
      padding: 0;
      box-shadow: none;
      margin-top: 0;
    }
    @media (max-width: 1000px) {
      :root { --header-height: 138px; }
      .header { flex-direction: column; align-items: flex-start; gap: 12px; }
      .header-meta { align-items: flex-start; text-align: left; }
      .dashboard-nav { grid-template-columns: 1fr; }
      .tiles { grid-template-columns: 1fr 1fr; }
    }
    @media (max-width: 700px) {
      :root { --header-height: 176px; }
      body { padding-left: 14px; padding-right: 14px; }
      .header-shell { padding-left: 14px; padding-right: 14px; }
      .header-brand { align-items: flex-start; }
      .header-logo { width: 150px; max-width: 46vw; }
      .title { font-size: 1.35rem; }
      .control-panel, .detail-panel { padding: 16px; }
      .tiles { grid-template-columns: 1fr; }
    }

    /* ===== MAP Profitability Section (namespaced) ===== */
    #view-profitability .prof-section-head {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      gap: 12px;
      margin-bottom: 14px;
    }
    #view-profitability .prof-section-head h3 {
      margin: 0 0 4px;
      font-size: 18px;
    }
    #view-profitability .prof-section-note {
      color: var(--muted);
      font-size: 13px;
    }
    #view-profitability .prof-helper-note {
      margin-top: 10px;
      padding: 10px 12px;
      border: 1px solid rgba(37, 99, 235, 0.18);
      border-radius: 10px;
      background: rgba(37, 99, 235, 0.06);
      color: #1e293b;
      font-size: 12px;
      line-height: 1.5;
    }
    #view-profitability .prof-helper-note strong {
      color: #0f172a;
    }
    #view-profitability .prof-tabs {
      display: flex;
      flex-wrap: wrap;
      gap: 0.5rem;
      margin: 0 0 1rem;
    }
    #view-profitability .prof-tab {
      border: 1px solid rgba(255,255,255,0.18);
      border-radius: 8px;
      background: rgba(255,255,255,0.03);
      color: var(--text);
      padding: 0.45rem 0.8rem;
      font-size: 0.8rem;
      font-weight: 700;
      cursor: pointer;
      transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    }
    #view-profitability .prof-tab.active {
      border-color: #2563eb;
      color: #fff;
      background: rgba(37, 99, 235, 0.9);
    }
    #view-profitability .prof-tab-panel {
      display: none;
    }
    #view-profitability .prof-tab-panel.active {
      display: block;
    }
    #view-profitability .prof-metrics {
      display: grid;
      grid-template-columns: repeat(5, minmax(0, 1fr));
      gap: 14px;
      margin-bottom: 16px;
    }
    #view-profitability .prof-metrics-compact {
      grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }
    #view-profitability .prof-metric {
      background: var(--accent);
      border-radius: 8px;
      padding: 12px;
      min-height: 84px;
    }
    #view-profitability .prof-metric .label {
      font-size: 12px;
      color: #a8c3eb;
      margin-bottom: 6px;
    }
    #view-profitability .prof-metric .value {
      font-size: 24px;
      font-weight: 700;
    }
    #view-profitability .prof-product-cell {
      display: flex;
      flex-direction: column;
      gap: 3px;
      min-width: 180px;
    }
    #view-profitability .prof-product-name {
      font-weight: 600;
      color: #0f172a;
    }
    #view-profitability .prof-inline-asin {
      font-size: 12px;
      color: var(--muted);
      letter-spacing: 0.02em;
      word-break: break-all;
    }
    #view-profitability .prof-toolbar {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      align-items: center;
      margin-bottom: 14px;
    }
    #view-profitability .prof-search-input,
    #view-profitability .prof-select-input,
    #view-profitability .prof-price-input {
      width: 100%;
      min-height: 40px;
      padding: 9px 12px;
      border-radius: 8px;
      border: 1px solid rgba(255,255,255,0.16);
      background: rgba(0,0,0,0.25);
      color: var(--text);
      font: inherit;
    }
    #view-profitability .prof-search-wrap {
      flex: 1 1 320px;
    }
    @media (max-width: 900px) {
      #view-profitability .prof-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }
      #view-profitability .prof-metrics-compact {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }
    }
    @media (max-width: 640px) {
      #view-profitability .prof-metrics,
      #view-profitability .prof-metrics-compact {
        grid-template-columns: 1fr;
      }
    }
    #view-profitability .status-chip {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      border-radius: 999px;
      padding: 4px 10px;
      font-size: 12px;
      font-weight: 700;
      border: 1px solid transparent;
      white-space: nowrap;
    }
    #view-profitability .status-keep {
      background: rgba(0, 184, 148, 0.12);
      color: #047857;
      border-color: rgba(0, 184, 148, 0.34);
      font-weight: 600;
    }

    :root {
      --bg: #ffffff;
      --card: #ffffff;
      --card-2: #f8fafc;
      --accent: #eff6ff;
      --accent-2: #2563eb;
      --text: #0f172a;
      --green: #22c55e;
      --yellow: #f59e0b;
      --orange: #f59e0b;
      --red: #ef4444;
      --black: #0f172a;
      --muted: #64748b;
      --border: #dbe5f1;
      --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.06);
      --shadow-panel: 0 16px 40px rgba(15, 23, 42, 0.08);
    }
    body {
      font-family: "Inter", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
      background: var(--bg);
      color: var(--text);
    }
    .header-shell {
      padding-top: 0;
      backdrop-filter: blur(10px);
      background: rgba(255, 255, 255, 0.92);
      border-bottom: 1px solid var(--border);
    }
    .top-nav,
    .header,
    .control-panel,
    .detail-panel,
    .card {
      background: #ffffff;
      border-color: var(--border);
      box-shadow: var(--shadow-soft);
    }
    .top-nav {
      min-height: 58px;
    }
    .back-btn {
      border-color: #cbd5e1;
      background: #f8fafc;
      color: var(--text);
      font-size: 14px;
      font-weight: 600;
      width: auto;
      padding: 0 14px;
    }
    .back-btn:hover {
      background: #eff6ff;
      border-color: #93c5fd;
    }
    .header {
      border-radius: 0 0 18px 18px;
      border-top: 0;
      box-shadow: none;
    }
    .header-logo {
      filter: none;
    }
    .header-logo.logo-light-bg {
      background: transparent;
      border-radius: 0;
      padding: 0;
      box-shadow: none;
      filter: none;
    }
    .title,
    .view-title {
      color: #2563eb;
    }
    .card h2 {
      color: var(--text);
    }
    .sub,
    .powered-by {
      color: var(--muted);
    }
    .powered-by {
      letter-spacing: 0.08em;
    }
    .control-panel {
      background: #f8fafc;
    }
    table {
      color: var(--text);
    }
    th,
    td {
      border-bottom: 1px solid var(--border);
    }
    th {
      color: #334155;
      background: #f8fafc;
    }
    tr:nth-child(even) {
      background: rgba(248, 250, 252, 0.8);
    }
    .metric,
    #view-profitability .prof-metric,
    #view-profitability .prof-calc-metric,
    .placeholder-note,
    .placeholder-metric {
      background: #eff6ff;
      border: 1px solid #bfdbfe;
      box-shadow: none;
    }
    .metric .label,
    #view-profitability .prof-metric .label,
    #view-profitability .prof-calc-metric .label,
    .placeholder-metric .label {
      color: #2563eb;
    }
    .placeholder-metric .value {
      color: #94a3b8;
    }
    .alert.warn {
      background: rgba(245, 158, 11, 0.12);
      border-color: rgba(245, 158, 11, 0.3);
      color: #92400e;
    }
    .alert.error {
      background: rgba(239, 68, 68, 0.08);
      border-color: rgba(239, 68, 68, 0.24);
      color: #b91c1c;
    }
    .orders-toggle-btn {
      background: #ffffff;
      color: var(--muted);
      border-color: var(--border);
    }
    .orders-toggle-btn:hover {
      background: #eff6ff;
      color: #1d4ed8;
    }
    .orders-toggle-btn.active-toggle {
      background: #2563eb;
      color: #ffffff;
      border-color: #2563eb;
    }
    .sales-placeholder {
      border-color: #bfdbfe;
      color: #475569;
      background: #eff6ff;
    }
    .ipi-console {
      border-color: var(--border);
      background: #f8fafc;
    }
    .ipi-field label,
    .ipi-log-title,
    .ipi-feedback {
      color: #475569;
    }
    .ipi-field input,
    #view-profitability .prof-search-input,
    #view-profitability .prof-select-input,
    #view-profitability .prof-price-input {
      border-color: var(--border);
      background: #ffffff;
      color: var(--text);
    }
    .ipi-submit {
      border-color: #2563eb;
      background: #2563eb;
    }
    .view-switcher {
      background: #ffffff;
      border-color: var(--border);
      box-shadow: var(--shadow-soft);
    }
    .view-tab {
      border-color: transparent;
      color: #64748b;
    }
    .view-tab:hover {
      color: #1d4ed8;
      background: #eff6ff;
    }
    .view-tab.active {
      background: #2563eb;
      border-color: #2563eb;
      color: #ffffff;
      box-shadow: 0 10px 20px rgba(37, 99, 235, 0.18);
    }
    .tile-brand,
    .tile-alert {
      background: #ffffff;
    }
    .tile-alert {
      border-color: rgba(239, 68, 68, 0.26) !important;
      box-shadow: 0 12px 24px rgba(239, 68, 68, 0.08) !important;
    }
    .detail-panel {
      background: #ffffff;
      border-top: 2px solid #2563eb;
    }
    /* Blue accents throughout */
    .header-shell {
      border-bottom: 2px solid #2563eb;
    }
    .control-panel {
      background: linear-gradient(180deg, #f0f5ff 0%, #f8fafc 100%);
      border: 1px solid #dbeafe;
    }
    .section-view {
      border-left: 3px solid #2563eb;
    }
    .section-view h2 {
      color: #2563eb;
    }
    .top-nav {
      background: linear-gradient(90deg, #ffffff 0%, #f0f5ff 100%);
      border-bottom: 1px solid #dbeafe;
    }
    .metric .value {
      color: #2563eb;
    }
    .brand-center-title .title {
      color: #2563eb;
    }
    .powered-by {
      color: #2563eb;
      font-weight: 600;
    }
    #view-profitability .status-raise {
      background: rgba(253, 203, 110, 0.15);
      color: #92400e;
      border-color: rgba(253, 203, 110, 0.34);
    }

    /* Three-tier MAP status badges */
    .map-status {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      border-radius: 999px;
      padding: 3px 10px;
      font-size: 12px;
      font-weight: 700;
      white-space: nowrap;
      border: 1px solid transparent;
    }
    .map-status small {
      font-size: 0.78em;
      font-weight: 600;
      opacity: 0.82;
      line-height: 1;
    }
    .map-below {
      background: rgba(239, 68, 68, 0.12);
      color: #EF4444;
      border-color: rgba(239, 68, 68, 0.3);
    }
    .map-at {
      background: rgba(34, 197, 94, 0.12);
      color: #22C55E;
      border-color: rgba(34, 197, 94, 0.3);
    }
    .map-above {
      background: rgba(59, 130, 246, 0.12);
      color: #3B82F6;
      border-color: rgba(59, 130, 246, 0.3);
    }
    .map-above-april1 {
      background: rgba(124, 58, 237, 0.14);
      color: #a78bfa;
      border-color: rgba(124, 58, 237, 0.34);
    }

    #view-profitability .prof-table-wrap {
      overflow: auto;
      max-height: 70vh;
      border-radius: 10px;
      border: 1px solid rgba(255,255,255,0.08);
      margin-bottom: 16px;
    }
    #view-profitability table {
      width: 100%;
      border-collapse: collapse;
      font-size: 13px;
      min-width: 980px;
    }
    #view-profitability th,
    #view-profitability td {
      text-align: left;
      padding: 10px 8px;
      border-bottom: 1px solid rgba(255,255,255,0.07);
      vertical-align: middle;
    }
    #view-profitability th {
      position: sticky;
      top: 0;
      background: #10203b;
      color: #bcd2f7;
      font-weight: 600;
      cursor: pointer;
      user-select: none;
      white-space: nowrap;
    }
    #view-profitability tbody tr:nth-child(even) {
      background: rgba(255,255,255,0.02);
    }
    #view-profitability tbody tr.row-green {
      background: rgba(0, 184, 148, 0.08);
    }
    #view-profitability tbody tr.row-yellow {
      background: rgba(253, 203, 110, 0.08);
    }
    #view-profitability tbody tr.row-red {
      background: rgba(231, 76, 60, 0.08);
    }
    #view-profitability .prof-table-meta {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 10px;
      margin-bottom: 10px;
      color: var(--muted);
      font-size: 12px;
    }
    #view-profitability .prof-positive { color: var(--green); }
    #view-profitability .prof-warning { color: var(--yellow); }
    #view-profitability .prof-negative { color: var(--red); }
    #view-profitability .prof-muted { color: var(--muted); }
    #view-profitability .prof-subsection {
      background: var(--card);
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 12px;
      padding: 16px;
      margin-bottom: 16px;
    }
    #view-profitability .prof-calculator-grid {
      display: grid;
      grid-template-columns: minmax(280px, 360px) 1fr;
      gap: 16px;
      align-items: start;
    }
    #view-profitability .prof-calculator-panel {
      background: rgba(15, 52, 96, 0.35);
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 12px;
      padding: 14px;
    }
    #view-profitability .prof-field-group {
      display: grid;
      gap: 6px;
      margin-bottom: 12px;
    }
    #view-profitability .prof-field-group label {
      color: #bcd2f7;
      font-size: 12px;
      font-weight: 600;
    }
    #view-profitability .prof-calc-status {
      border-radius: 10px;
      padding: 12px;
      border: 1px solid transparent;
      font-size: 13px;
      font-weight: 600;
      margin-top: 10px;
    }
    #view-profitability .prof-calc-status.good {
      color: #bdf7ea;
      background: rgba(0, 184, 148, 0.14);
      border-color: rgba(0, 184, 148, 0.35);
    }
    #view-profitability .prof-calc-status.bad {
      color: #ffd8d4;
      background: rgba(231, 76, 60, 0.14);
      border-color: rgba(231, 76, 60, 0.35);
    }
    #view-profitability .prof-calc-metrics {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 12px;
    }
    #view-profitability .prof-calc-metric {
      background: rgba(255,255,255,0.03);
      border: 1px solid rgba(255,255,255,0.07);
      border-radius: 10px;
      padding: 12px;
    }
    #view-profitability .prof-calc-metric .label {
      color: #a8c3eb;
      font-size: 12px;
      margin-bottom: 6px;
    }
    #view-profitability .prof-calc-metric .value {
      font-size: 21px;
      font-weight: 700;
    }
    #view-profitability .prof-empty-state,
    #view-profitability .prof-loading-state {
      padding: 18px;
      color: var(--muted);
      text-align: center;
    }
    @media (max-width: 1150px) {
      #view-profitability .prof-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
      #view-profitability .prof-calc-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    }
    @media (max-width: 900px) {
      #view-profitability .prof-calculator-grid { grid-template-columns: 1fr; }
      #view-profitability .prof-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    }
    @media (max-width: 640px) {
      #view-profitability .prof-metrics,
      #view-profitability .prof-calc-metrics { grid-template-columns: 1fr; }
    }

    #view-profitability .status-raise {
      background: rgba(245, 158, 11, 0.12);
      color: #92400e;
      border-color: rgba(245, 158, 11, 0.28);
    }
    #view-profitability .prof-tab {
      border-color: var(--border);
      background: #ffffff;
      color: var(--muted);
    }
    #view-profitability .prof-tab:hover {
      background: #eff6ff;
      color: #1d4ed8;
    }
    #view-profitability .prof-tab.active {
      background: #2563eb;
      border-color: #2563eb;
      color: #ffffff;
      box-shadow: 0 10px 20px rgba(37, 99, 235, 0.18);
    }
    #view-profitability .prof-table-wrap,
    #view-profitability .prof-subsection,
    #view-profitability .prof-calculator-panel,
    #view-profitability .prof-calc-metric {
      border-color: var(--border);
      background: #ffffff;
    }
    #view-profitability th {
      background: #f8fafc;
      color: #334155;
    }
    #view-profitability td {
      border-bottom-color: var(--border);
    }
    #view-profitability tbody tr:nth-child(even) {
      background: rgba(248, 250, 252, 0.8);
    }
    #view-profitability tbody tr.row-green {
      background: rgba(34, 197, 94, 0.08);
    }
    #view-profitability tbody tr.row-yellow {
      background: rgba(245, 158, 11, 0.08);
    }
    #view-profitability tbody tr.row-red {
      background: rgba(239, 68, 68, 0.08);
    }
    #view-profitability {
      --prof-left-purple-bg: #f3e8ff;
      --prof-left-purple-header-bg: #ede9fe;
      --prof-left-purple-border: #d8b4fe;
      --prof-right-danger-bg: rgba(239, 68, 68, 0.12);
      --prof-right-warning-bg: rgba(245, 158, 11, 0.12);
    }
    #view-profitability th[data-prof-table="current"]:nth-child(-n+8) {
      background: var(--prof-left-purple-header-bg);
      color: #6d28d9;
      border-bottom-color: var(--prof-left-purple-border);
    }
    #view-profitability #prof-currentTableBody td:nth-child(-n+8) {
      background: var(--prof-left-purple-bg);
    }
    #view-profitability .prof-buybox-cell,
    #view-profitability .prof-risk-cell {
      font-weight: 600;
    }
    #view-profitability .prof-right-danger-cell {
      background: var(--prof-right-danger-bg);
      color: #b91c1c;
    }
    #view-profitability .prof-right-warning-cell {
      background: var(--prof-right-warning-bg);
      color: #92400e;
    }
    #view-profitability .prof-field-group label,
    #view-profitability .prof-calc-metric .label {
      color: #475569;
    }
    #view-profitability .prof-calc-status.good {
      color: #166534;
      background: rgba(34, 197, 94, 0.1);
      border-color: rgba(34, 197, 94, 0.24);
    }
    #view-profitability .prof-calc-status.bad {
      color: #b91c1c;
      background: rgba(239, 68, 68, 0.08);
      border-color: rgba(239, 68, 68, 0.22);
    }

    @media (max-width: 640px) {
      :root {
        --header-height: auto;
      }

      html,
      body {
        overflow-x: hidden;
      }

      body {
        padding: 12px 12px 24px;
      }

      .container {
        max-width: 100%;
        overflow-x: hidden;
      }

      .header-shell,
      body.brand-mode .header-shell,
      body.seller-nav-visible .header-shell {
        position: static;
        inset: auto;
        padding: 0;
        margin-bottom: 12px;
        background: transparent;
        border-bottom: 0;
        backdrop-filter: none;
      }

      .header,
      .brand-only-header .header {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        align-items: flex-start;
        gap: 12px;
        padding: 14px 14px 18px;
        border: 1px solid #dbeafe;
        border-radius: 18px;
      }

      .header-brand,
      .brand-only-header .header-brand {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        justify-self: stretch;
        align-items: flex-start;
        gap: 12px;
        min-width: 0;
      }

      .header-logo {
        display: block;
        width: clamp(104px, 32vw, 132px);
        max-width: 36%;
        flex: 0 0 auto;
      }

      .header-logo.logo-light-bg {
        max-width: none;
      }

      .brand-lockup-logo.header-logo.logo-light-bg {
        max-width: min(300px, 70vw);
      }

      .header-brand > div:not(.header-logo) {
        min-width: 0;
        flex: 1 1 auto;
      }

      .title {
        font-size: 1.45rem;
        line-height: 1.08;
        white-space: normal;
        overflow-wrap: anywhere;
      }

      .sub,
      .header-meta .sub,
      .brand-only-header .brand-center-title .subtitle {
        font-size: 0.82rem;
        line-height: 1.35;
        white-space: normal;
      }

      .brand-only-header .brand-center-title {
        justify-self: stretch;
        align-items: flex-start;
        text-align: left;
        width: 100%;
      }

      .brand-only-header .brand-center-title .title {
        font-size: 1.4rem;
        line-height: 1.05;
        white-space: normal;
      }

      .brand-only-header .brand-center-title .subtitle {
        display: block;
        margin-top: 2px;
        font-size: 0.82rem;
      }

      .header-meta,
      .brand-only-header .header-meta {
        justify-self: stretch;
        align-items: flex-start;
        text-align: left;
        width: 100%;
        gap: 4px;
        padding-top: 10px;
        border-top: 1px solid #e2e8f0;
      }

      .header-meta .sub {
        white-space: normal;
      }

      .powered-by {
        display: block;
        font-size: 0.72rem;
        letter-spacing: 0.06em;
        white-space: normal;
      }

      .dashboard-nav {
        grid-template-columns: 1fr;
        gap: 10px;
        margin-bottom: 12px;
        min-width: 0;
      }

      .top-nav {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        align-items: stretch;
        min-height: 0;
        padding: 10px 12px;
        gap: 8px;
        min-width: 0;
      }

      .back-btn {
        min-height: 40px;
        width: 100%;
      }

      .view-title {
        font-size: 0.96rem;
        line-height: 1.25;
        min-width: 0;
      }

      .seller-nav-row,
      .brand-nav-row {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
        padding: 12px;
        border-radius: 16px;
        margin-top: 14px;
      }

      .seller-nav-row .seller-nav-logo,
      .brand-nav-row .brand-nav-logo {
        display: none;
      }

      .seller-nav-row .seller-nav-back-wrap,
      .brand-nav-row .brand-nav-back-wrap {
        position: static;
        left: auto;
        right: auto;
        top: auto;
        transform: none;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
      }

      .seller-nav-row .seller-nav-section-title,
      .brand-nav-row .brand-nav-title {
        text-align: left;
      }

      .seller-nav-row .seller-nav-toggle-wrap,
      .brand-nav-row .brand-nav-select-wrap {
        position: static;
        left: auto;
        right: auto;
        top: auto;
        transform: none;
        width: 100%;
      }

      .brand-nav-row .brand-nav-select-wrap {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
        align-items: stretch;
      }

      .brand-nav-row .brand-nav-select {
        width: 100%;
        min-width: 0;
      }

      .seller-nav-row .seller-nav-toggle-wrap .view-switcher {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: stretch;
        width: 100% !important;
        max-width: none;
        gap: 8px;
        padding: 10px 12px;
        background: rgba(17, 27, 49, 0.78);
        border: 1px solid var(--border);
        box-shadow: var(--shadow-soft);
        min-width: 0;
      }

      .seller-nav-row .seller-nav-toggle-wrap .view-tab,
      #viewSwitcher .view-tab {
        min-height: 44px;
        padding: 10px 12px;
        font-size: 0.88rem;
        line-height: 1.15;
        min-width: 0;
      }

      .seller-nav-row .seller-nav-toggle-wrap .view-switcher button[title*="Sign out"],
      .brand-nav-row .brand-nav-select-wrap button[title*="Sign out"] {
        grid-column: 1 / -1;
        margin-left: 0 !important;
        margin-top: 2px;
        width: 100%;
        min-height: 42px;
      }

      .view-switcher,
      .metric,
      .card,
      .tile,
      .section-view,
      .control-panel,
      .detail-panel,
      .tiles {
        min-width: 0;
      }

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

      .metric {
        min-width: 0;
      }

      .tiles {
        gap: 12px;
      }

      .tile {
        width: 100%;
        max-width: 100%;
      }

      .control-panel,
      .detail-panel,
      .card,
      .section-view {
        width: 100%;
        max-width: 100%;
      }

      .section-view {
        overflow: visible;
      }

      .section-view.active {
        overflow: visible;
      }

      .section-view > * {
        min-width: 0;
      }

      .section-view .table-audit-wrap,
      .section-view [class$="-table-wrap"],
      .section-view [class*="-table-wrap "],
      .section-view .mv-breaks-wrap,
      .section-view .as-breaks-wrap,
      .section-view .prof-table-wrap,
      .section-view .rd-table-wrap,
      .section-view .rd-group-table,
      .section-view .wi-table-wrap,
      .section-view .wi-map-wrap,
      .section-view .sm-table-wrap,
      .section-view .sm-kit-wrap,
      .section-view .lh-table-wrap,
      .section-view .fba-fee-table-wrap,
      .section-view .ag-table-wrap,
      .section-view .map-table-wrap {
        max-width: 100%;
      }
    }
