:root {
      --bg: #f4f6f9;
      --panel: #ffffff;
      --ink: #142126;
      --muted: #6f7f8b;
      --line: #e4ebf0;
      --brand: #005bff;
      --brand-dark: #0048cc;
      --blue: #005bff;
      --red: #b42318;
      --green: #166534;
      --orange: #c2410c;
      --soft: #eaf7f5;
      --shadow: 0 18px 42px rgba(35, 50, 66, .08);
      font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
    }

    * { box-sizing: border-box; }
    body { margin: 0; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
    .app { display: grid; grid-template-columns: 256px minmax(0, 1fr); height: 100vh; overflow: hidden; }
    aside {
      background: #0b0f19;
      color: #fff;
      padding: 0 16px 18px;
      display: flex;
      flex-direction: column;
      gap: 20px;
      border-right: 1px solid #020617;
      box-shadow: none;
    }
    h1, h2, h3 { margin: 0; letter-spacing: 0; }
    h1 { font-size: 12px; line-height: 1.25; font-weight: 900; }
    h2 { font-size: 15px; font-weight: 800; }
    h3 { font-size: 15px; margin-bottom: 14px; font-weight: 800; }
    .hint { color: #94a3b8; line-height: 1.6; font-size: 13px; margin: 8px 0 0; }
    nav { display: grid; gap: 8px; }
    .tab-btn { text-align: left; background: transparent; color: #94a3b8; border: 0; border-left: 2px solid transparent; border-radius: 0 12px 12px 0; padding: 12px 14px; cursor: pointer; font-weight: 700; font-size: 12px; display: flex; align-items: center; gap: 10px; }
    .tab-btn.active { background: linear-gradient(90deg, rgba(0,91,255,.22), rgba(0,91,255,.06)); border-left-color: #005bff; color: #fff; box-shadow: none; }
    .tab-btn:hover:not(.active) { background: #111827; color: #e2e8f0; }
    .side-card { margin-top: auto; background: #070a12; border: 1px solid #020617; border-radius: 0; padding: 14px; color: #94a3b8; font-size: 11px; }
    .side-card strong { display: block; font-size: 22px; margin-top: 8px; }
    aside > section:first-child {
      min-height: 64px;
      display: grid;
      align-content: center;
      border-bottom: 1px solid #020617;
      margin: 0 -16px 16px;
      padding: 0 24px;
    }
    main { padding: 0; display: grid; grid-template-rows: 64px minmax(0, 1fr); align-content: start; min-width: 0; overflow: auto; }
    .topbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; height: 64px; background: #fff; border-bottom: 1px solid #eef2f7; padding: 0 32px; position: sticky; top: 0; z-index: 4; }
    .status { color: var(--muted); font-size: 13px; }
    .grid { display: grid; gap: 16px; }
    .metrics { grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 20px; }
    .split { grid-template-columns: 420px minmax(0, 1fr); align-items: start; }
    .wide-split { grid-template-columns: minmax(0, 1.3fr) minmax(340px, .7fr); align-items: start; }
    .panel { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); padding: 20px; min-width: 0; }
    .dashboard-brief {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 16px;
      border-bottom: 1px solid #e2e8f0;
      padding: 0 0 18px;
    }
    .dashboard-brief h2 {
      font-size: 17px;
      color: #0f172a;
      font-weight: 900;
    }
    .dashboard-brief p {
      margin: 5px 0 0;
      color: #94a3b8;
      font-size: 12px;
      font-weight: 700;
    }
    .live-chip {
      display: inline-flex;
      align-items: center;
      gap: 7px;
      color: #475569;
      background: #f1f5f9;
      border-radius: 999px;
      padding: 7px 11px;
      font-size: 12px;
      font-weight: 800;
    }
    .live-chip span {
      width: 7px;
      height: 7px;
      border-radius: 999px;
      background: #005bff;
      box-shadow: 0 0 0 5px rgba(0, 91, 255, .1);
      animation: pulse-dot 1.6s ease-in-out infinite;
    }
    .api-panel {
      padding: 14px 16px;
      border-style: dashed;
      box-shadow: none;
    }
    .api-panel .notice {
      padding: 9px 11px;
      font-size: 12px;
    }
    .summary-panel {
      padding: 16px 18px;
      box-shadow: none;
      border-color: #e8eef5;
    }
    .summary-panel h3 { margin-bottom: 4px; }
    .summary-panel p {
      margin: 0;
      color: #94a3b8;
      font-size: 12px;
      font-weight: 700;
    }
    .range-pills,
    .period-tabs {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 4px;
      background: #f1f5f9;
      border: 1px solid #e2e8f0;
      border-radius: 10px;
    }
    .range-pills button,
    .period-tabs button {
      background: transparent;
      color: #64748b;
      padding: 7px 11px;
      font-size: 12px;
      border-radius: 7px;
    }
    .range-pills button.active,
    .period-tabs button.active {
      background: #fff;
      color: var(--brand);
      box-shadow: 0 1px 4px rgba(15, 23, 42, .08);
    }
    .metric {
      min-height: 128px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      background: #fff;
      padding: 22px;
      border-color: #eef2f7;
      box-shadow: 0 1px 3px rgba(15, 23, 42, .03);
    }
    .metric span {
      color: #94a3b8;
      font-size: 12px;
      text-transform: uppercase;
      letter-spacing: .04em;
      font-weight: 900;
    }
    .metric strong {
      display: block;
      font-size: 30px;
      margin-top: 8px;
      letter-spacing: -0.01em;
      font-weight: 950;
      font-variant-numeric: tabular-nums;
    }
    .metric strong small {
      color: #94a3b8;
      font-size: 13px;
      font-weight: 700;
    }
    .metric-sub {
      color: #94a3b8;
      font-size: 12px;
      font-weight: 700;
      margin-top: 8px;
    }
    .metric-sub b { color: #475569; }
    .metric-split {
      display: flex;
      height: 5px;
      background: #f1f5f9;
      border-radius: 999px;
      overflow: hidden;
      margin-top: 12px;
    }
    .metric-split i {
      display: block;
      width: 66%;
      background: #005bff;
    }
    .metric-split em {
      display: block;
      width: 34%;
      background: #cb11ab;
    }
    label { display: grid; gap: 7px; color: #33444d; font-size: 13px; font-weight: 700; }
    input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 11px; font-size: 14px; outline: none; background: #fff; color: var(--ink); }
    input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,118,110,.12); }
    form { display: grid; gap: 12px; }
    .cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    button { border: 0; border-radius: 8px; padding: 10px 13px; cursor: pointer; font-weight: 700; white-space: nowrap; }
    .primary { background: var(--brand); color: #fff; }
    .primary:hover { background: var(--brand-dark); }
    .secondary { background: #e9f0f2; color: #17313b; }
    .danger { background: #fff0ed; color: var(--red); }
    .actions { display: flex; gap: 8px; flex-wrap: wrap; }
    .total { background: var(--soft); border: 1px solid #cbe8e4; border-radius: 8px; padding: 13px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
    .total span { color: var(--muted); font-size: 13px; }
    .total strong { font-size: 22px; color: var(--brand-dark); }
    .table-wrap { overflow: auto; }
    .orders-table-wrap {
      max-height: min(640px, calc(100vh - 210px));
      border: 1px solid var(--line);
      border-radius: 8px;
    }
    .orders-table-wrap table { min-width: 1460px; }
    .orders-table-wrap th { z-index: 2; }
    .table-status {
      margin: -4px 0 10px;
      color: var(--muted);
      font-size: 12px;
      font-weight: 700;
    }
    .section-note {
      margin: 4px 0 0;
      color: #94a3b8;
      font-size: 12px;
      font-weight: 700;
    }
    .store-overview-panel .table-wrap {
      border: 1px solid var(--line);
      border-radius: 8px;
    }
    .store-table {
      min-width: 1040px;
    }
    .store-table th,
    .store-table td {
      padding: 13px 12px;
    }
    .import-box {
      display: grid;
      grid-template-columns: minmax(180px, 240px) minmax(260px, 1fr) auto auto;
      gap: 12px;
      align-items: end;
    }
    .muted-cell {
      color: #94a3b8;
      font-weight: 700;
    }
    .positive { color: #059669; }
    .negative { color: var(--red); }
    table { width: 100%; min-width: 980px; border-collapse: collapse; }
    th, td { border-bottom: 1px solid var(--line); padding: 11px 9px; text-align: left; font-size: 14px; vertical-align: middle; }
    th { background: #f7fafb; color: #465961; font-size: 12px; position: sticky; top: 0; }
    .money { font-variant-numeric: tabular-nums; white-space: nowrap; }
    .sku { color: var(--muted); font-size: 12px; margin-top: 3px; }
    .competitor-img {
      width: 58px;
      height: 58px;
      border-radius: 8px;
      object-fit: cover;
      background: #eef3f4;
      border: 1px solid var(--line);
      display: block;
      cursor: zoom-in;
      transition: transform .15s ease, box-shadow .15s ease;
    }
    .competitor-img:hover {
      transform: scale(1.04);
      box-shadow: 0 10px 24px rgba(20, 33, 38, .16);
    }
    .image-modal {
      position: fixed;
      inset: 0;
      display: none;
      place-items: center;
      background: rgba(20, 33, 38, .72);
      z-index: 20;
      padding: 28px;
    }
    .image-modal.open { display: grid; }
    .image-modal img {
      max-width: min(88vw, 760px);
      max-height: 86vh;
      border-radius: 8px;
      background: #fff;
      box-shadow: 0 24px 70px rgba(0,0,0,.3);
    }
    .image-modal button {
      position: fixed;
      right: 24px;
      top: 22px;
      background: #fff;
      color: #17313b;
    }
    .toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
    .toolbar h3 { margin-bottom: 0; }
    .order-filters {
      display: flex;
      align-items: end;
      justify-content: flex-end;
      gap: 10px;
      flex-wrap: wrap;
    }
    .order-filters label {
      min-width: 150px;
      font-size: 12px;
    }
    .order-filters select { min-width: 190px; }
    .date-range-picker {
      position: relative;
    }
    .date-range-button {
      background: #f8fafc;
      border: 1px solid #e2e8f0;
      color: #334155;
      min-width: 240px;
      text-align: left;
    }
    .date-range-panel {
      position: absolute;
      right: 0;
      top: 44px;
      display: none;
      grid-template-columns: minmax(560px, 1fr) 78px;
      gap: 14px;
      width: 690px;
      padding: 14px;
      background: #fff;
      border: 1px solid var(--line);
      border-radius: 10px;
      box-shadow: 0 18px 42px rgba(35, 50, 66, .16);
      z-index: 8;
    }
    .date-range-panel.open { display: grid; }
    .date-range-main {
      display: grid;
      gap: 12px;
    }
    .date-fields {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
    }
    .date-display {
      width: 100%;
      height: 48px;
      background: #fff;
      border: 1px solid #dbe4ec;
      color: #0f172a;
      text-align: left;
      font-weight: 800;
    }
    .calendar-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      color: #334155;
      font-size: 13px;
      font-weight: 900;
    }
    .calendar-head button {
      width: 28px;
      height: 28px;
      padding: 0;
      background: #f8fafc;
      color: #64748b;
      border: 1px solid #e2e8f0;
    }
    .calendar-months {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 18px;
    }
    .calendar-month {
      display: grid;
      gap: 8px;
    }
    .calendar-title {
      text-align: center;
      color: #334155;
      font-size: 14px;
      font-weight: 900;
    }
    .calendar-week,
    .calendar-days {
      display: grid;
      grid-template-columns: repeat(7, 1fr);
      gap: 4px;
    }
    .calendar-week span {
      color: #94a3b8;
      font-size: 12px;
      font-weight: 800;
      text-align: center;
    }
    .calendar-day {
      height: 28px;
      padding: 0;
      border-radius: 7px;
      background: transparent;
      color: #475569;
      font-size: 12px;
      font-weight: 800;
    }
    .calendar-empty {
      height: 28px;
      display: block;
    }
    .calendar-day:hover { background: #eff6ff; color: var(--brand); }
    .calendar-day.muted { color: #cbd5e1; }
    .calendar-day.in-range { background: #eef4ff; color: #2563eb; }
    .calendar-day.selected {
      background: var(--brand);
      color: #fff;
      box-shadow: 0 8px 18px rgba(0, 91, 255, .22);
    }
    .calendar-day.today {
      outline: 1px solid rgba(0, 91, 255, .35);
    }
    .quick-ranges {
      display: grid;
      gap: 4px;
      border-left: 1px solid var(--line);
      padding-left: 12px;
    }
    .quick-ranges button {
      background: transparent;
      color: var(--brand);
      padding: 4px 0;
      text-align: left;
      font-size: 13px;
    }
    .quick-ranges button:hover { color: var(--brand-dark); }
    .search { max-width: 360px; }
    .inline-select {
      display: flex;
      align-items: center;
      gap: 10px;
      color: #667781;
      font-size: 13px;
      font-weight: 700;
    }
    .inline-select select {
      width: 220px;
    }
    .tab { display: none; padding: 24px; }
    .tab.active { display: grid; gap: 16px; }
    .pill { display: inline-flex; border-radius: 999px; padding: 4px 8px; font-size: 12px; font-weight: 700; }
    .finance-badge {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 64px;
      border-radius: 999px;
      padding: 4px 8px;
      font-size: 12px;
      font-weight: 800;
      white-space: nowrap;
    }
    .finance-badge.actual { background: #e9f8ef; color: var(--green); }
    .finance-badge.learned { background: #eaf2ff; color: var(--brand); }
    .finance-badge.estimated { background: #fff7ed; color: var(--orange); }
    .finance-badge.ignored { background: #f1f5f9; color: #64748b; }
    .ok { background: #e9f8ef; color: var(--green); }
    .bad { background: #fff0ed; color: var(--red); }
    .mid { background: #fff7ed; color: var(--orange); }
    .change-up { color: var(--red); font-weight: 800; }
    .change-down { color: var(--green); font-weight: 800; }
    .trend-panel {
      background: #0b111e;
      border-color: #1f2937;
      box-shadow: 0 18px 42px rgba(2, 6, 23, .18);
    }
    .trend-panel .toolbar h3,
    .trend-panel .chart-heading h3 {
      color: #e2e8f0;
    }
    .trend-panel .chart-heading p {
      color: #64748b;
    }
    .trend-panel .legend { color: #94a3b8; }
    .trend-panel .chart-select button {
      background: rgba(15, 23, 42, .9);
      color: #cbd5e1;
      border-color: #1f2937;
    }
    .trend-panel .chart-menu {
      background: #111827;
      border-color: #1f2937;
      color: #e2e8f0;
    }
    .trend-panel .menu-label { color: #64748b; }
    .trend-panel .menu-option { color: #cbd5e1; }
    .trend-panel .menu-option.active { color: #60a5fa; }
    .chart-wrap {
      height: 360px;
      position: relative;
      border-radius: 8px;
      background: transparent;
      overflow: hidden;
      border: 1px solid #1f2937;
    }
    canvas { width: 100%; height: 100%; display: block; }
    .notice { background: #fff7ed; border: 1px solid #fed7aa; border-radius: 8px; padding: 12px; color: #7c2d12; font-size: 13px; line-height: 1.6; }
    .chart-tooltip {
      position: absolute;
      display: none;
      min-width: 150px;
      pointer-events: none;
      background: rgba(20, 33, 38, .92);
      color: #fff;
      border-radius: 8px;
      padding: 9px 10px;
      font-size: 12px;
      line-height: 1.55;
      box-shadow: 0 16px 34px rgba(20, 33, 38, .2);
      z-index: 2;
    }
    .chart-select {
      position: relative;
    }
    .chart-select button {
      background: #f4f8fb;
      color: #667781;
      padding: 9px 12px;
      font-size: 14px;
      border: 1px solid #e4ebf0;
    }
    .chart-menu {
      position: absolute;
      right: 0;
      top: 38px;
      display: none;
      width: 260px;
      background: #fff;
      border: 1px solid #edf1f3;
      border-radius: 8px;
      box-shadow: 0 20px 44px rgba(20, 33, 38, .16);
      padding: 14px 16px;
      z-index: 5;
    }
    .chart-menu.open { display: grid; gap: 14px; }
    .chart-heading {
      display: grid;
      gap: 4px;
    }
    .chart-heading p {
      margin: 0;
      color: #94a3b8;
      font-size: 12px;
    }
    .chart-controls {
      display: flex;
      align-items: center;
      gap: 18px;
      flex-wrap: wrap;
      justify-content: flex-end;
    }
    .legend {
      display: flex;
      align-items: center;
      gap: 14px;
      color: #475569;
      font-size: 12px;
      font-weight: 700;
    }
    .legend-item {
      display: inline-flex;
      align-items: center;
      gap: 7px;
      white-space: nowrap;
    }
    .legend-line {
      width: 24px;
      height: 3px;
      border-radius: 999px;
      background: #2f9cf4;
    }
    .legend-line.light {
      background: #b8dcfb;
    }
    .legend-line.dashed {
      height: 0;
      background: transparent;
      border-top: 2px dashed #94a3b8;
    }
    .legend-line.green {
      background: #10b981;
    }
    .legend-line.yellow {
      background: #fad961;
    }
    .legend-bar {
      width: 13px;
      height: 13px;
      border-radius: 3px;
      background: linear-gradient(180deg, #00f2fe, #4facfe);
    }
    .brand-mark {
      display: inline-flex;
      align-items: center;
      gap: 10px;
      color: #fff;
      letter-spacing: .08em;
    }
    .brand-mark::before {
      content: "";
      width: 8px;
      height: 18px;
      background: #005bff;
      border-radius: 3px;
      display: inline-block;
    }
    .live-badge {
      margin-left: auto;
      color: #f59e0b;
      background: rgba(245, 158, 11, .1);
      border-radius: 6px;
      padding: 2px 6px;
      font-size: 10px;
      font-weight: 900;
    }
    .connection-dot {
      color: #10b981;
      font-weight: 900;
    }
    @keyframes profit-glow {
      0%, 100% { box-shadow: 0 4px 20px -2px rgba(16, 185, 129, .12), 0 0 0 1px rgba(16, 185, 129, .15); }
      50% { box-shadow: 0 4px 25px 2px rgba(16, 185, 129, .22), 0 0 0 1px rgba(16, 185, 129, .35); }
    }
    .profit-card {
      border-color: rgba(16, 185, 129, .28);
      box-shadow: 0 2px 8px rgba(16, 185, 129, .04);
    }
    .profit-card strong {
      color: #059669;
    }
    @keyframes pulse-dot {
      0%, 100% { opacity: 1; transform: scale(1); }
      50% { opacity: .55; transform: scale(.78); }
    }
    .menu-group {
      display: grid;
      gap: 8px;
      border-bottom: 1px solid #edf1f3;
      padding-bottom: 12px;
    }
    .menu-group:last-child { border-bottom: 0; padding-bottom: 0; }
    .menu-label {
      color: #9aa7ae;
      font-size: 12px;
      font-weight: 700;
    }
    .menu-option {
      display: flex;
      align-items: center;
      justify-content: space-between;
      border-radius: 8px;
      padding: 8px 2px;
      color: #33444d;
      cursor: pointer;
      font-size: 15px;
    }
    .menu-option.active::after {
      content: "✓";
      color: #1677ff;
      font-weight: 900;
    }

    @media (max-width: 1100px) {
      .app { grid-template-columns: 1fr; }
      aside { min-height: auto; }
      nav { grid-template-columns: repeat(4, 1fr); }
      .side-card { margin-top: 0; }
      .split, .wide-split, .metrics { grid-template-columns: 1fr; }
    }
    @media (max-width: 680px) {
      main, aside { padding: 16px; }
      nav, .cols-2 { grid-template-columns: 1fr; }
      .topbar, .toolbar { align-items: stretch; flex-direction: column; }
    }
