:root {
      --ink: #16202d;
      --sub: #546170;
      --line: rgba(22, 32, 45, 0.12);
      --card: rgba(255, 251, 245, 0.92);
      --card-strong: #fffdfa;
      --accent: #1d7a4f;
      --accent2: #b25733;
      --shadow: 0 24px 60px rgba(10, 60, 35, 0.12);
      --radius: 24px;
    }
    * { box-sizing: border-box; }
    body {
      margin: 0;
      color: var(--ink);
      font-family: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
      background:
        radial-gradient(circle at top right, rgba(92, 210, 150, 0.16), transparent 24%),
        radial-gradient(circle at left top, rgba(29, 122, 79, 0.10), transparent 20%),
        linear-gradient(180deg, #edfaf3 0%, #e2f5eb 100%);
      min-height: 100vh;
    }
    .shell {
      width: min(1400px, calc(100vw - 32px));
      margin: 0 auto;
      padding: 20px 0 32px;
    }

    .topbar {
      display: flex;
      align-items: center;
      padding: 12px 22px;
      border-radius: 999px;
      border: 1px solid rgba(255, 255, 255, 0.6);
      background: rgba(240, 255, 248, 0.85);
      backdrop-filter: blur(10px);
      box-shadow: 0 12px 32px rgba(10, 60, 35, 0.08);
    }
    .topbar a {
      text-decoration: none;
      color: var(--accent);
      font-size: 16px;
      font-weight: 800;
    }

    .panel {
      margin-top: 14px;
      padding: 24px 28px;
      border-radius: var(--radius);
      border: 1px solid rgba(255, 255, 255, 0.55);
      background: var(--card);
      box-shadow: var(--shadow);
      backdrop-filter: blur(10px);
    }

    .hero {
      text-align: center;
      padding: 6px 0 18px;
    }
    .hero h1 {
      margin: 0;
      font-size: clamp(26px, 3.2vw, 40px);
      letter-spacing: 0.06em;
      color: var(--accent);
    }

    /* Controls */
    .controls-row {
      display: flex;
      flex-wrap: wrap;
      gap: 14px;
      align-items: flex-end;
      padding: 20px 0 8px;
      border-top: 1px solid var(--line);
      border-bottom: 1px solid var(--line);
    }

    .field {
      display: flex;
      flex-direction: column;
      gap: 8px;
      flex: 1 1 120px;
    }
    .field label {
      font-size: 18px;
      font-weight: 900;
      color: var(--ink);
      white-space: nowrap;
    }
    .field label .unit {
      font-size: 14px;
      color: var(--sub);
      font-weight: 700;
      margin-left: 4px;
    }
    .field input[type="number"] {
      width: 100%;
      height: 52px;
      padding: 0 14px;
      border: 1.5px solid var(--line);
      border-radius: 16px;
      background: #f4fbf7;
      color: var(--ink);
      font: 800 22px "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    }
    .field input[type="number"]:focus {
      outline: 3px solid rgba(29, 122, 79, 0.18);
      border-color: rgba(29, 122, 79, 0.5);
    }

    /* Class selector */
    .class-selector {
      display: flex;
      flex-direction: column;
      gap: 8px;
      flex: 3 1 320px;
    }
    .class-selector label {
      font-size: 18px;
      font-weight: 900;
      color: var(--ink);
    }
    .class-btns {
      display: flex;
      gap: 6px;
      flex-wrap: nowrap;
    }
    .class-btn {
      height: 52px;
      padding: 0 0;
      flex: 1;
      border: 1.5px solid rgba(29, 122, 79, 0.3);
      border-radius: 16px;
      background: #f0faf5;
      color: var(--accent);
      font-size: 16px;
      font-weight: 900;
      cursor: pointer;
      transition: all 0.15s;
      white-space: nowrap;
    }
    .class-btn:hover { background: #d8f5e7; }
    .class-btn.active {
      background: var(--accent);
      color: #fff;
      border-color: var(--accent);
      box-shadow: 0 8px 20px rgba(29, 122, 79, 0.28);
    }

    /* Bins */
    .bins-selector {
      display: flex;
      flex-direction: column;
      gap: 8px;
      flex: 1 1 170px;
    }

    .action-group {
      display: flex;
      gap: 10px;
      align-self: flex-end;
      flex: 0 0 auto;
    }
    .bins-selector label {
      font-size: 18px;
      font-weight: 900;
      color: var(--ink);
    }
    .bins-row {
      display: flex;
      align-items: center;
      gap: 12px;
    }
    .bins-row input[type="range"] {
      flex: 1;
      accent-color: var(--accent);
      cursor: pointer;
    }
    .bins-val {
      min-width: 40px;
      text-align: right;
      font-size: 22px;
      font-weight: 900;
      color: var(--accent);
    }

    /* Run button */
    .run-btn {
      height: 56px;
      padding: 0 28px;
      border: none;
      border-radius: 18px;
      background: linear-gradient(135deg, #1d7a4f 0%, #28a06a 100%);
      color: #fff;
      font-size: 20px;
      font-weight: 900;
      letter-spacing: 0.05em;
      cursor: pointer;
      box-shadow: 0 14px 32px rgba(29, 122, 79, 0.28);
      transition: transform 0.1s, box-shadow 0.1s;
    }
    .run-btn:hover {
      transform: translateY(-2px);
      box-shadow: 0 18px 40px rgba(29, 122, 79, 0.36);
    }

    .curve-btn {
      height: 56px;
      padding: 0 16px;
      border: 2px solid rgba(178, 87, 51, 0.4);
      border-radius: 18px;
      background: #fff8f4;
      color: #b25733;
      font-size: 16px;
      font-weight: 900;
      cursor: pointer;
      transition: all 0.15s;
      white-space: nowrap;
    }
    .curve-btn.active {
      background: linear-gradient(135deg, #b25733 0%, #d4805a 100%);
      color: #fff;
      border-color: #b25733;
      box-shadow: 0 8px 20px rgba(178, 87, 51, 0.28);
    }

    /* Stats */
    .stats-bar {
      display: flex;
      gap: 16px;
      flex-wrap: wrap;
      margin-top: 20px;
    }
    .stat-box {
      flex: 1 1 130px;
      padding: 14px 18px;
      border-radius: 18px;
      border: 1.5px solid rgba(29, 122, 79, 0.2);
      background: linear-gradient(160deg, #f0faf5 0%, #e2f5eb 100%);
      box-shadow: 0 8px 20px rgba(29, 122, 79, 0.1);
    }
    .stat-box .stat-label {
      font-size: 15px;
      font-weight: 800;
      color: var(--sub);
      margin-bottom: 4px;
    }
    .stat-box .stat-value {
      font-size: 28px;
      font-weight: 900;
      color: var(--accent);
      line-height: 1.1;
    }

    /* Class table - mini */
    .class-table-wrap {
      margin-top: 20px;
      overflow-x: auto;
    }
    .class-table {
      width: 100%;
      border-collapse: collapse;
      font-size: 15px;
    }
    .class-table th {
      padding: 8px 12px;
      background: rgba(29, 122, 79, 0.08);
      font-weight: 900;
      color: var(--ink);
      text-align: center;
      border-bottom: 2px solid rgba(29, 122, 79, 0.15);
      font-size: 16px;
    }
    .class-table td {
      padding: 7px 12px;
      text-align: center;
      border-bottom: 1px solid var(--line);
      font-weight: 700;
      font-size: 15px;
      color: var(--ink);
    }
    .class-table tr:last-child td { border-bottom: none; }
    .class-table td.highlight {
      color: var(--accent);
      font-weight: 900;
      font-size: 16px;
    }

    /* Chart */
    .chart-wrap {
      margin-top: 20px;
      padding: 20px;
      border-radius: 20px;
      border: 1px solid var(--line);
      background: var(--card-strong);
      position: relative;
      min-height: 440px;
    }
    .chart-wrap canvas { width: 100% !important; display: block; }

    .empty-state {
      position: absolute;
      inset: 0;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 12px;
      color: var(--sub);
      pointer-events: none;
    }
    .empty-state .icon { font-size: 56px; opacity: 0.4; }
    .empty-state p { font-size: 20px; font-weight: 800; margin: 0; opacity: 0.6; }

    /* Insight */
    .insight {
      margin-top: 16px;
      padding: 16px 22px;
      border-radius: 16px;
      background: linear-gradient(135deg, rgba(29, 122, 79, 0.07) 0%, rgba(92, 210, 150, 0.09) 100%);
      border: 1.5px solid rgba(29, 122, 79, 0.2);
      font-size: 20px;
      font-weight: 800;
      color: var(--ink);
      text-align: center;
      line-height: 1.6;
    }
    .insight .hl  { color: var(--accent); }
    .insight .hl2 { color: var(--accent2); }

    /* Two-col layout for table + chart */
    .body-grid {
      display: grid;
      grid-template-columns: 260px 1fr;
      gap: 20px;
      margin-top: 20px;
      align-items: start;
    }
    @media (max-width: 800px) {
      .body-grid { grid-template-columns: 1fr; }
    }
    .side-card {
      padding: 18px 16px;
      border-radius: 20px;
      border: 1px solid var(--line);
      background: var(--card-strong);
    }
    .side-card h3 {
      margin: 0 0 12px;
      font-size: 18px;
      font-weight: 900;
      color: var(--accent);
    }
