* {
      box-sizing: border-box;
    }

    body {
      margin: 0;
      font-family: Arial, Helvetica, sans-serif;
      background: linear-gradient(135deg, #eef6ff, #f8fbff, #eefaf6);
      color: #1f2937;
      padding: 20px;
    }

    .container {
      max-width: 1150px;
      margin: 0 auto;
    }

    .main-title {
      text-align: center;
      margin: 0 0 20px;
      font-size: 22px;
      font-weight: 800;
      color: #2563eb;
    }

    .card {
      background: rgba(255, 255, 255, 0.95);
      border-radius: 22px;
      padding: 24px;
      box-shadow: 0 12px 35px rgba(37, 99, 235, 0.08);
      border: 1px solid #dbeafe;
    }

    .section-title {
      font-size: 18px;
      font-weight: 800;
      color: #0f766e;
      margin-bottom: 14px;
    }

    .field-grid {
      display: grid;
      grid-template-columns: 1.15fr 1.2fr 0.72fr 1.1fr;
      gap: 16px;
      align-items: end;
    }

    .field-grid-second {
      display: grid;
      grid-template-columns: 130px 150px;
      gap: 16px;
      margin-top: 16px;
      max-width: 320px;
    }

    .sell-grid {
      display: grid;
      grid-template-columns: 220px;
      gap: 16px;
      max-width: 220px;
    }

    .field {
      display: flex;
      flex-direction: column;
    }

    .field label {
      margin-bottom: 8px;
      font-size: 14px;
      font-weight: 700;
      color: #334155;
    }

    .input-wrap {
      position: relative;
      display: flex;
      align-items: center;
    }

    .field input {
      width: 100%;
      min-height: 50px;
      border: 1px solid #dbeafe;
      outline: none;
      padding: 14px 16px;
      border-radius: 16px;
      font-size: 16px;
      font-weight: 700;
      color: #0f172a;
      text-align: center;
      transition: 0.2s ease;
      background: #ffffff;
    }

    .field input:focus {
      border-color: #60a5fa;
      box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.18);
    }

    .with-stepper input {
      padding-right: 64px;
    }

    .stepper {
      position: absolute;
      top: 50%;
      right: 8px;
      transform: translateY(-50%);
      display: flex;
      flex-direction: column;
      gap: 4px;
    }

    .stepper button {
      width: 24px;
      height: 18px;
      border: none;
      border-radius: 6px;
      cursor: pointer;
      font-size: 12px;
      font-weight: 800;
      line-height: 1;
      background: #dbeafe;
      color: #1d4ed8;
      transition: 0.2s ease;
    }

    .stepper button:hover {
      background: #bfdbfe;
    }

    .share-code { background: #fff7cc !important; }
    .investment { background: #dcfce7 !important; }
    .buy-price { background: #dbeafe !important; }
    .shares { background: #ede9fe !important; }
    .commission { background: #ffe4e6 !important; }
    .tax { background: #ffedd5 !important; }
    .sell-price { background: #ccfbf1 !important; }

    .readonly {
      cursor: not-allowed;
      opacity: 0.95;
    }

    .results-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 16px;
      margin-top: 20px;
    }

    .result-box {
      border-radius: 18px;
      padding: 18px;
      min-height: 110px;
      text-align: center;
      border: 1px solid rgba(0,0,0,0.04);
    }

    .result-box h3 {
      margin: 0 0 10px;
      font-size: 14px;
      font-weight: 800;
      color: #334155;
    }

    .result-box p {
      margin: 0;
      font-size: 24px;
      font-weight: 800;
      color: #0f172a;
      word-break: break-word;
    }

    .box1 { background: #dbeafe; }
    .box2 { background: #ede9fe; }
    .box3 { background: #e0f2fe; }
    .box4 { background: #dcfce7; }
    .box5 { background: #ffedd5; }
    .box6 { background: #f8fafc; transition: 0.2s ease; }

    .profit-bg {
      background: #dcfce7 !important;
      border-color: #86efac !important;
    }

    .loss-bg {
      background: #fee2e2 !important;
      border-color: #fca5a5 !important;
    }

    .neutral-bg {
      background: #f8fafc !important;
      border-color: #e2e8f0 !important;
    }

    .profit-text {
      color: #166534 !important;
    }

    .loss-text {
      color: #b91c1c !important;
    }

    .neutral-text {
      color: #0f172a !important;
    }

    .spacer {
      height: 28px;
    }

    .note {
      margin-top: 18px;
      text-align: center;
      color: #64748b;
      font-size: 13px;
      line-height: 1.7;
    }

    @media (max-width: 980px) {
      .field-grid,
      .results-grid {
        grid-template-columns: 1fr 1fr;
      }

      .field-grid-second {
        grid-template-columns: 130px 150px;
      }

      .sell-grid {
        max-width: 220px;
      }
    }

    @media (max-width: 640px) {
      body {
        padding: 12px;
      }

      .card {
        padding: 16px;
      }

      .field-grid,
      .field-grid-second,
      .results-grid,
      .sell-grid {
        grid-template-columns: 1fr;
        max-width: 100%;
      }

      .main-title {
        font-size: 24px;
      }

      .result-box p {
        font-size: 20px;
      }
    }
    
    .btn-group {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin: 15px 0;
    }

    .btn {
    padding: 12px 22px;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    transition: 0.2s ease;
    min-width: 140px;
    }

    .calculate-btn {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.25);
    }

    .calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.35);
    }

    .reset-btn {
    background: #f1f5f9;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    }

    .reset-btn:hover {
    background: #e2e8f0;
    transform: translateY(-2px);
    }
    
    .one-field {
  grid-template-columns: 180px;
  justify-content: center;
}

.sell-grid {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(180px, 260px);
  gap: 18px;
  align-items: end;
}

.break-even {
  background: #fff7d6;
  color: #7a4b00;
  border: 1px solid #f3cf69;
  font-weight: 800;
  text-align: center;
}

@media (max-width: 700px) {
  .sell-grid {
    grid-template-columns: 1fr;
  }

  .one-field {
    grid-template-columns: 1fr;
  }
}

.history-section {
  margin-top: 32px;
  padding: 24px;
  border-radius: 24px;
  background: linear-gradient(135deg, #eef6ff, #fff7ed);
  border: 1px solid #dbeafe;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.history-header h2 {
  margin: 0;
  font-size: 26px;
  font-weight: 900;
  color: #061a3a;
}

.clear-history-btn {
  border: 0;
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  color: #991b1b;
  font-weight: 900;
  padding: 11px 18px;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(185, 28, 28, 0.15);
}

.history-table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: 20px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  overflow: hidden;
}

.history-table th {
  background: linear-gradient(135deg, #dbeafe, #e0f2fe);
  color: #0f172a;
  font-weight: 900;
  font-size: 14px;
  padding: 16px 14px;
  text-align: center;
  white-space: nowrap;
}

.history-table td {
  padding: 16px 14px;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  border-bottom: 1px solid #eef2f7;
  white-space: nowrap;
}

.history-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.history-table tbody tr:hover {
  background: #eff6ff;
}

.history-profit {
  color: #047857 !important;
  font-weight: 900 !important;
}

.history-loss {
  color: #dc2626 !important;
  font-weight: 900 !important;
}

@media (max-width: 700px) {
  .history-section {
    padding: 18px;
    border-radius: 20px;
  }

  .history-header h2 {
    font-size: 22px;
  }

  .clear-history-btn {
    padding: 10px 14px;
  }
}